Skip to content

Commit 10a8f42

Browse files
committed
Merge pull request #1221 from pguyot/w26/fix-test_gc-beam
Fix test_gc test with BEAM `test_gc` was disabled because it failed more or less randomly with OTP26. It seems to be related to a change in how the eval string from the command line is processed by OTP, allocating more memory and therefore making the effect of garbage collector less obvious. Fix it by spawning a fresh process for the test. Special thanks to @karlsson for investigating this. Fixes #1219 These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 7f701bf + bb4af20 commit 10a8f42

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/run-tests-with-beam.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ jobs:
6161
otp: "25"
6262

6363
- os: "ubuntu-24.04"
64-
test_erlang_opts: "-s prime_smp,test_gc"
64+
test_erlang_opts: "-s prime_smp"
6565
otp: "26"
6666
container: erlang:26
6767

6868
- os: "ubuntu-24.04"
69-
test_erlang_opts: "-s prime_smp,test_gc"
69+
test_erlang_opts: "-s prime_smp"
7070
otp: "27"
7171
container: erlang:27
7272

tests/erlang_tests/test_gc.erl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,36 @@
2323
-export([start/0]).
2424

2525
start() ->
26+
{Pid, Ref} = spawn_opt(
27+
fun() ->
28+
test_gc()
29+
end,
30+
[monitor]
31+
),
32+
normal =
33+
receive
34+
{'DOWN', Ref, process, Pid, Reason} -> Reason;
35+
Other -> {unexpected, Other}
36+
after 5000 ->
37+
timeout
38+
end,
39+
0.
40+
41+
test_gc() ->
2642
{HeapSize, _} = make_a_big_heap(),
2743
MemorySize = erlang:process_info(self(), memory),
2844
true = erlang:garbage_collect(),
2945
{heap_size, NewHeapSize} = erlang:process_info(self(), heap_size),
3046
ok =
3147
case NewHeapSize < HeapSize of
3248
true -> ok;
33-
_ -> fail
49+
_ -> {fail, ?LINE, NewHeapSize, HeapSize}
3450
end,
3551
NewMemorySize = erlang:process_info(self(), memory),
3652
ok =
3753
case NewMemorySize < MemorySize of
3854
true -> ok;
39-
_ -> fail
55+
_ -> {fail, ?LINE, NewMemorySize, MemorySize}
4056
end,
4157
0.
4258

0 commit comments

Comments
 (0)