aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/code_SUITE_data
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-11-17 14:39:04 +0100
committerSverker Eriksson <[email protected]>2016-11-30 14:17:09 +0100
commit15789e168811d6e6bed082ea7c64db93e1d968e8 (patch)
tree2123ffc17a083438decc42e730d0b711188b4e5f /erts/emulator/test/code_SUITE_data
parentb3441cbd116fede332e1e4cfee4d48331be1fa62 (diff)
downloadotp-15789e168811d6e6bed082ea7c64db93e1d968e8.tar.gz
otp-15789e168811d6e6bed082ea7c64db93e1d968e8.tar.bz2
otp-15789e168811d6e6bed082ea7c64db93e1d968e8.zip
erts: Refactor test code
Diffstat (limited to 'erts/emulator/test/code_SUITE_data')
-rw-r--r--erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl58
1 files changed, 24 insertions, 34 deletions
diff --git a/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl b/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl
index 16dbbcec37..10d00b7d2a 100644
--- a/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl
+++ b/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl
@@ -62,25 +62,25 @@ do_it(Priv, Data, Type, Opts) ->
?line Purge = start_purge(my_code_test2, PurgeType),
- ?line {P0, M0} = spawn_monitor(fun () ->
+ ?line {P1, M1} = spawn_monitor(fun () ->
?line [{my_fun,F}] = ets:lookup(T, my_fun),
?line 4712 = F(1),
exit(completed)
end),
- ?line ok = wait_until(fun () ->
+ ?line ok = wait_until(fun () ->
{status, suspended}
- == process_info(P0, status)
+ == process_info(P1, status)
end),
?line ok = continue_purge(Purge),
- ?line {P1, M1} = spawn_monitor(fun () ->
+ ?line {P2, M2} = spawn_monitor(fun () ->
?line [{my_fun,F}] = ets:lookup(T, my_fun),
?line 4713 = F(2),
exit(completed)
end),
- ?line {P2, M2} = spawn_monitor(fun () ->
+ ?line {P3, M3} = spawn_monitor(fun () ->
?line [{my_fun,F}] = ets:lookup(T, my_fun),
?line 4714 = F(3),
exit(completed)
@@ -88,25 +88,25 @@ do_it(Priv, Data, Type, Opts) ->
?line ok = wait_until(fun () ->
{status, suspended}
- == process_info(P1, status)
+ == process_info(P2, status)
end),
?line ok = wait_until(fun () ->
{status, suspended}
- == process_info(P2, status)
+ == process_info(P3, status)
end),
?line {current_function,
{erts_code_purger,
pending_purge_lambda,
- 3}} = process_info(P0, current_function),
+ 3}} = process_info(P1, current_function),
?line {current_function,
{erts_code_purger,
pending_purge_lambda,
- 3}} = process_info(P1, current_function),
+ 3}} = process_info(P2, current_function),
?line {current_function,
{erts_code_purger,
pending_purge_lambda,
- 3}} = process_info(P2, current_function),
+ 3}} = process_info(P3, current_function),
case Type of
code_there ->
@@ -117,37 +117,27 @@ do_it(Priv, Data, Type, Opts) ->
case Type of
code_gone ->
- receive
- {'DOWN', M0, process, P0, Reason0} ->
- ?line {undef, _} = Reason0
- end,
- receive
- {'DOWN', M1, process, P1, Reason1} ->
- ?line {undef, _} = Reason1
- end,
- receive
- {'DOWN', M2, process, P2, Reason2} ->
- ?line {undef, _} = Reason2
- end;
+ ?line {undef, _} = wait_for_down(P1,M1),
+ ?line {undef, _} = wait_for_down(P2,M2),
+ ?line {undef, _} = wait_for_down(P3,M3);
_ ->
- receive
- {'DOWN', M0, process, P0, Reason0} ->
- ?line completed = Reason0
- end,
- receive
- {'DOWN', M1, process, P1, Reason1} ->
- ?line completed = Reason1
- end,
- receive
- {'DOWN', M2, process, P2, Reason2} ->
- ?line completed = Reason2
- end,
+ ?line completed = wait_for_down(P1,M1),
+ ?line completed = wait_for_down(P2,M2),
+ ?line completed = wait_for_down(P3,M3),
catch erlang:purge_module(my_code_test2),
catch erlang:delete_module(my_code_test2),
catch erlang:purge_module(my_code_test2)
end,
ok.
+wait_for_down(P,M) ->
+ receive
+ {'DOWN', M, process, P, Reason} ->
+ Reason
+ after 1000 ->
+ timeout
+ end.
+
wait_until(Fun) ->
wait_until(Fun, 20).