summaryrefslogtreecommitdiff
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <bmk@erlang.org>2019-11-29 15:21:38 +0100
committerMicael Karlberg <bmk@erlang.org>2019-11-29 15:21:38 +0100
commit32be3c5be5c473e5e157adf3ec62c97d9f2c7ba1 (patch)
tree141133ff095fd947eeaf271375a828cfc18a167f /erts
parent72d05c6fc05821a0ea296868ffff85a67ab3d582 (diff)
downloaderlang-32be3c5be5c473e5e157adf3ec62c97d9f2c7ba1.tar.gz
[esock|test] Restructure linux host info analyzis
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/test/socket_SUITE.erl106
1 files changed, 55 insertions, 51 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index ab2f93e874..9764112274 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -1872,56 +1872,7 @@ analyze_and_print_host_info() ->
end,
case {OsFam, OsName} of
{unix, linux} ->
- case file:read_file_info("/etc/issue") of
- {ok, _} ->
- io:format("Linux: ~s"
- "~n ~s"
- "~n",
- [Version, string:trim(os:cmd("cat /etc/issue"))]);
- _ ->
- io:format("Linux: ~s"
- "~n", [Version])
- end,
- Factor =
- case (catch linux_which_cpuinfo()) of
- {ok, {CPU, BogoMIPS}} ->
- io:format("CPU: ~s"
- "~nBogoMIPS: ~s"
- "~n", [CPU, BogoMIPS]),
- %% We first assume its a float, and if not try integer
- try list_to_float(BogoMIPS) of
- F when F > 1000 ->
- 1;
- F when F > 1000 ->
- 2;
- _ ->
- 3
- catch
- _:_:_ ->
- %%
- try list_to_integer(BogoMIPS) of
- I when I > 1000 ->
- 1;
- I when I > 1000 ->
- 2;
- _ ->
- 3
- catch
- _:_:_ ->
- 1
- end
- end;
- _ ->
- 1
- end,
- %% Check if we need to adjust the factor because of the memory
- try linux_which_meminfo() of
- AddFactor ->
- Factor + AddFactor
- catch
- _:_:_ ->
- Factor
- end;
+ analyze_and_print_linux_host_info(Version);
{unix, sunos} ->
io:format("Solaris: ~s"
"~n", [Version]),
@@ -1934,6 +1885,58 @@ analyze_and_print_host_info() ->
1
end.
+analyze_and_print_linux_host_info(Version) ->
+ case file:read_file_info("/etc/issue") of
+ {ok, _} ->
+ io:format("Linux: ~s"
+ "~n ~s"
+ "~n",
+ [Version, string:trim(os:cmd("cat /etc/issue"))]);
+ _ ->
+ io:format("Linux: ~s"
+ "~n", [Version])
+ end,
+ Factor =
+ case (catch linux_which_cpuinfo()) of
+ {ok, {CPU, BogoMIPS}} ->
+ io:format("CPU: "
+ "~n Model: ~s"
+ "~n BogoMIPS: ~s"
+ "~n", [CPU, BogoMIPS]),
+ %% We first assume its a float, and if not try integer
+ try list_to_float(string:trim(BogoMIPS)) of
+ F when F > 1000 ->
+ 1;
+ F when F > 1000 ->
+ 2;
+ _ ->
+ 3
+ catch
+ _:_:_ ->
+ %%
+ try list_to_integer(string:trim(BogoMIPS)) of
+ I when I > 1000 ->
+ 1;
+ I when I > 1000 ->
+ 2;
+ _ ->
+ 3
+ catch
+ _:_:_ ->
+ 1
+ end
+ end;
+ _ ->
+ 1
+ end,
+ %% Check if we need to adjust the factor because of the memory
+ try linux_which_meminfo() of
+ AddFactor ->
+ Factor + AddFactor
+ catch
+ _:_:_ ->
+ Factor
+ end.
linux_which_cpuinfo() ->
%% Check for x86 (Intel or AMD)
@@ -1971,7 +1974,8 @@ linux_which_cpuinfo() ->
linux_which_meminfo() ->
try [string:trim(S) || S <- string:tokens(os:cmd("grep MemTotal /proc/meminfo"), [$:])] of
[_, MemTotal] ->
- io:format("Memory: ~s"
+ io:format("Memory:"
+ "~n ~s"
"~n", [MemTotal]),
case string:tokens(MemTotal, [$ ]) of
[MemSzStr, MemUnit] ->