diff options
author | Björn Gustavsson <[email protected]> | 2012-10-17 16:47:29 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-10-26 11:30:37 +0200 |
commit | dafa6a1a7d478a61b220db811bc62f4b9b6d7de3 (patch) | |
tree | 15fdda8d131721cc806f9314a4cf75d5790b1b4b /lib/test_server/src/test_server_sup.erl | |
parent | 5778da0c036cb6707af98612f98e22663eb35092 (diff) | |
download | otp-dafa6a1a7d478a61b220db811bc62f4b9b6d7de3.tar.gz otp-dafa6a1a7d478a61b220db811bc62f4b9b6d7de3.tar.bz2 otp-dafa6a1a7d478a61b220db811bc62f4b9b6d7de3.zip |
Keep the information about the current test case consistent
Three pieces of information could be out of sync in testcase
supervisor process at the time when a timetrap occurred:
* test_server_loc (process dictionary) - may indicate that a
framework function is executing
* test_server_init_or_end_conf (process dictionary) - indicates whether
init_per_testcase or end_per_testcase is executing
* The current configuration (#st.config) - set using a synchronous
call
There could be in a crash in spawn_fw_call/7 because the current
configuration was not defined when it was expected to.
To avoid the problem, introduce set_tc_state/2 (and a corresponding
message) to allow setting both an indication what the testcase is
executing (e.g. init_per_testcase, framework call, and so on), and
the current configuration. Use only that information to handle
a timetrap timeout (and aborted testcase and the other reasons
for the testcase process to terminate). Completely remove
test_server_init_or_end_conf.
Diffstat (limited to 'lib/test_server/src/test_server_sup.erl')
-rw-r--r-- | lib/test_server/src/test_server_sup.erl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/test_server/src/test_server_sup.erl b/lib/test_server/src/test_server_sup.erl index 4a27c1ebae..9f0d1af3ef 100644 --- a/lib/test_server/src/test_server_sup.erl +++ b/lib/test_server/src/test_server_sup.erl @@ -64,13 +64,7 @@ timetrap(Timeout0, ReportTVal, Scale, Pid) -> true -> ReportTVal end, MFLs = test_server:get_loc(Pid), Mon = erlang:monitor(process, Pid), - Trap = - case get(test_server_init_or_end_conf) of - undefined -> - {timetrap_timeout,TimeToReport,MFLs}; - InitOrEnd -> - {timetrap_timeout,TimeToReport,MFLs,InitOrEnd} - end, + Trap = {timetrap_timeout,TimeToReport,MFLs}, exit(Pid, Trap), receive {'DOWN', Mon, process, Pid, _} -> @@ -520,6 +514,17 @@ framework_call(Callback,Func,Args,DefaultReturn) -> true -> put(test_server_loc, {Mod,Func,framework}), EH = fun(Reason) -> exit({fw_error,{Mod,Func,Reason}}) end, + SetTcState = case Func of + end_tc -> true; + init_tc -> true; + _ -> false + end, + case SetTcState of + true -> + test_server:set_tc_state({framework,Mod,Func}, undefined); + false -> + ok + end, try apply(Mod,Func,Args) of Result -> Result |