diff options
Diffstat (limited to 'lib/snmp/test/snmp_test_lib.erl')
-rw-r--r-- | lib/snmp/test/snmp_test_lib.erl | 84 |
1 files changed, 68 insertions, 16 deletions
diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl index 41330cfb78..d4e7c53e0a 100644 --- a/lib/snmp/test/snmp_test_lib.erl +++ b/lib/snmp/test/snmp_test_lib.erl @@ -39,7 +39,7 @@ replace_config/3, set_config/3, get_config/2, get_config/3]). -export([fail/3, skip/3]). -export([hours/1, minutes/1, seconds/1, sleep/1]). --export([flush_mqueue/0, trap_exit/0, trap_exit/1]). +-export([flush_mqueue/0, mqueue/0, mqueue/1, trap_exit/0, trap_exit/1]). -export([ping/1, local_nodes/0, nodes_on/1]). -export([start_node/2, stop_node/1]). -export([is_app_running/1, @@ -976,11 +976,13 @@ analyze_and_print_linux_host_info(Version) -> %% Check if we need to adjust the factor because of the memory try linux_which_meminfo() of AddFactor -> - io:format("TS Scale Factor: ~w~n", [timetrap_scale_factor()]), + io:format("TS Scale Factor: ~w (~w + ~w)~n", + [timetrap_scale_factor(), Factor, AddFactor]), {Factor + AddFactor, []} catch _:_:_ -> - io:format("TS Scale Factor: ~w~n", [timetrap_scale_factor()]), + io:format("TS Scale Factor: ~w (~w)~n", + [timetrap_scale_factor(), Factor]), {Factor, []} end. @@ -1017,6 +1019,18 @@ linux_cpuinfo_bogomips() -> "-" end. +linux_cpuinfo_BogoMIPS() -> + case linux_cpuinfo_lookup("BogoMIPS") of + BMips when is_list(BMips) -> + try lists:sum([bogomips_to_int(BM) || BM <- BMips]) + catch + _:_:_ -> + "-" + end; + _ -> + "-" + end. + linux_cpuinfo_total_bogomips() -> case linux_cpuinfo_lookup("total bogomips") of [TBM] -> @@ -1046,9 +1060,9 @@ bogomips_to_int(BM) -> linux_cpuinfo_model() -> case linux_cpuinfo_lookup("model") of - [M] -> + [M|_] -> M; - _ -> + _X -> "-" end. @@ -1062,8 +1076,8 @@ linux_cpuinfo_platform() -> linux_cpuinfo_model_name() -> case linux_cpuinfo_lookup("model name") of - [P|_] -> - P; + [M|_] -> + M; _ -> "-" end. @@ -1113,21 +1127,34 @@ linux_which_cpuinfo(yellow_dog) -> {ok, CPU}; linux_which_cpuinfo(wind_river) -> - CPU = + Model = case linux_cpuinfo_model() of "-" -> - throw(noinfo); - Model -> - case linux_cpuinfo_platform() of + %% Try 'model name' + case linux_cpuinfo_model_name() of "-" -> - Model; - Platform -> - Model ++ " (" ++ Platform ++ ")" - end + throw(noinfo); + MN -> + MN + end; + M -> + M + end, + CPU = + case linux_cpuinfo_platform() of + "-" -> + Model; + Platform -> + Model ++ " (" ++ Platform ++ ")" end, case linux_cpuinfo_total_bogomips() of "-" -> - {ok, CPU}; + case linux_cpuinfo_BogoMIPS() of + "-" -> + {ok, CPU}; + BMips -> + {ok, {CPU, BMips}} + end; BMips -> {ok, {CPU, BMips}} end; @@ -2157,6 +2184,20 @@ num_schedulers_to_factor() -> linux_info_lookup(Key, File) -> + %% try + %% begin + %% GREP = os:cmd("grep " ++ "\"" ++ Key ++ "\"" ++ " " ++ File), + %% io:format("linux_info_lookup() -> GREP: ~p~n", [GREP]), + %% TOKENS = string:tokens(GREP, [$:,$\n]), + %% io:format("linux_info_lookup() -> TOKENS: ~p~n", [TOKENS]), + %% INFO = [string:trim(S) || S <- TOKENS], + %% io:format("linux_info_lookup() -> INFO: ~p~n", [INFO]), + %% linux_info_lookup_collect(Key, INFO, []) + %% end + %% catch + %% _:_:_ -> + %% "-" + %% end. try [string:trim(S) || S <- string:tokens(os:cmd("grep " ++ "\"" ++ Key ++ "\"" ++ " " ++ File), [$:,$\n])] of Info -> linux_info_lookup_collect(Key, Info, []) @@ -2200,6 +2241,17 @@ sleep(MSecs) -> %% Process utility function %% +mqueue() -> + mqueue(self()). +mqueue(Pid) when is_pid(Pid) -> + Key = messages, + case process_info(Pid, Key) of + {Key, Msgs} -> + Msgs; + _ -> + [] + end. + flush_mqueue() -> io:format("~p~n", [lists:reverse(flush_mqueue([]))]). |