diff options
78 files changed, 258 insertions, 1583 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 743c01d935..43114c6039 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -6539,7 +6539,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, struct linger lg; unsigned int sz = sizeof(lg); - if (sock_getopt(desc->s, IPPROTO_SCTP, SO_LINGER, + if (sock_getopt(desc->s, SOL_SOCKET, SO_LINGER, &lg, &sz) < 0) continue; /* Fill in the response: */ PLACE_FOR(spec, i, @@ -6575,7 +6575,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, { case INET_OPT_RCVBUF : { - proto = IPPROTO_SCTP; + proto = SOL_SOCKET; type = SO_RCVBUF; is_int = 1; tag = am_recbuf; @@ -6583,7 +6583,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, } case INET_OPT_SNDBUF : { - proto = IPPROTO_SCTP; + proto = SOL_SOCKET; type = SO_SNDBUF; is_int = 1; tag = am_sndbuf; @@ -7029,8 +7029,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, i = LOAD_TUPLE(spec, i, 3); /* Now, convert "spec" into the returnable term: */ - /* desc->caller = 0; What does it mean? */ - driver_output_term(desc->port, spec, i); + driver_send_term(desc->port, driver_caller(desc->port), spec, i); FREE(spec); (*dest)[0] = INET_REP_SCTP; diff --git a/erts/emulator/test/busy_port_SUITE.erl b/erts/emulator/test/busy_port_SUITE.erl index dac2a70f59..3a29fd4d68 100644 --- a/erts/emulator/test/busy_port_SUITE.erl +++ b/erts/emulator/test/busy_port_SUITE.erl @@ -509,12 +509,12 @@ hs_busy_pcmd(Prt, Opts, StartFun, EndFun) -> P = spawn_link(fun () -> erlang:yield(), Tester ! {self(), doing_port_command}, - Start = os:timestamp(), + Start = now(), Res = try {return, port_command(Prt, [], Opts)} catch Exception:Error -> {Exception, Error} end, - End = os:timestamp(), + End = now(), Time = round(timer:now_diff(End, Start)/1000), Tester ! {self(), port_command_result, Res, Time} end), diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl index 3eaacdb044..19281f6d58 100644 --- a/erts/emulator/test/distribution_SUITE.erl +++ b/erts/emulator/test/distribution_SUITE.erl @@ -336,7 +336,7 @@ receiver2(Num, TotSize) -> link_to_busy(doc) -> "Test that link/1 to a busy distribution port works."; link_to_busy(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:seconds(30)), + ?line Dog = test_server:timetrap(test_server:seconds(60)), ?line {ok, Node} = start_node(link_to_busy), ?line Recv = spawn(Node, erlang, apply, [fun sink/1, [link_to_busy_sink]]), @@ -383,7 +383,7 @@ tail_applied_linker(Pid) -> exit_to_busy(doc) -> "Test that exit/2 to a busy distribution port works."; exit_to_busy(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:seconds(30)), + ?line Dog = test_server:timetrap(test_server:seconds(60)), ?line {ok, Node} = start_node(exit_to_busy), Tracer = case os:getenv("TRACE_BUSY_DIST_PORT") of diff --git a/erts/emulator/test/port_SUITE.erl b/erts/emulator/test/port_SUITE.erl index eac56a867d..0a1ef5a78f 100644 --- a/erts/emulator/test/port_SUITE.erl +++ b/erts/emulator/test/port_SUITE.erl @@ -724,6 +724,8 @@ open_ports(Name, Settings) -> []; system_limit -> []; + enomem -> + []; Other -> ?line test_server:fail({open_ports, Other}) end; diff --git a/erts/emulator/test/scheduler_SUITE.erl b/erts/emulator/test/scheduler_SUITE.erl index f16d0ea429..debb54579b 100644 --- a/erts/emulator/test/scheduler_SUITE.erl +++ b/erts/emulator/test/scheduler_SUITE.erl @@ -87,8 +87,17 @@ init_per_group(_GroupName, Config) -> end_per_group(_GroupName, Config) -> Config. - +init_per_testcase(update_cpu_info, Config) -> + case os:find_executable("taskset") of + false -> + {skip,"Could not find 'taskset' in path"}; + _ -> + init_per_tc(update_cpu_info, Config) + end; init_per_testcase(Case, Config) when is_list(Config) -> + init_per_tc(Case, Config). + +init_per_tc(Case, Config) -> Dog = ?t:timetrap(?DEFAULT_TIMEOUT), process_flag(priority, max), erlang:display({'------------', ?MODULE, Case, '------------'}), @@ -1030,7 +1039,7 @@ sbt_test(Config, CpuTCmd, ClBt, Bt, LP) -> ?line ok. scheduler_suspend(Config) when is_list(Config) -> - ?line Dog = ?t:timetrap(?t:minutes(2)), + ?line Dog = ?t:timetrap(?t:minutes(5)), ?line lists:foreach(fun (S) -> scheduler_suspend_test(Config, S) end, [64, 32, 16, default]), ?line ?t:timetrap_cancel(Dog), diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 31381abc40..e85e8e6ad3 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -25,6 +25,7 @@ -include_lib("test_server/include/test_server.hrl"). -include_lib("common_test/include/ct_event.hrl"). +-include_lib("common_test/include/ct.hrl"). -export([init_per_suite/1, init_per_suite/2, end_per_suite/1, init_per_testcase/2, end_per_testcase/2, @@ -46,9 +47,10 @@ init_per_suite(Config) -> init_per_suite(Config, Level) -> case os:type() of {win32, _} -> - %% Extend timeout for windows as starting node + %% Extend timeout to 1 hour for windows as starting node %% can take a long time there - test_server:timetrap( 120000 * test_server:timetrap_scale_factor()); + test_server:timetrap( 60*60*1000 * + test_server:timetrap_scale_factor()); _ -> ok end, diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c index 83772d9023..c781ccb302 100644 --- a/lib/crypto/c_src/crypto.c +++ b/lib/crypto/c_src/crypto.c @@ -43,7 +43,6 @@ #include <openssl/aes.h> #include <openssl/md5.h> #include <openssl/md4.h> -#include <openssl/md2.h> #include <openssl/sha.h> #include <openssl/bn.h> #include <openssl/objects.h> @@ -268,7 +267,6 @@ static ERL_NIF_TERM atom_true; static ERL_NIF_TERM atom_false; static ERL_NIF_TERM atom_sha; static ERL_NIF_TERM atom_md5; -static ERL_NIF_TERM atom_md2; static ERL_NIF_TERM atom_ripemd160; static ERL_NIF_TERM atom_error; static ERL_NIF_TERM atom_rsa_pkcs1_padding; @@ -339,7 +337,6 @@ static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) atom_false = enif_make_atom(env,"false"); atom_sha = enif_make_atom(env,"sha"); atom_md5 = enif_make_atom(env,"md5"); - atom_md2 = enif_make_atom(env,"md2"); atom_ripemd160 = enif_make_atom(env,"ripemd160"); atom_error = enif_make_atom(env,"error"); atom_rsa_pkcs1_padding = enif_make_atom(env,"rsa_pkcs1_padding"); @@ -1050,28 +1047,16 @@ static ERL_NIF_TERM dss_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv return(i > 0) ? atom_true : atom_false; } -struct hash_def { - int type; - unsigned int m_len; - unsigned char * (*func) (const unsigned char *d, size_t n, unsigned char *md); -}; - -static const struct hash_def md2_hash_def = { NID_md2, MD2_DIGEST_LENGTH, &MD2}; -static const struct hash_def md5_hash_def = { NID_md5, MD5_DIGEST_LENGTH, &MD5}; -static const struct hash_def sha1_hash_def = { NID_sha1, SHA_DIGEST_LENGTH, &SHA1}; - static ERL_NIF_TERM rsa_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Type, Data, Signature, Key=[E,N]) */ ErlNifBinary data_bin, sign_bin; unsigned char hmacbuf[SHA_DIGEST_LENGTH]; ERL_NIF_TERM head, tail, ret; - int i; + int i, is_sha; RSA* rsa = RSA_new(); - const struct hash_def *hash_def = NULL; - if (argv[0] == atom_sha) hash_def = &sha1_hash_def; - else if (argv[0] == atom_md5) hash_def = &md5_hash_def; - else if (argv[0] == atom_md2) hash_def = &md2_hash_def; + if (argv[0] == atom_sha) is_sha = 1; + else if (argv[0] == atom_md5) is_sha = 0; else goto badarg; if (!inspect_mpint(env, argv[1], &data_bin) @@ -1085,9 +1070,16 @@ static ERL_NIF_TERM rsa_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv ret = enif_make_badarg(env); } else { - (void) *hash_def->func(data_bin.data+4, data_bin.size-4, hmacbuf); - i = RSA_verify(hash_def->type, hmacbuf, hash_def->m_len, - sign_bin.data+4, sign_bin.size-4, rsa); + if (is_sha) { + SHA1(data_bin.data+4, data_bin.size-4, hmacbuf); + i = RSA_verify(NID_sha1, hmacbuf, SHA_DIGEST_LENGTH, + sign_bin.data+4, sign_bin.size-4, rsa); + } + else { + MD5(data_bin.data+4, data_bin.size-4, hmacbuf); + i = RSA_verify(NID_md5, hmacbuf, MD5_DIGEST_LENGTH, + sign_bin.data+4, sign_bin.size-4, rsa); + } ret = (i==1 ? atom_true : atom_false); } RSA_free(rsa); @@ -1229,12 +1221,10 @@ static ERL_NIF_TERM rsa_sign_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar unsigned char hmacbuf[SHA_DIGEST_LENGTH]; unsigned rsa_s_len; RSA *rsa = RSA_new(); - int i; - const struct hash_def *hash_def = NULL; + int i, is_sha; - if (argv[0] == atom_sha) hash_def = &sha1_hash_def; - else if (argv[0] == atom_md5) hash_def = &md5_hash_def; - else if (argv[0] == atom_md2) hash_def = &md2_hash_def; + if (argv[0] == atom_sha) is_sha = 1; + else if (argv[0] == atom_md5) is_sha = 0; else goto badarg; if (!inspect_mpint(env,argv[1],&data_bin) @@ -1250,10 +1240,18 @@ static ERL_NIF_TERM rsa_sign_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar return enif_make_badarg(env); } enif_alloc_binary(RSA_size(rsa), &ret_bin); - (void) *hash_def->func(data_bin.data+4, data_bin.size-4, hmacbuf); - ERL_VALGRIND_ASSERT_MEM_DEFINED(hmacbuf, hash_def->m_len); - i = RSA_sign(hash_def->type, hmacbuf, hash_def->m_len, - ret_bin.data, &rsa_s_len, rsa); + if (is_sha) { + SHA1(data_bin.data+4, data_bin.size-4, hmacbuf); + ERL_VALGRIND_ASSERT_MEM_DEFINED(hmacbuf, SHA_DIGEST_LENGTH); + i = RSA_sign(NID_sha1, hmacbuf, SHA_DIGEST_LENGTH, + ret_bin.data, &rsa_s_len, rsa); + } + else { + MD5(data_bin.data+4, data_bin.size-4, hmacbuf); + ERL_VALGRIND_ASSERT_MEM_DEFINED(hmacbuf, MD5_DIGEST_LENGTH); + i = RSA_sign(NID_md5, hmacbuf,MD5_DIGEST_LENGTH, + ret_bin.data, &rsa_s_len, rsa); + } RSA_free(rsa); if (i) { ERL_VALGRIND_MAKE_MEM_DEFINED(ret_bin.data, rsa_s_len); diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml index b593958264..4c20f81cae 100644 --- a/lib/crypto/doc/src/crypto.xml +++ b/lib/crypto/doc/src/crypto.xml @@ -795,7 +795,7 @@ Mpint() = <![CDATA[<<ByteLen:32/integer-big, Bytes:ByteLen/binary>>]]> <v>E, N, D = Mpint</v> <d>Where <c>E</c> is the public exponent, <c>N</c> is public modulus and <c>D</c> is the private exponent.</d> - <v>DigestType = md2 | md5 | sha</v> + <v>DigestType = md5 | sha</v> <d>The default <c>DigestType</c> is sha.</d> <v>Mpint = binary()</v> <v>Signature = binary()</v> @@ -817,7 +817,7 @@ Mpint() = <![CDATA[<<ByteLen:32/integer-big, Bytes:ByteLen/binary>>]]> <v>Key = [E, N]</v> <v>E, N = Mpint</v> <d>Where <c>E</c> is the public exponent and <c>N</c> is public modulus.</d> - <v>DigestType = md2 | md5 | sha</v> + <v>DigestType = md5 | sha</v> <d> The default <c>DigestType</c> is sha.</d> <v>Mpint = binary()</v> </type> diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index ddad00f4b4..c3e13d6b91 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -91,7 +91,7 @@ aes_ctr_stream_init, aes_ctr_stream_encrypt, aes_ctr_stream_decrypt, info_lib]). --type rsa_digest_type() :: 'md2' | 'md5' | 'sha'. +-type rsa_digest_type() :: 'md5' | 'sha'. -type dss_digest_type() :: 'none' | 'sha'. -type crypto_integer() :: binary() | integer(). diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl index 26d10d892a..486751766b 100644 --- a/lib/crypto/test/crypto_SUITE.erl +++ b/lib/crypto/test/crypto_SUITE.erl @@ -1083,30 +1083,16 @@ rsa_sign_test(Config) when is_list(Config) -> PrivKey = [crypto:mpint(PubEx), crypto:mpint(Mod), crypto:mpint(PrivEx)], PubKey = [crypto:mpint(PubEx), crypto:mpint(Mod)], - ?line Sig = crypto:rsa_sign(sized_binary(Msg), PrivKey), - ?line m(crypto:rsa_verify(sized_binary(Msg), sized_binary(Sig),PubKey), true), + ?line Sig1 = crypto:rsa_sign(sized_binary(Msg), PrivKey), + ?line m(crypto:rsa_verify(sized_binary(Msg), sized_binary(Sig1),PubKey), true), - ?line Sig_md2 = crypto:rsa_sign(md2, sized_binary(Msg), PrivKey), - ?line Sig_md5 = crypto:rsa_sign(md5, sized_binary(Msg), PrivKey), - ?line Sig_sha = crypto:rsa_sign(sha, sized_binary(Msg), PrivKey), - - ?line m(Sig =:= Sig_sha, true), - ?line m(Sig_md2 =:= Sig_md5, false), - ?line m(Sig_md2 =:= Sig_sha, false), - ?line m(Sig_md5 =:= Sig_sha, false), + ?line Sig2 = crypto:rsa_sign(md5, sized_binary(Msg), PrivKey), + ?line m(crypto:rsa_verify(md5, sized_binary(Msg), sized_binary(Sig2),PubKey), true), + + ?line m(Sig1 =:= Sig2, false), + ?line m(crypto:rsa_verify(md5, sized_binary(Msg), sized_binary(Sig1),PubKey), false), + ?line m(crypto:rsa_verify(sha, sized_binary(Msg), sized_binary(Sig1),PubKey), true), - ?line m(crypto:rsa_verify(md2, sized_binary(Msg), sized_binary(Sig_md2),PubKey), true), - ?line m(crypto:rsa_verify(md2, sized_binary(Msg), sized_binary(Sig_md5),PubKey), false), - ?line m(crypto:rsa_verify(md2, sized_binary(Msg), sized_binary(Sig_sha),PubKey), false), - - ?line m(crypto:rsa_verify(md5, sized_binary(Msg), sized_binary(Sig_md2),PubKey), false), - ?line m(crypto:rsa_verify(md5, sized_binary(Msg), sized_binary(Sig_md5),PubKey), true), - ?line m(crypto:rsa_verify(md5, sized_binary(Msg), sized_binary(Sig_sha),PubKey), false), - - ?line m(crypto:rsa_verify(sha, sized_binary(Msg), sized_binary(Sig_md2),PubKey), false), - ?line m(crypto:rsa_verify(sha, sized_binary(Msg), sized_binary(Sig_md5),PubKey), false), - ?line m(crypto:rsa_verify(sha, sized_binary(Msg), sized_binary(Sig_sha),PubKey), true), - ok. dsa_sign_test(doc) -> diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index 659297f993..d74c04385b 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -1399,10 +1399,14 @@ do_clause(C, Arg, ArgType0, OrigArgType, Map, true -> Any = t_any(), [Any || _ <- Pats]; false -> t_to_tlist(OrigArgType) end, - case bind_pat_vars(Pats, OrigArgTypes, [], Map1, State1) of - {error, bind, _, _, _} -> {{pattern_match, PatTypes}, false}; - {_, _} -> {{pattern_match_cov, PatTypes}, false} - end; + Tag = + case bind_pat_vars(Pats, OrigArgTypes, [], Map1, State1) of + {error, bind, _, _, _} -> pattern_match; + {error, record, _, _, _} -> record_match; + {error, opaque, _, _, _} -> opaque_match; + {_, _} -> pattern_match_cov + end, + {{Tag, PatTypes}, false}; false -> %% Try to find out if this is a default clause in a list %% comprehension and supress this. A real Hack(tm) @@ -1442,12 +1446,12 @@ do_clause(C, Arg, ArgType0, OrigArgType, Map, opaque -> [PatString, format_type(Type, State1), format_type(OpaqueTerm, State1)] end, - FailedMsg = case ErrorType of - bind -> {pattern_match, PatTypes}; - record -> {record_match, PatTypes}; - opaque -> {opaque_match, PatTypes} + FailedTag = case ErrorType of + bind -> pattern_match; + record -> record_match; + opaque -> opaque_match end, - {FailedMsg, Force0} + {{FailedTag, PatTypes}, Force0} end, WarnType = case Msg of {opaque_match, _} -> ?WARN_OPAQUE; diff --git a/lib/diameter/test/Makefile b/lib/diameter/test/Makefile index 64e200584f..dba1f126dc 100644 --- a/lib/diameter/test/Makefile +++ b/lib/diameter/test/Makefile @@ -40,16 +40,6 @@ VSN = $(DIAMETER_VSN) RELSYSDIR = $(RELEASE_PATH)/diameter_test -ifeq ($(findstring win32,$(TARGET)),win32) -MAKEFILE_SRC = Makefile.win32.src -else -MAKEFILE_SRC = Makefile.src -endif - -ifeq ($(TT_DIR),) -TT_DIR = /tmp -endif - # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- @@ -67,16 +57,7 @@ TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) SUITE_MODULES = $(filter diameter_%_SUITE, $(MODULES)) SUITES = $(SUITE_MODULES:diameter_%_SUITE=%) -EMAKEFILE = Emakefile -MAKE_EMAKE = $(wildcard $(TOP)/make/make_emakefile) - -ifeq ($(MAKE_EMAKE),) -BUILDTARGET = $(TARGET_FILES) RELTEST_FILES = $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE) -else -BUILDTARGET = emakebuild -RELTEST_FILES = $(EMAKEFILE) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE) -endif # ---------------------------------------------------- # FLAGS @@ -84,14 +65,8 @@ endif include ../src/app/diameter.mk -ifeq ($(USE_DIAMETER_TEST_CODE),true) -ERL_COMPILE_FLAGS += -DDIAMETER_TEST_CODE=mona_lisa_spelar_doom -endif - -ifeq ($(USE_DIAMETER_HIPE),true) -ERL_COMPILE_FLAGS += +native -DDIAMETER_hipe_special=true -endif - +# This is only used to compile suite locally when running with a +# target like 'all' below. Target release_tests only installs source. ERL_COMPILE_FLAGS += $(DIAMETER_ERL_COMPILE_FLAGS) \ -DDIAMETER_CT=true \ -I $(DIAMETER_TOP)/src/app @@ -100,35 +75,24 @@ ERL_COMPILE_FLAGS += $(DIAMETER_ERL_COMPILE_FLAGS) \ # Targets # ---------------------------------------------------- -all test: $(SUITES) - -tests debug opt: $(BUILDTARGET) - -beam targets: $(TARGET_FILES) - -emakebuild: $(EMAKEFILE) +all: $(SUITES) -$(EMAKEFILE): - $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o $(EBIN) '*_SUITE_make' $(MODULES) \ - | grep -v Warning \ - > $(EMAKEFILE) +tests debug opt: $(TARGET_FILES) clean: - rm -f $(EMAKEFILE) rm -f $(TARGET_FILES) rm -f depend.mk realclean: clean + rm -rf log rm -f errs core *~ -.PHONY: all emakebuild test tests debug opt beam targets clean realclean +.PHONY: all tests debug opt clean realclean docs: info: - @echo "MAKE_EMAKE = $(MAKE_EMAKE)" - @echo "EMAKEFILE = $(EMAKEFILE)" - @echo "BUILDTARGET = $(BUILDTARGET)" + @echo "TARGET_FILES = $(TARGET_FILES)" @echo @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" @echo "ERL = $(ERL)" @@ -144,15 +108,6 @@ info: help: @echo - @echo "This Makefile controls the test of the $(APPLICATION) application." - @echo - @echo "There are two separate ways to perform the test of $(APPLICATION)." - @echo - @echo " a) Run the official OTP test-server (which we do not describe here)" - @echo - @echo " b) Run individual suites using targets in this makefile, target" - @echo " xxx running the testcases contained in $(APPLICATION)_xxx_SUITE." - @echo @echo "Targets:" @echo @echo " all" @@ -161,10 +116,10 @@ help: @echo " $(SUITES)" @echo " Run a specific test suite." @echo - @echo " beam" + @echo " tests" @echo " Compile all test-code." @echo - @echo " clean" + @echo " clean | realclean" @echo " Remove generated files." @echo @echo " info" @@ -183,7 +138,7 @@ help: # Exit with a non-zero status if the output looks to indicate failure. # diameter_ct:run/1 itself can't tell (it seems). -$(SUITES): log targets +$(SUITES): log tests $(ERL) -noshell \ -pa $(DIAMETER_TOP)/ebin \ -sname diameter_test_$@ \ @@ -207,7 +162,7 @@ release_spec: release_docs_spec: -release_tests_spec: tests +release_tests_spec: $(INSTALL_DIR) $(RELSYSDIR) $(INSTALL_DATA) $(RELTEST_FILES) $(RELSYSDIR) diff --git a/lib/diameter/test/diameter_relay_SUITE.erl b/lib/diameter/test/diameter_relay_SUITE.erl index 6b2fda7855..d3d1fe690a 100644 --- a/lib/diameter/test/diameter_relay_SUITE.erl +++ b/lib/diameter/test/diameter_relay_SUITE.erl @@ -147,13 +147,6 @@ end_per_group(_, _) -> init_per_suite(Config) -> ok = diameter:start(), - - dbg:tracer(port, dbg:trace_port(file, "relay.dbg")), - dbg:p(all,c), - dbg:tpl(diameter_service, x), - dbg:tp(?MODULE, x), - - [S1,S2,S3,S4] = S = [server(N, ?DICT_COMMON) || N <- [?SERVER1, ?SERVER2, ?SERVER3, diff --git a/lib/edoc/doc/overview.edoc b/lib/edoc/doc/overview.edoc index fa699c6f08..2af425272e 100644 --- a/lib/edoc/doc/overview.edoc +++ b/lib/edoc/doc/overview.edoc @@ -3,7 +3,7 @@ EDoc overview page -@author Richard Carlsson <[email protected]> +@author Richard Carlsson <[email protected]> @copyright 2003-2006 Richard Carlsson @version {@version} @title Welcome to EDoc @@ -277,12 +277,12 @@ The following tags can be used before a module declaration: Examples: ```%% @author Richard Carlsson''' -```%% @author Richard Carlsson <[email protected]> +```%% @author Richard Carlsson <[email protected]> %% [http://user.it.uu.se/~richardc/]''' -```%% @author <[email protected]>''' +```%% @author <[email protected]>''' -```%% @author [email protected] [http://user.it.uu.se/~richardc/]''' +```%% @author [email protected] [http://user.it.uu.se/~richardc/]''' </dd> <dt><a name="mtag-copyright">`@copyright'</a></dt> diff --git a/lib/edoc/include/edoc_doclet.hrl b/lib/edoc/include/edoc_doclet.hrl index a99ff1fbab..60ec7f44e4 100644 --- a/lib/edoc/include/edoc_doclet.hrl +++ b/lib/edoc/include/edoc_doclet.hrl @@ -18,7 +18,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% Author contact: [email protected] +%% Author contact: [email protected] %% ===================================================================== -define(NO_APP, []). diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl index a279f7dcb3..544465b14a 100644 --- a/lib/edoc/src/edoc.erl +++ b/lib/edoc/src/edoc.erl @@ -15,7 +15,7 @@ %% USA %% %% @copyright 2001-2007 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @version {@version} %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc.hrl b/lib/edoc/src/edoc.hrl index 31cf45ade9..98debba4ab 100644 --- a/lib/edoc/src/edoc.hrl +++ b/lib/edoc/src/edoc.hrl @@ -18,7 +18,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% Author contact: [email protected] +%% Author contact: [email protected] %% ===================================================================== %% Note: Documentation in this file is included by edoc_extract.erl diff --git a/lib/edoc/src/edoc_data.erl b/lib/edoc/src/edoc_data.erl index e3b5a0d51b..aad0b14371 100644 --- a/lib/edoc/src/edoc_data.erl +++ b/lib/edoc/src/edoc_data.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_doclet.erl b/lib/edoc/src/edoc_doclet.erl index c66be9d7c7..385d20e9ae 100644 --- a/lib/edoc/src/edoc_doclet.erl +++ b/lib/edoc/src/edoc_doclet.erl @@ -15,7 +15,7 @@ %% USA %% %% @copyright 2003-2006 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_extract.erl b/lib/edoc/src/edoc_extract.erl index 1209d86fe5..5a79e127f6 100644 --- a/lib/edoc/src/edoc_extract.erl +++ b/lib/edoc/src/edoc_extract.erl @@ -15,7 +15,7 @@ %% USA %% %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== @@ -75,7 +75,7 @@ source(Forms, Comments, File, Env, Opts) when is_list(Forms) -> source(Forms1, Comments, File, Env, Opts); source(Forms, Comments, File, Env, Opts) -> Tree = erl_recomment:quick_recomment_forms(Forms, Comments), - TypeDocs = find_type_docs(Forms, Comments), + TypeDocs = find_type_docs(Forms, Comments, Env, File), source1(Tree, File, Env, Opts, TypeDocs). %% @spec source(Forms, File::filename(), Env::edoc_env(), @@ -111,7 +111,7 @@ source(Forms, Comments, File, Env, Opts) -> source(Forms, File, Env, Opts) when is_list(Forms) -> source(erl_syntax:form_list(Forms), File, Env, Opts); source(Tree, File0, Env, Opts) -> - TypeDocs = find_type_docs(Tree, []), + TypeDocs = find_type_docs(Tree, [], Env, File0), source1(Tree, File0, Env, Opts, TypeDocs). %% Forms0 and Comments is used for extracting Erlang type documentation. @@ -635,14 +635,17 @@ file_macros(_Context, Env) -> %% The same thing using -type: %% -type t() :: t1(). % Some docs of t/0; %% Further docs of t/0. -find_type_docs(Forms0, Comments) -> +find_type_docs(Forms0, Comments, Env, File) -> Tree = erl_recomment:recomment_forms(Forms0, Comments), Forms = preprocess_forms(Tree), - edoc_specs:docs(Forms, fun find_fun/2). + Env1 = add_macro_defs(edoc_macros:std_macros(Env), [], Env), + F = fun(C, Line) -> find_fun(C, Line, Env1, File) end, + edoc_specs:docs(Forms, F). -find_fun(C0, Line) -> +find_fun(C0, Line, Env, File) -> C1 = comment_text(C0), Text = lists:append([C#comment.text || C <- C1]), Comm = #comment{line = Line, text = Text}, [Tag | _] = scan_tags([Comm]), - Tag. + [Tag1] = edoc_macros:expand_tags([Tag], Env, File), + Tag1. diff --git a/lib/edoc/src/edoc_layout.erl b/lib/edoc/src/edoc_layout.erl index 1c0841815f..951cec121c 100644 --- a/lib/edoc/src/edoc_layout.erl +++ b/lib/edoc/src/edoc_layout.erl @@ -14,7 +14,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2001-2006 Richard Carlsson %% @see edoc %% @end diff --git a/lib/edoc/src/edoc_lib.erl b/lib/edoc/src/edoc_lib.erl index 6c698e83ef..7fd8358add 100644 --- a/lib/edoc/src/edoc_lib.erl +++ b/lib/edoc/src/edoc_lib.erl @@ -15,7 +15,7 @@ %% USA %% %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== @@ -403,8 +403,13 @@ escape_uri([C | Cs]) -> escape_uri([]) -> []. -escape_byte(C) -> - "%" ++ hex_octet(C). +escape_byte(C) when C >= 0, C =< 255 -> + [$%, hex_digit(C bsr 4), hex_digit(C band 15)]. + +hex_digit(N) when N >= 0, N =< 9 -> + N + $0; +hex_digit(N) when N > 9, N =< 15 -> + N + $a - 10. % utf8([C | Cs]) when C > 16#7f -> % [((C band 16#c0) bsr 6) + 16#c0, C band 16#3f ++ 16#80 | utf8(Cs)]; @@ -413,13 +418,6 @@ escape_byte(C) -> % utf8([]) -> % []. -hex_octet(N) when N =< 9 -> - [$0 + N]; -hex_octet(N) when N > 15 -> - hex_octet(N bsr 4) ++ hex_octet(N band 15); -hex_octet(N) -> - [N - 10 + $a]. - %% Please note that URI are *not* file names. Don't use the stdlib %% 'filename' module for operations on (any parts of) URI. diff --git a/lib/edoc/src/edoc_macros.erl b/lib/edoc/src/edoc_macros.erl index 5b512cb53a..70fb38bf0a 100644 --- a/lib/edoc/src/edoc_macros.erl +++ b/lib/edoc/src/edoc_macros.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2001-2005 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_parser.yrl b/lib/edoc/src/edoc_parser.yrl index 3ce4cde4fb..4d6428f75b 100644 --- a/lib/edoc/src/edoc_parser.yrl +++ b/lib/edoc/src/edoc_parser.yrl @@ -22,7 +22,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% Author contact: [email protected] +%% Author contact: [email protected] %% ===================================================================== Nonterminals @@ -255,7 +255,7 @@ throws -> etype where_defs: %% "%% USA" %% "%%" %% "%% @private" -%% "%% @author Richard Carlsson <[email protected]>" +%% "%% @author Richard Carlsson <[email protected]>" %% "%% ====================================================================" %% . @@ -455,8 +455,6 @@ parse_throws(S, L) -> -spec throw_error(term(), erl_scan:line()) -> no_return(). -throw_error({L, M, D}, _L0) -> - throw({error,L,{format_error,M,D}}); throw_error({parse_spec, E}, L) -> throw_error({"specification", E}, L); throw_error({parse_typedef, E}, L) -> @@ -468,7 +466,4 @@ throw_error({parse_throws, E}, L) -> throw_error(parse_param, L) -> throw({error, L, "missing parameter name"}); throw_error({Where, E}, L) when is_list(Where) -> - throw({error,L,{"unknown error parsing ~s: ~P.",[Where,E,15]}}); -throw_error(E, L) -> - %% Just in case. - throw({error,L,{"unknown parse error: ~P.",[E,15]}}). + throw({error,L,{"unknown error parsing ~s: ~P.",[Where,E,15]}}). diff --git a/lib/edoc/src/edoc_refs.erl b/lib/edoc/src/edoc_refs.erl index b974cf77c1..1f578a3b83 100644 --- a/lib/edoc/src/edoc_refs.erl +++ b/lib/edoc/src/edoc_refs.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @see edoc_parse_ref %% @end diff --git a/lib/edoc/src/edoc_report.erl b/lib/edoc/src/edoc_report.erl index f082513bee..9bec08ab97 100644 --- a/lib/edoc/src/edoc_report.erl +++ b/lib/edoc/src/edoc_report.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_run.erl b/lib/edoc/src/edoc_run.erl index 1355db840f..48b6137ac1 100644 --- a/lib/edoc/src/edoc_run.erl +++ b/lib/edoc/src/edoc_run.erl @@ -15,7 +15,7 @@ %% USA %% %% @copyright 2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_scanner.erl b/lib/edoc/src/edoc_scanner.erl index 8e895ad1ad..754fcef643 100644 --- a/lib/edoc/src/edoc_scanner.erl +++ b/lib/edoc/src/edoc_scanner.erl @@ -16,7 +16,7 @@ %% @private %% @copyright Richard Carlsson 2001-2003. Portions created by Ericsson %% are Copyright 1999, Ericsson Utvecklings AB. All Rights Reserved. -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end diff --git a/lib/edoc/src/edoc_tags.erl b/lib/edoc/src/edoc_tags.erl index 80989428ce..2d986988c2 100644 --- a/lib/edoc/src/edoc_tags.erl +++ b/lib/edoc/src/edoc_tags.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_types.erl b/lib/edoc/src/edoc_types.erl index a54544868c..60c6cecb97 100644 --- a/lib/edoc/src/edoc_types.erl +++ b/lib/edoc/src/edoc_types.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== diff --git a/lib/edoc/src/edoc_types.hrl b/lib/edoc/src/edoc_types.hrl index 1353bfb93a..05c61d70ff 100644 --- a/lib/edoc/src/edoc_types.hrl +++ b/lib/edoc/src/edoc_types.hrl @@ -18,7 +18,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% Author contact: [email protected] +%% Author contact: [email protected] %% ===================================================================== %% Type specification data structures diff --git a/lib/edoc/src/edoc_wiki.erl b/lib/edoc/src/edoc_wiki.erl index 2f2d14853c..5c71658af5 100644 --- a/lib/edoc/src/edoc_wiki.erl +++ b/lib/edoc/src/edoc_wiki.erl @@ -16,7 +16,7 @@ %% %% @private %% @copyright 2001-2003 Richard Carlsson -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @see edoc %% @end %% ===================================================================== @@ -249,10 +249,20 @@ expand_triple([], L, _, L0) -> expand_uri("http:/" ++ Cs, L, As) -> expand_uri(Cs, L, "/:ptth", As); +expand_uri("https:/" ++ Cs, L, As) -> + expand_uri(Cs, L, "/:sptth", As); expand_uri("ftp:/" ++ Cs, L, As) -> expand_uri(Cs, L, "/:ptf", As); expand_uri("file:/" ++ Cs, L, As) -> expand_uri(Cs, L, "/:elif", As); +expand_uri("mailto:/" ++ Cs, L, As) -> + expand_uri(Cs, L, "/:otliam", As); +expand_uri("nfs:/" ++ Cs, L, As) -> + expand_uri(Cs, L, "/:sfn", As); +expand_uri("shttp:/" ++ Cs, L, As) -> + expand_uri(Cs, L, "/:ptths", As); +expand_uri("xmpp:/" ++ Cs, L, As) -> + expand_uri(Cs, L, "/:ppmx", As); expand_uri(Cs, L, As) -> expand(Cs, L, [$[ | As]). diff --git a/lib/edoc/src/otpsgml_layout.erl b/lib/edoc/src/otpsgml_layout.erl index d425dc0ed8..2c4cd919bb 100644 --- a/lib/edoc/src/otpsgml_layout.erl +++ b/lib/edoc/src/otpsgml_layout.erl @@ -14,7 +14,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @author Kenneth Lundin <[email protected]> %% @copyright 2001-2004 Richard Carlsson %% @see edoc_layout diff --git a/lib/edoc/vsn.mk b/lib/edoc/vsn.mk index 30cf191ffc..22f225dd9b 100644 --- a/lib/edoc/vsn.mk +++ b/lib/edoc/vsn.mk @@ -1 +1 @@ -EDOC_VSN = 0.7.8 +EDOC_VSN = 0.7.9 diff --git a/lib/eunit/AUTHORS b/lib/eunit/AUTHORS deleted file mode 100644 index b7c1426aff..0000000000 --- a/lib/eunit/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Richard Carlsson <[email protected]> -Micka�l R�mond <[email protected]> diff --git a/lib/eunit/Makefile b/lib/eunit/Makefile index ee69d5e8e0..cd85dff06a 100644 --- a/lib/eunit/Makefile +++ b/lib/eunit/Makefile @@ -13,8 +13,6 @@ # Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings # AB. All Rights Reserved.'' # -# $Id$ -# include $(ERL_TOP)/make/target.mk include $(ERL_TOP)/make/$(TARGET)/otp.mk diff --git a/lib/eunit/doc/.gitignore b/lib/eunit/doc/.gitignore new file mode 100644 index 0000000000..7fcda5db42 --- /dev/null +++ b/lib/eunit/doc/.gitignore @@ -0,0 +1,4 @@ +*.html +stylesheet.css +erlang.png +edoc-info diff --git a/lib/eunit/doc/edoc-info b/lib/eunit/doc/edoc-info deleted file mode 100644 index 1c04b2ed1a..0000000000 --- a/lib/eunit/doc/edoc-info +++ /dev/null @@ -1,3 +0,0 @@ -{application,eunit}. -{packages,[]}. -{modules,[eunit,eunit_surefire]}. diff --git a/lib/eunit/doc/erlang.png b/lib/eunit/doc/erlang.png Binary files differdeleted file mode 100644 index 987a618e24..0000000000 --- a/lib/eunit/doc/erlang.png +++ /dev/null diff --git a/lib/eunit/doc/eunit.html b/lib/eunit/doc/eunit.html deleted file mode 100644 index a181d12ce3..0000000000 --- a/lib/eunit/doc/eunit.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>Module eunit</title> -<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc"> -</head> -<body bgcolor="white"> -<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<hr> - -<h1>Module eunit</h1> -<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>This module is the main EUnit user interface. -<p>Copyright � 2004-2009 Micka�l R�mond, Richard Carlsson</p> - -<p><b>Version:</b> 2.1.1, Apr 22 2009 22:37:19</p> -<p><b>Authors:</b> Micka�l R�mond (<a href="mailto:[email protected]"><tt>[email protected]</tt></a>) [<em>web site:</em> <tt><a href="http://www.process-one.net/" target="_top">http://www.process-one.net/</a></tt>], Richard Carlsson (<a href="mailto:[email protected]"><tt>[email protected]</tt></a>) [<em>web site:</em> <tt><a href="http://user.it.uu.se/~richardc/" target="_top">http://user.it.uu.se/~richardc/</a></tt>].</p> - -<h2><a name="description">Description</a></h2>This module is the main EUnit user interface. -<h2><a name="index">Function Index</a></h2> -<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#start-0">start/0</a></td><td>Starts the EUnit server.</td></tr> -<tr><td valign="top"><a href="#stop-0">stop/0</a></td><td>Stops the EUnit server.</td></tr> -<tr><td valign="top"><a href="#test-1">test/1</a></td><td>Equivalent to <a href="#test-2"><tt>test(Tests, [])</tt></a>. -</td></tr> -<tr><td valign="top"><a href="#test-2">test/2</a></td><td>Runs a set of tests.</td></tr> -</table> - -<h2><a name="functions">Function Details</a></h2> - -<h3 class="function"><a name="start-0">start/0</a></h3> -<div class="spec"> -<p><tt>start() -> any()</tt></p> -</div><p>Starts the EUnit server. Normally, you don't need to call this - function; it is started automatically.</p> - -<h3 class="function"><a name="stop-0">stop/0</a></h3> -<div class="spec"> -<p><tt>stop() -> any()</tt></p> -</div><p>Stops the EUnit server. Normally, you don't need to call this - function.</p> - -<h3 class="function"><a name="test-1">test/1</a></h3> -<div class="spec"> -<p><tt>test(Tests) -> any()</tt></p> -</div><p>Equivalent to <a href="#test-2"><tt>test(Tests, [])</tt></a>.</p> - - -<h3 class="function"><a name="test-2">test/2</a></h3> -<div class="spec"> -<p><tt>test(Tests::term(), Options::[term()]) -> ok | {error, term()}</tt></p> -</div><p><p>Runs a set of tests. The format of <code>Tests</code> is described in the - section <a href="overview-summary.html#EUnit_test_representation">EUnit test - representation</a> of the overview.</p> - - Example: <pre> eunit:test(fred)</pre><p> runs all tests in the module <code>fred</code> - and also any tests in the module <code>fred_tests</code>, if that module exists.</p> - - Options: - <dl> - <dt><code>verbose</code></dt> - <dd>Displays more details about the running tests.</dd> - </dl> - - Options in the environment variable EUNIT are also included last in - the option list, i.e., have lower precedence than those in <code>Options</code>.</p> -<p><b>See also:</b> <a href="#test-1">test/1</a>.</p> -<hr> - -<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<p><i>Generated by EDoc, Apr 22 2009, 22:37:19.</i></p> -</body> -</html> diff --git a/lib/eunit/doc/eunit_surefire.html b/lib/eunit/doc/eunit_surefire.html deleted file mode 100644 index f2ecbae572..0000000000 --- a/lib/eunit/doc/eunit_surefire.html +++ /dev/null @@ -1,78 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>Module eunit_surefire</title> -<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc"> -</head> -<body bgcolor="white"> -<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<hr> - -<h1>Module eunit_surefire</h1> -<ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Surefire reports for EUnit (Format used by Maven and Atlassian -Bamboo for example to integrate test results). -<p>Copyright � 2009 Micka�l R�mond, Paul Guyot</p> - -<p><b>Behaviours:</b> <a href="eunit_listener.html"><tt>eunit_listener</tt></a>.</p> -<p><b>Authors:</b> Micka�l R�mond (<a href="mailto:[email protected]"><tt>[email protected]</tt></a>).</p> -<p><b>See also:</b> <a href="eunit.html">eunit</a>.</p> - -<h2><a name="description">Description</a></h2><p>Surefire reports for EUnit (Format used by Maven and Atlassian -Bamboo for example to integrate test results). Based on initial code -from Paul Guyot.</p> - - Example: Generate XML result file in the current directory: - <pre> eunit:test([fib, eunit_examples], - [{report,{eunit_surefire,[{dir,"."}]}}]).</pre> -<h2><a name="index">Function Index</a></h2> -<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#handle_begin-3">handle_begin/3</a></td><td></td></tr> -<tr><td valign="top"><a href="#handle_cancel-3">handle_cancel/3</a></td><td></td></tr> -<tr><td valign="top"><a href="#handle_end-3">handle_end/3</a></td><td></td></tr> -<tr><td valign="top"><a href="#init-1">init/1</a></td><td></td></tr> -<tr><td valign="top"><a href="#start-0">start/0</a></td><td></td></tr> -<tr><td valign="top"><a href="#start-1">start/1</a></td><td></td></tr> -<tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td></td></tr> -</table> - -<h2><a name="functions">Function Details</a></h2> - -<h3 class="function"><a name="handle_begin-3">handle_begin/3</a></h3> -<div class="spec"> -<p><tt>handle_begin(X1, Data, St) -> any()</tt></p> -</div> - -<h3 class="function"><a name="handle_cancel-3">handle_cancel/3</a></h3> -<div class="spec"> -<p><tt>handle_cancel(X1, Data, St) -> any()</tt></p> -</div> - -<h3 class="function"><a name="handle_end-3">handle_end/3</a></h3> -<div class="spec"> -<p><tt>handle_end(X1, Data, St) -> any()</tt></p> -</div> - -<h3 class="function"><a name="init-1">init/1</a></h3> -<div class="spec"> -<p><tt>init(Options) -> any()</tt></p> -</div> - -<h3 class="function"><a name="start-0">start/0</a></h3> -<div class="spec"> -<p><tt>start() -> any()</tt></p> -</div> - -<h3 class="function"><a name="start-1">start/1</a></h3> -<div class="spec"> -<p><tt>start(Options) -> any()</tt></p> -</div> - -<h3 class="function"><a name="terminate-2">terminate/2</a></h3> -<div class="spec"> -<p><tt>terminate(X1, St) -> any()</tt></p> -</div> -<hr> - -<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<p><i>Generated by EDoc, Apr 22 2009, 22:37:19.</i></p> -</body> -</html> diff --git a/lib/eunit/doc/index.html b/lib/eunit/doc/index.html deleted file mode 100644 index 9bd8e8cf6b..0000000000 --- a/lib/eunit/doc/index.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>The eunit application</title> -</head> -<frameset cols="20%,80%"> -<frame src="modules-frame.html" name="modulesFrame" title=""> - -<frame src="overview-summary.html" name="overviewFrame" title=""> -<noframes> -<h2>This page uses frames</h2> -<p>Your browser does not accept frames. -<br>You should go to the <a href="overview-summary.html">non-frame version</a> instead. -</p> -</noframes> -</frameset> -</html>
\ No newline at end of file diff --git a/lib/eunit/doc/modules-frame.html b/lib/eunit/doc/modules-frame.html deleted file mode 100644 index a484e99d4c..0000000000 --- a/lib/eunit/doc/modules-frame.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>The eunit application</title> -<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc"> -</head> -<body bgcolor="white"> -<h2 class="indextitle">Modules</h2> -<table width="100%" border="0" summary="list of modules"> -<tr><td><a href="eunit.html" target="overviewFrame" class="module">eunit</a></td></tr> -<tr><td><a href="eunit_surefire.html" target="overviewFrame" class="module">eunit_surefire</a></td></tr></table> -</body> -</html>
\ No newline at end of file diff --git a/lib/eunit/doc/overview-summary.html b/lib/eunit/doc/overview-summary.html deleted file mode 100644 index ea7beba8b3..0000000000 --- a/lib/eunit/doc/overview-summary.html +++ /dev/null @@ -1,1032 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>EUnit - a Lightweight Unit Testing Framework for Erlang -</title> -<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc"> -</head> -<body bgcolor="white"> -<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<h1>EUnit - a Lightweight Unit Testing Framework for Erlang -</h1> -<p>Copyright � 2004-2007 Micka�l R�mond, Richard Carlsson</p> -<p><b>Version:</b> 2.1.1, Apr 22 2009 22:37:19 -</p> -<p><b>Authors:</b> Richard Carlsson (<a href="mailto:[email protected]"><tt>[email protected]</tt></a>) [<em>web site:</em> <tt><a href="http://user.it.uu.se/~richardc/" target="_top">http://user.it.uu.se/~richardc/</a></tt>], Micka�l R�mond (<a href="mailto:[email protected]"><tt>[email protected]</tt></a>) [<em>web site:</em> <tt><a href="http://www.process-one.net/" target="_top">http://www.process-one.net/</a></tt>].</p> -<p>EUnit is a unit testing framework for Erlang. It is very powerful -and flexible, is easy to use, and has small syntactical overhead.</p> - -<ul> -<li><a href="#Unit_testing">Unit testing</a></li> -<li><a href="#Terminology">Terminology</a></li> -<li><a href="#Getting_started">Getting started</a></li> -<li><a href="#EUnit_macros">EUnit macros</a></li> -<li><a href="#EUnit_test_representation">EUnit test representation</a></li> -</ul> - -<p>EUnit builds on ideas from the family of unit testing frameworks for -Object Oriented languages that originated with JUnit by Beck and Gamma -(and Beck's previous framework SUnit for Smalltalk). However, EUnit uses -techniques more adapted to functional and concurrent programming, and is -typically less verbose than its relatives.</p> - -<p>Although EUnit uses many preprocessor macros, they have been designed to -be as nonintrusive as possible, and should not cause conflicts with -existing code. Adding EUnit tests to a module should thus not normally -require changing existing code. Furthermore, tests that only exercise -the exported functions of a module can always be placed in a completely -separate module, avoiding any conflicts entirely.</p> - -<h3><a name="Unit_testing">Unit testing</a></h3> - -<p>Unit Testing is testing of individual program "units" in relative -isolation. There is no particular size requirement: a unit can be a -function, a module, a process, or even a whole application, but the most -typical testing units are individual functions or modules. In order to -test a unit, you specify a set of individual tests, set up the smallest -necessary environment for being able to run those tests (often, you -don't need to do any setup at all), you run the tests and collect the -results, and finally you do any necessary cleanup so that the test can -be run again later. A Unit Testing Framework tries to help you in each -stage of this process, so that it is easy to write tests, easy to run -them, and easy to see which tests failed (so you can fix the bugs).</p> - -<h4><a name="Advantages_of_unit_testing">Advantages of unit testing</a></h4> - -<dl> - <dt>Reduces the risks of changing the program</dt> - <dd>Most programs will be modified during their lifetime: bugs will be - fixed, features will be added, optimizations may become necessary, or - the code will need to be refactored or cleaned up in other ways to - make it easier to work with. But every change to a working program is - a risk of introducing new bugs - or reintroducing bugs that had - previously been fixed. Having a set of unit tests that you can run - with very little effort makes it easy to know that the code still - works as it should (this use is called <em>regression testing</em>; - see <a href="#Terminology">Terminology</a>). This goes a long way to reduce the - resistance to changing and refactoring code.</dd> - <dt>Helps guide and speed up the development process</dt> - <dd>By focusing on getting the code to pass the tests, the programmer - can become more productive, not overspecify or get lost in premature - optimizations, and create code that is correct from the very beginning - (so-called <em>test-driven development</em>; see <a href="#Terminology">Terminology</a>).</dd> - <dt>Helps separate interface from implementation</dt> - <dd>When writing tests, the programmer may discover dependencies - (in order to get the tests to run) that ought not to be there, and - which need to be abstracted away to get a cleaner design. This helps - eliminate bad dependencies before they spread throughout the - code.</dd> - <dt>Makes component integration easier</dt> - <dd>By testing in a bottom-up fashion, beginning with the smallest - program units and creating a confidence in that they work as they - should, it becomes easier to test that a higher-level component, - consisting of several such units, also behaves according to - specification (known as <em>integration testing</em>; see <a href="#Terminology">Terminology</a>).</dd> - <dt>Is self-documenting</dt> - <dd>The tests can be read as documentation, typically showing both - examples of correct and incorrect usage, along with the expected - consequences.</dd> -</dl> - -<h3><a name="Terminology">Terminology</a></h3> - -<dl> - <dt>Unit testing</dt> - <dd>Testing that a program unit behaves as it is supposed to do (in - itself), according to its specifications. Unit tests have an important - function as regression tests, when the program later is modified for - some reason, since they check that the program still behaves according - to specification.</dd> - <dt>Regression testing</dt> - <dd>Running a set of tests after making changes to a program, to check - that the program behaves as it did before the changes (except, of - course, for any intentional changes in behaviour). Unit tests are - important as regression tests, but regression testing can involve more - than just unit testing, and may also test behaviour that might not be - part of the normal specification (such as bug-for-bug-compatibility). - </dd> - <dt>Integration testing</dt> - <dd>Testing that a number of individually developed program units - (assumed to already have been separately unit tested) work together as - expected. Depending on the system being developed, integration testing - may be as simple as "just another level of unit testing", but might - also involve other kinds of tests (compare <em>system testing</em>). -</dd> - <dt>System testing</dt> - <dd>Testing that a complete system behaves according to its - specification. Specifically, system testing should not require knowing - any details about the implementation. It typically involves testing - many different aspects of the system behaviour apart from the basic - functionality, such as performance, usability, and reliability.</dd> - <dt>Test-driven development</dt> - <dd>A program development technique where you continuously write tests - <em>before</em> you implement the code that is supposed to pass those - tests. This can help you focus on solving the right problems, and not - make a more complicated implementation than necessary, by letting the - unit tests determine when a program is "done": if it fulfils its - specifications, there is no need to keep adding functionality.</dd> - <dt>Mock object</dt> - <dd>Sometimes, testing some unit <code>A</code> (e.g., a function) requires that - it collaborates somehow with some other unit <code>B</code> (perhaps being passed - as an argument, or by reference) - but <code>B</code> has not been implemented - yet. A "mock object" - an object which, for the purposes of testing - <code>A</code>, looks and behaves like a real <code>B</code> - might then be used instead. - (This is of course only useful if it would be significantly more work - to implement a real <code>B</code> than to create a mock object.)</dd> - <dt>Test case</dt> - <dd>A single, well-defined test, that somehow can be uniquely - identified. When executed, the test case either <em>passes</em> or - <em>fails</em>; the test report should identify exactly which test - cases failed.</dd> - <dt>Test suite</dt> - <dd>A collection of test cases, generally with a specific, common - target for testing, such as a single function, module, or subsystem. A - test suite may also be recursively composed by smaller test - suites.</dd> -</dl> - -<h3><a name="Getting_started">Getting started</a></h3> -<ul> - <li><a href="#Including_the_EUnit_header_file">Including the EUnit header file</a></li> - <li><a href="#Writing_simple_test_functions">Writing simple test functions</a></li> - <li><a href="#Running_EUnit">Running EUnit</a></li> - <li><a href="#Writing_test_generating_functions">Writing test generating functions</a></li> - <li><a href="#An_example">An example</a></li> - <li><a href="#Disabling_testing">Disabling testing</a></li> - <li><a href="#Avoiding_compile-time_dependency_on_EUnit">Avoiding compile-time dependency on EUnit</a></li> -</ul> - -<h4><a name="Including_the_EUnit_header_file">Including the EUnit header file</a></h4> - -The simplest way to use EUnit in an Erlang module is to add the -following line at the beginning of the module (after the <code>-module</code> -declaration, but before any function definitions): -<pre> -include_lib("eunit/include/eunit.hrl").</pre> - -This will have the following effect: -<ul> - <li>Creates an exported function <code>test()</code> (unless testing is turned - off, and the module does not already contain a test() function), that - can be used to run all the unit tests defined in the module</li> - <li>Causes all functions whose names match <code>..._test()</code> or <code>..._test_()</code> - to be automatically exported from the module (unless testing is - turned off, or the <code>EUNIT_NOAUTO</code> macro is defined)</li> - <li>Makes all the preprocessor macros of EUnit available, to help - writing tests</li> -</ul> - -<strong>Note:</strong> For <code>-include_lib(...)</code> to work, the Erlang -module search path <em>must</em> contain a directory whose name ends in -<code>eunit/ebin</code> (pointing to the <code>ebin</code> subdirectory of the EUnit -installation directory). If EUnit is installed as <code>lib/eunit</code> under your -Erlang/OTP system directory, its <code>ebin</code> subdirectory will be -automatically added to the search path when Erlang starts. Otherwise, -you need to add the directory explicitly, by passing a <code>-pa</code> flag to the -<code>erl</code> or <code>erlc</code> command. For example, a Makefile could contain the -following action for compiling <code>.erl</code> files: -<pre> erlc -pa "path/to/eunit/ebin" $(ERL_COMPILE_FLAGS) -o$(EBIN) $<</pre> -or if you want Eunit to always be available when you run Erlang -interactively, you can add a line like the following to your -<code>$HOME/.erlang</code> file: -<pre> code:add_path("/path/to/eunit/ebin").</pre> - -<h4><a name="Writing_simple_test_functions">Writing simple test functions</a></h4> - -<p>The EUnit framework makes it extremely easy to write unit tests in -Erlang. There are a few different ways of writing them, though, so we -start with the simplest:</p> - -<p>A function with a name ending in <code>..._test()</code> is recognized by EUnit as -a simple test function - it takes no arguments, and its execution either -succeeds (returning some arbitrary value that EUnit will throw away), or -fails by throwing an exception of some kind (or by not terminating, in -which case it will be aborted after a while).</p> - -An example of a simple test function could be the following: -<pre> reverse_test() -> lists:reverse([1,2,3]).</pre><p> -This just tests that the function <code>lists:reverse(List)</code> does not crash -when <code>List</code> is <code>[1,2,3]</code>. It is not a great test, but many people write -simple functions like this one to test the basic functionality of their -code, and those tests can be used directly by EUnit, without changes, -as long as their function names match.</p> - -<h5><a name="Use_exceptions_to_signal_failure">Use exceptions to signal failure</a></h5> - -To write more interesting tests, we need to make them crash (throw an -exception) when they don't get the result they expect. A simple way of -doing this is to use pattern matching with <code>=</code>, as in the following -examples: -<pre> reverse_nil_test() -> [] = lists:reverse([]). - reverse_one_test() -> [1] = lists:reverse([1]). - reverse_two_test() -> [2,1] = lists:reverse([1,2]).</pre><p> -If there was some bug in <code>lists:reverse/1</code> that made it return something -other than <code>[2,1]</code> when it got <code>[1,2]</code> as input, then the last test -above would throw a <code>badmatch</code> error. The first two (we assume they do -not get a <code>badmatch</code>) would simply return <code>[]</code> and <code>[1]</code>, respectively, -so both succeed. (Note that EUnit is not psychic: if you write a test -that returns a value, even if it is the wrong value, EUnit will consider -it a success. You must make sure that the test is written so that it -causes a crash if the result is not what it should be.)</p> - -<h5><a name="Using_assert_macros">Using assert macros</a></h5> - -If you want to use Boolean operators for your tests, the <code>assert</code> -macro comes in handy (see <a href="#EUnit_macros">EUnit macros</a> for details): -<pre> length_test() -> ?assert(length([1,2,3]) =:= 3).</pre><p> -The <code>?assert(Expression)</code> macro will evaluate <code>Expression</code>, and if that -does not evaluate to <code>true</code>, it will throw an exception; otherwise it -just returns <code>ok</code>. In the above example, the test will thus fail if the -call to <code>length</code> does not return 3.</p> - -<h4><a name="Running_EUnit">Running EUnit</a></h4> - -<p>If you have added the declaration -<code>-include_lib("eunit/include/eunit.hrl")</code> to your module, as described -above, you only need to compile the module, and run the automatically -exported function <code>test()</code>. For example, if your module was named <code>m</code>, -then calling <code>m:test()</code> will run EUnit on all the tests defined in the -module. You do not need to write <code>-export</code> declarations for the test -functions. This is all done by magic.</p> - -<p>You can also use the function <a href="eunit.html#test-1"><code>eunit:test/1</code></a> to run arbitrary -tests, for example to try out some more advanced test descriptors (see -<a href="#EUnit_test_representation">EUnit test representation</a>). For example, running -<code>eunit:test(m)</code> does the same thing as the auto-generated function -<code>m:test()</code>, while <code>eunit:test({inparallel, m})</code> runs the same test -cases but executes them all in parallel.</p> - -<h5><a name="Putting_tests_in_separate_modules">Putting tests in separate modules</a></h5> - -<p>If you want to separate your test code from your normal code (at least -for testing the exported functions), you can simply write the test -functions in a module named <code>m_tests</code> (note: not <code>m_test</code>), if your -module is named <code>m</code>. Then, whenever you ask EUnit to test the module -<code>m</code>, it will also look for the module <code>m_tests</code> and run those tests as -well. See <code>ModuleName</code> in the section <a href="#Primitives">Primitives</a> for details.</p> - -<h5><a name="EUnit_captures_standard_output">EUnit captures standard output</a></h5> - -<p>If your test code writes to the standard output, you may be surprised to -see that the text does not appear on the console when the tests are -running. This is because EUnit captures all standard output from test -functions (this also includes setup and cleanup functions, but not -generator functions), so that it can be included in the test report if -errors occur. To bypass EUnit and print text directly to the console -while testing, you can write to the <code>user</code> output stream, as in -<code>io:format(user, "~w", [Term])</code>. The recommended way of doing this is to -use the EUnit <a href="#Debugging_macros">Debugging macros</a>, which make it much simpler.</p> - -<h4><a name="Writing_test_generating_functions">Writing test generating functions</a></h4> - -<p>A drawback of simple test functions is that you must write a separate -function (with a separate name) for each test case. A more compact way -of writing tests (and much more flexible, as we shall see), is to write -functions that <em>return</em> tests, instead of <em>being</em> tests.</p> - -<p>A function with a name ending in <code>..._test_()</code> (note the final -underscore) is recognized by EUnit as a <em>test generator</em> -function. Test generators return a <em>representation</em> of a <em>set -of tests</em> to be executed by EUnit.</p> - -<h5><a name="Representing_a_test_as_data">Representing a test as data</a></h5> - -The most basic representation of a test is a single fun-expression that -takes no arguments. For example, the following test generator: -<pre> basic_test_() -> - fun () -> ?assert(1 + 1 =:= 2) end.</pre> -will have the same effect as the following simple test: -<pre> simple_test() -> - ?assert(1 + 1 =:= 2).</pre><p> -(in fact, EUnit will handle all simple tests just like it handles -fun-expressions: it will put them in a list, and run them one by one).</p> - -<h5><a name="Using_macros_to_write_tests">Using macros to write tests</a></h5> - -To make tests more compact and readable, as well as automatically add -information about the line number in the source code where a test -occurred (and reduce the number of characters you have to type), you can -use the <code>_test</code> macro (note the initial underscore character), like -this: -<pre> basic_test_() -> - ?_test(?assert(1 + 1 =:= 2)).</pre><p> -The <code>_test</code> macro takes any expression (the "body") as argument, and -places it within a fun-expression (along with some extra information). -The body can be any kind of test expression, just like the body of a -simple test function.</p> - -<h5><a name="Underscore-prefixed_macros_create_test_objects">Underscore-prefixed macros create test objects</a></h5> - -But this example can be made even shorter! Most test macros, such as the -family of <code>assert</code> macros, have a corresponding form with an initial -underscore character, which automatically adds a <code>?_test(...)</code> wrapper. -The above example can then simply be written: -<pre> basic_test_() -> - ?_assert(1 + 1 =:= 2).</pre><p> -which has exactly the same meaning (note the <code>_assert</code> instead of -<code>assert</code>). You can think of the initial underscore as signalling -<em>test object</em>.</p> - -<h4><a name="An_example">An example</a></h4> - -Sometimes, an example says more than a thousand words. The following -small Erlang module shows how EUnit can be used in practice. -<pre> -module(fib). - -export([fib/1]). - -include_lib("eunit/include/eunit.hrl"). - - fib(0) -> 1; - fib(1) -> 1; - fib(N) when N > 1 -> fib(N-1) + fib(N-2). - - fib_test_() -> - [?_assert(fib(0) =:= 1), - ?_assert(fib(1) =:= 1), - ?_assert(fib(2) =:= 2), - ?_assert(fib(3) =:= 3), - ?_assert(fib(4) =:= 5), - ?_assert(fib(5) =:= 8), - ?_assertException(error, function_clause, fib(-1)), - ?_assert(fib(31) =:= 2178309) - ].</pre> - -<p>(Author's note: When I first wrote this example, I happened to write a -<code>*</code> instead of <code>+</code> in the <code>fib</code> function. Of course, this showed up -immediately when I ran the tests.)</p> - -<p>See <a href="#EUnit_test_representation">EUnit test representation</a> for a full list of all the ways -you can specify test sets in EUnit.</p> - -<h4><a name="Disabling_testing">Disabling testing</a></h4> - -Testing can be turned off by defining the <code>NOTEST</code> macro when compiling, -for example as an option to <code>erlc</code>, as in: -<pre> erlc -DNOTEST my_module.erl</pre> -or by adding a macro definition to the code, <em>before the EUnit header -file is included</em>: -<pre> -define(NOTEST, 1).</pre><p> -(the value is not important, but should typically be 1 or <code>true</code>). -Note that unless the <code>EUNIT_NOAUTO</code> macro is defined, disabling testing -will also automatically strip all test functions from the code, except -for any that are explicitly declared as exported.</p> - -For instance, to use EUnit in your application, but with testing turned -off by default, put the following lines in a header file: -<pre> -define(NOTEST, true). - -include_lib("eunit/include/eunit.hrl").</pre> -and then make sure that every module of your application includes that -header file. This means that you have a only a single place to modify in -order to change the default setting for testing. To override the <code>NOTEST</code> -setting without modifying the code, you can define <code>TEST</code> in a compiler -option, like this: -<pre> erlc -DTEST my_module.erl</pre> - -<p>See <a href="#Compilation_control_macros">Compilation control macros</a> for details about these -macros.</p> - -<h4><a name="Avoiding_compile-time_dependency_on_EUnit">Avoiding compile-time dependency on EUnit</a></h4> - -If you are distributing the source code for your application for other -people to compile and run, you probably want to ensure that the code -compiles even if EUnit is not available. Like the example in the -previous section, you can put the following lines in a common header -file: -<pre> -ifdef(TEST). - -include_lib("eunit/include/eunit.hrl"). - -endif.</pre><p> -and, of course, also make sure that you place all test code that uses -EUnit macros within <code>-ifdef(TEST)</code> or <code>-ifdef(EUNIT)</code> sections.</p> - - -<h3><a name="EUnit_macros">EUnit macros</a></h3> - -<p>Although all the functionality of EUnit is avaliable even without the -use of preprocessor macros, the EUnit header file defines a number of -such macros in order to make it as easy as possible to write unit tests -as compactly as possible and without getting too many details in the -way.</p> - -<p>Except where explicitly stated, using EUnit macros will never introduce -run-time dependencies on the EUnit library code, regardless of whether -your code is compiled with testing enabled or disabled.</p> - -<ul> -<li><a href="#Basic_macros">Basic macros</a></li> -<li><a href="#Compilation_control_macros">Compilation control macros</a></li> -<li><a href="#Utility_macros">Utility macros</a></li> -<li><a href="#Assert_macros">Assert macros</a></li> -<li><a href="#Macros_for_running_external_commands">Macros for running external commands</a></li> -<li><a href="#Debugging_macros">Debugging macros</a></li> -</ul> - -<h4><a name="Basic_macros">Basic macros</a></h4> - -<dl> -<dt><code>_test(Expr)</code></dt> -<dd>Turns <code>Expr</code> into a "test object", by wrapping it in a -fun-expression and a source line number. Technically, this is the same -as <code>{?LINE, fun () -> (Expr) end}</code>. -</dd> -</dl> - -<h4><a name="Compilation_control_macros">Compilation control macros</a></h4> - -<dl> -<dt><code>EUNIT</code></dt> -<dd>This macro is always defined to <code>true</code> whenever EUnit is enabled at -compile time. This is typically used to place testing code within -conditional compilation, as in: -<pre> -ifdef(EUNIT). - % test code here - ... - -endif.</pre> -e.g., to ensure that the code can be compiled without including the -EUnit header file, when testing is disabled. See also the macros <code>TEST</code> -and <code>NOTEST</code>. -</dd> - -<dt><code>EUNIT_NOAUTO</code></dt> -<dd>If this macro is defined, the automatic exporting or stripping of -test functions will be disabled. -</dd> - -<dt><code>TEST</code></dt> -<dd><p>This macro is always defined (to <code>true</code>, unless previously defined -by the user to have another value) whenever EUnit is enabled at compile -time. This can be used to place testing code within conditional -compilation; see also the macros <code>NOTEST</code> and <code>EUNIT</code>.</p> - -<p>For testing code that is strictly dependent on EUnit, it may be -preferable to use the <code>EUNIT</code> macro for this purpose, while for code -that uses more generic testing conventions, using the <code>TEST</code> macro may -be preferred.</p> - -The <code>TEST</code> macro can also be used to override the <code>NOTEST</code> macro. If -<code>TEST</code> is defined <em>before</em> the EUnit header file is -included (even if <code>NOTEST</code> is also defined), then the code will be -compiled with EUnit enabled. -</dd> - -<dt><code>NOTEST</code></dt> -<dd><p>This macro is always defined (to <code>true</code>, unless previously defined -by the user to have another value) whenever EUnit is <em>disabled</em> -at compile time. (Compare the <code>TEST</code> macro.)</p> - -This macro can also be used for conditional compilation, but is more -typically used to disable testing: If <code>NOTEST</code> is defined -<em>before</em> the EUnit header file is included, and <code>TEST</code> -is <em>not</em> defined, then the code will be compiled with EUnit -disabled. See also <a href="#Disabling_testing">Disabling testing</a>. -</dd> - -<dt><code>NOASSERT</code></dt> -<dd>If this macro is defined, the assert macros will have no effect, -when testing is also disabled. See <a href="#Assert_macros">Assert macros</a>. When -testing is enabled, the assert macros are always enabled automatically -and cannot be disabled. -</dd> - -<dt><code>ASSERT</code></dt> -<dd>If this macro is defined, it overrides the NOASSERT macro, forcing -the assert macros to always be enabled regardless of other settings. -</dd> - -<dt><code>NODEBUG</code></dt> -<dd>If this macro is defined, the debugging macros will have no effect. -See <a href="#Debugging_macros">Debugging macros</a>. <code>NODEBUG</code> also implies <code>NOASSERT</code>, -unless testing is enabled. -</dd> - -<dt><code>DEBUG</code></dt> -<dd>If this macro is defined, it overrides the NODEBUG macro, forcing -the debugging macros to be enabled. -</dd> -</dl> - -<h4><a name="Utility_macros">Utility macros</a></h4> - -<p>The following macros can make tests more compact and readable:</p> - -<dl> -<dt><code>LET(Var,Arg,Expr)</code></dt> -<dd>Creates a local binding <code>Var = Arg</code> in <code>Expr</code>. (This is the same as -<code>(fun(Var)->(Expr)end)(Arg)</code>.) Note that the binding is not exported -outside of <code>Expr</code>, and that within <code>Expr</code>, this binding of <code>Var</code> will -shadow any binding of <code>Var</code> in the surrounding scope. -</dd> -<dt><code>IF(Cond,TrueCase,FalseCase)</code></dt> -<dd>Evaluates <code>TrueCase</code> if <code>Cond</code> evaluates to <code>true</code>, or otherwise -evaluates <code>FalseCase</code> if <code>Cond</code> evaluates to <code>false</code>. (This is the same -as <code>(case (Cond) of true->(TrueCase); false->(FalseCase) end)</code>.) Note -that it is an error if <code>Cond</code> does not yield a boolean value. -</dd> -</dl> - -<h4><a name="Assert_macros">Assert macros</a></h4> - -<p>(Note that these macros also have corresponding forms which start with -an "<code>_</code>" (underscore) character, as in <code>?_assert(BoolExpr)</code>, that create -a "test object" instead of performing the test immediately. This is -equivalent to writing <code>?_test(assert(BoolExpr))</code>, etc.)</p> - -<p>If the macro <code>NOASSERT</code> is defined before the EUnit header file is -included, these macros have no effect when testing is also disabled; see -<a href="#Compilation_control_macros">Compilation control macros</a> for details.</p> - -<dl> -<dt><code>assert(BoolExpr)</code></dt> -<dd><p>Evaluates the expression <code>BoolExpr</code>, if testing is enabled. Unless -the result is <code>true</code>, an informative exception will be generated. If -there is no exception, the result of the macro expression is the atom -<code>ok</code>, and the value of <code>BoolExpr</code> is discarded. If testing is disabled, -the macro will not generate any code except the atom <code>ok</code>, and -<code>BoolExpr</code> will not be evaluated.</p> - -Typical usage: -<pre> ?assert(f(X, Y) =:= [])</pre> - -The <code>assert</code> macro can be used anywhere in a program, not just in unit -tests, to check pre/postconditions and invariants. For example: -<pre> some_recursive_function(X, Y, Z) -> - ?assert(X + Y > Z), - ...</pre> -</dd> -<dt><code>assertNot(BoolExpr)</code></dt> -<dd>Equivalent to <code>assert(not (BoolExpr))</code>. -</dd> -<dt><code>assertMatch(GuardedPattern, Expr)</code></dt> -<dd><p>Evaluates <code>Expr</code> and matches the result against <code>GuardedPattern</code>, if -testing is enabled. If the match fails, an informative exception will be -generated; see the <code>assert</code> macro for further details. <code>GuardedPattern</code> -can be anything that you can write on the left hand side of the <code>-></code> -symbol in a case-clause, except that it cannot contain comma-separated -guard tests.</p> - -<p>The main reason for using <code>assertMatch</code> also for simple matches, instead -of matching with <code>=</code>, is that it produces more detailed error messages.</p> - -Examples: -<pre> ?assertMatch({found, {fred, _}}, lookup(bloggs, Table))</pre> -<pre> ?assertMatch([X|_] when X > 0, binary_to_list(B))</pre> -</dd> -<dt><code>assertEqual(Expect, Expr)</code></dt> -<dd><p>Evaluates the expressions <code>Expect</code> and <code>Expr</code> and compares the -results for equality, if testing is enabled. If the values are not -equal, an informative exception will be generated; see the <code>assert</code> -macro for further details.</p> - -<p><code>assertEqual</code> is more suitable than than <code>assertMatch</code> when the -left-hand side is a computed value rather than a simple pattern, and -gives more details than <code>?assert(Expect =:= Expr)</code>.</p> - -Examples: -<pre> ?assertEqual("b" ++ "a", lists:reverse("ab"))</pre> -<pre> ?assertEqual(foo(X), bar(Y))</pre> -</dd> -<dt><code>assertException(ClassPattern, TermPattern, Expr)</code></dt> -<dt><code>assertError(TermPattern, Expr)</code></dt> -<dt><code>assertExit(TermPattern, Expr)</code></dt> -<dt><code>assertThrow(TermPattern, Expr)</code></dt> -<dd><p>Evaluates <code>Expr</code>, catching any exception and testing that it matches -the expected <code>ClassPattern:TermPattern</code>. If the match fails, or if no -exception is thrown by <code>Expr</code>, an informative exception will be -generated; see the <code>assert</code> macro for further details. The -<code>assertError</code>, <code>assertExit</code>, and <code>assertThrow</code> macros, are equivalent to -using <code>assertException</code> with a <code>ClassPattern</code> of <code>error</code>, <code>exit</code>, or -<code>throw</code>, respectively.</p> - -Examples: -<pre> ?assertError(badarith, X/0)</pre> -<pre> ?assertExit(normal, exit(normal))</pre> -<pre> ?assertException(throw, {not_found,_}, throw({not_found,42}))</pre> -</dd> -</dl> - -<h4><a name="Macros_for_running_external_commands">Macros for running external commands</a></h4> - -<p>Keep in mind that external commands are highly dependent on the -operating system. You can use the standard library function <code>os:type()</code> -in test generator functions, to produce different sets of tests -depending on the current operating system.</p> - -<p>Note: these macros introduce a run-time dependency on the EUnit library -code, if compiled with testing enabled.</p> - -<dl> -<dt><code>assertCmd(CommandString)</code></dt> -<dd><p>Runs <code>CommandString</code> as an external command, if testing is enabled. -Unless the returned status value is 0, an informative exception will be -generated. If there is no exception, the result of the macro expression -is the atom <code>ok</code>. If testing is disabled, the macro will not generate -any code except the atom <code>ok</code>, and the command will not be executed.</p> - -Typical usage: -<pre> ?assertCmd("mkdir foo")</pre> -</dd> -<dt><code>assertCmdStatus(N, CommandString)</code></dt> -<dd>Like the <code>assertCmd(CommandString)</code> macro, but generates an -exception unless the returned status value is <code>N</code>. -</dd> -<dt><code>assertCmdOutput(Text, CommandString)</code></dt> -<dd>Runs <code>CommandString</code> as an external command, if testing is enabled. -Unless the output produced by the command exactly matches the specified -string <code>Text</code>, an informative exception will be generated. (Note that -the output is normalized to use a single LF character as line break on -all platforms.) If there is no exception, the result of the macro -expression is the atom <code>ok</code>. If testing is disabled, the macro will not -generate any code except the atom <code>ok</code>, and the command will not be -executed. -</dd> -<dt><code>cmd(CommandString)</code></dt> -<dd><p>Runs <code>CommandString</code> as an external command. Unless the returned -status value is 0 (indicating success), an informative exception will be -generated; otherwise, the result of the macro expression is the output -produced by the command, as a flat string. The output is normalized to -use a single LF character as line break on all platforms.</p> - -<p>This macro is useful in the setup and cleanup sections of fixtures, -e.g., for creating and deleting files or perform similar operating -system specific tasks, to make sure that the test system is informed of -any failures.</p> - -A Unix-specific example: -<pre> {setup, - fun () -> ?cmd("mktemp") end, - fun (FileName) -> ?cmd("rm " ++ FileName) end, - ...}</pre> -</dd> -</dl> - -<h4><a name="Debugging_macros">Debugging macros</a></h4> - -<p>To help with debugging, EUnit defines several useful macros for printing -messages directly to the console (rather than to the standard output). -Furthermore, these macros all use the same basic format, which includes -the file and line number where they occur, making it possible in some -development environments (e.g., when running Erlang in an Emacs buffer) -to simply click on the message and jump directly to the corresponding -line in the code.</p> - -<p>If the macro <code>NODEBUG</code> is defined before the EUnit header file is -included, these macros have no effect; see -<a href="#Compilation_control_macros">Compilation control macros</a> for details.</p> - -<dl> -<dt><code>debugHere</code></dt> -<dd>Just prints a marker showing the current file and line number. Note -that this is an argument-less macro. The result is always <code>ok</code>.</dd> -<dt><code>debugMsg(Text)</code></dt> -<dd>Outputs the message <code>Text</code> (which can be a plain string, an IO-list, -or just an atom). The result is always <code>ok</code>.</dd> -<dt><code>debugFmt(FmtString, Args)</code></dt> -<dd>This formats the text like <code>io:format(FmtString, Args)</code> and outputs -it like <code>debugMsg</code>. The result is always <code>ok</code>.</dd> -<dt><code>debugVal(Expr)</code></dt> -<dd>Prints both the source code for <code>Expr</code> and its current value. E.g., -<code>?debugVal(f(X))</code> might be displayed as "<code>f(X) = 42</code>". (Large terms are -shown truncated.) The result is always the value of <code>Expr</code>, so this -macro can be wrapped around any expression to display its value when -the code is compiled with debugging enabled.</dd> -<dt><code>debugTime(Text,Expr)</code></dt> -<dd>Prints <code>Text</code> and the wall clock time for evaluation of <code>Expr</code>. The -result is always the value of <code>Expr</code>, so this macro can be wrapped -around any expression to show its run time when the code is compiled -with debugging enabled. For example, <code>List1 = ?debugTime("sorting", -lists:sort(List))</code> might show as "<code>sorting: 0.015 s</code>".</dd> - -</dl> - - -<h3><a name="EUnit_test_representation">EUnit test representation</a></h3> - -<p>The way EUnit represents tests and test sets as data is flexible, -powerful, and concise. This section describes the representation in -detail.</p> - -<ul> -<li><a href="#Simple_test_objects">Simple test objects</a></li> -<li><a href="#Test_sets_and_deep_lists">Test sets and deep lists</a></li> -<li><a href="#Titles">Titles</a></li> -<li><a href="#Primitives">Primitives</a></li> -<li><a href="#Control">Control</a></li> -<li><a href="#Fixtures">Fixtures</a></li> -<li><a href="#Lazy_generators">Lazy generators</a></li> -</ul> - -<h4><a name="Simple_test_objects">Simple test objects</a></h4> - -A <em>simple test object</em> is one of the following: -<ul> - <li>A nullary functional value (i.e., a fun that takes zero - arguments). Examples: -<pre> fun () -> ... end</pre> -<pre> fun some_function/0</pre> -<pre> fun some_module:some_function/0</pre> - </li> - <li>A pair of atoms <code>{ModuleName, FunctionName}</code>, referring to the - function <code>ModuleName:FunctionName/0</code></li> - <li>A pair <code>{LineNumber, SimpleTest}</code>, where <code>LineNumber</code> is a - nonnegative integer and <code>SimpleTest</code> is another simple test - object. <code>LineNumber</code> should indicate the source line of the test. - Pairs like this are usually only created via <code>?_test(...)</code> macros; - see <a href="#Basic_macros">Basic macros</a>.</li> -</ul><p> -In brief, a simple test object consists of a single function that takes -no arguments (possibly annotated with some additional metadata, i.e., a -line number). Evaluation of the function either <em>succeeds</em>, by -returning some value (which is ignored), or <em>fails</em>, by throwing -an exception.</p> - -<h4><a name="Test_sets_and_deep_lists">Test sets and deep lists</a></h4> - -<p>A test set can be easily created by placing a sequence of test objects -in a list. If <code>T_1</code>, ..., <code>T_N</code> are individual test objects, then <code>[T_1, -..., T_N]</code> is a test set consisting of those objects (in that order).</p> - -<p>Test sets can be joined in the same way: if <code>S_1</code>, ..., <code>S_K</code> are test -sets, then <code>[S_1, ..., S_K]</code> is also a test set, where the tests of -<code>S_i</code> are ordered before those of <code>S_(i+1)</code>, for each subset <code>S_i</code>.</p> - -<p>Thus, the main representation of test sets is <em>deep lists</em>, and -a simple test object can be viewed as a test set containing only a -single test; there is no difference between <code>T</code> and <code>[T]</code>.</p> - -<p>A module can also be used to represent a test set; see <code>ModuleName</code> -under <a href="#Primitives">Primitives</a> below.</p> - -<h4><a name="Titles">Titles</a></h4> - -<p>Any test or test set <code>T</code> can be annotated with a title, by wrapping it -in a pair <code>{Title, T}</code>, where <code>Title</code> is a string. For convenience, any -test which is normally represented using a tuple can simply be given a -title string as the first element, i.e., writing <code>{"The Title", ...}</code> -instead of adding an extra tuple wrapper as in <code>{"The Title", {...}}</code>.</p> - - -<h4><a name="Primitives">Primitives</a></h4> - -The following are primitives, which do not contain other test sets as -arguments: -<dl> -<dt><code>ModuleName::atom()</code> -</dt> -<dd>A single atom represents a module name, and is equivalent to -<code>{module, ModuleName}</code>. This is often used as in the call -<code>eunit:test(some_module)</code>. -</dd> -<dt><code>{module, ModuleName::atom()}</code> -</dt> -<dd><p>This composes a test set from the exported test functions of the -named module, i.e., those functions with arity zero whose names end -with <code>_test</code> or <code>_test_</code>. Basically, the <code>..._test()</code> functions become -simple tests, while the <code>..._test_()</code> functions become generators.</p> - -In addition, EUnit will also look for another module whose name is -<code>ModuleName</code> plus the suffix <code>_tests</code>, and if it exists, all the tests -from that module will also be added. (If <code>ModuleName</code> already contains -the suffix <code>_tests</code>, this is not done.) E.g., the specification -<code>{module, mymodule}</code> will run all tests in the modules <code>mymodule</code> and -<code>mymodule_tests</code>. Typically, the <code>_tests</code> module should only contain -test cases that use the public interface of the main module (and no -other code). -</dd> -<dt><code>{application, AppName::atom(), Info::list()}</code> -</dt> -<dd>This is a normal Erlang/OTP application descriptor, as found in an - <code>.app</code> file. The resulting test set consists of the modules listed in - the <code>modules</code> entry in <code>Info</code>. -</dd> -<dt><code>{application, AppName::atom()}</code> -</dt> -<dd>This creates a test set from all the modules belonging to the -specified application, by consulting the application's <code>.app</code> file -(see <code>{file, FileName}</code>), or if no such file exists, by testing all -object files in the application's <tt>ebin</tt>-directory (see <code>{dir, -Path}</code>); if that does not exist, the <code>code:lib_dir(AppName)</code> directory -is used. -</dd> -<dt><code>Path::string()</code> -</dt> -<dd>A single string represents the path of a file or directory, and is -equivalent to <code>{file, Path}</code>, or <code>{dir, Path}</code>, respectively, depending -on what <code>Path</code> refers to in the file system. -</dd> -<dt><code>{file, FileName::string()}</code> -</dt> -<dd><p>If <code>FileName</code> has a suffix that indicates an object file (<code>.beam</code>), -EUnit will try to reload the module from the specified file and test it. -Otherwise, the file is assumed to be a text file containing test -specifications, which will be read using the standard library function -<code>file:path_consult/2</code>.</p> - -Unless the file name is absolute, the file is first searched for -relative to the current directory, and then using the normal search path -(<code>code:get_path()</code>). This means that the names of typical "app" files -can be used directly, without a path, e.g., <code>"mnesia.app"</code>. -</dd> -<dt><code>{dir, Path::string()}</code> -</dt> -<dd>This tests all object files in the specified directory, as if they -had been individually specified using <code>{file, FileName}</code>. -</dd> -<dt><code>{generator, GenFun::(() -> Tests)}</code> -</dt> -<dd>The generator function <code>GenFun</code> is called to produce a test -set. -</dd> -<dt><code>{generator, ModuleName::atom(), FunctionName::atom()}</code> -</dt> -<dd>The function <code>ModuleName:FunctionName()</code> is called to produce a test -set. -</dd> -<dt><code>{with, X::any(), [AbstractTestFun::((any()) -> any())]}</code> -</dt> -<dd>Distributes the value <code>X</code> over the unary functions in the list, -turning them into nullary test functions. An <code>AbstractTestFun</code> is like -an ordinary test fun, but takes one argument instead of zero - it's -basically missing some information before it can be a proper test. In -practice, <code>{with, X, [F_1, ..., F_N]}</code> is equivalent to <code>[fun () -> -F_1(X) end, ..., fun () -> F_N(X) end]</code>. This is particularly useful if -your abstract test functions are already implemented as proper -functions: <code>{with, FD, [fun filetest_a/1, fun filetest_b/1, fun -filetest_c/1]}</code> is equivalent to <code>[fun () -> filetest_a(FD) end, fun () --> filetest_b(FD) end, fun () -> filetest_c(FD) end]</code>, but much more -compact. See also <a href="#Fixtures">Fixtures</a>, below. -</dd> -</dl> - -<h4><a name="Control">Control</a></h4> - -The following representations control how and where tests are executed: -<dl> -<dt><code>{spawn, Tests}</code></dt> -<dd>Runs the specified tests in a separate subprocess, while the current -test process waits for it to finish. This is useful for tests that need -a fresh, isolated process state. (Note that EUnit always starts at least -one such a subprocess automatically; tests are never executed by the -caller's own process.)</dd> -<dt><code>{spawn, Node::atom(), Tests}</code></dt> -<dd>Like <code>{spawn, Tests}</code>, but runs the specified tests on the given -Erlang node.</dd> -<dt><code>{timeout, Time::number(), Tests}</code></dt> -<dd>Runs the specified tests under the given timeout. Time is in -seconds; e.g., 60 means one minute and 0.1 means 1/10th of a second. If -the timeout is exceeded, the unfinished tests will be forced to -terminate. Note that if a timeout is set around a fixture, it includes -the time for setup and cleanup, and if the timeout is triggered, the -entire fixture is abruptly terminated (without running the -cleanup).</dd> -<dt><code>{inorder, Tests}</code></dt> -<dd>Runs the specified tests in strict order. Also see <code>{inparallel, -Tests}</code>. By default, tests are neither marked as <code>inorder</code> or -<code>inparallel</code>, but may be executed as the test framework chooses.</dd> -<dt><code>{inparallel, Tests}</code></dt> -<dd>Runs the specified tests in parallel (if possible). Also see -<code>{inorder, Tests}</code>.</dd> -<dt><code>{inparallel, N::integer(), Tests}</code></dt> -<dd>Like <code>{inparallel, Tests}</code>, but running no more than <code>N</code> subtests -simultaneously.</dd> -</dl> - -<h4><a name="Fixtures">Fixtures</a></h4> - -<p>A "fixture" is some state that is necessary for a particular set of -tests to run. EUnit's support for fixtures makes it easy to set up such -state locally for a test set, and automatically tear it down again when -the test set is finished, regardless of the outcome (success, failures, -timeouts, etc.).</p> - -<p>To make the descriptions simpler, we first list some definitions: -<center> -<table border="0" cellspacing="4"> -<tr> -<td><code>Setup</code></td><td><code>() -> (R::any())</code></td> -</tr> -<tr> -<td><code>SetupX</code></td><td><code>(X::any()) -> (R::any())</code></td> -</tr> -<tr> -<td><code>Cleanup</code></td><td><code>(R::any()) -> any()</code></td> -</tr> -<tr> -<td><code>CleanupX</code></td><td><code>(X::any(), R::any()) -> any()</code></td> -</tr> -<tr> -<td><code>Instantiator</code></td><td><code>((R::any()) -> Tests) | {with, [AbstractTestFun::((any()) -> any())]}</code></td> -</tr> -<tr> -<td><code>Where</code></td><td><code>local | spawn | {spawn, Node::atom()}</code></td> -</tr> -</table> -</center> -(these are explained in more detail further below.)</p> - -The following representations specify fixture handling for test sets: -<dl> -<dt><code>{setup, Setup, Tests | Instantiator}</code></dt> -<dt><code>{setup, Setup, Cleanup, Tests | Instantiator}</code></dt> -<dt><code>{setup, Where, Setup, Tests | Instantiator}</code></dt> -<dt><code>{setup, Where, Setup, Cleanup, Tests | Instantiator}</code></dt> -<dd><code>setup</code> sets up a single fixture for running all of the specified -tests, with optional teardown afterwards. The arguments are described in -detail below. -</dd> -<dt><code>{node, Node::atom(), Tests | Instantiator}</code></dt> -<dt><code>{node, Node::atom(), Args::string(), Tests | Instantiator}</code></dt> -<dd><code>node</code> is like <code>setup</code>, but with a built-in behaviour: it starts a -slave node for the duration of the tests. The atom <code>Node</code> should have -the format <code>[email protected]</code>, and <code>Args</code> are the optional -arguments to the new node; see <code>slave:start_link/3</code> for details. -</dd> -<dt><code>{foreach, Where, Setup, Cleanup, [Tests | Instantiator]}</code></dt> -<dt><code>{foreach, Setup, Cleanup, [Tests | Instantiator]}</code></dt> -<dt><code>{foreach, Where, Setup, [Tests | Instantiator]}</code></dt> -<dt><code>{foreach, Setup, [Tests | Instantiator]}</code></dt> -<dd><code>foreach</code> is used to set up a fixture and optionally tear it down -afterwards, repeated for each single one of the specified test sets. -</dd> -<dt><code>{foreachx, Where, SetupX, CleanupX, - Pairs::[{X::any(), ((X::any(), R::any()) -> Tests)}]}</code></dt> -<dt><code>{foreachx, SetupX, CleanupX, Pairs}</code></dt> -<dt><code>{foreachx, Where, SetupX, Pairs}</code></dt> -<dt><code>{foreachx, SetupX, Pairs}</code></dt> -<dd><code>foreachx</code> is like <code>foreach</code>, but uses a list of pairs, each -containing an extra argument <code>X</code> and an extended instantiator function. -</dd> -</dl> - -<p>A <code>Setup</code> function is executed just before any of the specified tests -are run, and a <code>Cleanup</code> function is executed when no more of the -specified tests will be run, regardless of the reason. A <code>Setup</code> -function takes no argument, and returns some value which will be passed -as it is to the <code>Cleanup</code> function. A <code>Cleanup</code> function should do -whatever necessary and return some arbitrary value, such as the atom -<code>ok</code>. (<code>SetupX</code> and <code>CleanupX</code> functions are similar, but receive one -additional argument: some value <code>X</code>, which depends on the context.) When -no <code>Cleanup</code> function is specified, a dummy function is used which has -no effect.</p> - -<p>An <code>Instantiator</code> function receives the same value as the <code>Cleanup</code> -function, i.e., the value returned by the <code>Setup</code> function. It should -then behave much like a generator (see <a href="#Primitives">Primitives</a>), and -return a test set whose tests have been <em>instantiated</em> with the -given value. A special case is the syntax <code>{with, [AbstractTestFun]}</code> -which represents an instantiator function that distributes the value -over a list of unary functions; see <a href="#Primitives">Primitives</a>: <code>{with, X, -[...]}</code> for more details.</p> - -A <code>Where</code> term controls how the specified tests are executed. The -default is <code>spawn</code>, which means that the current process handles the -setup and teardown, while the tests are executed in a subprocess. -<code>{spawn, Node}</code> is like <code>spawn</code>, but runs the subprocess on the -specified node. <code>local</code> means that the current process will handle both -setup/teardown and running the tests - the drawback is that if a test -times out so that the process is killed, the <em>cleanup will not be -performed</em>; hence, avoid this for persistent fixtures such as file -operations. In general, 'local' should only be used when: -<ul> - <li>the setup/teardown needs to be executed by the process that will - run the tests;</li> - <li>no further teardown needs to be done if the process is killed - (i.e., no state outside the process was affected by the setup)</li> -</ul> - -<h4><a name="Lazy_generators">Lazy generators</a></h4> - -<p>Sometimes, it can be convenient not to produce the whole set of test -descriptions before the testing begins; for example, if you want to -generate a huge amount of tests that would take up too much space to -keep in memory all at once.</p> - -<p>It is fairly easy to write a generator which, each time it is called, -either produces an empty list if it is done, or otherwise produces a -list containing a single test case plus a new generator which will -produce the rest of the tests. This demonstrates the basic pattern:</p> - -<pre> lazy_test_() -> - lazy_gen(10000). - - lazy_gen(N) -> - {generator, - fun () -> - if N > 0 -> - [?_test(...) - | lazy_gen(N-1)]; - true -> - [] - end - end}.</pre> - -<p>When EUnit traverses the test representation in order to run the tests, -the new generator will not be called to produce the next test until the -previous test has been executed.</p> - -Note that it is easiest to write this kind of recursive generator using -a help function, like the <code>lazy_gen/1</code> function above. It can also be -written using a recursive fun, if you prefer to not clutter your -function namespace and are comfortable with writing that kind of code. - -<hr> -<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div> -<p><i>Generated by EDoc, Apr 22 2009, 22:37:19.</i></p> -</body> -</html> diff --git a/lib/eunit/doc/overview.edoc b/lib/eunit/doc/overview.edoc index 2583f0be25..ad449cb6fc 100644 --- a/lib/eunit/doc/overview.edoc +++ b/lib/eunit/doc/overview.edoc @@ -5,8 +5,7 @@ @title EUnit - a Lightweight Unit Testing Framework for Erlang -@author Richard Carlsson <[email protected]> - [http://user.it.uu.se/~richardc/] +@author Richard Carlsson <[email protected]> @author Micka�l R�mond <[email protected]> [http://www.process-one.net/] @copyright 2004-2007 Micka�l R�mond, Richard Carlsson diff --git a/lib/eunit/doc/packages-frame.html b/lib/eunit/doc/packages-frame.html deleted file mode 100644 index 52b45534f5..0000000000 --- a/lib/eunit/doc/packages-frame.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<title>The eunit application</title> -<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc"> -</head> -<body bgcolor="white"> -<h2 class="indextitle">Packages</h2> -<table width="100%" border="0" summary="list of packages"></table> -</body> -</html>
\ No newline at end of file diff --git a/lib/eunit/doc/stylesheet.css b/lib/eunit/doc/stylesheet.css deleted file mode 100644 index e426a90483..0000000000 --- a/lib/eunit/doc/stylesheet.css +++ /dev/null @@ -1,55 +0,0 @@ -/* standard EDoc style sheet */ -body { - font-family: Verdana, Arial, Helvetica, sans-serif; - margin-left: .25in; - margin-right: .2in; - margin-top: 0.2in; - margin-bottom: 0.2in; - color: #000000; - background-color: #ffffff; -} -h1,h2 { - margin-left: -0.2in; -} -div.navbar { - background-color: #add8e6; - padding: 0.2em; -} -h2.indextitle { - padding: 0.4em; - background-color: #add8e6; -} -h3.function,h3.typedecl { - background-color: #add8e6; - padding-left: 1em; -} -div.spec { - margin-left: 2em; - background-color: #eeeeee; -} -a.module,a.package { - text-decoration:none -} -a.module:hover,a.package:hover { - background-color: #eeeeee; -} -ul.definitions { - list-style-type: none; -} -ul.index { - list-style-type: none; - background-color: #eeeeee; -} - -/* - * Minor style tweaks - */ -ul { - list-style-type: square; -} -table { - border-collapse: collapse; -} -td { - padding: 3 -} diff --git a/lib/eunit/examples/Makefile b/lib/eunit/examples/Makefile index d1b5bac224..48ec2ebf2b 100644 --- a/lib/eunit/examples/Makefile +++ b/lib/eunit/examples/Makefile @@ -13,8 +13,6 @@ # Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings # AB. All Rights Reserved.'' # -# $Id$ -# include $(ERL_TOP)/make/target.mk include $(ERL_TOP)/make/$(TARGET)/otp.mk diff --git a/lib/eunit/include/eunit.hrl b/lib/eunit/include/eunit.hrl index 493ba60a2d..db68d8ae60 100644 --- a/lib/eunit/include/eunit.hrl +++ b/lib/eunit/include/eunit.hrl @@ -13,8 +13,6 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit.hrl 337 2009-03-09 08:38:28Z rcarlsson $ -%% %% Copyright (C) 2004-2006 Micka�l R�mond, Richard Carlsson %% Including this file turns on testing and defines TEST, unless NOTEST diff --git a/lib/eunit/src/eunit.erl b/lib/eunit/src/eunit.erl index 15fc3bdf32..95857e83c8 100644 --- a/lib/eunit/src/eunit.erl +++ b/lib/eunit/src/eunit.erl @@ -13,13 +13,10 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit.erl 339 2009-04-05 14:10:47Z rcarlsson $ -%% %% @copyright 2004-2009 Micka�l R�mond, Richard Carlsson %% @author Micka�l R�mond <[email protected]> %% [http://www.process-one.net/] -%% @author Richard Carlsson <[email protected]> -%% [http://user.it.uu.se/~richardc/] +%% @author Richard Carlsson <[email protected]> %% @version {@version}, {@date} {@time} %% @doc This module is the main EUnit user interface. diff --git a/lib/eunit/src/eunit_autoexport.erl b/lib/eunit/src/eunit_autoexport.erl index 7b153c1194..099bcb222e 100644 --- a/lib/eunit/src/eunit_autoexport.erl +++ b/lib/eunit/src/eunit_autoexport.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_autoexport.erl 329 2009-03-01 11:23:32Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_data.erl b/lib/eunit/src/eunit_data.erl index 288dd74ddf..392d378a0e 100644 --- a/lib/eunit/src/eunit_data.erl +++ b/lib/eunit/src/eunit_data.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_internal.hrl b/lib/eunit/src/eunit_internal.hrl index 8d0ac30bd7..92694ec39b 100644 --- a/lib/eunit/src/eunit_internal.hrl +++ b/lib/eunit/src/eunit_internal.hrl @@ -1,11 +1,7 @@ %% ------------------------------------------------------------------- %% File: eunit_internal.hrl %% -%% $Id: eunit_internal.hrl 329 2009-03-01 11:23:32Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> -%% @copyright 2006 Richard Carlsson -%% @doc +%% Copyright (C) 2006 Richard Carlsson <[email protected]> -define(SERVER, eunit_server). -define(DEFAULT_TEST_SUFFIX, "_test"). diff --git a/lib/eunit/src/eunit_lib.erl b/lib/eunit/src/eunit_lib.erl index 45d2387e7b..1c41e229c5 100644 --- a/lib/eunit/src/eunit_lib.erl +++ b/lib/eunit/src/eunit_lib.erl @@ -13,13 +13,10 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_lib.erl 339 2009-04-05 14:10:47Z rcarlsson $ -%% %% @copyright 2004-2007 Micka�l R�mond, Richard Carlsson %% @author Micka�l R�mond <[email protected]> %% [http://www.process-one.net/] -%% @author Richard Carlsson <[email protected]> -%% [http://user.it.uu.se/~richardc/] +%% @author Richard Carlsson <[email protected]> %% @private %% @see eunit %% @doc Utility functions for eunit diff --git a/lib/eunit/src/eunit_listener.erl b/lib/eunit/src/eunit_listener.erl index 20faecbf01..ecaac424a2 100644 --- a/lib/eunit/src/eunit_listener.erl +++ b/lib/eunit/src/eunit_listener.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2009 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_proc.erl b/lib/eunit/src/eunit_proc.erl index e2d51d8bd5..ec7d93fd48 100644 --- a/lib/eunit/src/eunit_proc.erl +++ b/lib/eunit/src/eunit_proc.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_serial.erl b/lib/eunit/src/eunit_serial.erl index d9ccae86f9..80e79116e3 100644 --- a/lib/eunit/src/eunit_serial.erl +++ b/lib/eunit/src/eunit_serial.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_server.erl b/lib/eunit/src/eunit_server.erl index 2cdfef2668..2002930abb 100644 --- a/lib/eunit/src/eunit_server.erl +++ b/lib/eunit/src/eunit_server.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_server.erl 267 2008-10-19 18:48:03Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_striptests.erl b/lib/eunit/src/eunit_striptests.erl index 606e44b286..c6ade389ba 100644 --- a/lib/eunit/src/eunit_striptests.erl +++ b/lib/eunit/src/eunit_striptests.erl @@ -13,10 +13,8 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_striptests.erl 329 2009-03-01 11:23:32Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> -%% @author Eric Merritt <[email protected]> +%% @author Richard Carlsson <[email protected]> +%% @author Eric Merritt <[email protected]> %% @copyright 2006 Richard Carlsson, Eric Merritt %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_surefire.erl b/lib/eunit/src/eunit_surefire.erl index 6e0a447105..2a6cbca14d 100644 --- a/lib/eunit/src/eunit_surefire.erl +++ b/lib/eunit/src/eunit_surefire.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: $ -%% -%% @author Micka�l R�mond <[email protected]> +%% @author Micka�l R�mond <[email protected]> %% @copyright 2009 Micka�l R�mond, Paul Guyot %% @see eunit %% @doc Surefire reports for EUnit (Format used by Maven and Atlassian @@ -58,7 +56,7 @@ { name :: chars(), description :: chars(), - result :: ok | {failed, tuple()} | {aborted, tuple()} | {skipped, tuple()}, + result :: ok | {failed, tuple()} | {aborted, tuple()} | {skipped, term()}, time :: integer(), output :: binary() }). @@ -311,7 +309,6 @@ write_testcase( output = Output}, FileDescriptor) -> DescriptionAttr = case Description of - <<>> -> []; [] -> []; _ -> [<<" description=\"">>, escape_attr(Description), <<"\"">>] end, @@ -320,7 +317,6 @@ write_testcase( <<"\" name=\"">>, escape_attr(Name), <<"\"">>, DescriptionAttr], ContentAndEndTag = case {Result, Output} of - {ok, []} -> [<<"/>">>, ?NEWLINE]; {ok, <<>>} -> [<<"/>">>, ?NEWLINE]; _ -> [<<">">>, ?NEWLINE, format_testcase_result(Result), format_testcase_output(Output), ?INDENT, <<"</testcase>">>, ?NEWLINE] end, @@ -369,7 +365,6 @@ format_testcase_result({skipped, Term}) -> %% Empty output is simply the empty string. %% Other output is inside a <system-out> xml tag. %% ---------------------------------------------------------------------------- -format_testcase_output([]) -> []; format_testcase_output(Output) -> [?INDENT, ?INDENT, <<"<system-out>">>, escape_text(Output), ?NEWLINE, ?INDENT, ?INDENT, <<"</system-out>">>, ?NEWLINE]. @@ -387,8 +382,6 @@ format_time_s([Digit1, Digit2, Digit3 | Tail]) -> [lists:reverse(Tail), $., Digi %% Escape a suite's name to generate the filename. %% Remark: we might overwrite another testsuite's file. %% ---------------------------------------------------------------------------- -escape_suitename([Head | _T] = List) when is_list(Head) -> - escape_suitename(lists:flatten(List)); escape_suitename(Binary) when is_binary(Binary) -> escape_suitename(binary_to_list(Binary)); escape_suitename("module '" ++ String) -> @@ -396,7 +389,6 @@ escape_suitename("module '" ++ String) -> escape_suitename(String) -> escape_suitename(String, []). -escape_suitename(Binary, Acc) when is_binary(Binary) -> escape_suitename(binary_to_list(Binary), Acc); escape_suitename([], Acc) -> lists:reverse(Acc); escape_suitename([$ | Tail], Acc) -> escape_suitename(Tail, [$_ | Acc]); escape_suitename([$' | Tail], Acc) -> escape_suitename(Tail, Acc); diff --git a/lib/eunit/src/eunit_test.erl b/lib/eunit/src/eunit_test.erl index 9ac1d1e7d9..bca49ae626 100644 --- a/lib/eunit/src/eunit_test.erl +++ b/lib/eunit/src/eunit_test.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_test.erl 336 2009-03-06 14:43:21Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_tests.erl b/lib/eunit/src/eunit_tests.erl index a63d102d98..47ea0aaf46 100644 --- a/lib/eunit/src/eunit_tests.erl +++ b/lib/eunit/src/eunit_tests.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_tests.erl 238 2007-11-15 10:23:54Z mremond $ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2007 Richard Carlsson %% @private %% @see eunit diff --git a/lib/eunit/src/eunit_tty.erl b/lib/eunit/src/eunit_tty.erl index 5fe0140559..e3e7b710b2 100644 --- a/lib/eunit/src/eunit_tty.erl +++ b/lib/eunit/src/eunit_tty.erl @@ -13,9 +13,7 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id: eunit_tty.erl 330 2009-03-01 16:28:02Z rcarlsson $ -%% -%% @author Richard Carlsson <[email protected]> +%% @author Richard Carlsson <[email protected]> %% @copyright 2006-2009 Richard Carlsson %% @private %% @see eunit diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl index 7ff170776e..0ff827ac37 100644 --- a/lib/hipe/cerl/erl_types.erl +++ b/lib/hipe/cerl/erl_types.erl @@ -243,12 +243,11 @@ -define(REC_TYPE_LIMIT, 2). -define(TUPLE_TAG_LIMIT, 5). --define(TUPLE_ARITY_LIMIT, 10). +-define(TUPLE_ARITY_LIMIT, 8). -define(SET_LIMIT, 13). -define(MAX_BYTE, 255). -define(MAX_CHAR, 16#10ffff). --define(WIDENING_LIMIT, 7). -define(UNIT_MULTIPLIER, 8). -define(TAG_IMMED1_SIZE, 4). diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index 86cccebc29..b677f34ed0 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -81,6 +81,13 @@ init_per_suite(Config) -> end_per_suite(Config) -> Config. +init_per_testcase(big_boot_embedded, Config) -> + case catch crypto:start() of + ok -> + init_per_testcase(do_big_boot_embedded, Config); + _Else -> + {skip, "Needs crypto!"} + end; init_per_testcase(_Func, Config) -> Dog=?t:timetrap(?t:minutes(5)), P=code:get_path(), @@ -573,11 +580,13 @@ add_del_path(Config) when is_list(Config) -> clash(Config) when is_list(Config) -> DDir = ?config(data_dir,Config)++"clash/", P = code:get_path(), + [TestServerPath|_] = [Path || Path <- code:get_path(), + re:run(Path,"test_server/?$",[]) /= nomatch], %% test non-clashing entries - %% remove "." to prevent clash with test-server path - ?line true = code:del_path("."), + %% remove TestServerPath to prevent clash with test-server path + ?line true = code:del_path(TestServerPath), ?line true = code:add_path(DDir++"foobar-0.1/ebin"), ?line true = code:add_path(DDir++"zork-0.8/ebin"), test_server:capture_start(), @@ -589,8 +598,8 @@ clash(Config) when is_list(Config) -> %% test clashing entries - %% remove "." to prevent clash with test-server path - ?line true = code:del_path("."), + %% remove TestServerPath to prevent clash with test-server path + ?line true = code:del_path(TestServerPath), ?line true = code:add_path(DDir++"foobar-0.1/ebin"), ?line true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"), test_server:capture_start(), @@ -603,9 +612,9 @@ clash(Config) when is_list(Config) -> %% test "Bad path can't read" - %% remove "." to prevent clash with test-server path + %% remove TestServerPath to prevent clash with test-server path Priv = ?config(priv_dir, Config), - ?line true = code:del_path("."), + ?line true = code:del_path(TestServerPath), TmpEzFile = Priv++"foobar-0.tmp.ez", ?line {ok, _} = file:copy(DDir++"foobar-0.1.ez", TmpEzFile), ?line true = code:add_path(TmpEzFile++"/foobar-0.1/ebin"), diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl index 03e734445c..1b534a5fc4 100644 --- a/lib/kernel/test/gen_sctp_SUITE.erl +++ b/lib/kernel/test/gen_sctp_SUITE.erl @@ -212,7 +212,9 @@ xfer_active(Config) when is_list(Config) -> ?line test_server:fail({unexpected,flush()}) end, ?line io:format("SbAssocId=~p~n", [SbAssocId]), - ?line ok = gen_sctp:send(Sa, SaAssocId, 0, Data), + ?line ok = + do_from_other_process( + fun () -> gen_sctp:send(Sa, SaAssocId, 0, Data) end), ?line receive {sctp,Sb,Loopback,Pa, {[#sctp_sndrcvinfo{stream=Stream, @@ -378,11 +380,14 @@ def_sndrcvinfo(Config) when is_list(Config) -> end end, ?line ok = - gen_sctp:send( - S2, - #sctp_sndrcvinfo{stream=0, ppid=20, assoc_id=S2AssocId}, - <<"4: ",Data/binary>>), - ?line case ok(gen_sctp:recv(S1)) of + do_from_other_process( + fun () -> + gen_sctp:send( + S2, + #sctp_sndrcvinfo{stream=0, ppid=20, assoc_id=S2AssocId}, + <<"4: ",Data/binary>>) + end), + ?line case ok(do_from_other_process(fun() -> gen_sctp:recv(S1) end)) of {Loopback,P2, [#sctp_sndrcvinfo{ stream=0, ppid=20, context=0, assoc_id=S1AssocId}], @@ -575,6 +580,8 @@ api_opts(doc) -> api_opts(suite) -> []; api_opts(Config) when is_list(Config) -> + ?line Sndbuf = 32768, + ?line Recbuf = 65536, ?line {ok,S} = gen_sctp:open(0), ?line OSType = os:type(), ?line case {inet:setopts(S, [{linger,{true,2}}]),OSType} of @@ -582,7 +589,15 @@ api_opts(Config) when is_list(Config) -> ok; {{error,einval},{unix,sunos}} -> ok - end. + end, + ?line ok = inet:setopts(S, [{sndbuf,Sndbuf}]), + ?line ok = inet:setopts(S, [{recbuf,Recbuf}]), + ?line case inet:getopts(S, [sndbuf]) of + {ok,[{sndbuf,SB}]} when SB >= Sndbuf -> ok + end, + ?line case inet:getopts(S, [recbuf]) of + {ok,[{recbuf,RB}]} when RB >= Recbuf -> ok + end. implicit_inet6(Config) when is_list(Config) -> ?line Hostname = ok(inet:gethostname()), @@ -638,3 +653,31 @@ implicit_inet6(S1, Addr) -> {{0,0,0,0,0,0,0,0},P2} -> ok end, ?line ok = gen_sctp:close(S2). + + + +do_from_other_process(Fun) -> + Parent = self(), + Ref = make_ref(), + Child = + spawn(fun () -> + try Fun() of + Result -> + Parent ! {Ref,Result} + catch + Class:Reason -> + Stacktrace = erlang:get_stacktrace(), + Parent ! {Ref,Class,Reason,Stacktrace} + end + end), + Mref = erlang:monitor(process, Child), + receive + {Ref,Result} -> + receive {'DOWN',Mref,_,_,_} -> Result end; + {Ref,Class,Reason,Stacktrace} -> + receive {'DOWN',Mref,_,_,_} -> + erlang:raise(Class, Reason, Stacktrace) + end; + {'DOWN',Mref,_,_,Reason} -> + erlang:exit(Reason) + end. diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 1bb173a3ac..aaa20b7398 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -294,7 +294,7 @@ t_getaddr_v6(Config) when is_list(Config) -> ?line {Name,FullName,IPStr,_IP,_,IP_46_Str,IP46} = ct:get_config(test_host_ipv4_only), case {inet:getaddr(IP_46_Str, inet6),inet:getaddr(Name, inet6)} of - {{ok,IP46},{ok,_}} -> + {{ok,IP46},{ok,V4Addr}} when V4Addr /= {0,0,0,0,0,0,0,1} -> %% Since we suceeded in parsing an IPv6 address string and %% look up the name, this computer fully supports IPv6. ?line {ok,IP46} = inet:getaddr(IP46, inet6), diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl index 6064a9b2d9..8a3d220e46 100644 --- a/lib/kernel/test/inet_res_SUITE.erl +++ b/lib/kernel/test/inet_res_SUITE.erl @@ -117,9 +117,15 @@ ns_init(ZoneDir, PrivDir, DataDir) -> case os:type() of {unix,_} when ZoneDir =:= undefined -> undefined; {unix,_} -> - {ok,S} = gen_udp:open(0, [{reuseaddr,true}]), - {ok,PortNum} = inet:port(S), - gen_udp:close(S), + PortNum = case {os:type(),os:version()} of + {{unix,solaris},{M,V,_}} when M =< 5, V < 10 -> + 11895 + random:uniform(100); + _ -> + {ok,S} = gen_udp:open(0, [{reuseaddr,true}]), + {ok,PNum} = inet:port(S), + gen_udp:close(S), + PNum + end, RunNamed = filename:join(DataDir, ?RUN_NAMED), NS = {{127,0,0,1},PortNum}, P = erlang:open_port({spawn_executable,RunNamed}, diff --git a/lib/kernel/test/inet_res_SUITE_data/run-named b/lib/kernel/test/inet_res_SUITE_data/run-named index b418607d48..7caa3756ef 100755 --- a/lib/kernel/test/inet_res_SUITE_data/run-named +++ b/lib/kernel/test/inet_res_SUITE_data/run-named @@ -2,7 +2,7 @@ ## ## %CopyrightBegin% ## -## Copyright Ericsson AB 2009. All Rights Reserved. +## Copyright Ericsson AB 2009-2011. All Rights Reserved. ## ## The contents of this file are subject to the Erlang Public License, ## Version 1.1, (the "License"); you may not use this file except in @@ -155,7 +155,7 @@ $NAMED $NAMED_FG -c "$CONF_FILE" >"$LOG_FILE" 2>&1 </dev/null & NAMED=$! trap "kill -TERM $NAMED >/dev/null 2>&1; wait $NAMED >/dev/null 2>&1" \ 0 1 2 3 15 -sleep 1 # Give name server time to load its zone files +sleep 2 # Give name server time to load its zone files echo "Running: Enter \`\`quit'' to terminate nameserver[$NAMED]..." while read LINE; do test :"$LINE" = :'quit' && break diff --git a/lib/mnesia/src/mnesia.appup.src b/lib/mnesia/src/mnesia.appup.src index 3691aa249a..fe4e5e2e7a 100644 --- a/lib/mnesia/src/mnesia.appup.src +++ b/lib/mnesia/src/mnesia.appup.src @@ -1,11 +1,13 @@ %% -*- erlang -*- {"%VSN%", [ + {"4.4.19", [{restart_application, mnesia}]}, {"4.4.18", [{restart_application, mnesia}]}, {"4.4.17", [{restart_application, mnesia}]}, {"4.4.16", [{restart_application, mnesia}]} ], [ + {"4.4.19", [{restart_application, mnesia}]}, {"4.4.18", [{restart_application, mnesia}]}, {"4.4.17", [{restart_application, mnesia}]}, {"4.4.16", [{restart_application, mnesia}]} diff --git a/lib/mnesia/vsn.mk b/lib/mnesia/vsn.mk index 2fa629d064..a21ab007ef 100644 --- a/lib/mnesia/vsn.mk +++ b/lib/mnesia/vsn.mk @@ -1 +1 @@ -MNESIA_VSN = 4.4.19 +MNESIA_VSN = 4.5 diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index b3ce49e2ca..9a3832c68b 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -79,7 +79,7 @@ <p><code> rsa_padding() = 'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding' | 'rsa_no_padding'</code></p> - <p><code> rsa_digest_type() = 'md2' | 'md5' | 'sha' </code></p> + <p><code> rsa_digest_type() = 'md5' | 'sha' </code></p> <p><code> dss_digest_type() = 'none' | 'sha' </code></p> diff --git a/lib/public_key/src/pubkey_cert.erl b/lib/public_key/src/pubkey_cert.erl index 61082a1ec5..5ab9642279 100644 --- a/lib/public_key/src/pubkey_cert.erl +++ b/lib/public_key/src/pubkey_cert.erl @@ -38,7 +38,7 @@ %%==================================================================== %%-------------------------------------------------------------------- --spec verify_data(DER::binary()) -> {md2 | md5 | sha, binary(), binary()}. +-spec verify_data(DER::binary()) -> {md5 | sha, binary(), binary()}. %% %% Description: Extracts data from DerCert needed to call public_key:verify/4. %%-------------------------------------------------------------------- @@ -378,8 +378,6 @@ digest_type(?sha1WithRSAEncryption) -> sha; digest_type(?md5WithRSAEncryption) -> md5; -digest_type(?md2WithRSAEncryption) -> - md2; digest_type(?'id-dsa-with-sha1') -> sha. diff --git a/lib/public_key/src/public_key.appup.src b/lib/public_key/src/public_key.appup.src index 18fae54d18..4986801dad 100644 --- a/lib/public_key/src/public_key.appup.src +++ b/lib/public_key/src/public_key.appup.src @@ -1,12 +1,6 @@ %% -*- erlang -*- {"%VSN%", [ - {"0.12", - [ - {update, public_key, soft, soft_purge, soft_purge, []}, - {update, pubkey_cert, soft, soft_purge, soft_purge, []}, - ] - }, {"0.11", [ {update, public_key, soft, soft_purge, soft_purge, []}, @@ -41,12 +35,6 @@ } ], [ - {"0.12", - [ - {update, public_key, soft, soft_purge, soft_purge, []}, - {update, pubkey_cert, soft, soft_purge, soft_purge, []}, - ] - }, {"0.11", [ {update, public_key, soft, soft_purge, soft_purge, []}, diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index 940efffcd0..33fcce2c44 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -55,7 +55,7 @@ -type rsa_padding() :: 'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding' | 'rsa_no_padding'. -type public_crypt_options() :: [{rsa_pad, rsa_padding()}]. --type rsa_digest_type() :: 'md2' | 'md5' | 'sha'. +-type rsa_digest_type() :: 'md5' | 'sha'. -type dss_digest_type() :: 'none' | 'sha'. -define(UINT32(X), X:32/unsigned-big-integer). @@ -307,8 +307,7 @@ encrypt_private(PlainText, #'RSAPrivateKey'{modulus = N, sign(PlainText, DigestType, #'RSAPrivateKey'{modulus = N, publicExponent = E, privateExponent = D}) when is_binary(PlainText), - (DigestType == md2 orelse - DigestType == md5 orelse + (DigestType == md5 orelse DigestType == sha) -> crypto:rsa_sign(DigestType, sized_binary(PlainText), [crypto:mpint(E), @@ -336,10 +335,7 @@ sign(PlainText, sha, #'DSAPrivateKey'{p = P, q = Q, g = G, x = X}) %%-------------------------------------------------------------------- verify(PlainText, DigestType, Signature, #'RSAPublicKey'{modulus = Mod, publicExponent = Exp}) - when is_binary(PlainText), - (DigestType == md2 orelse - DigestType == md5 orelse - DigestType == sha) -> + when is_binary (PlainText), DigestType == sha; DigestType == md5 -> crypto:rsa_verify(DigestType, sized_binary(PlainText), sized_binary(Signature), diff --git a/lib/public_key/test/public_key_SUITE.erl b/lib/public_key/test/public_key_SUITE.erl index a9c198c581..b11e4d092a 100644 --- a/lib/public_key/test/public_key_SUITE.erl +++ b/lib/public_key/test/public_key_SUITE.erl @@ -537,10 +537,7 @@ rsa_sign_verify(Config) when is_list(Config) -> false = public_key:verify(Msg, sha, <<1:8, RSASign/binary>>, PublicRSA), RSASign1 = public_key:sign(Msg, md5, PrivateRSA), - true = public_key:verify(Msg, md5, RSASign1, PublicRSA), - - RSASign2 = public_key:sign(Msg, md2, PrivateRSA), - true = public_key:verify(Msg, md2, RSASign2, PublicRSA). + true = public_key:verify(Msg, md5, RSASign1, PublicRSA). %%-------------------------------------------------------------------- diff --git a/lib/public_key/vsn.mk b/lib/public_key/vsn.mk index 66ac78a65d..3c6b012152 100644 --- a/lib/public_key/vsn.mk +++ b/lib/public_key/vsn.mk @@ -1 +1 @@ -PUBLIC_KEY_VSN = 0.13 +PUBLIC_KEY_VSN = 0.12 diff --git a/lib/typer/src/typer.erl b/lib/typer/src/typer.erl index fd906c8c46..f2a70f49b7 100644 --- a/lib/typer/src/typer.erl +++ b/lib/typer/src/typer.erl @@ -466,14 +466,20 @@ write_typed_file(File, Info) -> case file:make_dir(TyperAnnDir) of {error, Reason} -> case Reason of - eexist -> %% TypEr dir exists; remove old typer files - ok = file:delete(NewFileName), + eexist -> %% TypEr dir exists; remove old typer files if they exist + case file:delete(NewFileName) of + ok -> ok; + {error, enoent} -> ok; + {error, _} -> + Msg = io_lib:format("Error in deleting file ~s\n", [NewFileName]), + fatal_error(Msg) + end, write_typed_file(File, Info, NewFileName); enospc -> Msg = io_lib:format("Not enough space in ~p\n", [Dir]), fatal_error(Msg); eacces -> - Msg = io:format("No write permission in ~p\n", [Dir]), + Msg = io_lib:format("No write permission in ~p\n", [Dir]), fatal_error(Msg); _ -> Msg = io_lib:format("Unhandled error ~s when writing ~p\n", |