File 2411-snmp-test-Linux-distro.patch of Package erlang
From 58797a485aecb0033724a8e0c1fc7238ad539c52 Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Thu, 16 Apr 2020 21:58:47 +0200
Subject: [PATCH 11/14] [snmp|test] Linux distro...
---
lib/snmp/test/snmp_test_lib.erl | 55 +++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 13 deletions(-)
diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl
index aa3e262413..3ae1bc792c 100644
--- a/lib/snmp/test/snmp_test_lib.erl
+++ b/lib/snmp/test/snmp_test_lib.erl
@@ -883,24 +883,38 @@ analyze_and_print_host_info() ->
10
end
end.
+
+linux_which_distro(Version) ->
+ case [string:trim(S) ||
+ S <- string:tokens(os:cmd("cat /etc/issue"), [$\n])] of
+ [DistroStr|_] ->
+ io:format("Linux: ~s"
+ "~n ~s"
+ "~n",
+ [Version, DistroStr]),
+ case DistroStr of
+ "Wind River Linux" ++ _ ->
+ wind_river;
+ "MontaVista" ++ _ ->
+ montavista;
+ "Yellow Dog" ++ _ ->
+ yellow_dog;
+ _ ->
+ other
+ end;
+ X ->
+ io:format("Linux: ~s"
+ "~n ~p"
+ "~n",
+ [Version, X]),
+ other
+ end.
analyze_and_print_linux_host_info(Version) ->
Distro =
case file:read_file_info("/etc/issue") of
{ok, _} ->
- DistroStr = string:trim(os:cmd("cat /etc/issue")),
- io:format("Linux: ~s"
- "~n ~s"
- "~n",
- [Version, DistroStr]),
- case DistroStr of
- "Wind River Linux" ++ _ ->
- wind_river;
- "MontaVista" ++ _ ->
- montavista;
- _ ->
- other
- end;
+ linux_which_distro(Version);
_ ->
io:format("Linux: ~s"
"~n", [Version]),
@@ -1055,6 +1069,21 @@ linux_which_cpuinfo(montavista) ->
{ok, {CPU, BMips}}
end;
+linux_which_cpuinfo(yellow_dog) ->
+ CPU =
+ case linux_cpuinfo_cpu() of
+ "-" ->
+ throw(noinfo);
+ Model ->
+ case linux_cpuinfo_motherboard() of
+ "-" ->
+ Model;
+ MB ->
+ Model ++ " (" ++ MB ++ ")"
+ end
+ end,
+ {ok, CPU};
+
linux_which_cpuinfo(wind_river) ->
CPU =
case linux_cpuinfo_model() of
--
2.16.4