summaryrefslogtreecommitdiff
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <bmk@erlang.org>2019-11-29 15:29:34 +0100
committerMicael Karlberg <bmk@erlang.org>2019-11-29 15:29:34 +0100
commit5eaf5db26fc537c58c83db85f86e3abc32c07f3a (patch)
treec34cb3ee187d7266dc805633886219cb93094632 /erts
parent42b89b302b618e37e0e92b0b60fcad9f7c8a50ec (diff)
parent8b07f68f69315f046aa885845c77d0ef14db7a3b (diff)
downloaderlang-5eaf5db26fc537c58c83db85f86e3abc32c07f3a.tar.gz
Merge branch 'bmk/erts/esock/20191127/test_tweaking_openbsd' into bmk/erts/esock/20191127/test_tweaking
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/test/socket_SUITE.erl92
1 files changed, 92 insertions, 0 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index 9764112274..596396b046 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -1873,6 +1873,8 @@ analyze_and_print_host_info() ->
case {OsFam, OsName} of
{unix, linux} ->
analyze_and_print_linux_host_info(Version);
+ {unix, openbsd} ->
+ analyze_and_print_openbsd_host_info(Version);
{unix, sunos} ->
io:format("Solaris: ~s"
"~n", [Version]),
@@ -1938,6 +1940,96 @@ analyze_and_print_linux_host_info(Version) ->
Factor
end.
+%% Just to be clear: This is ***not*** scientific...
+analyze_and_print_openbsd_host_info(Version) ->
+ io:format("OpenBSD:"
+ "~n Version: ~p"
+ "~n", [Version]),
+ Extract =
+ fun(Key) ->
+ string:tokens(string:trim(os:cmd("sysctl " ++ Key)), [$=])
+ end,
+ try
+ begin
+ CPU =
+ case Extract("hw.model") of
+ ["hw.model", Model] ->
+ string:trim(Model);
+ _ ->
+ "-"
+ end,
+ CPUSpeed =
+ case Extract("hw.cpuspeed") of
+ ["hw.cpuspeed", Speed] ->
+ list_to_integer(Speed);
+ _ ->
+ -1
+ end,
+ NCPU =
+ case Extract("hw.ncpufound") of
+ ["hw.ncpufound", N] ->
+ list_to_integer(N);
+ _ ->
+ -1
+ end,
+ Memory =
+ case Extract("hw.physmem") of
+ ["hw.physmem", PhysMem] ->
+ list_to_integer(PhysMem) div 1024;
+ _ ->
+ -1
+ end,
+ io:format("CPU:"
+ "~n Model: ~s"
+ "~n Speed: ~w"
+ "~n N: ~w"
+ "~nMemory:"
+ "~n ~w KB"
+ "~n", [CPU, CPUSpeed, NCPU, Memory]),
+ CPUFactor =
+ if
+ (CPUSpeed =:= -1) ->
+ 1;
+ (CPUSpeed >= 2000) ->
+ if
+ (NCPU >= 4) ->
+ 1;
+ (NCPU >= 2) ->
+ 2;
+ true ->
+ 3
+ end;
+ true ->
+ if
+ (NCPU >= 4) ->
+ 2;
+ (NCPU >= 2) ->
+ 3;
+ true ->
+ 4
+ end
+ end,
+ MemAddFactor =
+ if
+ (Memory =:= -1) ->
+ 0;
+ (Memory >= 8388608) ->
+ 0;
+ (Memory >= 4194304) ->
+ 1;
+ (Memory >= 2097152) ->
+ 2;
+ true ->
+ 3
+ end,
+ CPUFactor + MemAddFactor
+ end
+ catch
+ _:_:_ ->
+ 1
+ end.
+
+
linux_which_cpuinfo() ->
%% Check for x86 (Intel or AMD)
CPU =