From dab88ad5dc3a8dd23a898953fe48366d865074ea Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 11 Feb 2013 15:47:07 +0100 Subject: [test_server] Use simpler tc name in unicode test to make it work on windows A test case in test_server_unicode_SUITE contained characters that were not allowed in filenames on windows - e.g. \. The test case name will be used as filename for the HTML log for the test, so this failed on windows. This is now corrected. --- .../test/test_server_SUITE_data/test_server_unicode_SUITE.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/test_server/test/test_server_SUITE_data/test_server_unicode_SUITE.erl b/lib/test_server/test/test_server_SUITE_data/test_server_unicode_SUITE.erl index 662adedd4c..284b51babe 100644 --- a/lib/test_server/test/test_server_SUITE_data/test_server_unicode_SUITE.erl +++ b/lib/test_server/test/test_server_SUITE_data/test_server_unicode_SUITE.erl @@ -21,14 +21,14 @@ -export([all/1, init_per_suite/1, end_per_suite/1]). -export([init_per_testcase/2, end_per_testcase/2]). --export([':#"|@\\ difficult_case_name_äöå'/1, +-export(['#=@: difficult_case_name_äöå'/1, print_and_log_unicode/1, print_and_log_latin1/1]). -include_lib("test_server/include/test_server.hrl"). all(suite) -> - [':#"|@\\ difficult_case_name_äöå', + ['#=@: difficult_case_name_äöå', print_and_log_unicode, print_and_log_latin1]. @@ -57,7 +57,7 @@ cancel_timetrap(Config) -> %%%----------------------------------------------------------------- %%% Test cases -':#"|@\\ difficult_case_name_äöå'(Config) when is_list(Config) -> +'#=@: difficult_case_name_äöå'(Config) when is_list(Config) -> ok. print_and_log_unicode(Config) when is_list(Config) -> -- cgit v1.2.3 From 79406f338464a9ba94c8531c8a7a44a01ad14b42 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 12 Feb 2013 14:31:24 +0100 Subject: [test_server] Fix encoding of HTML file references to work on windows The URI encoding when in unicode file name mode did not preserve @, : and /, and thus some links were did not work on windows (think c:/). This has been corrected. --- lib/test_server/src/erl2html2.erl | 2 +- lib/test_server/src/test_server_ctrl.erl | 33 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/test_server/src/erl2html2.erl b/lib/test_server/src/erl2html2.erl index 9c0ca64173..5584c1e50c 100644 --- a/lib/test_server/src/erl2html2.erl +++ b/lib/test_server/src/erl2html2.erl @@ -126,7 +126,7 @@ build_html(SFd,DFd,Encoding,Functions) -> build_html(SFd,DFd,Encoding,file:read_line(SFd),1,Functions,false). build_html(SFd,DFd,Encoding,{ok,Str},L,[{F,A,L}|Functions],_IsFuncDef) -> - FALink = http_uri:encode(F++"-"++integer_to_list(A)), + FALink = test_server_ctrl:uri_encode(F++"-"++integer_to_list(A),utf8), file:write(DFd,[""]), build_html(SFd,DFd,Encoding,{ok,Str},L,Functions,true); build_html(SFd,DFd,Encoding,{ok,Str},L,[{clause,L}|Functions],_IsFuncDef) -> diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl index 5d4d392166..950ff862c6 100644 --- a/lib/test_server/src/test_server_ctrl.erl +++ b/lib/test_server/src/test_server_ctrl.erl @@ -5375,31 +5375,28 @@ uri_encode(File,Encoding) -> Components = filename:split(File), filename:join([uri_encode_comp(C,Encoding) || C <- Components]). -uri_encode_comp("/",_) -> - "/"; -uri_encode_comp(Chars,utf8) -> - http_uri:encode(Chars); -uri_encode_comp(Chars,latin1) -> - do_uri_encode(Chars). - -%% Encode a file reference to a latin1 filename so it can be inserted -%% in a utf8 encoded HTML file. -%% This does the same as http_uri:encode/1, except it also encodes all -%% characters >127 - i.e. latin1 but not ASCII. -do_uri_encode([Char|Chars]) -> - case Char>127 orelse sets:is_element(Char, reserved()) of +%% Encode the reference to a "filename of the given encoding" so it +%% can be inserted in a utf8 encoded HTML file. +%% This does almost the same as http_uri:encode/1, except +%% 1. it does not convert @, : and / (in order to preserve nodename and c:/) +%% 2. if the file name is in latin1, it also encodes all +%% characters >127 - i.e. latin1 but not ASCII. +uri_encode_comp([Char|Chars],Encoding) -> + Reserved = sets:is_element(Char, reserved()), + case (Char>127 andalso Encoding==latin1) orelse Reserved of true -> - [ $% | http_util:integer_to_hexlist(Char)] ++ do_uri_encode(Chars); + [ $% | http_util:integer_to_hexlist(Char)] ++ + uri_encode_comp(Chars,Encoding); false -> - [Char | do_uri_encode(Chars)] + [Char | uri_encode_comp(Chars,Encoding)] end; -do_uri_encode([]) -> +uri_encode_comp([],_) -> []. %% Copied from http_uri.erl, but slightly modified -%% (not converting @ and :) +%% (not converting @, : and /) reserved() -> - sets:from_list([$;, $&, $=, $+, $,, $/, $?, + sets:from_list([$;, $&, $=, $+, $,, $?, $#, $[, $], $<, $>, $\", ${, $}, $|, $\\, $', $^, $%, $ ]). -- cgit v1.2.3 From a08294628c7a20468c81e90db0be27ff091fd627 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 14 Feb 2013 16:28:23 +0100 Subject: [reltool] Increase timetrap timeout for reltool_server_SUTIE to 10 minutes The timeout of 5 minutes sometimes expired for test case use_selected_vsn on some platforms. --- lib/reltool/test/reltool_test_lib.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reltool/test/reltool_test_lib.erl b/lib/reltool/test/reltool_test_lib.erl index 61f783190c..3485365ed9 100644 --- a/lib/reltool/test/reltool_test_lib.erl +++ b/lib/reltool/test/reltool_test_lib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2012. All Rights Reserved. +%% Copyright Ericsson AB 2009-2013. 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 @@ -25,7 +25,7 @@ init_per_suite(Config) when is_list(Config)-> global:register_name(reltool_global_logger, group_leader()), - incr_timetrap(Config, 5). + incr_timetrap(Config, 10). end_per_suite(Config) when is_list(Config)-> global:unregister_name(reltool_global_logger), @@ -51,7 +51,7 @@ set_kill_timer(Config) -> Time = case lookup_config(tc_timeout, Config) of [] -> - timer:minutes(5); + timer:minutes(10); ConfigTime when is_integer(ConfigTime) -> ConfigTime end, -- cgit v1.2.3 From 020003d41403b6ec75ffe38babdfbba8dd2d099a Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 15 Feb 2013 12:16:17 +0100 Subject: [test_server] Clean up unused code in test_server_SUITE --- lib/test_server/test/test_server_SUITE.erl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/test_server/test/test_server_SUITE.erl b/lib/test_server/test/test_server_SUITE.erl index bea2c0dc49..1a2fc632da 100644 --- a/lib/test_server/test/test_server_SUITE.erl +++ b/lib/test_server/test/test_server_SUITE.erl @@ -323,11 +323,7 @@ generate_and_run_unicode_test(Config0,Encoding) -> Config1 = lists:keydelete(node,1,Config0), Config2 = lists:keydelete(work_dir,1,Config1), NodeName = list_to_atom("test_server_tester_" ++ atom_to_list(Encoding)), - ErtsSwitch = case Encoding of - latin1 -> "+fnl"; - utf8 -> "+fnu" - end, - Config = start_node(Config2,NodeName,ErtsSwitch), + Config = start_node(Config2,NodeName,erts_switch(Encoding)), %% Compile the suite Node = proplists:get_value(node,Config), -- cgit v1.2.3 From 9138513e1e80e2956b34138d711b63b93e6a9eb0 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 18 Feb 2013 19:34:23 +0100 Subject: [common_test] Extend timers for slave nodes in ct_cover_SUITE Also, rename some nodes to avoid node name clash between test cases, and ensure proper cleanup of nodes. --- lib/common_test/test/ct_cover_SUITE.erl | 39 +++++++++++++--------- .../test/ct_cover_SUITE_data/cover_SUITE.erl | 18 +++++++--- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/lib/common_test/test/ct_cover_SUITE.erl b/lib/common_test/test/ct_cover_SUITE.erl index cb49dc423f..ec2680f664 100644 --- a/lib/common_test/test/ct_cover_SUITE.erl +++ b/lib/common_test/test/ct_cover_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2012. All Rights Reserved. +%% Copyright Ericsson AB 2012-2013. 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 @@ -59,10 +59,8 @@ init_per_testcase(TestCase, Config) -> ct_test_support:init_per_testcase(TestCase, Config). end_per_testcase(TestCase, Config) -> - Node = fullname(existing_node), - case lists:member(Node,nodes()) of - true -> rpc:call(Node,erlang,halt,[]); - false -> ok + try apply(?MODULE,TestCase,[cleanup,Config]) + catch error:undef -> ok end, ct_test_support:end_per_testcase(TestCase, Config). @@ -125,33 +123,35 @@ slave_start_slave(Config) -> %% spec file. %% Check that cover is collected from test node and slave node. cover_node_option(Config) -> - {ok, HostStr}=inet:gethostname(), - Host = list_to_atom(HostStr), DataDir = ?config(data_dir,Config), - {ok,Node} = ct_slave:start(Host,existing_node, - [{erl_flags,"-pa " ++ DataDir}]), + {ok,Node} = start_slave(existing_node_1, "-pa " ++ DataDir), false = check_cover(Node), CoverSpec = default_cover_file_content() ++ [{nodes,[Node]}], CoverFile = create_cover_file(cover_node_option,CoverSpec,Config), {ok,Events} = run_test(cover_node_option,cover_node_option, [{cover,CoverFile}],Config), check_calls(Events,2), - {ok,Node} = ct_slave:stop(existing_node), + {ok,Node} = ct_slave:stop(existing_node_1), + ok. + +cover_node_option(cleanup,_Config) -> + _ = ct_slave:stop(existing_node_1), ok. %% Test ct_cover:add_nodes/1 and ct_cover:remove_nodes/1 %% Check that cover is collected from added node ct_cover_add_remove_nodes(Config) -> - {ok, HostStr}=inet:gethostname(), - Host = list_to_atom(HostStr), DataDir = ?config(data_dir,Config), - {ok,Node} = ct_slave:start(Host,existing_node, - [{erl_flags,"-pa " ++ DataDir}]), + {ok,Node} = start_slave(existing_node_2, "-pa " ++ DataDir), false = check_cover(Node), {ok,Events} = run_test(ct_cover_add_remove_nodes,ct_cover_add_remove_nodes, [],Config), check_calls(Events,2), - {ok,Node} = ct_slave:stop(existing_node), + {ok,Node} = ct_slave:stop(existing_node_2), + ok. + +ct_cover_add_remove_nodes(cleanup,_Config) -> + _ = ct_slave:stop(existing_node_2), ok. %% Test that the test suite itself can be cover compiled and that @@ -310,3 +310,12 @@ create_cover_file(Filename,Terms,Config) -> end,Terms), ok = file:close(Fd), File. + +start_slave(Name,Args) -> + {ok, HostStr}=inet:gethostname(), + Host = list_to_atom(HostStr), + ct_slave:start(Host,Name, + [{erl_flags,Args}, + {boot_timeout,10}, % extending some timers for slow test hosts + {init_timeout,10}, + {startup_timeout,10}]). diff --git a/lib/common_test/test/ct_cover_SUITE_data/cover_SUITE.erl b/lib/common_test/test/ct_cover_SUITE_data/cover_SUITE.erl index fdc3323f0a..d967590c72 100644 --- a/lib/common_test/test/ct_cover_SUITE_data/cover_SUITE.erl +++ b/lib/common_test/test/ct_cover_SUITE_data/cover_SUITE.erl @@ -1,7 +1,7 @@ %%-------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2012. All Rights Reserved. +%% Copyright Ericsson AB 2012-2013. 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 @@ -76,7 +76,7 @@ slave(Config) -> cover_compiled = code:which(cover_test_mod), cover_test_mod:foo(), N1 = nodename(slave,1), - {ok,Node} = ct_slave:start(N1), + {ok,Node} = start_slave(N1), cover_compiled = rpc:call(Node,code,which,[cover_test_mod]), rpc:call(Node,cover_test_mod,foo,[]), {ok,Node} = ct_slave:stop(N1), @@ -87,7 +87,7 @@ slave_start_slave(Config) -> cover_test_mod:foo(), N1 = nodename(slave_start_slave,1), N2 = nodename(slave_start_slave,2), - {ok,Node} = ct_slave:start(N1), + {ok,Node} = start_slave(N1), cover_compiled = rpc:call(Node,code,which,[cover_test_mod]), rpc:call(Node,cover_test_mod,foo,[]), {ok,Node2} = rpc:call(Node,ct_slave,start,[N2]), @@ -99,7 +99,7 @@ slave_start_slave(Config) -> cover_node_option(Config) -> cover_compiled = code:which(cover_test_mod), cover_test_mod:foo(), - Node = fullname(existing_node), + Node = fullname(existing_node_1), cover_compiled = rpc:call(Node,code,which,[cover_test_mod]), rpc:call(Node,cover_test_mod,foo,[]), ok. @@ -107,7 +107,7 @@ cover_node_option(Config) -> ct_cover_add_remove_nodes(Config) -> cover_compiled = code:which(cover_test_mod), cover_test_mod:foo(), - Node = fullname(existing_node), + Node = fullname(existing_node_2), Beam = rpc:call(Node,code,which,[cover_test_mod]), false = (Beam == cover_compiled), @@ -154,3 +154,11 @@ kill_slaves(Case, [Node|Nodes]) -> kill_slaves(Case,Nodes); kill_slaves(_,[]) -> ok. + +start_slave(Name) -> + {ok, HostStr}=inet:gethostname(), + Host = list_to_atom(HostStr), + ct_slave:start(Host,Name, + [{boot_timeout,10}, % extending some timers for slow test hosts + {init_timeout,10}, + {startup_timeout,10}]). -- cgit v1.2.3 From 35030ae2cd6a6a6af4986f9f1ae8a98d76f43863 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 19 Feb 2013 16:50:27 +0100 Subject: [jinterface] Make tests handle space in path on windows Add quotes around classpath on windows. --- lib/jinterface/test/jitu.erl | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/jinterface/test/jitu.erl b/lib/jinterface/test/jitu.erl index 571a2dc9c7..0de074a9c9 100644 --- a/lib/jinterface/test/jitu.erl +++ b/lib/jinterface/test/jitu.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2012. All Rights Reserved. +%% Copyright Ericsson AB 2004-2013. 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 @@ -84,24 +84,26 @@ to_string([]) -> []. % filename:join(Dir, File)). classpath(Dir) -> - PS = + {PS,Quote,EscSpace} = case os:type() of - {win32, _} -> ";"; - _ -> ":" + {win32, _} -> {";","\"",""}; + _ -> {":","","\\"} end, es(Dir++PS++ filename:join([code:lib_dir(jinterface),"priv","OtpErlang.jar"])++PS++ case os:getenv("CLASSPATH") of false -> ""; Classpath -> Classpath - end). - -es(L) -> - lists:flatmap(fun($ ) -> - "\\ "; - (C) -> - [C] - end,lists:flatten(L)). + end, + Quote, + EscSpace). + +es(L,Quote,EscSpace) -> + Quote++lists:flatmap(fun($ ) -> + EscSpace++" "; + (C) -> + [C] + end,lists:flatten(L)) ++ Quote. cmd(Cmd) -> PortOpts = [{line,80},eof,exit_status,stderr_to_stdout], -- cgit v1.2.3 From fc6ce3f254fb231d157a765e1720612d0611baa2 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 5 Mar 2013 09:58:06 +0100 Subject: [jinterface] Kill process between tests to avoid consequential error In some cases when a test case fails, the erl_link_server process (which is spawned by many test cases in jinterface_SUITE) does not terminate. This causes the next test case to fail with a badarg as it tries to register a new process with the same name. To avoid this, erl_link_server, if it exists, is now killed in end_per_testcase. Also, some compiler warnings are removed from jitu.erl. --- lib/jinterface/test/jinterface_SUITE.erl | 6 +++++- lib/jinterface/test/jitu.erl | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/jinterface/test/jinterface_SUITE.erl b/lib/jinterface/test/jinterface_SUITE.erl index 82bc878112..b438da12d0 100644 --- a/lib/jinterface/test/jinterface_SUITE.erl +++ b/lib/jinterface/test/jinterface_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2011. All Rights Reserved. +%% Copyright Ericsson AB 2004-2013. 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 @@ -184,6 +184,10 @@ init_per_testcase(_Case,Config) -> [{watch_dog,Dog}|Config]. end_per_testcase(_Case,Config) -> + case whereis(erl_link_server) of + undefined -> ok; + Pid -> exit(Pid,kill) + end, ?t:timetrap_cancel(?config(watch_dog,Config)), ok. diff --git a/lib/jinterface/test/jitu.erl b/lib/jinterface/test/jitu.erl index 0de074a9c9..0e1af0ff22 100644 --- a/lib/jinterface/test/jitu.erl +++ b/lib/jinterface/test/jitu.erl @@ -48,7 +48,7 @@ java(Java, Dir, Class, Args, Props) -> -init_all(Config) when list(Config) -> +init_all(Config) when is_list(Config) -> case find_executable(["java"]) of false -> {skip,"Found no Java VM"}; Path -> [{java,Path}|Config] @@ -69,13 +69,13 @@ find_executable([E|T]) -> Path -> Path end. -to_string([H|T]) when integer(H) -> +to_string([H|T]) when is_integer(H) -> integer_to_list(H)++" "++to_string(T); -to_string([H|T]) when atom(H) -> +to_string([H|T]) when is_atom(H) -> atom_to_list(H)++" "++to_string(T); -to_string([H|T]) when pid(H) -> +to_string([H|T]) when is_pid(H) -> pid_to_list(H)++" "++to_string(T); -to_string([H|T]) when list(H) -> +to_string([H|T]) when is_list(H) -> lists:flatten(H)++" "++to_string(T); to_string([]) -> []. @@ -109,12 +109,12 @@ cmd(Cmd) -> PortOpts = [{line,80},eof,exit_status,stderr_to_stdout], io:format("cmd: ~s~n", [Cmd]), case catch open_port({spawn,Cmd}, PortOpts) of - Port when port(Port) -> + Port when is_port(Port) -> Result = cmd_loop(Port, []), io:format("cmd res: ~w~n", [Result]), case Result of 0 -> ok; - ExitCode when integer(ExitCode) -> {error,ExitCode}; + ExitCode when is_integer(ExitCode) -> {error,ExitCode}; Error -> Error end; {'EXIT',Reason} -> -- cgit v1.2.3 From 0541bbab72df88b91d5725ad209aef1a951a4448 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 14 Mar 2013 10:56:09 +0100 Subject: [sasl] Fix tests that compare execution time Tests that compare execution time for release_handler:install_release sometimes fail. This has been corrected by multiplying the time with the CPU utilization in order to disregard wait time for e.g. file access and and non-erlang related load. --- lib/sasl/test/release_handler_SUITE.erl | 60 +++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/lib/sasl/test/release_handler_SUITE.erl b/lib/sasl/test/release_handler_SUITE.erl index 82b7a738bb..97ba70c9bd 100644 --- a/lib/sasl/test/release_handler_SUITE.erl +++ b/lib/sasl/test/release_handler_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2012. All Rights Reserved. +%% Copyright Ericsson AB 2011-2013. 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 @@ -1094,9 +1094,11 @@ otp_9395_update_many_mods(Conf) when is_list(Conf) -> [RelVsn2, filename:join(Rel2Dir, "sys.config")]), %% First, install release directly and check how much time it takes + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,true]), {TInst0,{ok, _, []}} = timer:tc(rpc,call,[Node, release_handler, install_release, [RelVsn2]]), - ct:log("install_release: ~.2f",[TInst0/1000000]), + SWT0 = rpc:call(Node,erlang,statistics,[scheduler_wall_time]), +% ct:log("install_release: ~.2f",[TInst0/1000000]), %% Restore to old release, spawn processes again and load to get old code {_,RelVsn1} = init:script_id(), @@ -1113,15 +1115,32 @@ otp_9395_update_many_mods(Conf) when is_list(Conf) -> {TCheck,{ok, _RelVsn1, []}} = timer:tc(rpc,call,[Node, release_handler, check_install_release, [RelVsn2,[purge]]]), - ct:log("check_install_release with purge: ~.2f",[TCheck/1000000]), +% ct:log("check_install_release with purge: ~.2f",[TCheck/1000000]), %% Finally install release after check and purge, and check that %% this install was faster than the first. + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,false]), + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,true]), {TInst2,{ok, _RelVsn1, []}} = timer:tc(rpc,call,[Node, release_handler, install_release, [RelVsn2]]), - ct:log("install_release: ~.2f",[TInst2/1000000]), - - true = (TInst2 < TInst0), + SWT2 = rpc:call(Node,erlang,statistics,[scheduler_wall_time]), +% ct:log("install_release: ~.2f",[TInst2/1000000]), + + %% Calculate and print real time and CPU utilization + SumFun = fun({_,A,T},{AAcc,TAcc}) -> {A+AAcc,T+TAcc} end, + {SumA0,SumT0} = lists:foldl(SumFun,{0,0},SWT0), + {SumA2,SumT2} = lists:foldl(SumFun,{0,0},SWT2), + TI0=TInst0/1000000, + TI2=TInst2/1000000, + CPU0=SumA0/SumT0, + CPU2=SumA2/SumT2, + X0 = TI0*CPU0, + X2 = TI2*CPU2, + ct:log("First run: T=~.2fsec, CPU=~.2f, T*CPU=~.2f~n" + "Second run: T=~.2fsec, CPU=~.2f, T*CPU=~.2f~n", + [TI0, CPU0, X0, TI2, CPU2, X2]), + + true = (X2 =< X0), % disregarding wait time for file access etc. ok. @@ -1172,9 +1191,11 @@ otp_9395_rm_many_mods(Conf) when is_list(Conf) -> [RelVsn2, filename:join(Rel2Dir, "sys.config")]), %% First, install release directly and check how much time it takes + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,true]), {TInst0,{ok, _, []}} = timer:tc(rpc,call,[Node, release_handler, install_release, [RelVsn2]]), - ct:log("install_release: ~.2f",[TInst0/1000000]), + SWT0 = rpc:call(Node,erlang,statistics,[scheduler_wall_time]), +% ct:log("install_release: ~.2f",[TInst0/1000000]), %% Restore to old release, spawn processes again and load to get old code {_,RelVsn1} = init:script_id(), @@ -1191,15 +1212,32 @@ otp_9395_rm_many_mods(Conf) when is_list(Conf) -> {TCheck,{ok, _RelVsn1, []}} = timer:tc(rpc,call,[Node, release_handler, check_install_release, [RelVsn2,[purge]]]), - ct:log("check_install_release with purge: ~.2f",[TCheck/1000000]), +% ct:log("check_install_release with purge: ~.2f",[TCheck/1000000]), %% Finally install release after check and purge, and check that %% this install was faster than the first. + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,false]), + rpc:call(Node,erlang,system_flag,[scheduler_wall_time,true]), {TInst2,{ok, _RelVsn1, []}} = timer:tc(rpc,call,[Node, release_handler, install_release, [RelVsn2]]), - ct:log("install_release: ~.2f",[TInst2/1000000]), - - true = (TInst2 =< TInst0), + SWT2 = rpc:call(Node,erlang,statistics,[scheduler_wall_time]), +% ct:log("install_release: ~.2f",[TInst2/1000000]), + + %% Calculate and print real time and CPU utilization + SumFun = fun({_,A,T},{AAcc,TAcc}) -> {A+AAcc,T+TAcc} end, + {SumA0,SumT0} = lists:foldl(SumFun,{0,0},SWT0), + {SumA2,SumT2} = lists:foldl(SumFun,{0,0},SWT2), + TI0=TInst0/1000000, + TI2=TInst2/1000000, + CPU0=SumA0/SumT0, + CPU2=SumA2/SumT2, + X0 = TI0*CPU0, + X2 = TI2*CPU2, + ct:log("First run: T=~.2fsec, CPU=~.2f, T*CPU=~.2f~n" + "Second run: T=~.2fsec, CPU=~.2f, T*CPU=~.2f~n", + [TI0, CPU0, X0, TI2, CPU2, X2]), + + true = (X2 =< X0), % disregarding wait time for file access etc. ok. -- cgit v1.2.3