aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/gc_SUITE.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2017-05-24 15:32:31 +0200
committerJohn Högberg <[email protected]>2017-05-31 12:38:05 +0200
commit0ddedf0680ae23ead8ebf7999af846ce5d722d36 (patch)
treeefa0dd4302f8ab528a548c2539e6b633833af86f /erts/emulator/test/gc_SUITE.erl
parent05dce0f330c83278cb134c7235a5353ce4116307 (diff)
downloadotp-0ddedf0680ae23ead8ebf7999af846ce5d722d36.tar.gz
otp-0ddedf0680ae23ead8ebf7999af846ce5d722d36.tar.bz2
otp-0ddedf0680ae23ead8ebf7999af846ce5d722d36.zip
Fix a race condition that consistently affected lc+lcnt builds
The garbage_collect message could be received while waiting for trace messages, causing the test to crash erroneously.
Diffstat (limited to 'erts/emulator/test/gc_SUITE.erl')
-rw-r--r--erts/emulator/test/gc_SUITE.erl32
1 files changed, 19 insertions, 13 deletions
diff --git a/erts/emulator/test/gc_SUITE.erl b/erts/emulator/test/gc_SUITE.erl
index 35dd147550..02b1927621 100644
--- a/erts/emulator/test/gc_SUITE.erl
+++ b/erts/emulator/test/gc_SUITE.erl
@@ -268,24 +268,30 @@ minor_major_gc_option_async(_Config) ->
erlang:trace(P4, true, [garbage_collection]),
?assertEqual(async,
erlang:garbage_collect(P4, [{type, minor}, {async, Ref}])),
+ receive
+ {garbage_collect, Ref, true} ->
+ ok
+ after 10000 ->
+ ct:pal("Did not receive an async GC notification", []),
+ ?assert(false)
+ end,
expect_trace_messages(P4, [gc_minor_start, gc_minor_end]),
erlang:trace(P4, false, [garbage_collection]),
- receive {garbage_collect, Ref, true} -> ok;
- Other4 -> ct:pal("Unexpected message: ~p~n"
- ++ "while waiting for async gc result", [Other4])
- after 2000 -> ?assert(false)
- end,
erlang:exit(P4, kill).
-%% Given a list of atoms, trace tags - receives messages and checks if they are
-%% trace events, and if the tag matches. Else will crash failing the test.
-expect_trace_messages(_Pid, []) -> ok;
-expect_trace_messages(Pid, [Tag | TraceTags]) ->
+%% Ensures that trace messages with the provided tags have all been received.
+%% The test fails if there's any unmatched messages left in the mailbox after
+%% all tags have been matched.
+expect_trace_messages(_Pid, []) ->
receive
- {trace, Pid, Tag, _Data} -> ok;
- AnythingElse ->
- ct:pal("Unexpected message: ~p~nWhile expected {trace, _, ~p, _}",
- [AnythingElse, Tag]),
+ Anything ->
+ ct:pal("Unexpected message: ~p", [Anything]),
?assert(false)
+ after 0 ->
+ ok
+ end;
+expect_trace_messages(Pid, [Tag | TraceTags]) ->
+ receive
+ {trace, Pid, Tag, _Data} -> ok
end,
expect_trace_messages(Pid, TraceTags).