diff options
author | Kjell Winblad <[email protected]> | 2019-05-29 10:50:24 +0200 |
---|---|---|
committer | Kjell Winblad <[email protected]> | 2019-06-11 11:34:38 +0200 |
commit | 8ff68249905b367b4b7179aa4c600511bfec5b87 (patch) | |
tree | 9a6054a98af344113d07e68fc89d59c5010797a8 | |
parent | ab1b97e874a0c014af0f1bcf54140970c06a03af (diff) | |
download | otp-8ff68249905b367b4b7179aa4c600511bfec5b87.tar.gz otp-8ff68249905b367b4b7179aa4c600511bfec5b87.tar.bz2 otp-8ff68249905b367b4b7179aa4c600511bfec5b87.zip |
Fix the test case cpu_sup_SUITE:util_values
The message signaling that the spinning processes had stopped was
previously sent too early.
-rw-r--r-- | lib/os_mon/test/cpu_sup_SUITE.erl | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index 3a8346ac44..7a8065c591 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -155,45 +155,56 @@ tiny_diff(A, B) -> -define(SPIN_TIME, 1000). +spinner(Parent) -> + receive + stop -> Parent ! stopped + after 0 -> spinner(Parent) + end. + %% Test utilization values util_values(Config) when is_list(Config) -> - + NrOfProcessors = + case erlang:system_info(logical_processors_available) of + unknown -> 2; + X -> X + end, Tester = self(), Ref = make_ref(), - Loop = fun (L) -> L(L) end, Spinner = fun () -> - NrOfProcesses = 100, - Loopers = [spawn_link(fun () -> Loop(Loop) end) - || _ <- lists:seq(1,NrOfProcesses)], + Spinner = self(), + NrOfProcesses = NrOfProcessors, + Loopers = + [spawn_link(fun () -> spinner(Spinner) end) + || _ <- lists:seq(1,NrOfProcesses)], receive after ?SPIN_TIME -> ok end, - [(fun () -> - unlink(Looper), - exit(Looper, kill), - Tester ! Ref - end)() - || Looper <- Loopers] - + [begin + Looper ! stop, + receive stopped -> ok end + end + || Looper <- Loopers], + Tester ! Ref end, + Spin = fun () -> + spawn_link(Spinner), + receive Ref -> ok end + end, cpu_sup:util(), receive after ?SPIN_TIME -> ok end, LowUtil0 = cpu_sup:util(), - NrOfProcessors = erlang:system_info(logical_processors_available), case LowUtil0 of - U when U > ((100.0 / NrOfProcessors) * 0.5) -> + U when U > ((100.0 / NrOfProcessors) * 0.33) -> %% We cannot run this test if the system is doing other %% work at the same time as the result will be unreliable {skip, io_lib:format("CPU utilization was too high (~f%)", [LowUtil0])}; _ -> cpu_sup:util(), - spawn_link(Spinner), - receive Ref -> ok end, + Spin(), HighUtil1 = cpu_sup:util(), receive after ?SPIN_TIME -> ok end, LowUtil1 = cpu_sup:util(), - spawn_link(Spinner), - receive Ref -> ok end, + Spin(), HighUtil2 = cpu_sup:util(), receive after ?SPIN_TIME -> ok end, |