aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server
diff options
context:
space:
mode:
Diffstat (limited to 'lib/test_server')
-rw-r--r--lib/test_server/src/test_server.erl45
-rw-r--r--lib/test_server/src/test_server_ctrl.erl62
2 files changed, 76 insertions, 31 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index 98a2e21e21..51754cb3b4 100644
--- a/lib/test_server/src/test_server.erl
+++ b/lib/test_server/src/test_server.erl
@@ -36,7 +36,8 @@
-export([capture_start/0,capture_stop/0,capture_get/0]).
-export([messages_get/0]).
-export([hours/1,minutes/1,seconds/1,sleep/1,adjusted_sleep/1,timecall/3]).
--export([timetrap_scale_factor/0,timetrap/1,timetrap_cancel/1,timetrap_cancel/0]).
+-export([timetrap_scale_factor/0,timetrap/1,get_timetrap_info/0,
+ timetrap_cancel/1,timetrap_cancel/0]).
-export([m_out_of_n/3,do_times/4,do_times/2]).
-export([call_crash/3,call_crash/4,call_crash/5]).
-export([temp_name/1]).
@@ -1139,7 +1140,7 @@ run_test_case_eval(Mod, Func, Args0, Name, Ref, RunInit,
{auto_skip,Reason} ->
Where = {Mod,Func},
NewResult = do_end_tc_call(Mod,Func, Where, {{skip,Reason},Args0},
- {skip,{fw_auto_skip,Reason}}),
+ {skip,Reason}),
{{0,NewResult},Where,[]}
end,
exit({Ref,Time,Value,Loc,Opts}).
@@ -1257,11 +1258,15 @@ run_test_case_eval1(Mod, Func, Args, Name, RunInit, TCCallback) ->
end.
do_end_tc_call(M,F, Loc, Res, Return) ->
+ IsSuite = case lists:reverse(atom_to_list(M)) of
+ [$E,$T,$I,$U,$S,$_|_] -> true;
+ _ -> false
+ end,
FwMod = os:getenv("TEST_SERVER_FRAMEWORK"),
{Mod,Func} =
if FwMod == M ; FwMod == "undefined"; FwMod == false ->
{M,F};
- is_list(Loc) and (length(Loc)>1) ->
+ (not IsSuite) and is_list(Loc) and (length(Loc)>1) ->
%% If failure in other module (M) than suite, try locate
%% suite name in Loc list and call end_tc with Suite:TestCase
%% instead of M:F.
@@ -1524,7 +1529,10 @@ get_loc(Pid) ->
process_info(Pid, [current_stacktrace,dictionary]),
lists:foreach(fun({Key,Val}) -> put(Key, Val) end, Dict),
Stk = [rewrite_loc_item(Loc) || Loc <- Stk0],
- put(test_server_loc, Stk),
+ case get(test_server_loc) of
+ undefined -> put(test_server_loc, Stk);
+ _ -> ok
+ end,
get_loc().
%% find the latest known Suite:Testcase
@@ -1856,7 +1864,9 @@ fail() ->
break(Comment) ->
case erase(test_server_timetraps) of
undefined -> ok;
- List -> lists:foreach(fun({Ref,_}) -> timetrap_cancel(Ref) end, List)
+ List -> lists:foreach(fun({Ref,_,_}) ->
+ timetrap_cancel(Ref)
+ end, List)
end,
io:format(user,
"\n\n\n--- SEMIAUTOMATIC TESTING ---"
@@ -1945,8 +1955,8 @@ timetrap1(Timeout, Scale) ->
TCPid = self(),
Ref = spawn_link(test_server_sup,timetrap,[Timeout,Scale,TCPid]),
case get(test_server_timetraps) of
- undefined -> put(test_server_timetraps,[{Ref,TCPid}]);
- List -> put(test_server_timetraps,[{Ref,TCPid}|List])
+ undefined -> put(test_server_timetraps,[{Ref,TCPid,{Timeout,Scale}}]);
+ List -> put(test_server_timetraps,[{Ref,TCPid,{Timeout,Scale}}|List])
end,
Ref.
@@ -2057,7 +2067,7 @@ timetrap_cancel(infinity) ->
timetrap_cancel(Handle) ->
case get(test_server_timetraps) of
undefined -> ok;
- [{Handle,_}] -> erase(test_server_timetraps);
+ [{Handle,_,_}] -> erase(test_server_timetraps);
Timers -> put(test_server_timetraps,
lists:keydelete(Handle, 1, Timers))
end,
@@ -2073,13 +2083,30 @@ timetrap_cancel() ->
ok;
Timers ->
case lists:keysearch(self(), 2, Timers) of
- {value,{Handle,_}} ->
+ {value,{Handle,_,_}} ->
timetrap_cancel(Handle);
_ ->
ok
end
end.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% get_timetrap_info() -> {Timeout,Scale} | undefined
+%%
+%% Read timetrap info for current test case
+get_timetrap_info() ->
+ case get(test_server_timetraps) of
+ undefined ->
+ undefined;
+ Timers ->
+ case lists:keysearch(self(), 2, Timers) of
+ {value,{_,_,Info}} ->
+ Info;
+ _ ->
+ undefined
+ end
+ end.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% hours(N) -> Milliseconds
%% minutes(N) -> Milliseconds
diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl
index 70422adccd..3432b3bc8e 100644
--- a/lib/test_server/src/test_server_ctrl.erl
+++ b/lib/test_server/src/test_server_ctrl.erl
@@ -1826,18 +1826,27 @@ start_log_file() ->
exit({cant_create_log_dir,{MkDirError,Dir}})
end,
TestDir = timestamp_filename_get(filename:join(Dir, "run.")),
- case file:make_dir(TestDir) of
- ok ->
- ok;
- MkDirError2 ->
- exit({cant_create_log_dir,{MkDirError2,TestDir}})
- end,
-
- ok = file:write_file(filename:join(Dir, ?last_file), TestDir ++ "\n"),
- ok = file:write_file(?last_file, TestDir ++ "\n"),
-
- put(test_server_log_dir_base,TestDir),
- MajorName = filename:join(TestDir, ?suitelog_name),
+ TestDir1 =
+ case file:make_dir(TestDir) of
+ ok ->
+ TestDir;
+ {error,eexist} ->
+ timer:sleep(1000),
+ %% we need min 1 second between timestamps unfortunately
+ TestDirX = timestamp_filename_get(filename:join(Dir, "run.")),
+ case file:make_dir(TestDirX) of
+ ok ->
+ TestDirX;
+ MkDirError2 ->
+ exit({cant_create_log_dir,{MkDirError2,TestDirX}})
+ end;
+ MkDirError2 ->
+ exit({cant_create_log_dir,{MkDirError2,TestDir}})
+ end,
+ ok = file:write_file(filename:join(Dir, ?last_file), TestDir1 ++ "\n"),
+ ok = file:write_file(?last_file, TestDir1 ++ "\n"),
+ put(test_server_log_dir_base,TestDir1),
+ MajorName = filename:join(TestDir1, ?suitelog_name),
HtmlName = MajorName ++ ?html_ext,
{ok,Major} = file:open(MajorName, [write]),
{ok,Html} = file:open(HtmlName, [write]),
@@ -1850,14 +1859,14 @@ start_log_file() ->
make_html_link(LinkName ++ ?html_ext, HtmlName,
filename:basename(Dir)),
- PrivDir = filename:join(TestDir, ?priv_dir),
+ PrivDir = filename:join(TestDir1, ?priv_dir),
ok = file:make_dir(PrivDir),
put(test_server_priv_dir,PrivDir++"/"),
print_timestamp(13,"Suite started at "),
- LogInfo = [{topdir,Dir},{rundir,lists:flatten(TestDir)}],
+ LogInfo = [{topdir,Dir},{rundir,lists:flatten(TestDir1)}],
test_server_sup:framework_call(report, [loginfo,LogInfo]),
- {ok,TestDir}.
+ {ok,TestDir1}.
make_html_link(LinkName, Target, Explanation) ->
%% if possible use a relative reference to Target.
@@ -2725,23 +2734,32 @@ run_test_cases_loop([{conf,Ref,Props,{Mod,Func}}|_Cases]=Cs0,
"(configuration case ~w)", [What]);
(_) -> ok
end,
-
CfgProps = if StartConf ->
if Shuffle == undefined ->
[{tc_group_properties,Props}];
true ->
- [{tc_group_properties,[Shuffle|delete_shuffle(Props)]}]
+ [{tc_group_properties,
+ [Shuffle|delete_shuffle(Props)]}]
end;
not StartConf ->
{TcOk,TcSkip,TcFail} = get_tc_results(Status1),
[{tc_group_properties,get_props(Mode0)},
- {tc_group_result,[{ok,TcOk},{skipped,TcSkip},{failed,TcFail}]}]
+ {tc_group_result,[{ok,TcOk},
+ {skipped,TcSkip},
+ {failed,TcFail}]}]
end,
- ActualCfg =
- update_config(hd(Config), [{priv_dir,get(test_server_priv_dir)},
- {data_dir,get_data_dir(Mod)}] ++ CfgProps),
+ TSDirs = [{priv_dir,get(test_server_priv_dir)},{data_dir,get_data_dir(Mod)}],
+ ActualCfg =
+ if not StartConf ->
+ update_config(hd(Config), TSDirs ++ CfgProps);
+ true ->
+ GroupPath = lists:flatmap(fun({_Ref,[],_T}) -> [];
+ ({_Ref,GrProps,_T}) -> [GrProps]
+ end, Mode0),
+ update_config(hd(Config),
+ TSDirs ++ [{tc_group_path,GroupPath} | CfgProps])
+ end,
CurrMode = curr_mode(Ref, Mode0, Mode),
-
ConfCaseResult = run_test_case(Ref, 0, Mod, Func, [ActualCfg], skip_init, target,
TimetrapData, CurrMode),