From 601807d2ea08a3787c50a5c6fb05efe35aecaeb5 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 3 Mar 2016 12:49:38 +0100 Subject: Set default value for crash_dump_dir test_server_sup:crash_dump_dir() is expected to return {ok,Dir}, but if there was no test framework set, then it would return just 'ok'. To avoid crash, the function will no returm {ok,Cwd} if no framework is set. --- lib/test_server/src/test_server_sup.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/test_server/src/test_server_sup.erl b/lib/test_server/src/test_server_sup.erl index 1c0eb18d70..c4530ba62f 100644 --- a/lib/test_server/src/test_server_sup.erl +++ b/lib/test_server/src/test_server_sup.erl @@ -594,7 +594,10 @@ cleanup_crash_dumps() -> delete_files(Dumps). crash_dump_dir() -> - {ok,Dir} = test_server_sup:framework_call(get_log_dir,[]), + %% If no framework is known, then we use current working directory + %% - in most cases that will be the same as the default log + %% directory. + {ok,Dir} = test_server_sup:framework_call(get_log_dir,[],file:get_cwd()), Dir. tar_crash_dumps() -> -- cgit v1.2.3 From f0046c37852993bde960c3a456c1ac1c0078d792 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 3 Mar 2016 12:43:28 +0100 Subject: Fix code_SUITE after test_server change test_server:start_node does no longer add the test_server path to the new node, since the needed code is present in the default path. This caused two test cases in code_SUITE to fail. code_SUITE:mult_lib_roots: Expected the test_server path to be first in the code path. This check is removed. code_SUITE:bad_erl_libs: Started a node with "-env ERL_LIBS ", i.e. not giving any value to the ERL_LIBS variable. This test succeeded by accident, since the combination with arguments set by test_server_node.erl and by slave.erl caused the node start to work, and no further checks were present in the test. This part of the test case is now removed. --- lib/kernel/test/code_SUITE.erl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index 2b77ec8972..6f19f67fb5 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -1133,9 +1133,8 @@ mult_lib_roots(Config) when is_list(Config) -> ?t:start_node(mult_lib_roots, slave, [{args,"-env ERL_LIBS "++ErlLibs}]), - TSPath = filename:dirname(code:which(test_server)), Path0 = rpc:call(Node, code, get_path, []), - [TSPath,"."|Path1] = Path0, + ["."|Path1] = Path0, [Kernel|Path2] = Path1, [Stdlib|Path3] = Path2, mult_lib_verify_lib(Kernel, "kernel"), @@ -1179,16 +1178,19 @@ mult_lib_remove_prefix([$/|T], []) -> T. bad_erl_libs(Config) when is_list(Config) -> {ok,Node} = - ?t:start_node(mult_lib_roots, slave, - [{args,"-env ERL_LIBS "}]), - + ?t:start_node(bad_erl_libs, slave, []), + Code = rpc:call(Node,code,get_path,[]), ?t:stop_node(Node), {ok,Node2} = - ?t:start_node(mult_lib_roots, slave, + ?t:start_node(bad_erl_libs, slave, [{args,"-env ERL_LIBS /no/such/dir"}]), - + Code2 = rpc:call(Node,code,get_path,[]), ?t:stop_node(Node2), + + %% Test that code path is not affected by the faulty ERL_LIBS + Code == Code2, + ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3 From 983f1346c536527b4fc9ed1d27cfb01d71392e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 7 Mar 2016 12:57:17 +0100 Subject: io_SUITE: Don't fail on fast computers with rough timers On a computer which is fast, but with timers with low resolution, the measured time for an empty queue could be zero, which could cause the test case to fail. Add a calibration function to scale up the amount the amount of work so that the measured time will not be lower than 50 ms. --- lib/stdlib/test/io_SUITE.erl | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 0e897631ff..9507e972bc 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -2253,12 +2253,14 @@ io_lib_width_too_small(_Config) -> %% Test that the time for a huge message queue is not %% significantly slower than with an empty message queue. io_with_huge_message_queue(Config) when is_list(Config) -> - case test_server:is_native(gen) of - true -> + case {test_server:is_native(gen),test_server:is_cover()} of + {true,_} -> {skip, "gen is native - huge message queue optimization " "is not implemented"}; - false -> + {_,true} -> + {skip,"Running under cover"}; + {false,false} -> do_io_with_huge_message_queue(Config) end. @@ -2266,19 +2268,23 @@ do_io_with_huge_message_queue(Config) -> PrivDir = ?privdir(Config), File = filename:join(PrivDir, "slask"), {ok, F1} = file:open(File, [write]), - - {Time,ok} = timer:tc(fun() -> writes(1000, F1) end), + Test = fun(Times) -> + {Time,ok} = timer:tc(fun() -> writes(Times, F1) end), + Time + end, + {Times,EmptyTime} = calibrate(100, Test), [self() ! {msg,N} || N <- lists:seq(1, 500000)], erlang:garbage_collect(), - {NewTime,ok} = timer:tc(fun() -> writes(1000, F1) end), + FullTime = Test(Times), file:close(F1), - io:format("Time for empty message queue: ~p", [Time]), - io:format("Time for huge message queue: ~p", [NewTime]), + file:delete(File), + io:format("Number of writes: ~p", [Times]), + io:format("Time for empty message queue: ~p", [EmptyTime]), + io:format("Time for huge message queue: ~p", [FullTime]), - IsCover = test_server:is_cover(), - case (NewTime+1) / (Time+1) of - Q when Q < 10; IsCover -> + case (FullTime+1) / (EmptyTime+1) of + Q when Q < 10 -> ok; Q -> io:format("Q = ~p", [Q]), @@ -2286,6 +2292,18 @@ do_io_with_huge_message_queue(Config) -> end, ok. +%% Make sure that the time is not too short. That could cause the +%% test case to fail. +calibrate(N, Test) when N =< 100000 -> + case Test(N) of + Time when Time < 50000 -> + calibrate(10*N, Test); + Time -> + {N,Time} + end; +calibrate(N, _) -> + N. + writes(0, _) -> ok; writes(N, F1) -> file:write(F1, "hello\n"), -- cgit v1.2.3