aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/test/ct_cover_nomerge_SUITE.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2014-05-21 16:39:03 +0200
committerSiri Hansen <[email protected]>2014-06-05 14:20:12 +0200
commit5a3c4668908254ee930c8db2e5cf9741945f9b2b (patch)
tree8a0943383986ffcd55aca542ef99e12957c14b73 /lib/common_test/test/ct_cover_nomerge_SUITE.erl
parent1118f1cf1baf5803c3a67939f609ee728dea85ee (diff)
downloadotp-5a3c4668908254ee930c8db2e5cf9741945f9b2b.tar.gz
otp-5a3c4668908254ee930c8db2e5cf9741945f9b2b.tar.bz2
otp-5a3c4668908254ee930c8db2e5cf9741945f9b2b.zip
Improve cover analysis via common_test
This addresses several bugs in common_test (ct) when using the cover analysis mechanism: In a ct test run, one can give a cover spec file which indicates that cover analysis shall be run, including a number of modules and a number of nodes. During the ct test run, multiple jobs may be started in test_server, and when the cover option is used, test_server would cover compile and analyse all given modules for each job. This commit instead allows the compilation and analysis to be explicitly ordered by ct for each test run. This way each module will only be cover compiled and analysed once. The cover log will be located in the common_test log directory (ct_run.<timestamp>), and the "Coverage log" link in each suite.log.html will point to this file. A new button is also added in the top level ct index file, which points to the cover log. This change also reduces the need of using the 'export' and 'import' options, since there is no longer any need to accumulate cover data over multiple test_server jobs. However, these options may still be used for importing and exporting cover data in order to store or accumulate data from multiple ct test runs. The 'nodes' option was earlier only used by ct to start cover on the given nodes before starting the first test_server job. After this job was completed, test_server would stop cover completely and then start it again for the next job without any knowledge of the 'nodes' options. For the next test_server jobs cover would therefore no longer be running on these nodes. Explcit calls to ct_cover:add_nodes had to be done in order to collect data through all test_server jobs. This bug has now been solved, since cover is no longer stopped between each test_server job. Finally, ct no longer stores cover data using ct_util:set_testdata. This was earlier used by ct_cover:add_nodes to make sure no node was added twice.This did, however, cause some problems when ct and cover were out of sync. ct could belive that a node was running cover and thus reject adding this node, while in reality cover had been stopped on the node (e.g. by test_server) so no cover data was collected. ct_cover:add_nodes will now instead use cover:which_nodes to check if a node is already running.
Diffstat (limited to 'lib/common_test/test/ct_cover_nomerge_SUITE.erl')
-rw-r--r--lib/common_test/test/ct_cover_nomerge_SUITE.erl44
1 files changed, 15 insertions, 29 deletions
diff --git a/lib/common_test/test/ct_cover_nomerge_SUITE.erl b/lib/common_test/test/ct_cover_nomerge_SUITE.erl
index 4344fc30df..8e2ee1b500 100644
--- a/lib/common_test/test/ct_cover_nomerge_SUITE.erl
+++ b/lib/common_test/test/ct_cover_nomerge_SUITE.erl
@@ -79,34 +79,29 @@ all() ->
local(Config) ->
DataDir = ?config(data_dir, Config),
Spec = filename:join(DataDir, "local.spec"),
- PrivDir = ?config(priv_dir,Config),
- ExportFile = filename:join(PrivDir,"local.coverdata"),
- CoverSpec = [{incl_mods,[?mod]},
- {export, ExportFile}],
+ CoverSpec = [{incl_mods,[?mod]}],
CoverFile = create_cover_file(local,CoverSpec,Config),
{Opts,ERPid} = setup([{spec,Spec},{label,local},{cover,CoverFile}], Config),
{ok,Events} = execute(local, local, Opts, ERPid, Config),
false = check_cover(Config),
- check_calls(Events,[{t1,1},{t2,2}]),
+ check_calls(Events,2),
ok.
remote(Config) ->
DataDir = ?config(data_dir, Config),
Spec = filename:join(DataDir, "remote.spec"),
%% extending some timers for slow test hosts
- {ok,_Node} = ct_slave:start(ct_nomerge,[{boot_timeout,15},
+ {ok,Node} = ct_slave:start(ct_nomerge,[{boot_timeout,15},
{init_timeout,15},
{startup_timeout,15}]),
- PrivDir = ?config(priv_dir,Config),
- ExportFile = filename:join(PrivDir,"remote.coverdata"),
- CoverSpec = [{incl_mods,[?mod]},
- {export, ExportFile}],
+ CoverSpec = [{nodes,[Node]},
+ {incl_mods,[?mod]}],
CoverFile = create_cover_file(remote,CoverSpec,Config),
{Opts,ERPid} = setup([{spec,Spec},{label,remote},{cover,CoverFile}], Config),
{ok,Events} = execute(remote, remote, Opts, ERPid, Config),
false = check_cover(Config),
- check_calls(Events,[{t1,1},{t2,2}]),
+ check_calls(Events,2),
ok.
remote(cleanup,_Config) ->
{ok,_} = ct_slave:stop(ct_nomerge),
@@ -120,18 +115,15 @@ remote_nostop(Config) ->
{init_timeout,15},
{startup_timeout,15}]),
- PrivDir = ?config(priv_dir,Config),
- ExportFile = filename:join(PrivDir,"remote_nostop.coverdata"),
CoverSpec = [{nodes,[Node]},
- {incl_mods,[?mod]},
- {export,ExportFile}],
+ {incl_mods,[?mod]}],
CoverFile = create_cover_file(remote_nostop,CoverSpec,Config),
{Opts,ERPid} = setup([{spec,Spec},{label,remote_nostop},
{cover,CoverFile},{cover_stop,false}],
Config),
{ok,Events} = execute(remote_nostop, remote_nostop, Opts, ERPid, Config),
{true,[Node],[cover_test_mod]} = check_cover(Config),
- check_calls(Events,[{t1,1},{t2,2}]),
+ check_calls(Events,2),
ok.
remote_nostop(cleanup,Config) ->
CtNode = ?config(ct_node,Config),
@@ -195,24 +187,18 @@ check_cover(Node) when is_atom(Node) ->
false
end.
-%% Get the log dir "run.<timestamp>" for all tests
-get_run_dirs(Events,Testcase) ->
- [filename:dirname(TCLog) ||
+%% Get the log dir "ct_run.<timestamp>" for all (both!) tests
+get_log_dirs(Events) ->
+ [LogDir ||
{ct_test_support_eh,
- {event,tc_logfile,_Node,
- {{_Suite,TC},TCLog}}} <- Events,
- TC==Testcase].
+ {event,start_logging,_Node,LogDir}} <- Events].
%% Check that each coverlog includes N calls to ?mod:foo/0
check_calls(Events,N) ->
check_calls(Events,{?mod,foo,0},N).
-check_calls(Events,MFA,[{Testcase,N}|Expected]) ->
- CoverLogs =
- [filename:join(D,"all.coverdata") || D <- get_run_dirs(Events,Testcase)],
- ok = do_check_logs(CoverLogs,MFA,N),
- check_calls(Events,MFA,Expected);
-check_calls(_,_,[]) ->
- ok.
+check_calls(Events,MFA,N) ->
+ CoverLogs = [filename:join(D,"all.coverdata") || D <- get_log_dirs(Events)],
+ do_check_logs(CoverLogs,MFA,N).
do_check_logs([CoverLog|CoverLogs],{Mod,_,_} = MFA,N) ->
{ok,_} = cover:start(),