aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/test/cpu_sup_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/os_mon/test/cpu_sup_SUITE.erl')
-rw-r--r--lib/os_mon/test/cpu_sup_SUITE.erl246
1 files changed, 123 insertions, 123 deletions
diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl
index 13d47c6a89..e061fd87c6 100644
--- a/lib/os_mon/test/cpu_sup_SUITE.erl
+++ b/lib/os_mon/test/cpu_sup_SUITE.erl
@@ -35,11 +35,11 @@
-define(default_timeout, ?t:minutes(1)).
init_per_suite(Config) when is_list(Config) ->
- ?line ok = application:start(os_mon),
+ ok = application:start(os_mon),
Config.
end_per_suite(Config) when is_list(Config) ->
- ?line ok = application:stop(os_mon),
+ ok = application:stop(os_mon),
Config.
init_per_testcase(unavailable, Config) ->
@@ -61,14 +61,14 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
case test_server:os_type() of
- {unix, sunos} ->
- [load_api, util_api, util_values, port, unavailable];
- {unix, linux} ->
- [load_api, util_api, util_values, port, unavailable];
- {unix, freebsd} ->
- [load_api, util_api, util_values, port, unavailable];
- {unix, _OSname} -> [load_api];
- _OS -> [unavailable]
+ {unix, sunos} ->
+ [load_api, util_api, util_values, port, unavailable];
+ {unix, linux} ->
+ [load_api, util_api, util_values, port, unavailable];
+ {unix, freebsd} ->
+ [load_api, util_api, util_values, port, unavailable];
+ {unix, _OSname} -> [load_api];
+ _OS -> [unavailable]
end.
groups() ->
@@ -88,25 +88,25 @@ load_api(doc) ->
load_api(Config) when is_list(Config) ->
%% nprocs()
- ?line N = cpu_sup:nprocs(),
- ?line true = is_integer(N),
- ?line true = N>0,
- ?line true = N<1000000,
+ N = cpu_sup:nprocs(),
+ true = is_integer(N),
+ true = N>0,
+ true = N<1000000,
%% avg1()
- ?line Load1 = cpu_sup:avg1(),
- ?line true = is_integer(Load1),
- ?line true = Load1>0,
+ Load1 = cpu_sup:avg1(),
+ true = is_integer(Load1),
+ true = Load1>0,
%% avg5()
- ?line Load5 = cpu_sup:avg5(),
- ?line true = is_integer(Load5),
- ?line true = Load5>0,
+ Load5 = cpu_sup:avg5(),
+ true = is_integer(Load5),
+ true = Load5>0,
%% avg15()
- ?line Load15 = cpu_sup:avg15(),
- ?line true = is_integer(Load15),
- ?line true = Load15>0,
+ Load15 = cpu_sup:avg15(),
+ true = is_integer(Load15),
+ true = Load15>0,
ok.
@@ -117,54 +117,54 @@ util_api(doc) ->
util_api(Config) when is_list(Config) ->
%% Some useful funs when testing util/1
BusyP = fun({user, _Share}) -> true;
- ({nice_user, _Share}) -> true;
- ({kernel, _Share}) -> true;
- ({hard_irq, _Share}) -> true;
- ({soft_irq, _Share}) -> true;
- (_) -> false
- end,
+ ({nice_user, _Share}) -> true;
+ ({kernel, _Share}) -> true;
+ ({hard_irq, _Share}) -> true;
+ ({soft_irq, _Share}) -> true;
+ (_) -> false
+ end,
NonBusyP = fun({wait, _Share}) -> true;
- ({idle, _Share}) -> true;
- ({steal, _Share}) -> true;
- (_) -> false
- end,
+ ({idle, _Share}) -> true;
+ ({steal, _Share}) -> true;
+ (_) -> false
+ end,
Sum = fun({_Tag, X}, Acc) -> Acc+X end,
%% util()
- ?line Util1 = cpu_sup:util(),
- ?line true = is_number(Util1),
- ?line true = Util1>0,
- ?line Util2 = cpu_sup:util(),
- ?line true = is_number(Util2),
- ?line true = Util2>0,
+ Util1 = cpu_sup:util(),
+ true = is_number(Util1),
+ true = Util1>0,
+ Util2 = cpu_sup:util(),
+ true = is_number(Util2),
+ true = Util2>0,
%% util([])
- ?line {all, Busy1, NonBusy1, []} = cpu_sup:util([]),
- ?line 100.00 = Busy1 + NonBusy1,
+ {all, Busy1, NonBusy1, []} = cpu_sup:util([]),
+ 100.00 = Busy1 + NonBusy1,
%% util([detailed])
- ?line {Cpus2, Busy2, NonBusy2, []} = cpu_sup:util([detailed]),
- ?line true = lists:all(fun(X) -> is_integer(X) end, Cpus2),
- ?line true = lists:all(BusyP, Busy2),
- ?line true = lists:all(NonBusyP, NonBusy2),
- ?line 100.00 = lists:foldl(Sum,0,Busy2)+lists:foldl(Sum,0,NonBusy2),
+ {Cpus2, Busy2, NonBusy2, []} = cpu_sup:util([detailed]),
+ true = lists:all(fun(X) -> is_integer(X) end, Cpus2),
+ true = lists:all(BusyP, Busy2),
+ true = lists:all(NonBusyP, NonBusy2),
+ 100.00 = lists:foldl(Sum,0,Busy2)+lists:foldl(Sum,0,NonBusy2),
%% util([per_cpu])
- ?line [{Cpu3, Busy3, NonBusy3, []}|_] = cpu_sup:util([per_cpu]),
- ?line true = is_integer(Cpu3),
- ?line 100.00 = Busy3 + NonBusy3,
+ [{Cpu3, Busy3, NonBusy3, []}|_] = cpu_sup:util([per_cpu]),
+ true = is_integer(Cpu3),
+ 100.00 = Busy3 + NonBusy3,
%% util([detailed, per_cpu])
- ?line [{Cpu4, Busy4, NonBusy4, []}|_] =
- cpu_sup:util([detailed, per_cpu]),
- ?line true = is_integer(Cpu4),
- ?line true = lists:all(BusyP, Busy2),
- ?line true = lists:all(NonBusyP, NonBusy2),
- ?line 100.00 = lists:foldl(Sum,0,Busy4)+lists:foldl(Sum,0,NonBusy4),
+ [{Cpu4, Busy4, NonBusy4, []}|_] =
+ cpu_sup:util([detailed, per_cpu]),
+ true = is_integer(Cpu4),
+ true = lists:all(BusyP, Busy2),
+ true = lists:all(NonBusyP, NonBusy2),
+ 100.00 = lists:foldl(Sum,0,Busy4)+lists:foldl(Sum,0,NonBusy4),
%% bad util/1 calls
- ?line {'EXIT',{badarg,_}} = (catch cpu_sup:util(detailed)),
- ?line {'EXIT',{badarg,_}} = (catch cpu_sup:util([detialed])),
+ {'EXIT',{badarg,_}} = (catch cpu_sup:util(detailed)),
+ {'EXIT',{badarg,_}} = (catch cpu_sup:util([detialed])),
ok.
@@ -180,37 +180,37 @@ util_values(Config) when is_list(Config) ->
Ref = make_ref(),
Loop = fun (L) -> L(L) end,
Spinner = fun () ->
- Looper = spawn_link(fun () -> Loop(Loop) end),
- receive after ?SPIN_TIME -> ok end,
- unlink(Looper),
- exit(Looper, kill),
- Tester ! Ref
- end,
+ Looper = spawn_link(fun () -> Loop(Loop) end),
+ receive after ?SPIN_TIME -> ok end,
+ unlink(Looper),
+ exit(Looper, kill),
+ Tester ! Ref
+ end,
- ?line cpu_sup:util(),
+ cpu_sup:util(),
- ?line spawn_link(Spinner),
- ?line receive Ref -> ok end,
- ?line HighUtil1 = cpu_sup:util(),
+ spawn_link(Spinner),
+ receive Ref -> ok end,
+ HighUtil1 = cpu_sup:util(),
- ?line receive after ?SPIN_TIME -> ok end,
- ?line LowUtil1 = cpu_sup:util(),
+ receive after ?SPIN_TIME -> ok end,
+ LowUtil1 = cpu_sup:util(),
- ?line spawn_link(Spinner),
- ?line receive Ref -> ok end,
- ?line HighUtil2 = cpu_sup:util(),
+ spawn_link(Spinner),
+ receive Ref -> ok end,
+ HighUtil2 = cpu_sup:util(),
- ?line receive after ?SPIN_TIME -> ok end,
- ?line LowUtil2 = cpu_sup:util(),
+ receive after ?SPIN_TIME -> ok end,
+ LowUtil2 = cpu_sup:util(),
Utils = [{high1,HighUtil1}, {low1,LowUtil1},
- {high2,HighUtil2}, {low2,LowUtil2}],
+ {high2,HighUtil2}, {low2,LowUtil2}],
?t:format("Utils: ~p~n", [Utils]),
- ?line false = LowUtil1 > HighUtil1,
- ?line false = LowUtil1 > HighUtil2,
- ?line false = LowUtil2 > HighUtil1,
- ?line false = LowUtil2 > HighUtil2,
+ false = LowUtil1 > HighUtil1,
+ false = LowUtil1 > HighUtil2,
+ false = LowUtil2 > HighUtil1,
+ false = LowUtil2 > HighUtil2,
ok.
@@ -224,37 +224,37 @@ port(doc) ->
["Test that cpu_sup handles a terminating port program"];
port(Config) when is_list(Config) ->
case cpu_sup_os_pid() of
- {ok, PidStr} ->
- %% Monitor cpu_sup
- ?line MonRef = erlang:monitor(process, cpu_sup),
- ?line N1 = cpu_sup:nprocs(),
- ?line true = N1>0,
-
- %% Kill the port program
- case os:cmd("kill -9 " ++ PidStr) of
- [] ->
- %% cpu_sup should not terminate
- receive
- {'DOWN', MonRef, _, _, Reason} ->
- ?line ?t:fail({unexpected_exit_reason, Reason})
- after 3000 ->
- ok
- end,
-
- %% Give cpu_sup time to restart cpu_sup port
- ?t:sleep(?t:seconds(3)),
- ?line N2 = cpu_sup:nprocs(),
- ?line true = N2>0,
-
- erlang:demonitor(MonRef),
- ok;
-
- Line ->
- erlang:demonitor(MonRef),
- {skip, {not_killed, Line}}
- end;
- _ ->
- {skip, os_pid_not_found }
+ {ok, PidStr} ->
+ %% Monitor cpu_sup
+ MonRef = erlang:monitor(process, cpu_sup),
+ N1 = cpu_sup:nprocs(),
+ true = N1>0,
+
+ %% Kill the port program
+ case os:cmd("kill -9 " ++ PidStr) of
+ [] ->
+ %% cpu_sup should not terminate
+ receive
+ {'DOWN', MonRef, _, _, Reason} ->
+ ?t:fail({unexpected_exit_reason, Reason})
+ after 3000 ->
+ ok
+ end,
+
+ %% Give cpu_sup time to restart cpu_sup port
+ ?t:sleep(?t:seconds(3)),
+ N2 = cpu_sup:nprocs(),
+ true = N2>0,
+
+ erlang:demonitor(MonRef),
+ ok;
+
+ Line ->
+ erlang:demonitor(MonRef),
+ {skip, {not_killed, Line}}
+ end;
+ _ ->
+ {skip, os_pid_not_found }
end.
terminate(suite) ->
@@ -271,23 +271,23 @@ unavailable(doc) ->
unavailable(Config) when is_list(Config) ->
%% Make sure all API functions return their dummy values
- ?line 0 = cpu_sup:nprocs(),
- ?line 0 = cpu_sup:avg1(),
- ?line 0 = cpu_sup:avg5(),
- ?line 0 = cpu_sup:avg15(),
- ?line 0 = cpu_sup:util(),
- ?line {all,0,0,[]} = cpu_sup:util([]),
- ?line {all,0,0,[]} = cpu_sup:util([detailed]),
- ?line {all,0,0,[]} = cpu_sup:util([per_cpu]),
- ?line {all,0,0,[]} = cpu_sup:util([detailed,per_cpu]),
+ 0 = cpu_sup:nprocs(),
+ 0 = cpu_sup:avg1(),
+ 0 = cpu_sup:avg5(),
+ 0 = cpu_sup:avg15(),
+ 0 = cpu_sup:util(),
+ {all,0,0,[]} = cpu_sup:util([]),
+ {all,0,0,[]} = cpu_sup:util([detailed]),
+ {all,0,0,[]} = cpu_sup:util([per_cpu]),
+ {all,0,0,[]} = cpu_sup:util([detailed,per_cpu]),
ok.
restart(suite) ->
[];
restart(Config) when is_list(Config) ->
- ?line ok = application:set_env(os_mon, start_cpu_sup, true),
- ?line {ok, _Pid} = supervisor:restart_child(os_mon_sup, cpu_sup),
+ ok = application:set_env(os_mon, start_cpu_sup, true),
+ {ok, _Pid} = supervisor:restart_child(os_mon_sup, cpu_sup),
ok.
%% Aux
@@ -295,6 +295,6 @@ restart(Config) when is_list(Config) ->
cpu_sup_os_pid() ->
Str = os:cmd("ps -e | grep '[c]pu_sup'"),
case io_lib:fread("~s", Str) of
- {ok, [Pid], _Rest} -> {ok, Pid};
- _ -> {error, pid_not_found}
+ {ok, [Pid], _Rest} -> {ok, Pid};
+ _ -> {error, pid_not_found}
end.