aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-04-08 12:07:44 +0200
committerSiri Hansen <[email protected]>2013-04-08 12:07:44 +0200
commite4ee152324697864dc5b41c9a66b73b54bcde73d (patch)
tree7e8d1f529db262b3a5ad54db5655fb979e1a485c /lib
parent36dc385f283a3566fdc4a67c63299837e8c90f7a (diff)
parentb046454d76031067f6b49faec938ad422b47c44b (diff)
downloadotp-e4ee152324697864dc5b41c9a66b73b54bcde73d.tar.gz
otp-e4ee152324697864dc5b41c9a66b73b54bcde73d.tar.bz2
otp-e4ee152324697864dc5b41c9a66b73b54bcde73d.zip
Merge branch 'siri/cuddle-with-tests' into maint
* siri/cuddle-with-tests: [reltool] Clean up work dir after test [observer] Add debug printouts in ttb_SUITE
Diffstat (limited to 'lib')
-rw-r--r--lib/observer/test/ttb_SUITE.erl7
-rw-r--r--lib/reltool/test/reltool_server_SUITE.erl50
2 files changed, 53 insertions, 4 deletions
diff --git a/lib/observer/test/ttb_SUITE.erl b/lib/observer/test/ttb_SUITE.erl
index f3fcd9f283..fd32e6aa71 100644
--- a/lib/observer/test/ttb_SUITE.erl
+++ b/lib/observer/test/ttb_SUITE.erl
@@ -1483,12 +1483,19 @@ logic(N, M, TracingType) ->
?t:stop_node(ttb_helper:get_node(client)),
timer:sleep(2500),
?line {ok,_ClientNode} = ?t:start_node(client,slave,[]),
+ ct:log("client started",[]),
?line ok = ttb_helper:c(code, add_paths, [code:get_path()]),
+ ct:log("paths added",[]),
?line ttb_helper:c(client, init, []),
+ ct:log("client initiated",[]),
?line helper_msgs(N, TracingType),
+ ct:log("helper msgs sent and flushed",[]),
?line {_, D} = ttb:stop([return_fetch_dir]),
+ ct:log("stopped ~p",[D]),
?line ttb:format(D, [{out, ?OUTPUT}, {handler, ret_caller_call_handler2()}]),
+ ct:log("formatted ~p",[{D,?OUTPUT}]),
?line {ok, Ret} = file:consult(?OUTPUT),
+ ct:log("consulted: ~p",[Ret]),
?line M = length(Ret).
begin_trace_with_resume(ServerNode, ClientNode, Dest) ->
diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl
index adea716e99..b1e1787f18 100644
--- a/lib/reltool/test/reltool_server_SUITE.erl
+++ b/lib/reltool/test/reltool_server_SUITE.erl
@@ -28,6 +28,7 @@
-include_lib("reltool/src/reltool.hrl").
-include("reltool_test_lib.hrl").
-include_lib("common_test/include/ct.hrl").
+-include_lib("kernel/include/file.hrl").
-define(NODE_NAME, '__RELTOOL__TEMPORARY_TEST__NODE__').
-define(WORK_DIR, "reltool_work_dir").
@@ -36,8 +37,9 @@
%% Initialization functions.
init_per_suite(Config) ->
+ {ok,Cwd} = file:get_cwd(),
?ignore(file:make_dir(?WORK_DIR)),
- reltool_test_lib:init_per_suite(Config).
+ [{cwd,Cwd}|reltool_test_lib:init_per_suite(Config)].
end_per_suite(Config) ->
reltool_test_lib:end_per_suite(Config).
@@ -49,9 +51,49 @@ init_per_testcase(Func,Config) ->
pang -> ok
end,
reltool_test_lib:init_per_testcase(Func,Config).
-end_per_testcase(Func,Config) ->
+end_per_testcase(Func,Config) ->
+ ok = file:set_cwd(filename:join(?config(cwd,Config),?WORK_DIR)),
+ {ok,All} = file:list_dir("."),
+ Files = [F || F <- All, false == lists:prefix("save.",F)],
+ case ?config(tc_status,Config) of
+ ok ->
+ ok;
+ _Fail ->
+ SaveDir = "save."++atom_to_list(Func),
+ ok = file:make_dir(SaveDir),
+ save_test_result(Files,SaveDir)
+ end,
+ rm_files(Files),
+ ok = file:set_cwd(?config(cwd,Config)),
reltool_test_lib:end_per_testcase(Func,Config).
+
+save_test_result(Files,DestDir) ->
+ Tar = "copy.tar",
+ ok = erl_tar:create(Tar, Files),
+ ok = erl_tar:extract(Tar, [{cwd,DestDir}]),
+ ok = file:delete(Tar),
+ ok.
+
+rm_files([F | Fs]) ->
+ case file:read_file_info(F) of
+ {ok,#file_info{type=directory}} ->
+ rm_dir(F);
+ {ok,_Regular} ->
+ ok = file:delete(F)
+ end,
+ rm_files(Fs);
+rm_files([]) ->
+ ok.
+
+rm_dir(Dir) ->
+ {ok,Files} = file:list_dir(Dir),
+ rm_files([filename:join(Dir, F) || F <- Files]),
+ ok = file:del_dir(Dir).
+
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SUITE specification
@@ -506,7 +548,7 @@ create_script(_Config) ->
%% ?m(OrigScript2, Script2),
?m(equal, diff_script(OrigScript, Script)),
-
+
%% Stop server
?m(ok, reltool:stop(Pid)),
ok.
@@ -755,7 +797,7 @@ create_target(_Config) ->
Erl = filename:join([TargetDir, "bin", "erl"]),
{ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)),
?msym(ok, stop_node(Node)),
-
+
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%