aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/test_server.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2011-11-15 22:58:24 +0100
committerPeter Andersson <[email protected]>2011-12-02 14:38:40 +0100
commit15214a3d1918f4388d2aa9f12a3fd7005da2b65d (patch)
tree7b09a15bde18f52ef03941449db004f646bde1de /lib/test_server/src/test_server.erl
parent0ea7684efdc443a9a4e2b35c97c7eee1b047fc44 (diff)
downloadotp-15214a3d1918f4388d2aa9f12a3fd7005da2b65d.tar.gz
otp-15214a3d1918f4388d2aa9f12a3fd7005da2b65d.tar.bz2
otp-15214a3d1918f4388d2aa9f12a3fd7005da2b65d.zip
Implement the group info function
OTP-9235
Diffstat (limited to 'lib/test_server/src/test_server.erl')
-rw-r--r--lib/test_server/src/test_server.erl43
1 files changed, 35 insertions, 8 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index 98a2e21e21..1b344c6c7e 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]).
@@ -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