From dafa6a1a7d478a61b220db811bc62f4b9b6d7de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 17 Oct 2012 16:47:29 +0200 Subject: 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. --- lib/test_server/src/test_server_sup.erl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/test_server/src/test_server_sup.erl') 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 -- cgit v1.2.3