From 5d8ec8313876352d128c2fb6e368b77e85b479f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 16:03:36 +0200 Subject: Remove ?line macros --- lib/os_mon/test/cpu_sup_SUITE.erl | 246 +++++------ lib/os_mon/test/memsup_SUITE.erl | 821 +++++++++++++++++------------------ lib/os_mon/test/os_mon_SUITE.erl | 56 +-- lib/os_mon/test/os_mon_mib_SUITE.erl | 521 +++++++++++----------- lib/os_mon/test/os_sup_SUITE.erl | 150 +++---- 5 files changed, 896 insertions(+), 898 deletions(-) (limited to 'lib/os_mon') 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. diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index 904c9b95b0..1c1e898538 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -34,11 +34,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(_Case, Config) -> @@ -54,13 +54,13 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> All = case test_server:os_type() of - {unix, sunos} -> - [api, alarm1, alarm2, process, config, timeout, - unavailable, port]; - {unix, linux} -> - [api, alarm1, alarm2, process, timeout]; - _OS -> [api, alarm1, alarm2, process] - end, + {unix, sunos} -> + [api, alarm1, alarm2, process, config, timeout, + unavailable, port]; + {unix, linux} -> + [api, alarm1, alarm2, process, timeout]; + _OS -> [api, alarm1, alarm2, process] + end, Bugs = [otp_5910], All ++ Bugs. @@ -81,87 +81,87 @@ api(doc) -> api(Config) when is_list(Config) -> %% get_memory_data() - ?line RegMemData = memsup:get_memory_data(), + RegMemData = memsup:get_memory_data(), case RegMemData of - {TotMem, AllBytes, {Pid, PidBytes}} when is_integer(TotMem), - is_integer(AllBytes), - is_pid(Pid), - is_integer(PidBytes) -> - ok; - {0, 0, _WorstPid} -> - ?line ?t:fail(first_data_collection_failed); - _ -> - ?line ?t:fail({bad_return, RegMemData}) + {TotMem, AllBytes, {Pid, PidBytes}} when is_integer(TotMem), + is_integer(AllBytes), + is_pid(Pid), + is_integer(PidBytes) -> + ok; + {0, 0, _WorstPid} -> + ?t:fail(first_data_collection_failed); + _ -> + ?t:fail({bad_return, RegMemData}) end, %% get_system_memory_data() - ?line ExtMemData = memsup:get_system_memory_data(), + ExtMemData = memsup:get_system_memory_data(), Tags = [ total_memory, - free_memory, - system_total_memory, - largest_free, - number_of_free, - free_swap, - total_swap, - cached_memory, - buffered_memory, - shared_memory], - - ?line true = lists:all(fun({Tag,Value}) when is_atom(Tag), - is_integer(Value) -> - lists:member(Tag, Tags); - (_) -> - false - end, - ExtMemData), + free_memory, + system_total_memory, + largest_free, + number_of_free, + free_swap, + total_swap, + cached_memory, + buffered_memory, + shared_memory], + + true = lists:all(fun({Tag,Value}) when is_atom(Tag), + is_integer(Value) -> + lists:member(Tag, Tags); + (_) -> + false + end, + ExtMemData), %% get_os_wordsize() - ?line ok = case memsup:get_os_wordsize() of - 32 -> ok; - 64 -> ok; - unsupported_os -> ok; - _ -> error - end, + ok = case memsup:get_os_wordsize() of + 32 -> ok; + 64 -> ok; + unsupported_os -> ok; + _ -> error + end, %% get_check_interval() - ?line 60000 = memsup:get_check_interval(), + 60000 = memsup:get_check_interval(), %% set_check_interval(Minutes) - ?line ok = memsup:set_check_interval(2), - ?line 120000 = memsup:get_check_interval(), - ?line {'EXIT',{badarg,_}} = - (catch memsup:set_check_interval(0.2)), - ?line 120000 = memsup:get_check_interval(), - ?line ok = memsup:set_check_interval(1), + ok = memsup:set_check_interval(2), + 120000 = memsup:get_check_interval(), + {'EXIT',{badarg,_}} = + (catch memsup:set_check_interval(0.2)), + 120000 = memsup:get_check_interval(), + ok = memsup:set_check_interval(1), %% get_procmem_high_watermark() - ?line 5 = memsup:get_procmem_high_watermark(), + 5 = memsup:get_procmem_high_watermark(), %% set_procmem_high_watermark() - ?line ok = memsup:set_procmem_high_watermark(0.1), - ?line 10 = memsup:get_procmem_high_watermark(), - ?line {'EXIT',{badarg,_}} = - (catch memsup:set_procmem_high_watermark(-0.1)), - ?line 10 = memsup:get_procmem_high_watermark(), - ?line ok = memsup:set_procmem_high_watermark(0.05), + ok = memsup:set_procmem_high_watermark(0.1), + 10 = memsup:get_procmem_high_watermark(), + {'EXIT',{badarg,_}} = + (catch memsup:set_procmem_high_watermark(-0.1)), + 10 = memsup:get_procmem_high_watermark(), + ok = memsup:set_procmem_high_watermark(0.05), %% get_sysmem_high_watermark() - ?line 80 = memsup:get_sysmem_high_watermark(), + 80 = memsup:get_sysmem_high_watermark(), %% set_sysmem_high_watermark() - ?line ok = memsup:set_sysmem_high_watermark(0.9), - ?line 90 = memsup:get_sysmem_high_watermark(), - ?line {'EXIT',{badarg,_}} = - (catch memsup:set_sysmem_high_watermark(-0.9)), - ?line 90 = memsup:get_sysmem_high_watermark(), - ?line ok = memsup:set_sysmem_high_watermark(0.8), + ok = memsup:set_sysmem_high_watermark(0.9), + 90 = memsup:get_sysmem_high_watermark(), + {'EXIT',{badarg,_}} = + (catch memsup:set_sysmem_high_watermark(-0.9)), + 90 = memsup:get_sysmem_high_watermark(), + ok = memsup:set_sysmem_high_watermark(0.8), %% get|set_helper_timeout - ?line 30 = memsup:get_helper_timeout(), - ?line ok = memsup:set_helper_timeout(29), - ?line 29 = memsup:get_helper_timeout(), - ?line {'EXIT',{badarg,_}} = (catch memsup:set_helper_timeout(31.0)), - ?line 29 = memsup:get_helper_timeout(), + 30 = memsup:get_helper_timeout(), + ok = memsup:set_helper_timeout(29), + 29 = memsup:get_helper_timeout(), + {'EXIT',{badarg,_}} = (catch memsup:set_helper_timeout(31.0)), + 29 = memsup:get_helper_timeout(), ok. %%---------------------------------------------------------------------- @@ -176,140 +176,140 @@ alarm1(Config) when is_list(Config) -> %% If system memory usage is too high, the testcase cannot %% be run correctly - ?line {Total, Alloc, {_Pid,_PidAlloc}} = memsup:get_memory_data(), + {Total, Alloc, {_Pid,_PidAlloc}} = memsup:get_memory_data(), io:format("alarm1: Total: ~p, Alloc: ~p~n", [Total, Alloc]), - ?line SysUsage = Alloc/Total, + SysUsage = Alloc/Total, if - SysUsage>0.99 -> - {skip, sys_mem_too_high}; - true -> - alarm1(Config, SysUsage) + SysUsage>0.99 -> + {skip, sys_mem_too_high}; + true -> + alarm1(Config, SysUsage) end. alarm1(_Config, SysUsage) -> %% Set a long memory check interval, we will force memory checks %% instead - ?line ok = memsup:set_check_interval(60), + ok = memsup:set_check_interval(60), %% Check thresholds - ?line SysThreshold = (memsup:get_sysmem_high_watermark()/100), - ?line ProcThreshold = (memsup:get_procmem_high_watermark()/100), + SysThreshold = (memsup:get_sysmem_high_watermark()/100), + ProcThreshold = (memsup:get_procmem_high_watermark()/100), %% Check if a system alarm already should be set or not SysP = if - SysUsage>SysThreshold -> true; - SysUsage= false - end, + SysUsage>SysThreshold -> true; + SysUsage= false + end, %% If system memory is higher than threshold, make sure the system %% alarm is set. Otherwise, make sure it is not set case alarm_set(system_memory_high_watermark) of - {true, []} when SysP -> - ok; - false when not SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, SysThreshold}) + {true, []} when SysP -> + ok; + false when not SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Lower/raise the threshold to clear/set the alarm NewSysThreshold = if - SysP -> - Value = 1.1*SysUsage, - if - Value > 0.99 -> 0.99; - true -> Value - end; - not SysP -> 0.9*SysUsage - end, + SysP -> + Value = 1.1*SysUsage, + if + Value > 0.99 -> 0.99; + true -> Value + end; + not SysP -> 0.9*SysUsage + end, - ?line ok = memsup:set_sysmem_high_watermark(NewSysThreshold), + ok = memsup:set_sysmem_high_watermark(NewSysThreshold), %% Initiate and wait for a new data collection - ?line ok = force_collection(), + ok = force_collection(), %% Make sure the alarm is cleared/set ?t:sleep(?t:seconds(5)), case alarm_set(system_memory_high_watermark) of - {true, []} when not SysP -> - ok; - false when SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) + {true, []} when not SysP -> + ok; + false when SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) end, %% Reset the threshold to set/clear the alarm again - ?line ok = memsup:set_sysmem_high_watermark(SysThreshold), - ?line ok = force_collection(), + ok = memsup:set_sysmem_high_watermark(SysThreshold), + ok = force_collection(), ?t:sleep(?t:seconds(1)), case alarm_set(system_memory_high_watermark) of - {true, []} when SysP -> - ok; - false when not SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, SysThreshold}) + {true, []} when SysP -> + ok; + false when not SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Check memory usage - ?line {Total2, _, {WorstPid, PidAlloc}} = memsup:get_memory_data(), + {Total2, _, {WorstPid, PidAlloc}} = memsup:get_memory_data(), %% Check if a process alarm already should be set or not PidUsage = PidAlloc/Total2, ProcP = if - PidUsage>ProcThreshold -> true; - PidUsage= false - end, + PidUsage>ProcThreshold -> true; + PidUsage= false + end, %% Make sure the process alarm is set/not set accordingly case alarm_set(process_memory_high_watermark) of - {true, WorstPid} when ProcP -> - ok; - false when not ProcP -> - ok; - {true, BadPid1} when ProcP -> - ?line ?t:fail({proc_alarm, WorstPid, BadPid1}); - _ -> - ?line ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + {true, WorstPid} when ProcP -> + ok; + false when not ProcP -> + ok; + {true, BadPid1} when ProcP -> + ?t:fail({proc_alarm, WorstPid, BadPid1}); + _ -> + ?t:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Lower/raise the threshold to clear/set the alarm NewProcThreshold = if - ProcP -> 1.1*PidUsage; - not ProcP -> 0.9*PidUsage - end, - ?line ok = memsup:set_procmem_high_watermark(NewProcThreshold), - ?line ok = force_collection(), + ProcP -> 1.1*PidUsage; + not ProcP -> 0.9*PidUsage + end, + ok = memsup:set_procmem_high_watermark(NewProcThreshold), + ok = force_collection(), ?t:sleep(?t:seconds(1)), case alarm_set(process_memory_high_watermark) of - {true, WorstPid} when not ProcP -> - ok; - false when ProcP -> - ok; - {true, BadPid2} when not ProcP -> - ?line test_server:fail({proc_alarm, WorstPid, BadPid2}); - _ -> - ?line ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + {true, WorstPid} when not ProcP -> + ok; + false when ProcP -> + ok; + {true, BadPid2} when not ProcP -> + test_server:fail({proc_alarm, WorstPid, BadPid2}); + _ -> + ?t:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Reset the threshold to clear/set the alarm - ?line ok = memsup:set_procmem_high_watermark(ProcThreshold), - ?line ok = force_collection(), + ok = memsup:set_procmem_high_watermark(ProcThreshold), + ok = force_collection(), ?t:sleep(?t:seconds(1)), case alarm_set(process_memory_high_watermark) of - {true, WorstPid} when ProcP -> - ok; - false when not ProcP -> - ok; - {true, BadPid3} when ProcP -> - ?line test_server:fail({proc_alarm, WorstPid, BadPid3}); - _ -> - ?line ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + {true, WorstPid} when ProcP -> + ok; + false when not ProcP -> + ok; + {true, BadPid3} when ProcP -> + test_server:fail({proc_alarm, WorstPid, BadPid3}); + _ -> + ?t:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Reset memory check interval - ?line ok = memsup:set_check_interval(1), + ok = memsup:set_check_interval(1), ok. alarm2(suite) -> @@ -320,94 +320,94 @@ alarm2(Config) when is_list(Config) -> %% If system memory usage is too high, the testcase cannot %% be run correctly - ?line {Total, Alloc, {_Pid,_PidAlloc}} = memsup:get_memory_data(), - ?line SysUsage = Alloc/Total, + {Total, Alloc, {_Pid,_PidAlloc}} = memsup:get_memory_data(), + SysUsage = Alloc/Total, if - SysUsage>0.99 -> - {skip, sys_mem_too_high}; - true -> - alarm2(Config, SysUsage) + SysUsage>0.99 -> + {skip, sys_mem_too_high}; + true -> + alarm2(Config, SysUsage) end. alarm2(_Config, _SysUsage) -> %% Change memsup_system_only and restart memsup - ?line ok = application:set_env(os_mon, memsup_system_only, true), - ?line ok = supervisor:terminate_child(os_mon_sup, memsup), - ?line {ok, _Memsup1} = supervisor:restart_child(os_mon_sup, memsup), + ok = application:set_env(os_mon, memsup_system_only, true), + ok = supervisor:terminate_child(os_mon_sup, memsup), + {ok, _Memsup1} = supervisor:restart_child(os_mon_sup, memsup), %% Set a long memory check interval, we will force memory checks %% instead - ?line ok = memsup:set_check_interval(60), + ok = memsup:set_check_interval(60), %% Check data and thresholds - ?line {Total, Alloc, undefined} = memsup:get_memory_data(), - ?line SysThreshold = (memsup:get_sysmem_high_watermark()/100), - ?line true = is_integer(memsup:get_procmem_high_watermark()), + {Total, Alloc, undefined} = memsup:get_memory_data(), + SysThreshold = (memsup:get_sysmem_high_watermark()/100), + true = is_integer(memsup:get_procmem_high_watermark()), %% Check if a system alarm already should be set or not - ?line SysUsage = Alloc/Total, + SysUsage = Alloc/Total, SysP = if - SysUsage>SysThreshold -> true; - SysUsage= false - end, + SysUsage>SysThreshold -> true; + SysUsage= false + end, %% If system memory is higher than threshold, make sure the system %% alarm is set. Otherwise, make sure it is not set case alarm_set(system_memory_high_watermark) of - {true, []} when SysP -> - ok; - false when not SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, SysThreshold}) + {true, []} when SysP -> + ok; + false when not SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Lower/raise the threshold to clear/set the alarm NewSysThreshold = if - SysP -> - Value = 1.1*SysUsage, - if - Value > 0.99 -> 0.99; - true -> Value - end; - not SysP -> 0.9*SysUsage - end, + SysP -> + Value = 1.1*SysUsage, + if + Value > 0.99 -> 0.99; + true -> Value + end; + not SysP -> 0.9*SysUsage + end, - ?line ok = memsup:set_sysmem_high_watermark(NewSysThreshold), + ok = memsup:set_sysmem_high_watermark(NewSysThreshold), %% Initiate and wait for a new data collection - ?line ok = force_collection(), + ok = force_collection(), %% Make sure the alarm is cleared/set ?t:sleep(?t:seconds(1)), case alarm_set(system_memory_high_watermark) of - {true, []} when not SysP -> - ok; - false when SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) + {true, []} when not SysP -> + ok; + false when SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) end, %% Reset the threshold to set/clear the alarm again - ?line ok = memsup:set_sysmem_high_watermark(SysThreshold), - ?line ok = force_collection(), + ok = memsup:set_sysmem_high_watermark(SysThreshold), + ok = force_collection(), ?t:sleep(?t:seconds(1)), case alarm_set(system_memory_high_watermark) of - {true, []} when SysP -> - ok; - false when not SysP -> - ok; - _ -> - ?line ?t:fail({sys_alarm, SysUsage, SysThreshold}) + {true, []} when SysP -> + ok; + false when not SysP -> + ok; + _ -> + ?t:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Reset memsup_system_only and restart memsup %% (memory check interval is then automatically reset) - ?line ok = application:set_env(os_mon, memsup_system_only, false), - ?line ok = supervisor:terminate_child(os_mon_sup, memsup), - ?line {ok, _Memsup2} = supervisor:restart_child(os_mon_sup, memsup), + ok = application:set_env(os_mon, memsup_system_only, false), + ok = supervisor:terminate_child(os_mon_sup, memsup), + {ok, _Memsup2} = supervisor:restart_child(os_mon_sup, memsup), ok. @@ -428,31 +428,31 @@ process(Config) when is_list(Config) -> %% Set a long memory check interval, we will force memory checks %% instead - ?line ok = memsup:set_check_interval(60), + ok = memsup:set_check_interval(60), %% Collect data MemData = memsup:get_memory_data(), io:format("process: memsup:get_memory_data() = ~p~n", [MemData]), - ?line {_Total,_Free,{_,Bytes}} = MemData, + {_Total,_Free,{_,Bytes}} = MemData, %% Start a new process larger than Worst - ?line WorsePid = spawn(fun() -> new_hog(Bytes) end), + WorsePid = spawn(fun() -> new_hog(Bytes) end), ?t:sleep(?t:seconds(1)), %% Initiate and wait for a new data collection - ?line ok = force_collection(), + ok = force_collection(), %% Check that get_memory_data() returns updated result - ?line case memsup:get_memory_data() of - {_, _, {WorsePid, _MoreBytes}} -> - ok; - {_, _, BadWorst} -> - ?line ?t:fail({worst_pid, BadWorst}) - end, + case memsup:get_memory_data() of + {_, _, {WorsePid, _MoreBytes}} -> + ok; + {_, _, BadWorst} -> + ?t:fail({worst_pid, BadWorst}) + end, %% Reset memory check interval - ?line exit(WorsePid, done), - ?line ok = memsup:set_check_interval(1), + exit(WorsePid, done), + ok = memsup:set_check_interval(1), ok. new_hog(Bytes) -> @@ -463,7 +463,7 @@ new_hog(Bytes) -> new_hog_1(List) -> receive - _Any -> exit(List) + _Any -> exit(List) end. config(suite) -> @@ -474,47 +474,47 @@ config(Config) when is_list(Config) -> %% Change configuration parameters and make sure change is reflected %% when memsup is restarted - ?line ok = application:set_env(os_mon, memory_check_interval, 2), - ?line ok = - application:set_env(os_mon, system_memory_high_watermark, 0.9), - ?line ok = - application:set_env(os_mon, process_memory_high_watermark, 0.1), - ?line ok = application:set_env(os_mon, memsup_helper_timeout, 35), - ?line ok = application:set_env(os_mon, memsup_system_only, true), - - ?line ok = supervisor:terminate_child(os_mon_sup, memsup), - ?line {ok, _Child1} = supervisor:restart_child(os_mon_sup, memsup), - - ?line 120000 = memsup:get_check_interval(), - ?line 90 = memsup:get_sysmem_high_watermark(), - ?line 10 = memsup:get_procmem_high_watermark(), - ?line 35 = memsup:get_helper_timeout(), + ok = application:set_env(os_mon, memory_check_interval, 2), + ok = + application:set_env(os_mon, system_memory_high_watermark, 0.9), + ok = + application:set_env(os_mon, process_memory_high_watermark, 0.1), + ok = application:set_env(os_mon, memsup_helper_timeout, 35), + ok = application:set_env(os_mon, memsup_system_only, true), + + ok = supervisor:terminate_child(os_mon_sup, memsup), + {ok, _Child1} = supervisor:restart_child(os_mon_sup, memsup), + + 120000 = memsup:get_check_interval(), + 90 = memsup:get_sysmem_high_watermark(), + 10 = memsup:get_procmem_high_watermark(), + 35 = memsup:get_helper_timeout(), %% Also try this with bad parameter values, should be ignored - ?line ok = application:set_env(os_mon, memory_check_interval, 0.2), - ?line ok = - application:set_env(os_mon, system_memory_high_watermark, -0.9), - ?line ok = - application:set_env(os_mon, process_memory_high_watermark,-0.1), - ?line ok = application:set_env(os_mon, memsup_helper_timeout, 0.35), - ?line ok = application:set_env(os_mon, memsup_system_only, arne), - - ?line ok = supervisor:terminate_child(os_mon_sup, memsup), - ?line {ok, _Child2} = supervisor:restart_child(os_mon_sup, memsup), - - ?line 60000 = memsup:get_check_interval(), - ?line 80 = memsup:get_sysmem_high_watermark(), - ?line 5 = memsup:get_procmem_high_watermark(), - ?line 30 = memsup:get_helper_timeout(), + ok = application:set_env(os_mon, memory_check_interval, 0.2), + ok = + application:set_env(os_mon, system_memory_high_watermark, -0.9), + ok = + application:set_env(os_mon, process_memory_high_watermark,-0.1), + ok = application:set_env(os_mon, memsup_helper_timeout, 0.35), + ok = application:set_env(os_mon, memsup_system_only, arne), + + ok = supervisor:terminate_child(os_mon_sup, memsup), + {ok, _Child2} = supervisor:restart_child(os_mon_sup, memsup), + + 60000 = memsup:get_check_interval(), + 80 = memsup:get_sysmem_high_watermark(), + 5 = memsup:get_procmem_high_watermark(), + 30 = memsup:get_helper_timeout(), %% Reset configuration parameters - ?line ok = application:set_env(os_mon, memory_check_interval, 1), - ?line ok = - application:set_env(os_mon, system_memory_high_watermark, 0.8), - ?line ok = - application:set_env(os_mon, process_memory_high_watermark,0.05), - ?line ok = application:set_env(os_mon, memsup_helper_timeout, 30), - ?line ok = application:set_env(os_mon, memsup_system_only, false), + ok = application:set_env(os_mon, memory_check_interval, 1), + ok = + application:set_env(os_mon, system_memory_high_watermark, 0.8), + ok = + application:set_env(os_mon, process_memory_high_watermark,0.05), + ok = application:set_env(os_mon, memsup_helper_timeout, 30), + ok = application:set_env(os_mon, memsup_system_only, false), ok. @@ -525,28 +525,28 @@ unavailable(doc) -> unavailable(Config) when is_list(Config) -> %% Close memsup - ?line ok = application:set_env(os_mon, start_memsup, false), - ?line ok = supervisor:terminate_child(os_mon_sup, memsup), + ok = application:set_env(os_mon, start_memsup, false), + ok = supervisor:terminate_child(os_mon_sup, memsup), %% Make sure all API functions return their dummy values - ?line {0,0,{_Pid,0}} = memsup:get_memory_data(), - ?line ok = application:set_env(os_mon, memsup_system_only, true), - ?line {0,0,undefined} = memsup:get_memory_data(), - ?line ok = application:set_env(os_mon, memsup_system_only, false), - ?line [] = memsup:get_system_memory_data(), - ?line 0 = memsup:get_os_wordsize(), - ?line 60000 = memsup:get_check_interval(), - ?line ok = memsup:set_check_interval(2), - ?line 5 = memsup:get_procmem_high_watermark(), - ?line ok = memsup:set_procmem_high_watermark(0.10), - ?line 80 = memsup:get_sysmem_high_watermark(), - ?line ok = memsup:set_sysmem_high_watermark(0.90), - ?line 30 = memsup:get_helper_timeout(), - ?line ok = memsup:set_helper_timeout(35), + {0,0,{_Pid,0}} = memsup:get_memory_data(), + ok = application:set_env(os_mon, memsup_system_only, true), + {0,0,undefined} = memsup:get_memory_data(), + ok = application:set_env(os_mon, memsup_system_only, false), + [] = memsup:get_system_memory_data(), + 0 = memsup:get_os_wordsize(), + 60000 = memsup:get_check_interval(), + ok = memsup:set_check_interval(2), + 5 = memsup:get_procmem_high_watermark(), + ok = memsup:set_procmem_high_watermark(0.10), + 80 = memsup:get_sysmem_high_watermark(), + ok = memsup:set_sysmem_high_watermark(0.90), + 30 = memsup:get_helper_timeout(), + ok = memsup:set_helper_timeout(35), %% Start memsup again, - ?line ok = application:set_env(os_mon, start_memsup, true), - ?line {ok, _Child} = supervisor:restart_child(os_mon_sup, memsup), + ok = application:set_env(os_mon, start_memsup, true), + {ok, _Child} = supervisor:restart_child(os_mon_sup, memsup), ok. @@ -558,15 +558,15 @@ timeout(Config) when is_list(Config) -> %% Set a long memory check interval and memsup_helper timeout, %% we will force memory checks instead and fake timeouts - ?line ok = memsup:set_check_interval(60), - ?line ok = memsup:set_helper_timeout(3600), + ok = memsup:set_check_interval(60), + ok = memsup:set_helper_timeout(3600), %% Provoke a timeout during memory collection - ?line memsup ! time_to_collect, - ?line memsup ! reg_collection_timeout, + memsup ! time_to_collect, + memsup ! reg_collection_timeout, %% Not much we can check though, except that memsup is still running - ?line {_,_,_} = memsup:get_memory_data(), + {_,_,_} = memsup:get_memory_data(), %% Provoke a timeout during extensive memory collection %% We fake a gen_server:call/2 to be able to send a timeout message @@ -574,34 +574,34 @@ timeout(Config) when is_list(Config) -> %% Linux should be handled the same way as solaris. -% TimeoutMsg = case ?t:os_type() of -% {unix, sunos} -> ext_collection_timeout; -% {unix, linux} -> reg_collection_timeout -% end, + % TimeoutMsg = case ?t:os_type() of + % {unix, sunos} -> ext_collection_timeout; + % {unix, linux} -> reg_collection_timeout + % end, TimeoutMsg = ext_collection_timeout, - ?line Pid = whereis(memsup), - ?line Mref = erlang:monitor(process, Pid), - ?line Pid ! {'$gen_call', {self(), Mref}, get_system_memory_data}, - ?line Pid ! TimeoutMsg, + Pid = whereis(memsup), + Mref = erlang:monitor(process, Pid), + Pid ! {'$gen_call', {self(), Mref}, get_system_memory_data}, + Pid ! TimeoutMsg, receive - {Mref, []} -> - erlang:demonitor(Mref), - ?line ok; - {Mref, Res} -> - erlang:demonitor(Mref), - ?line ?t:fail({unexpected_result, Res}); - {'DOWN', Mref, _, _, _} -> - ?line ?t:fail(no_result) + {Mref, []} -> + erlang:demonitor(Mref), + ok; + {Mref, Res} -> + erlang:demonitor(Mref), + ?t:fail({unexpected_result, Res}); + {'DOWN', Mref, _, _, _} -> + ?t:fail(no_result) end, %% Reset memory check interval and memsup_helper timeout - ?line ok = memsup:set_check_interval(1), - ?line ok = memsup:set_helper_timeout(30), - ?line memsup ! time_to_collect, + ok = memsup:set_check_interval(1), + ok = memsup:set_helper_timeout(30), + memsup ! time_to_collect, - ?line [_|_] = memsup:get_system_memory_data(), + [_|_] = memsup:get_system_memory_data(), ok. @@ -610,44 +610,44 @@ port(suite) -> port(doc) -> ["Test that memsup handles a terminating port program"]; port(Config) when is_list(Config) -> - ?line Str = os:cmd("ps -e | grep '[m]emsup'"), + Str = os:cmd("ps -e | grep '[m]emsup'"), case io_lib:fread("~s", Str) of - {ok, [Pid], _Rest} -> - - %% Monitor memsup - ?line MonRef = erlang:monitor(process, memsup), - ?line {Total1,_Alloc1,_Worst1} = memsup:get_memory_data(), - ?line true = Total1>0, - - %% Kill the port program - case os:cmd("kill -9 " ++ Pid) of - [] -> - - %% memsup should now terminate - receive - {'DOWN', MonRef, _, _, {port_died, _Reason}} -> - ok; - {'DOWN', MonRef, _, _, Reason} -> - ?line ?t:fail({unexpected_exit_reason, Reason}) - after - 3000 -> - ?line ?t:fail(still_alive) - end, - - %% Give os_mon_sup time to restart memsup - ?t:sleep(?t:seconds(3)), - ?line {Total2,_Alloc2,_Worst2} = - memsup:get_memory_data(), - ?line true = Total2>0, - - ok; - - Line -> - erlang:demonitor(MonRef), - {skip, {not_killed, Line}} - end; - _ -> - {skip, {os_pid_not_found, Str}} + {ok, [Pid], _Rest} -> + + %% Monitor memsup + MonRef = erlang:monitor(process, memsup), + {Total1,_Alloc1,_Worst1} = memsup:get_memory_data(), + true = Total1>0, + + %% Kill the port program + case os:cmd("kill -9 " ++ Pid) of + [] -> + + %% memsup should now terminate + receive + {'DOWN', MonRef, _, _, {port_died, _Reason}} -> + ok; + {'DOWN', MonRef, _, _, Reason} -> + ?t:fail({unexpected_exit_reason, Reason}) + after + 3000 -> + ?t:fail(still_alive) + end, + + %% Give os_mon_sup time to restart memsup + ?t:sleep(?t:seconds(3)), + {Total2,_Alloc2,_Worst2} = + memsup:get_memory_data(), + true = Total2>0, + + ok; + + Line -> + erlang:demonitor(MonRef), + {skip, {not_killed, Line}} + end; + _ -> + {skip, {os_pid_not_found, Str}} end. otp_5910(suite) -> @@ -656,58 +656,58 @@ otp_5910(doc) -> ["Test that alarms are cleared and not set twice"]; otp_5910(Config) when is_list(Config) -> Alarms = - [system_memory_high_watermark, process_memory_high_watermark], + [system_memory_high_watermark, process_memory_high_watermark], %% Make sure memsup sets both alarms - ?line ok = application:set_env(os_mon, memory_check_interval, 60), - ?line ok = memsup:set_check_interval(60), - ?line SysThreshold = (memsup:get_sysmem_high_watermark()/100), - ?line ProcThreshold = (memsup:get_procmem_high_watermark()/100), + ok = application:set_env(os_mon, memory_check_interval, 60), + ok = memsup:set_check_interval(60), + SysThreshold = (memsup:get_sysmem_high_watermark()/100), + ProcThreshold = (memsup:get_procmem_high_watermark()/100), MemData = memsup:get_memory_data(), io:format("otp_5910: memsup:get_memory_data() = ~p~n", [MemData]), - ?line {Total, Alloc, {_Pid, _Bytes}} = MemData, - ?line Pid = spawn_opt(fun() -> - receive - die -> ok - end - end, [{min_heap_size, 1000}]), + {Total, Alloc, {_Pid, _Bytes}} = MemData, + Pid = spawn_opt(fun() -> + receive + die -> ok + end + end, [{min_heap_size, 1000}]), %% Create a process guaranteed to live, be constant and %% break memsup process limit - ?line {memory, Bytes} = erlang:process_info(Pid,memory), - ?line SysUsage = Alloc/Total, - ?line ProcUsage = Bytes/Total, + {memory, Bytes} = erlang:process_info(Pid,memory), + SysUsage = Alloc/Total, + ProcUsage = Bytes/Total, if - SysUsage>SysThreshold -> - ok; - SysUsage= - ?line ok = application:set_env(os_mon, - sys_mem_high_watermark, - 0.5 * SysUsage), - ?line ok = memsup:set_sysmem_high_watermark(0.5 * SysUsage) + SysUsage>SysThreshold -> + ok; + SysUsage= + ok = application:set_env(os_mon, + sys_mem_high_watermark, + 0.5 * SysUsage), + ok = memsup:set_sysmem_high_watermark(0.5 * SysUsage) end, if - ProcUsage>ProcThreshold -> - ok; - ProcUsage= - ?line ok = application:set_env(os_mon, - proc_mem_high_watermark, - 0.5 * ProcUsage), - ?line ok = memsup:set_procmem_high_watermark(0.5 *ProcUsage) + ProcUsage>ProcThreshold -> + ok; + ProcUsage= + ok = application:set_env(os_mon, + proc_mem_high_watermark, + 0.5 * ProcUsage), + ok = memsup:set_procmem_high_watermark(0.5 *ProcUsage) end, - ?line ok = force_collection(), + ok = force_collection(), ?t:sleep(?t:seconds(1)), lists:foreach(fun(AlarmId) -> - case alarm_set(AlarmId) of - {true, _} -> ok; - false -> - ?line ?t:fail({alarm_not_set, - AlarmId}) - end - end, - Alarms), + case alarm_set(AlarmId) of + {true, _} -> ok; + false -> + ?t:fail({alarm_not_set, + AlarmId}) + end + end, + Alarms), %% Kill guaranteed process... Pid ! die, @@ -716,41 +716,40 @@ otp_5910(Config) when is_list(Config) -> %% Wait a little to make sure memsup has been restarted, %% then make sure the alarms are set once, but not twice ?t:sleep(?t:seconds(1)), - ?line MemUsage = memsup:get_memory_data(), + MemUsage = memsup:get_memory_data(), SetAlarms = alarm_handler:get_alarms(), case lists:foldl(fun(system_memory_high_watermark, {S, P}) -> - {S+1, P}; - (process_memory_high_watermark, {S, P}) -> - {S, P+1}; - (_AlarmId, Acc0) -> - Acc0 - end, - {0, 0}, - SetAlarms) of - {0, 0} -> - ok; - _ -> - ?line ?t:fail({bad_number_of_alarms, SetAlarms, MemUsage}) + {S+1, P}; + (process_memory_high_watermark, {S, P}) -> + {S, P+1}; + (_AlarmId, Acc0) -> + Acc0 + end, + {0, 0}, + SetAlarms) of + {0, 0} -> + ok; + _ -> + ?t:fail({bad_number_of_alarms, SetAlarms, MemUsage}) end, %% Stop OS_Mon and make sure all memsup alarms are cleared - ?line ok = application:stop(os_mon), + ok = application:stop(os_mon), ?t:sleep(?t:seconds(1)), lists:foreach(fun(AlarmId) -> - case alarm_set(AlarmId) of - false -> ok; - {true, _} -> - ?line ?t:fail({alarm_is_set, AlarmId}) - end - end, - Alarms), + case alarm_set(AlarmId) of + false -> ok; + {true, _} -> + ?t:fail({alarm_is_set, AlarmId}) + end + end, + Alarms), %% Reset configuration and restart OS_Mon - ?line ok = application:set_env(os_mon,memory_check_interval,1), - ?line ok = application:set_env(os_mon,sys_mem_high_watermark,0.8), - ?line ok = application:set_env(os_mon,proc_mem_high_watermark,0.05), - ?line ok = application:start(os_mon), - + ok = application:set_env(os_mon,memory_check_interval,1), + ok = application:set_env(os_mon,sys_mem_high_watermark,0.8), + ok = application:set_env(os_mon,proc_mem_high_watermark,0.05), + ok = application:start(os_mon), ok. %%---------------------------------------------------------------------- @@ -765,30 +764,30 @@ force_collection() -> force_collection(TimerRef) -> receive - {trace, _Pid, 'receive', {collected_sys, _Sys}} -> - erlang:cancel_timer(TimerRef), - erlang:trace(whereis(memsup), false, ['receive']), - flush(), - ok; - {trace, _Pid, 'receive', reg_collection_timeout} -> - erlang:cancel_timer(TimerRef), - erlang:trace(whereis(memsup), false, ['receive']), - flush(), - collection_timeout; - timout -> - erlang:trace(whereis(memsup), false, ['receive']), - flush(), - timeout; - _Msg -> - force_collection(TimerRef) + {trace, _Pid, 'receive', {collected_sys, _Sys}} -> + erlang:cancel_timer(TimerRef), + erlang:trace(whereis(memsup), false, ['receive']), + flush(), + ok; + {trace, _Pid, 'receive', reg_collection_timeout} -> + erlang:cancel_timer(TimerRef), + erlang:trace(whereis(memsup), false, ['receive']), + flush(), + collection_timeout; + timout -> + erlang:trace(whereis(memsup), false, ['receive']), + flush(), + timeout; + _Msg -> + force_collection(TimerRef) end. flush() -> receive - {trace, _, _, _} -> - flush(); - timeout -> - flush() + {trace, _, _, _} -> + flush(); + timeout -> + flush() after 0 -> - ok + ok end. diff --git a/lib/os_mon/test/os_mon_SUITE.erl b/lib/os_mon/test/os_mon_SUITE.erl index 0f7ae3a508..a80d30f6b0 100644 --- a/lib/os_mon/test/os_mon_SUITE.erl +++ b/lib/os_mon/test/os_mon_SUITE.erl @@ -22,7 +22,7 @@ %% Test server specific exports -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2]). + init_per_group/2,end_per_group/2]). -export([init_per_testcase/2, end_per_testcase/2]). %% Test cases @@ -44,8 +44,8 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> case test_server:os_type() of - {unix, sunos} -> [app_file, appup_file, config]; - _OS -> [app_file, appup_file] + {unix, sunos} -> [app_file, appup_file, config]; + _OS -> [app_file, appup_file] end. groups() -> @@ -69,7 +69,7 @@ app_file(suite) -> app_file(doc) -> ["Testing .app file"]; app_file(Config) when is_list(Config) -> - ?line ok = test_server:app_test(os_mon), + ok = test_server:app_test(os_mon), ok. appup_file(Config) when is_list(Config) -> @@ -84,29 +84,29 @@ config(Config) when is_list(Config) -> IsReg = fun(Name) -> is_pid(whereis(Name)) end, IsNotReg = fun(Name) -> undefined == whereis(Name) end, - ?line ok = application:start(os_mon), - ?line true = lists:all(IsReg, [cpu_sup, disksup, memsup]), - ?line ok = application:stop(os_mon), - - ?line ok = application:set_env(os_mon, start_cpu_sup, false), - ?line ok = application:start(os_mon), - ?line true = lists:all(IsReg, [disksup, memsup]), - ?line true = IsNotReg(cpu_sup), - ?line ok = application:stop(os_mon), - ?line ok = application:set_env(os_mon, start_cpu_sup, true), - - ?line ok = application:set_env(os_mon, start_disksup, false), - ?line ok = application:start(os_mon), - ?line true = lists:all(IsReg, [cpu_sup, memsup]), - ?line true = IsNotReg(disksup), - ?line ok = application:stop(os_mon), - ?line ok = application:set_env(os_mon, start_disksup, true), - - ?line ok = application:set_env(os_mon, start_memsup, false), - ?line ok = application:start(os_mon), - ?line true = lists:all(IsReg, [cpu_sup, disksup]), - ?line true = IsNotReg(memsup), - ?line ok = application:stop(os_mon), - ?line ok = application:set_env(os_mon, start_memsup, true), + ok = application:start(os_mon), + true = lists:all(IsReg, [cpu_sup, disksup, memsup]), + ok = application:stop(os_mon), + + ok = application:set_env(os_mon, start_cpu_sup, false), + ok = application:start(os_mon), + true = lists:all(IsReg, [disksup, memsup]), + true = IsNotReg(cpu_sup), + ok = application:stop(os_mon), + ok = application:set_env(os_mon, start_cpu_sup, true), + + ok = application:set_env(os_mon, start_disksup, false), + ok = application:start(os_mon), + true = lists:all(IsReg, [cpu_sup, memsup]), + true = IsNotReg(disksup), + ok = application:stop(os_mon), + ok = application:set_env(os_mon, start_disksup, true), + + ok = application:set_env(os_mon, start_memsup, false), + ok = application:start(os_mon), + true = lists:all(IsReg, [cpu_sup, disksup]), + true = IsNotReg(memsup), + ok = application:stop(os_mon), + ok = application:set_env(os_mon, start_memsup, true), ok. diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index f8fb9e20fc..f966e5ec58 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -36,22 +36,22 @@ % Test server specific exports -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, - init_per_suite/1, end_per_suite/1, - init_per_testcase/2, end_per_testcase/2]). + init_per_suite/1, end_per_suite/1, + init_per_testcase/2, end_per_testcase/2]). % Test cases must be exported. -export([update_load_table/1]). -export([get_mem_sys_mark/1, get_mem_proc_mark/1, get_disk_threshold/1, - get_load_table/1, get_disk_table/1, - real_snmp_request/1, load_unload/1]). + get_load_table/1, get_disk_table/1, + real_snmp_request/1, load_unload/1]). -export([sys_tot_mem/1, sys_used_mem/1, large_erl_process/1, - large_erl_process_mem/1, cpu_load/1, cpu_load5/1, cpu_load15/1, - os_wordsize/1, sys_tot_mem64/1, sys_used_mem64/1, - large_erl_process_mem64/1, disk_descr/1, disk_kbytes/1, - disk_capacity/1]). + large_erl_process_mem/1, cpu_load/1, cpu_load5/1, cpu_load15/1, + os_wordsize/1, sys_tot_mem64/1, sys_used_mem64/1, + large_erl_process_mem64/1, disk_descr/1, disk_kbytes/1, + disk_capacity/1]). -export([]). -export([otp_6351/1, otp_7441/1]). @@ -75,7 +75,7 @@ end_per_testcase(_Case, Config) when is_list(Config) -> Config. suite() -> [{ct_hooks,[ts_install_cth]}, - {require, snmp_mgr_agent, snmp}]. + {require, snmp_mgr_agent, snmp}]. all() -> [load_unload, get_mem_sys_mark, get_mem_proc_mark, @@ -112,9 +112,9 @@ end_per_group(_GroupName, Config) -> %% variable, but should NOT alter/remove any existing entries. %%-------------------------------------------------------------------- init_per_suite(Config) -> - ?line application:start(sasl), - ?line application:start(mnesia), - ?line application:start(os_mon), + application:start(sasl), + application:start(mnesia), + application:start(os_mon), ok = ct_snmp:start(Config,snmp_mgr_agent), @@ -156,8 +156,8 @@ load_unload(doc) -> ["Test to unload and the reload the OTP.mib "]; load_unload(suite) -> []; load_unload(Config) when is_list(Config) -> - ?line os_mon_mib:unload(snmp_master_agent), - ?line os_mon_mib:load(snmp_master_agent), + os_mon_mib:unload(snmp_master_agent), + os_mon_mib:load(snmp_master_agent), ok. %%--------------------------------------------------------------------- @@ -166,13 +166,13 @@ update_load_table(doc) -> update_load_table(suite) -> []; update_load_table(Config) when is_list(Config) -> - ?line Node = start_node(), - ?line ok = rpc:call(Node,application,start,[sasl]), - ?line ok = rpc:call(Node,application,start,[os_mon]), - ?line ok = os_mon_mib:update_load_table(), - ?line rpc:call(Node,application,stop,[os_mon]), - ?line ok = os_mon_mib:update_load_table(), - ?line stop_node(Node), + Node = start_node(), + ok = rpc:call(Node,application,start,[sasl]), + ok = rpc:call(Node,application,start,[os_mon]), + ok = os_mon_mib:update_load_table(), + rpc:call(Node,application,stop,[os_mon]), + ok = os_mon_mib:update_load_table(), + stop_node(Node), ok. otp_6351(doc) -> @@ -180,21 +180,21 @@ otp_6351(doc) -> otp_6351(suite) -> []; otp_6351(Config) when is_list(Config) -> - ?line Node = start_node(), - ?line ok = rpc:call(Node,application,start,[sasl]), - ?line ok = rpc:call(Node,application,load,[os_mon]), - ?line ok = rpc:call(Node,application,set_env, - [os_mon,memsup_system_only,true]), - ?line ok = rpc:call(Node,application,start,[os_mon]), - ?line Res = rpc:call(Node,os_mon_mib,get_load,[Node]), + Node = start_node(), + ok = rpc:call(Node,application,start,[sasl]), + ok = rpc:call(Node,application,load,[os_mon]), + ok = rpc:call(Node,application,set_env, + [os_mon,memsup_system_only,true]), + ok = rpc:call(Node,application,start,[os_mon]), + Res = rpc:call(Node,os_mon_mib,get_load,[Node]), if - is_tuple(Res), element(1, Res)==loadTable -> - ?line ok; - true -> - ?line ?t:fail(Res) + is_tuple(Res), element(1, Res)==loadTable -> + ok; + true -> + ?t:fail(Res) end, - ?line rpc:call(Node,application,stop,[os_mon]), - ?line stop_node(Node), + rpc:call(Node,application,stop,[os_mon]), + stop_node(Node), ok. @@ -208,10 +208,10 @@ get_mem_sys_mark(suite) -> []; get_mem_sys_mark(Config) when is_list(Config) -> case os_mon_mib:mem_sys_mark(get) of - {value, SysMark} when is_integer(SysMark) -> - ok; - _ -> - ?line test_server:fail(sys_mark_value_not_integer) + {value, SysMark} when is_integer(SysMark) -> + ok; + _ -> + test_server:fail(sys_mark_value_not_integer) end. %%--------------------------------------------------------------------- get_mem_proc_mark(doc) -> @@ -221,10 +221,10 @@ get_mem_proc_mark(suite) -> []; get_mem_proc_mark(Config) when is_list(Config) -> case os_mon_mib:mem_proc_mark(get) of - {value, ProcMark} when is_integer(ProcMark) -> - ok; - _ -> - ?line test_server:fail(proc_mark_value_not_integer) + {value, ProcMark} when is_integer(ProcMark) -> + ok; + _ -> + test_server:fail(proc_mark_value_not_integer) end. %%--------------------------------------------------------------------- get_disk_threshold(doc) -> @@ -233,11 +233,11 @@ get_disk_threshold(doc) -> get_disk_threshold(suite) -> []; get_disk_threshold(Config) when is_list(Config) -> - case os_mon_mib:disk_threshold(get) of - {value, ProcMark} when is_integer(ProcMark) -> - ok; - _ -> - ?line test_server:fail(disk_threshold_value_not_integer) + case os_mon_mib:disk_threshold(get) of + {value, ProcMark} when is_integer(ProcMark) -> + ok; + _ -> + test_server:fail(disk_threshold_value_not_integer) end. %%--------------------------------------------------------------------- @@ -259,56 +259,56 @@ get_load_table(Config) when is_list(Config) -> {_, _, {Pid, _}} = memsup:get_memory_data(), PidStr = lists:flatten(io_lib:format("~w", [Pid])), - ?line [{value, NodeStr},{value, PidStr}] = - os_mon_mib:load_table(get, [NodeLen | NodeStr], - [?loadErlNodeName, ?loadLargestErlProcess]), - - ?line Values = os_mon_mib:load_table(get, [NodeLen | NodeStr] , - [?loadSystemTotalMemory, - ?loadSystemUsedMemory, - ?loadLargestErlProcessUsedMemory, - ?loadCpuLoad, - ?loadCpuLoad5, - ?loadCpuLoad15, - ?loadOsWordsize, - ?loadSystemTotalMemory64, - ?loadSystemUsedMemory64, - ?loadLargestErlProcessUsedMemory64]), + [{value, NodeStr},{value, PidStr}] = + os_mon_mib:load_table(get, [NodeLen | NodeStr], + [?loadErlNodeName, ?loadLargestErlProcess]), + + Values = os_mon_mib:load_table(get, [NodeLen | NodeStr] , + [?loadSystemTotalMemory, + ?loadSystemUsedMemory, + ?loadLargestErlProcessUsedMemory, + ?loadCpuLoad, + ?loadCpuLoad5, + ?loadCpuLoad15, + ?loadOsWordsize, + ?loadSystemTotalMemory64, + ?loadSystemUsedMemory64, + ?loadLargestErlProcessUsedMemory64]), IsInt = fun({value, Val}) when is_integer(Val) -> - true; - (_) -> - false - end, + true; + (_) -> + false + end, NewValues = lists:filter(IsInt, Values), case length(NewValues) of - 10 -> - ok; - _ -> - ?line test_server:fail(value_not_integer) + 10 -> + ok; + _ -> + test_server:fail(value_not_integer) end, - ?line [{noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}] = - os_mon_mib:load_table(get, [3, 102, 111, 111], - [?loadErlNodeName, - ?loadSystemTotalMemory, - ?loadSystemUsedMemory, - ?loadLargestErlProcess, - ?loadLargestErlProcessUsedMemory, - ?loadCpuLoad, - ?loadCpuLoad5, - ?loadCpuLoad15, - ?loadOsWordsize, - ?loadSystemTotalMemory64, - ?loadSystemUsedMemory64, - ?loadLargestErlProcessUsedMemory64]), + [{noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}] = + os_mon_mib:load_table(get, [3, 102, 111, 111], + [?loadErlNodeName, + ?loadSystemTotalMemory, + ?loadSystemUsedMemory, + ?loadLargestErlProcess, + ?loadLargestErlProcessUsedMemory, + ?loadCpuLoad, + ?loadCpuLoad5, + ?loadCpuLoad15, + ?loadOsWordsize, + ?loadSystemTotalMemory64, + ?loadSystemUsedMemory64, + ?loadLargestErlProcessUsedMemory64]), ok. %%--------------------------------------------------------------------- @@ -318,32 +318,32 @@ sys_tot_mem(doc) -> sys_tot_mem(suite) -> []; sys_tot_mem(Config) when is_list(Config) -> - ?line [{[?loadSystemTotalMemory, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadSystemTotalMemory, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(sys_tot_mem_value_not_integer) + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(sys_tot_mem_value_not_integer) end. sys_used_mem(doc) -> []; sys_used_mem(suite) -> []; sys_used_mem(Config) when is_list(Config) -> - ?line [{[?loadSystemUsedMemory, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadSystemUsedMemory, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(sys_used_mem_value_not_integer) + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(sys_used_mem_value_not_integer) end. large_erl_process(doc) -> @@ -353,10 +353,10 @@ large_erl_process(suite) -> large_erl_process(Config) when is_list(Config) -> {_, _, {Pid, _}} = memsup:get_memory_data(), PidStr = lists:flatten(io_lib:format("~w", [Pid])), - ?line [{[?loadLargestErlProcess, Len | NodeStr], PidStr}] = - os_mon_mib:load_table(get_next,[], [?loadLargestErlProcess]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadLargestErlProcess, Len | NodeStr], PidStr}] = + os_mon_mib:load_table(get_next,[], [?loadLargestErlProcess]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), ok. large_erl_process_mem(doc) -> @@ -365,17 +365,17 @@ large_erl_process_mem(suite) -> []; large_erl_process_mem(Config) when is_list(Config) -> - ?line [{[?loadLargestErlProcessUsedMemory, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next,[], - [?loadLargestErlProcessUsedMemory]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), - - case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(erl_pid_mem_value_not_integer) + [{[?loadLargestErlProcessUsedMemory, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next,[], + [?loadLargestErlProcessUsedMemory]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + + case Mem of + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(erl_pid_mem_value_not_integer) end. cpu_load(doc) -> @@ -383,16 +383,16 @@ cpu_load(doc) -> cpu_load(suite) -> []; cpu_load(Config) when is_list(Config) -> - ?line [{[?loadCpuLoad, Len | NodeStr], Load}] = - os_mon_mib:load_table(get_next,[], [?loadCpuLoad]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadCpuLoad, Len | NodeStr], Load}] = + os_mon_mib:load_table(get_next,[], [?loadCpuLoad]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Load of - Load when is_integer(Load) -> - ok; - _ -> - ?line test_server:fail(cpu_load_value_not_integer) + Load when is_integer(Load) -> + ok; + _ -> + test_server:fail(cpu_load_value_not_integer) end. cpu_load5(doc) -> @@ -400,16 +400,16 @@ cpu_load5(doc) -> cpu_load5(suite) -> []; cpu_load5(Config) when is_list(Config) -> - ?line [{[?loadCpuLoad5, Len | NodeStr], Load}] = - os_mon_mib:load_table(get_next,[], [?loadCpuLoad5]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadCpuLoad5, Len | NodeStr], Load}] = + os_mon_mib:load_table(get_next,[], [?loadCpuLoad5]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Load of - Load when is_integer(Load) -> - ok; - _ -> - ?line test_server:fail(cpu_load5_value_not_integer) + Load when is_integer(Load) -> + ok; + _ -> + test_server:fail(cpu_load5_value_not_integer) end. cpu_load15(doc) -> @@ -417,66 +417,66 @@ cpu_load15(doc) -> cpu_load15(suite) -> []; cpu_load15(Config) when is_list(Config) -> - ?line [{[?loadCpuLoad15, Len | NodeStr], Load}] = - os_mon_mib:load_table(get_next,[], [?loadCpuLoad15]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), - - case Load of - Load when is_integer(Load) -> - ok; - _ -> - ?line test_server:fail(cpu_load15_value_not_integer) - end. + [{[?loadCpuLoad15, Len | NodeStr], Load}] = + os_mon_mib:load_table(get_next,[], [?loadCpuLoad15]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + + case Load of + Load when is_integer(Load) -> + ok; + _ -> + test_server:fail(cpu_load15_value_not_integer) + end. os_wordsize(doc) -> []; os_wordsize(suite) -> []; os_wordsize(Config) when is_list(Config) -> - ?line [{[?loadOsWordsize, Len | NodeStr], Wordsize}] = - os_mon_mib:load_table(get_next,[], [?loadOsWordsize]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), - - case Wordsize of - Wordsize when is_integer(Wordsize) -> - ok; - _ -> - ?line test_server:fail(os_wordsize_value_not_integer) - end. + [{[?loadOsWordsize, Len | NodeStr], Wordsize}] = + os_mon_mib:load_table(get_next,[], [?loadOsWordsize]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + + case Wordsize of + Wordsize when is_integer(Wordsize) -> + ok; + _ -> + test_server:fail(os_wordsize_value_not_integer) + end. sys_tot_mem64(doc) -> []; sys_tot_mem64(suite) -> []; sys_tot_mem64(Config) when is_list(Config) -> - ?line [{[?loadSystemTotalMemory64, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory64]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadSystemTotalMemory64, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory64]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(sys_tot_mem_value_not_integer) + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(sys_tot_mem_value_not_integer) end. sys_used_mem64(doc) -> []; sys_used_mem64(suite) -> []; sys_used_mem64(Config) when is_list(Config) -> - ?line [{[?loadSystemUsedMemory64, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory64]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + [{[?loadSystemUsedMemory64, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory64]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(sys_used_mem_value_not_integer) + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(sys_used_mem_value_not_integer) end. large_erl_process_mem64(doc) -> @@ -485,17 +485,17 @@ large_erl_process_mem64(suite) -> []; large_erl_process_mem64(Config) when is_list(Config) -> - ?line [{[?loadLargestErlProcessUsedMemory64, Len | NodeStr], Mem}] = - os_mon_mib:load_table(get_next,[], - [?loadLargestErlProcessUsedMemory64]), - ?line Len = length(NodeStr), - ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), - - case Mem of - Mem when is_integer(Mem) -> - ok; - _ -> - ?line test_server:fail(erl_pid_mem_value_not_integer) + [{[?loadLargestErlProcessUsedMemory64, Len | NodeStr], Mem}] = + os_mon_mib:load_table(get_next,[], + [?loadLargestErlProcessUsedMemory64]), + Len = length(NodeStr), + true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), + + case Mem of + Mem when is_integer(Mem) -> + ok; + _ -> + test_server:fail(erl_pid_mem_value_not_integer) end. %%--------------------------------------------------------------------- get_disk_table(doc) -> @@ -509,44 +509,44 @@ get_disk_table(Config) when is_list(Config) -> DiskDataLen = length(DiskData), if - DiskDataLen > 0 -> - ?line [{value, Value}] = - os_mon_mib:disk_table(get, [1,1], [?diskDescr]), - - case is_list(Value) of - true -> - ok; - false -> - ?line test_server:fail(value_not_a_string) - end, - - ?line Values = os_mon_mib:disk_table(get, [1,1], - [?diskId, - ?diskKBytes, - ?diskCapacity]), - - IsInt = fun({value, Val}) when is_integer(Val) -> - true; - (_) -> - false - end, - - NewValues = lists:filter(IsInt, Values), - - case length(NewValues) of - 3 -> - ok; - _ -> - ?line test_server:fail(value_not_integer) - end + DiskDataLen > 0 -> + [{value, Value}] = + os_mon_mib:disk_table(get, [1,1], [?diskDescr]), + + case is_list(Value) of + true -> + ok; + false -> + test_server:fail(value_not_a_string) + end, + + Values = os_mon_mib:disk_table(get, [1,1], + [?diskId, + ?diskKBytes, + ?diskCapacity]), + + IsInt = fun({value, Val}) when is_integer(Val) -> + true; + (_) -> + false + end, + + NewValues = lists:filter(IsInt, Values), + + case length(NewValues) of + 3 -> + ok; + _ -> + test_server:fail(value_not_integer) + end end, - ?line [{noValue,noSuchInstance}, {noValue,noSuchInstance}, - {noValue,noSuchInstance}, {noValue,noSuchInstance}] = - os_mon_mib:disk_table(get, [1, DiskDataLen + 1], [?diskId, - ?diskDescr, - ?diskKBytes, - ?diskCapacity]), + [{noValue,noSuchInstance}, {noValue,noSuchInstance}, + {noValue,noSuchInstance}, {noValue,noSuchInstance}] = + os_mon_mib:disk_table(get, [1, DiskDataLen + 1], [?diskId, + ?diskDescr, + ?diskKBytes, + ?diskCapacity]), ok. @@ -557,28 +557,28 @@ disk_descr(doc) -> disk_descr(suite) -> []; disk_descr(Config) when is_list(Config) -> - ?line [{[?diskDescr, 1,1], Descr}] = - os_mon_mib:disk_table(get_next, [], [?diskDescr]), + [{[?diskDescr, 1,1], Descr}] = + os_mon_mib:disk_table(get_next, [], [?diskDescr]), case Descr of - Descr when is_list(Descr) -> - ok; - _ -> - ?line test_server:fail(disk_descr_value_not_a_string) + Descr when is_list(Descr) -> + ok; + _ -> + test_server:fail(disk_descr_value_not_a_string) end. disk_kbytes(doc) -> []; disk_kbytes(suite) -> []; disk_kbytes(Config) when is_list(Config) -> - ?line [{[?diskKBytes, 1,1], Kbytes}] = - os_mon_mib:disk_table(get_next,[], [?diskKBytes]), + [{[?diskKBytes, 1,1], Kbytes}] = + os_mon_mib:disk_table(get_next,[], [?diskKBytes]), case Kbytes of - Kbytes when is_integer(Kbytes) -> - ok; - _ -> - ?line test_server:fail(disk_kbytes_value_not_integer) + Kbytes when is_integer(Kbytes) -> + ok; + _ -> + test_server:fail(disk_kbytes_value_not_integer) end. @@ -586,14 +586,14 @@ disk_capacity(doc) -> []; disk_capacity(suite) -> []; disk_capacity(Config) when is_list(Config) -> - ?line [{[?diskCapacity, 1,1], Capacity}] = - os_mon_mib:disk_table(get_next,[], [?diskCapacity]), + [{[?diskCapacity, 1,1], Capacity}] = + os_mon_mib:disk_table(get_next,[], [?diskCapacity]), case Capacity of - Capacity when is_integer(Capacity) -> - ok; - _ -> - ?line test_server:fail(disk_capacity_value_not_integer) + Capacity when is_integer(Capacity) -> + ok; + _ -> + test_server:fail(disk_capacity_value_not_integer) end. %%--------------------------------------------------------------------- @@ -607,15 +607,15 @@ real_snmp_request(Config) when is_list(Config) -> {_, _, {Pid, _}} = memsup:get_memory_data(), PidStr = lists:flatten(io_lib:format("~w", [Pid])), io:format("FOO: ~p~n", [PidStr]), - ?line ok = snmp_get([?loadEntry ++ - [?loadLargestErlProcess, Len | NodStr]], - PidStr), - ?line ok = snmp_get_next([?loadEntry ++ - [?loadSystemUsedMemory, Len | NodStr]], - ?loadEntry ++ [?loadSystemUsedMemory + 1, Len - | NodStr], PidStr), - ?line ok = snmp_set([?loadEntry ++ [?loadLargestErlProcess, Len | NodStr]], - s, "<0.101.0>", Config), + ok = snmp_get([?loadEntry ++ + [?loadLargestErlProcess, Len | NodStr]], + PidStr), + ok = snmp_get_next([?loadEntry ++ + [?loadSystemUsedMemory, Len | NodStr]], + ?loadEntry ++ [?loadSystemUsedMemory + 1, Len + | NodStr], PidStr), + ok = snmp_set([?loadEntry ++ [?loadLargestErlProcess, Len | NodStr]], + s, "<0.101.0>", Config), ok. otp_7441(doc) -> @@ -628,7 +628,7 @@ otp_7441(Config) when is_list(Config) -> Len = length(NodStr), Oids = [Oid|_] = [?loadEntry ++ [?loadSystemTotalMemory, Len | NodStr]], {noError,0,[#varbind{oid = Oid, variabletype = 'Unsigned32'}]} = - ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), + ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. @@ -636,9 +636,8 @@ otp_7441(Config) when is_list(Config) -> %% Internal functions %%--------------------------------------------------------------------- start_node() -> - ?line Pa = filename:dirname(code:which(?MODULE)), - ?line {ok,Node} = test_server:start_node(testnisse, slave, - [{args, " -pa " ++ Pa}]), + Pa = filename:dirname(code:which(?MODULE)), + {ok,Node} = test_server:start_node(testnisse, slave, [{args, " -pa " ++ Pa}]), Node. stop_node(Node) -> @@ -648,27 +647,27 @@ del_dir(Dir) -> io:format("Deleting: ~s~n",[Dir]), {ok, Files} = file:list_dir(Dir), FullPathFiles = lists:map(fun(File) -> filename:join(Dir, File) end, - Files), + Files), lists:foreach(fun file:delete/1, FullPathFiles), file:del_dir(Dir). %%--------------------------------------------------------------------- snmp_get(Oids = [Oid |_], Result) -> {noError,0,[#varbind{oid = Oid, - variabletype = 'OCTET STRING', - value = Result}]} = - ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), + variabletype = 'OCTET STRING', + value = Result}]} = + ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. snmp_get_next(Oids, NextOid, Result) -> {noError,0,[#varbind{oid = NextOid, - variabletype = 'OCTET STRING', - value = Result}]} = - ct_snmp:get_next_values(os_mon_mib_test, Oids, snmp_mgr_agent), + variabletype = 'OCTET STRING', + value = Result}]} = + ct_snmp:get_next_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. snmp_set(Oid, ValuType, Value, Config) -> {notWritable, _, _} = - ct_snmp:set_values(os_mon_mib_test, [{Oid, ValuType, Value}], - snmp_mgr_agent, Config), + ct_snmp:set_values(os_mon_mib_test, [{Oid, ValuType, Value}], + snmp_mgr_agent, Config), ok. diff --git a/lib/os_mon/test/os_sup_SUITE.erl b/lib/os_mon/test/os_sup_SUITE.erl index 5857faa0a6..56bd67563c 100644 --- a/lib/os_mon/test/os_sup_SUITE.erl +++ b/lib/os_mon/test/os_sup_SUITE.erl @@ -39,20 +39,20 @@ init_per_suite(Config) when is_list(Config) -> spawn(fun() -> message_receptor() end), - ?line application:load(os_mon), - ?line ok = application:set_env(os_mon, start_os_sup, true), - ?line ok = application:set_env(os_mon, os_sup_mfa, ?MFA), - ?line ok = application:set_env(os_mon, os_sup_enable, false), - ?line ok = application:start(os_mon), + application:load(os_mon), + ok = application:set_env(os_mon, start_os_sup, true), + ok = application:set_env(os_mon, os_sup_mfa, ?MFA), + ok = application:set_env(os_mon, os_sup_enable, false), + ok = application:start(os_mon), Config. end_per_suite(Config) when is_list(Config) -> - ?line application:stop(os_mon), - ?line ok = application:set_env(os_mon, start_os_sup, false), + application:stop(os_mon), + ok = application:set_env(os_mon, start_os_sup, false), MFA = {os_sup, error_report, [std_error]}, - ?line ok = application:set_env(os_mon, os_sup_mfa, MFA), - ?line ok = application:set_env(os_mon, os_sup_enable, true), - ?line exit(whereis(message_receptor), done), + ok = application:set_env(os_mon, os_sup_mfa, MFA), + ok = application:set_env(os_mon, os_sup_enable, true), + exit(whereis(message_receptor), done), Config. init_per_testcase(_Case, Config) -> @@ -68,12 +68,12 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> case test_server:os_type() of - {unix, sunos} -> [message, config, port]; - {win32, _OSname} -> [message]; - OS -> - Str = io_lib:format("os_sup not available for ~p", - [OS]), - {skip, lists:flatten(Str)} + {unix, sunos} -> [message, config, port]; + {win32, _OSname} -> [message]; + OS -> + Str = io_lib:format("os_sup not available for ~p", + [OS]), + {skip, lists:flatten(Str)} end. groups() -> @@ -94,23 +94,23 @@ message(Config) when is_list(Config) -> %% Fake an OS message Data = "10H11386278426HSystem4HTest5HError5HTesto", - ?line os_sup_server ! {faked_port, {data, Data}}, + os_sup_server ! {faked_port, {data, Data}}, %% Check with message_receptor that it has been received ?t:sleep(?t:seconds(1)), Msg = - case ?t:os_type() of - {unix, sunos} -> - {?TAG, Data}; - {win32, _} -> - {?TAG,{{1138,627842,0},"System","Test","Error","Testo"}} - end, - ?line message_receptor ! {check, self(), Msg}, + case ?t:os_type() of + {unix, sunos} -> + {?TAG, Data}; + {win32, _} -> + {?TAG,{{1138,627842,0},"System","Test","Error","Testo"}} + end, + message_receptor ! {check, self(), Msg}, receive - {result, true} -> - ok; - {result, Rec} -> - ?t:fail({no_message, Rec}) + {result, true} -> + ok; + {result, Rec} -> + ?t:fail({no_message, Rec}) end, ok. @@ -135,40 +135,40 @@ port(suite) -> port(doc) -> ["Test that os_sup handles a terminating port program"]; port(Config) when is_list(Config) -> - ?line Str = os:cmd("ps -e | grep '[f]errule'"), + Str = os:cmd("ps -e | grep '[f]errule'"), case io_lib:fread("~s", Str) of - {ok, [Pid], _Rest} -> - - %% Monitor os_sup_server - ?line MonRef = erlang:monitor(process, os_sup_server), - - %% Kill the port program - case os:cmd("kill -9 " ++ Pid) of - [] -> - - %% os_sup_server should now terminate - receive - {'DOWN', MonRef, _, _, {port_died, _Reason}} -> - ok; - {'DOWN', MonRef, _, _, Reason} -> - ?line ?t:fail({unexpected_exit_reason, Reason}) - after - 3000 -> - ?line ?t:fail(still_alive) - end, - - %% Give os_mon_sup time to restart os_sup - ?t:sleep(?t:seconds(3)), - ?line true = is_pid(whereis(os_sup_server)), - - ok; - - Line -> - erlang:demonitor(MonRef), - {skip, {not_killed, Line}} - end; - _ -> - {skip, {os_pid_not_found}} + {ok, [Pid], _Rest} -> + + %% Monitor os_sup_server + MonRef = erlang:monitor(process, os_sup_server), + + %% Kill the port program + case os:cmd("kill -9 " ++ Pid) of + [] -> + + %% os_sup_server should now terminate + receive + {'DOWN', MonRef, _, _, {port_died, _Reason}} -> + ok; + {'DOWN', MonRef, _, _, Reason} -> + ?t:fail({unexpected_exit_reason, Reason}) + after + 3000 -> + ?t:fail(still_alive) + end, + + %% Give os_mon_sup time to restart os_sup + ?t:sleep(?t:seconds(3)), + true = is_pid(whereis(os_sup_server)), + + ok; + + Line -> + erlang:demonitor(MonRef), + {skip, {not_killed, Line}} + end; + _ -> + {skip, {os_pid_not_found}} end. %%---------------------------------------------------------------------- @@ -184,18 +184,18 @@ message_receptor() -> message_receptor(Received) -> receive - %% Check if a certain message has been received - {check, From, Msg} -> - case lists:member(Msg, Received) of - true -> - From ! {result, true}, - message_receptor(lists:delete(Msg, Received)); - false -> - From ! {result, Received}, - message_receptor(Received) - end; - - %% Save all other messages - Msg -> - message_receptor([Msg|Received]) + %% Check if a certain message has been received + {check, From, Msg} -> + case lists:member(Msg, Received) of + true -> + From ! {result, true}, + message_receptor(lists:delete(Msg, Received)); + false -> + From ! {result, Received}, + message_receptor(Received) + end; + + %% Save all other messages + Msg -> + message_receptor([Msg|Received]) end. -- cgit v1.2.3 From 400d41eda5eca53b6b752c5b442d0f548266ce23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 17:43:39 +0200 Subject: Modernize use of timetraps --- lib/os_mon/test/cpu_sup_SUITE.erl | 26 +++++------------- lib/os_mon/test/disksup_SUITE.erl | 26 +++++------------- lib/os_mon/test/memsup_SUITE.erl | 52 +++++++++++++----------------------- lib/os_mon/test/os_mon_SUITE.erl | 36 +++---------------------- lib/os_mon/test/os_mon_mib_SUITE.erl | 28 +++++-------------- lib/os_mon/test/os_sup_SUITE.erl | 28 +++---------------- 6 files changed, 45 insertions(+), 151 deletions(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index e061fd87c6..597e53044d 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -21,7 +21,7 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). +-export([all/0, suite/0]). -export([init_per_suite/1, end_per_suite/1]). -export([init_per_testcase/2, end_per_testcase/2]). @@ -31,9 +31,6 @@ -export([port/1]). -export([terminate/1, unavailable/1, restart/1]). -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). - init_per_suite(Config) when is_list(Config) -> ok = application:start(os_mon), Config. @@ -46,18 +43,17 @@ init_per_testcase(unavailable, Config) -> terminate(Config), init_per_testcase(dummy, Config); init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{watchdog, Dog} | Config]. + Config. end_per_testcase(unavailable, Config) -> restart(Config), end_per_testcase(dummy, Config); -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), +end_per_testcase(_Case, _Config) -> ok. -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> case test_server:os_type() of @@ -71,16 +67,6 @@ all() -> _OS -> [unavailable] end. -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - load_api(suite) -> []; load_api(doc) -> diff --git a/lib/os_mon/test/disksup_SUITE.erl b/lib/os_mon/test/disksup_SUITE.erl index 8e2825ec26..8e44122f47 100644 --- a/lib/os_mon/test/disksup_SUITE.erl +++ b/lib/os_mon/test/disksup_SUITE.erl @@ -21,7 +21,7 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). +-export([all/0, suite/0]). -export([init_per_suite/1, end_per_suite/1]). -export([init_per_testcase/2, end_per_testcase/2]). @@ -32,9 +32,6 @@ -export([otp_5910/1]). -export([posix_only/1]). -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). - init_per_suite(Config) when is_list(Config) -> ok = application:start(os_mon), Config. @@ -47,19 +44,18 @@ init_per_testcase(unavailable, Config) -> terminate(Config), init_per_testcase(dummy, Config); init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{watchdog,Dog} | Config]. + Config. end_per_testcase(TC, Config) when TC =:= unavailable; TC =:= posix_only -> restart(Config), end_per_testcase(dummy, Config); -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), +end_per_testcase(_Case, _Config) -> ok. -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> Bugs = [otp_5910], @@ -70,16 +66,6 @@ all() -> _OS -> [unavailable] end. -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - api(suite) -> []; api(doc) -> ["Test of API functions"]; api(Config) when is_list(Config) -> diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index 1c1e898538..4a740a1c17 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -21,7 +21,7 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). +-export([all/0, suite/0]). -export([init_per_suite/1, end_per_suite/1]). -export([init_per_testcase/2, end_per_testcase/2]). @@ -30,9 +30,6 @@ -export([config/1, timeout/1, unavailable/1, port/1]). -export([otp_5910/1]). -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). - init_per_suite(Config) when is_list(Config) -> ok = application:start(os_mon), Config. @@ -42,15 +39,14 @@ end_per_suite(Config) when is_list(Config) -> Config. init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{watchdog,Dog} | Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), Config. -suite() -> [{ct_hooks,[ts_install_cth]}]. +end_per_testcase(_Case, _Config) -> + ok. + +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> All = case test_server:os_type() of @@ -64,15 +60,6 @@ all() -> Bugs = [otp_5910], All ++ Bugs. -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - api(suite) -> []; @@ -96,24 +83,23 @@ api(Config) when is_list(Config) -> %% get_system_memory_data() ExtMemData = memsup:get_system_memory_data(), - Tags = [ total_memory, - free_memory, - system_total_memory, - largest_free, - number_of_free, - free_swap, - total_swap, - cached_memory, - buffered_memory, - shared_memory], + Tags = [total_memory, + free_memory, + system_total_memory, + largest_free, + number_of_free, + free_swap, + total_swap, + cached_memory, + buffered_memory, + shared_memory], true = lists:all(fun({Tag,Value}) when is_atom(Tag), is_integer(Value) -> lists:member(Tag, Tags); (_) -> false - end, - ExtMemData), + end, ExtMemData), %% get_os_wordsize() ok = case memsup:get_os_wordsize() of @@ -180,7 +166,7 @@ alarm1(Config) when is_list(Config) -> io:format("alarm1: Total: ~p, Alloc: ~p~n", [Total, Alloc]), SysUsage = Alloc/Total, if - SysUsage>0.99 -> + SysUsage > 0.99 -> {skip, sys_mem_too_high}; true -> alarm1(Config, SysUsage) diff --git a/lib/os_mon/test/os_mon_SUITE.erl b/lib/os_mon/test/os_mon_SUITE.erl index a80d30f6b0..af70dc2a6c 100644 --- a/lib/os_mon/test/os_mon_SUITE.erl +++ b/lib/os_mon/test/os_mon_SUITE.erl @@ -21,26 +21,14 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2]). --export([init_per_testcase/2, end_per_testcase/2]). +-export([all/0, suite/0]). %% Test cases -export([app_file/1, appup_file/1, config/1]). -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). - -init_per_testcase(_Case, Config) -> - Dog = test_server:timetrap(?default_timeout), - [{watchdog, Dog}|Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - ok. - -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> case test_server:os_type() of @@ -48,22 +36,6 @@ all() -> _OS -> [app_file, appup_file] end. -groups() -> - []. - -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - app_file(suite) -> []; app_file(doc) -> diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index f966e5ec58..4927389a58 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -35,9 +35,8 @@ -include_lib("snmp/include/snmp_types.hrl"). % Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, - init_per_suite/1, end_per_suite/1, - init_per_testcase/2, end_per_testcase/2]). +-export([all/0, suite/0, groups/0, + init_per_suite/1, end_per_suite/1]). % Test cases must be exported. @@ -53,7 +52,6 @@ large_erl_process_mem64/1, disk_descr/1, disk_kbytes/1, disk_capacity/1]). --export([]). -export([otp_6351/1, otp_7441/1]). -define(TRAP_UDP, 5000). @@ -65,17 +63,11 @@ -define(MGR_PORT, 5001). %%--------------------------------------------------------------------- -init_per_testcase(_Case, Config) when is_list(Config) -> - Dog = test_server:timetrap(test_server:minutes(6)), - [{watchdog, Dog}|Config]. -end_per_testcase(_Case, Config) when is_list(Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - Config. - -suite() -> [{ct_hooks,[ts_install_cth]}, - {require, snmp_mgr_agent, snmp}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,6}}, + {require, snmp_mgr_agent, snmp}]. all() -> [load_unload, get_mem_sys_mark, get_mem_proc_mark, @@ -94,12 +86,6 @@ groups() -> {get_next_disk_table, [], [disk_descr, disk_kbytes, disk_capacity]}]. -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - %%--------------------------------------------------------------------- %%-------------------------------------------------------------------- @@ -198,8 +184,6 @@ otp_6351(Config) when is_list(Config) -> ok. - - %%--------------------------------------------------------------------- get_mem_sys_mark(doc) -> ["Simulates a get call to test the instrumentation function " diff --git a/lib/os_mon/test/os_sup_SUITE.erl b/lib/os_mon/test/os_sup_SUITE.erl index 56bd67563c..39e3c7e815 100644 --- a/lib/os_mon/test/os_sup_SUITE.erl +++ b/lib/os_mon/test/os_sup_SUITE.erl @@ -21,17 +21,13 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). +-export([all/0, suite/0]). -export([init_per_suite/1, end_per_suite/1]). --export([init_per_testcase/2, end_per_testcase/2]). %% Test cases -export([message/1]). -export([config/1, port/1]). -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). - -define(TAG, test_tag). -define(MFA, {?MODULE, test_mfa, [?TAG]}). @@ -55,16 +51,9 @@ end_per_suite(Config) when is_list(Config) -> exit(whereis(message_receptor), done), Config. -init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{watchdog,Dog} | Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), - ok. - -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,1}}]. all() -> case test_server:os_type() of @@ -76,15 +65,6 @@ all() -> {skip, lists:flatten(Str)} end. -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - message(suite) -> []; -- cgit v1.2.3 From ddff69ac445fe073682ac8aa9b9951b41ee450ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 17:45:30 +0200 Subject: Eliminate use of ?config() macro --- lib/os_mon/test/os_mon_mib_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index 4927389a58..4a94c5998b 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -116,7 +116,7 @@ init_per_suite(Config) -> %% Description: Cleanup after the whole suite %%-------------------------------------------------------------------- end_per_suite(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ConfDir = filename:join(PrivDir,"conf"), DbDir = filename:join(PrivDir,"db"), MgrDir = filename:join(PrivDir, "mgr"), -- cgit v1.2.3 From ab8b414921a2fe2738d7fcc0e66fe382a39ed247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 17:50:22 +0200 Subject: Eliminate use of test_server:fail/0,1 --- lib/os_mon/test/cpu_sup_SUITE.erl | 2 +- lib/os_mon/test/disksup_SUITE.erl | 18 +++++++-------- lib/os_mon/test/memsup_SUITE.erl | 45 ++++++++++++++++++------------------ lib/os_mon/test/os_mon_mib_SUITE.erl | 40 ++++++++++++++++---------------- lib/os_mon/test/os_sup_SUITE.erl | 6 ++--- 5 files changed, 55 insertions(+), 56 deletions(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index 597e53044d..bbdd46c21e 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -222,7 +222,7 @@ port(Config) when is_list(Config) -> %% cpu_sup should not terminate receive {'DOWN', MonRef, _, _, Reason} -> - ?t:fail({unexpected_exit_reason, Reason}) + ct:fail({unexpected_exit_reason, Reason}) after 3000 -> ok end, diff --git a/lib/os_mon/test/disksup_SUITE.erl b/lib/os_mon/test/disksup_SUITE.erl index 8e44122f47..6ce88ac10d 100644 --- a/lib/os_mon/test/disksup_SUITE.erl +++ b/lib/os_mon/test/disksup_SUITE.erl @@ -148,7 +148,7 @@ alarm(Config) when is_list(Config) -> true; true -> dump_info(), - ?t:fail({bad_alarms, Threshold1, Data1, Alarms1}) + ct:fail({bad_alarms, Threshold1, Data1, Alarms1}) end, %% Try to find a disk with space usage below Threshold1, @@ -173,7 +173,7 @@ alarm(Config) when is_list(Config) -> true; true -> dump_info(), - ?t:fail({bad_alarms, Threshold2, Data2, Alarms2}) + ct:fail({bad_alarms, Threshold2, Data2, Alarms2}) end; false -> ignore @@ -201,7 +201,7 @@ alarm(Config) when is_list(Config) -> ok; true -> dump_info(), - ?t:fail({bad_alarms, Threshold3, Data3, Alarms3}) + ct:fail({bad_alarms, Threshold3, Data3, Alarms3}) end; 100 -> ignore @@ -279,10 +279,10 @@ port(Config) when is_list(Config) -> {'DOWN', MonRef, _, _, {port_died, _Reason}} -> ok; {'DOWN', MonRef, _, _, Reason} -> - ?t:fail({unexpected_exit_reason, Reason}) + ct:fail({unexpected_exit_reason, Reason}) after 3000 -> - ?t:fail({still_alive, Str}) + ct:fail({still_alive, Str}) end, %% Give os_mon_sup time to restart disksup @@ -351,12 +351,12 @@ otp_5910(Config) when is_list(Config) -> Alarms = get_alarms(), if Over==0 -> - ?t:fail({threshold_too_low, Data2, Threshold}); + ct:fail({threshold_too_low, Data2, Threshold}); Over==length(Alarms) -> ok; true -> dump_info(), - ?t:fail({bad_alarms, Threshold, Data2, Alarms}) + ct:fail({bad_alarms, Threshold, Data2, Alarms}) end, %% Kill disksup @@ -371,7 +371,7 @@ otp_5910(Config) when is_list(Config) -> length(Alarms2)==length(Alarms) -> ok; true -> dump_info(), - ?t:fail({bad_alarms,Threshold,Data3,Alarms,Alarms2}) + ct:fail({bad_alarms,Threshold,Data3,Alarms,Alarms2}) end, %% Stop OS_Mon and make sure all disksup alarms are cleared @@ -380,7 +380,7 @@ otp_5910(Config) when is_list(Config) -> Alarms3 = get_alarms(), case get_alarms() of [] -> ok; - _ -> ?t:fail({alarms_not_cleared, Alarms3}) + _ -> ct:fail({alarms_not_cleared, Alarms3}) end, %% Reset threshold and restart OS_Mon diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index 4a740a1c17..2ad542042d 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -76,9 +76,9 @@ api(Config) when is_list(Config) -> is_integer(PidBytes) -> ok; {0, 0, _WorstPid} -> - ?t:fail(first_data_collection_failed); + ct:fail(first_data_collection_failed); _ -> - ?t:fail({bad_return, RegMemData}) + ct:fail({bad_return, RegMemData}) end, %% get_system_memory_data() @@ -195,7 +195,7 @@ alarm1(_Config, SysUsage) -> false when not SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, SysThreshold}) + ct:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Lower/raise the threshold to clear/set the alarm @@ -222,7 +222,7 @@ alarm1(_Config, SysUsage) -> false when SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) + ct:fail({sys_alarm, SysUsage, NewSysThreshold}) end, %% Reset the threshold to set/clear the alarm again @@ -235,7 +235,7 @@ alarm1(_Config, SysUsage) -> false when not SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, SysThreshold}) + ct:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Check memory usage @@ -255,9 +255,9 @@ alarm1(_Config, SysUsage) -> false when not ProcP -> ok; {true, BadPid1} when ProcP -> - ?t:fail({proc_alarm, WorstPid, BadPid1}); + ct:fail({proc_alarm, WorstPid, BadPid1}); _ -> - ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + ct:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Lower/raise the threshold to clear/set the alarm @@ -274,9 +274,9 @@ alarm1(_Config, SysUsage) -> false when ProcP -> ok; {true, BadPid2} when not ProcP -> - test_server:fail({proc_alarm, WorstPid, BadPid2}); + ct:fail({proc_alarm, WorstPid, BadPid2}); _ -> - ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + ct:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Reset the threshold to clear/set the alarm @@ -289,9 +289,9 @@ alarm1(_Config, SysUsage) -> false when not ProcP -> ok; {true, BadPid3} when ProcP -> - test_server:fail({proc_alarm, WorstPid, BadPid3}); + ct:fail({proc_alarm, WorstPid, BadPid3}); _ -> - ?t:fail({proc_alarm, PidUsage, ProcThreshold}) + ct:fail({proc_alarm, PidUsage, ProcThreshold}) end, %% Reset memory check interval @@ -346,7 +346,7 @@ alarm2(_Config, _SysUsage) -> false when not SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, SysThreshold}) + ct:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Lower/raise the threshold to clear/set the alarm @@ -373,7 +373,7 @@ alarm2(_Config, _SysUsage) -> false when SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, NewSysThreshold}) + ct:fail({sys_alarm, SysUsage, NewSysThreshold}) end, %% Reset the threshold to set/clear the alarm again @@ -386,7 +386,7 @@ alarm2(_Config, _SysUsage) -> false when not SysP -> ok; _ -> - ?t:fail({sys_alarm, SysUsage, SysThreshold}) + ct:fail({sys_alarm, SysUsage, SysThreshold}) end, %% Reset memsup_system_only and restart memsup @@ -433,7 +433,7 @@ process(Config) when is_list(Config) -> {_, _, {WorsePid, _MoreBytes}} -> ok; {_, _, BadWorst} -> - ?t:fail({worst_pid, BadWorst}) + ct:fail({worst_pid, BadWorst}) end, %% Reset memory check interval @@ -577,9 +577,9 @@ timeout(Config) when is_list(Config) -> ok; {Mref, Res} -> erlang:demonitor(Mref), - ?t:fail({unexpected_result, Res}); + ct:fail({unexpected_result, Res}); {'DOWN', Mref, _, _, _} -> - ?t:fail(no_result) + ct:fail(no_result) end, %% Reset memory check interval and memsup_helper timeout @@ -614,10 +614,10 @@ port(Config) when is_list(Config) -> {'DOWN', MonRef, _, _, {port_died, _Reason}} -> ok; {'DOWN', MonRef, _, _, Reason} -> - ?t:fail({unexpected_exit_reason, Reason}) + ct:fail({unexpected_exit_reason, Reason}) after 3000 -> - ?t:fail(still_alive) + ct:fail(still_alive) end, %% Give os_mon_sup time to restart memsup @@ -689,8 +689,7 @@ otp_5910(Config) when is_list(Config) -> case alarm_set(AlarmId) of {true, _} -> ok; false -> - ?t:fail({alarm_not_set, - AlarmId}) + ct:fail({alarm_not_set, AlarmId}) end end, Alarms), @@ -716,7 +715,7 @@ otp_5910(Config) when is_list(Config) -> {0, 0} -> ok; _ -> - ?t:fail({bad_number_of_alarms, SetAlarms, MemUsage}) + ct:fail({bad_number_of_alarms, SetAlarms, MemUsage}) end, %% Stop OS_Mon and make sure all memsup alarms are cleared @@ -726,7 +725,7 @@ otp_5910(Config) when is_list(Config) -> case alarm_set(AlarmId) of false -> ok; {true, _} -> - ?t:fail({alarm_is_set, AlarmId}) + ct:fail({alarm_is_set, AlarmId}) end end, Alarms), diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index 4a94c5998b..3f5d2210a4 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -177,7 +177,7 @@ otp_6351(Config) when is_list(Config) -> is_tuple(Res), element(1, Res)==loadTable -> ok; true -> - ?t:fail(Res) + ct:fail(Res) end, rpc:call(Node,application,stop,[os_mon]), stop_node(Node), @@ -195,7 +195,7 @@ get_mem_sys_mark(Config) when is_list(Config) -> {value, SysMark} when is_integer(SysMark) -> ok; _ -> - test_server:fail(sys_mark_value_not_integer) + ct:fail(sys_mark_value_not_integer) end. %%--------------------------------------------------------------------- get_mem_proc_mark(doc) -> @@ -208,7 +208,7 @@ get_mem_proc_mark(Config) when is_list(Config) -> {value, ProcMark} when is_integer(ProcMark) -> ok; _ -> - test_server:fail(proc_mark_value_not_integer) + ct:fail(proc_mark_value_not_integer) end. %%--------------------------------------------------------------------- get_disk_threshold(doc) -> @@ -221,7 +221,7 @@ get_disk_threshold(Config) when is_list(Config) -> {value, ProcMark} when is_integer(ProcMark) -> ok; _ -> - test_server:fail(disk_threshold_value_not_integer) + ct:fail(disk_threshold_value_not_integer) end. %%--------------------------------------------------------------------- @@ -271,7 +271,7 @@ get_load_table(Config) when is_list(Config) -> 10 -> ok; _ -> - test_server:fail(value_not_integer) + ct:fail(value_not_integer) end, [{noValue,noSuchInstance}, {noValue,noSuchInstance}, @@ -311,7 +311,7 @@ sys_tot_mem(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(sys_tot_mem_value_not_integer) + ct:fail(sys_tot_mem_value_not_integer) end. sys_used_mem(doc) -> @@ -327,7 +327,7 @@ sys_used_mem(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(sys_used_mem_value_not_integer) + ct:fail(sys_used_mem_value_not_integer) end. large_erl_process(doc) -> @@ -359,7 +359,7 @@ large_erl_process_mem(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(erl_pid_mem_value_not_integer) + ct:fail(erl_pid_mem_value_not_integer) end. cpu_load(doc) -> @@ -376,7 +376,7 @@ cpu_load(Config) when is_list(Config) -> Load when is_integer(Load) -> ok; _ -> - test_server:fail(cpu_load_value_not_integer) + ct:fail(cpu_load_value_not_integer) end. cpu_load5(doc) -> @@ -393,7 +393,7 @@ cpu_load5(Config) when is_list(Config) -> Load when is_integer(Load) -> ok; _ -> - test_server:fail(cpu_load5_value_not_integer) + ct:fail(cpu_load5_value_not_integer) end. cpu_load15(doc) -> @@ -410,7 +410,7 @@ cpu_load15(Config) when is_list(Config) -> Load when is_integer(Load) -> ok; _ -> - test_server:fail(cpu_load15_value_not_integer) + ct:fail(cpu_load15_value_not_integer) end. os_wordsize(doc) -> @@ -427,7 +427,7 @@ os_wordsize(Config) when is_list(Config) -> Wordsize when is_integer(Wordsize) -> ok; _ -> - test_server:fail(os_wordsize_value_not_integer) + ct:fail(os_wordsize_value_not_integer) end. sys_tot_mem64(doc) -> @@ -444,7 +444,7 @@ sys_tot_mem64(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(sys_tot_mem_value_not_integer) + ct:fail(sys_tot_mem_value_not_integer) end. sys_used_mem64(doc) -> @@ -460,7 +460,7 @@ sys_used_mem64(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(sys_used_mem_value_not_integer) + ct:fail(sys_used_mem_value_not_integer) end. large_erl_process_mem64(doc) -> @@ -479,7 +479,7 @@ large_erl_process_mem64(Config) when is_list(Config) -> Mem when is_integer(Mem) -> ok; _ -> - test_server:fail(erl_pid_mem_value_not_integer) + ct:fail(erl_pid_mem_value_not_integer) end. %%--------------------------------------------------------------------- get_disk_table(doc) -> @@ -501,7 +501,7 @@ get_disk_table(Config) when is_list(Config) -> true -> ok; false -> - test_server:fail(value_not_a_string) + ct:fail(value_not_a_string) end, Values = os_mon_mib:disk_table(get, [1,1], @@ -521,7 +521,7 @@ get_disk_table(Config) when is_list(Config) -> 3 -> ok; _ -> - test_server:fail(value_not_integer) + ct:fail(value_not_integer) end end, @@ -548,7 +548,7 @@ disk_descr(Config) when is_list(Config) -> Descr when is_list(Descr) -> ok; _ -> - test_server:fail(disk_descr_value_not_a_string) + ct:fail(disk_descr_value_not_a_string) end. disk_kbytes(doc) -> @@ -562,7 +562,7 @@ disk_kbytes(Config) when is_list(Config) -> Kbytes when is_integer(Kbytes) -> ok; _ -> - test_server:fail(disk_kbytes_value_not_integer) + ct:fail(disk_kbytes_value_not_integer) end. @@ -577,7 +577,7 @@ disk_capacity(Config) when is_list(Config) -> Capacity when is_integer(Capacity) -> ok; _ -> - test_server:fail(disk_capacity_value_not_integer) + ct:fail(disk_capacity_value_not_integer) end. %%--------------------------------------------------------------------- diff --git a/lib/os_mon/test/os_sup_SUITE.erl b/lib/os_mon/test/os_sup_SUITE.erl index 39e3c7e815..fb30e479a7 100644 --- a/lib/os_mon/test/os_sup_SUITE.erl +++ b/lib/os_mon/test/os_sup_SUITE.erl @@ -90,7 +90,7 @@ message(Config) when is_list(Config) -> {result, true} -> ok; {result, Rec} -> - ?t:fail({no_message, Rec}) + ct:fail({no_message, Rec}) end, ok. @@ -131,10 +131,10 @@ port(Config) when is_list(Config) -> {'DOWN', MonRef, _, _, {port_died, _Reason}} -> ok; {'DOWN', MonRef, _, _, Reason} -> - ?t:fail({unexpected_exit_reason, Reason}) + ct:fail({unexpected_exit_reason, Reason}) after 3000 -> - ?t:fail(still_alive) + ct:fail(still_alive) end, %% Give os_mon_sup time to restart os_sup -- cgit v1.2.3 From d0378c0daf08fd0ddc22cf3e3fbb5b01794e623f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 17:51:17 +0200 Subject: Replace use of test_server:format/2 with io:format/2 --- lib/os_mon/test/cpu_sup_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index bbdd46c21e..f2caf85a60 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -191,7 +191,7 @@ util_values(Config) when is_list(Config) -> Utils = [{high1,HighUtil1}, {low1,LowUtil1}, {high2,HighUtil2}, {low2,LowUtil2}], - ?t:format("Utils: ~p~n", [Utils]), + io:format("Utils: ~p~n", [Utils]), false = LowUtil1 > HighUtil1, false = LowUtil1 > HighUtil2, -- cgit v1.2.3 From a3115154f754ed9f8db0dd0bfb07642efe54261c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 17:58:41 +0200 Subject: Replace ?t:sleep/1 with ct:sleep/1 --- lib/os_mon/test/cpu_sup_SUITE.erl | 2 +- lib/os_mon/test/disksup_SUITE.erl | 6 +++--- lib/os_mon/test/memsup_SUITE.erl | 22 +++++++++++----------- lib/os_mon/test/os_sup_SUITE.erl | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index f2caf85a60..dcd689407c 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -228,7 +228,7 @@ port(Config) when is_list(Config) -> end, %% Give cpu_sup time to restart cpu_sup port - ?t:sleep(?t:seconds(3)), + ct:sleep({seconds, 3}), N2 = cpu_sup:nprocs(), true = N2>0, diff --git a/lib/os_mon/test/disksup_SUITE.erl b/lib/os_mon/test/disksup_SUITE.erl index 6ce88ac10d..0f0561571a 100644 --- a/lib/os_mon/test/disksup_SUITE.erl +++ b/lib/os_mon/test/disksup_SUITE.erl @@ -286,7 +286,7 @@ port(Config) when is_list(Config) -> end, %% Give os_mon_sup time to restart disksup - ?t:sleep(?t:seconds(3)), + ct:sleep({seconds,3}), [{_Disk2,Kbyte2,_Cap2}|_] = disksup:get_disk_data(), true = Kbyte2>0, @@ -364,7 +364,7 @@ otp_5910(Config) when is_list(Config) -> %% Wait a little to make sure disksup has been restarted, %% then make sure the alarms are set once, but not twice - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), Data3 = disksup:get_disk_data(), Alarms2 = get_alarms(), if @@ -376,7 +376,7 @@ otp_5910(Config) when is_list(Config) -> %% Stop OS_Mon and make sure all disksup alarms are cleared ok = application:stop(os_mon), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), Alarms3 = get_alarms(), case get_alarms() of [] -> ok; diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index 2ad542042d..8c31a8c39a 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -215,7 +215,7 @@ alarm1(_Config, SysUsage) -> ok = force_collection(), %% Make sure the alarm is cleared/set - ?t:sleep(?t:seconds(5)), + ct:sleep({seconds,5}), case alarm_set(system_memory_high_watermark) of {true, []} when not SysP -> ok; @@ -228,7 +228,7 @@ alarm1(_Config, SysUsage) -> %% Reset the threshold to set/clear the alarm again ok = memsup:set_sysmem_high_watermark(SysThreshold), ok = force_collection(), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), case alarm_set(system_memory_high_watermark) of {true, []} when SysP -> ok; @@ -267,7 +267,7 @@ alarm1(_Config, SysUsage) -> end, ok = memsup:set_procmem_high_watermark(NewProcThreshold), ok = force_collection(), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), case alarm_set(process_memory_high_watermark) of {true, WorstPid} when not ProcP -> ok; @@ -282,7 +282,7 @@ alarm1(_Config, SysUsage) -> %% Reset the threshold to clear/set the alarm ok = memsup:set_procmem_high_watermark(ProcThreshold), ok = force_collection(), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), case alarm_set(process_memory_high_watermark) of {true, WorstPid} when ProcP -> ok; @@ -366,7 +366,7 @@ alarm2(_Config, _SysUsage) -> ok = force_collection(), %% Make sure the alarm is cleared/set - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), case alarm_set(system_memory_high_watermark) of {true, []} when not SysP -> ok; @@ -379,7 +379,7 @@ alarm2(_Config, _SysUsage) -> %% Reset the threshold to set/clear the alarm again ok = memsup:set_sysmem_high_watermark(SysThreshold), ok = force_collection(), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), case alarm_set(system_memory_high_watermark) of {true, []} when SysP -> ok; @@ -423,7 +423,7 @@ process(Config) when is_list(Config) -> %% Start a new process larger than Worst WorsePid = spawn(fun() -> new_hog(Bytes) end), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), %% Initiate and wait for a new data collection ok = force_collection(), @@ -621,7 +621,7 @@ port(Config) when is_list(Config) -> end, %% Give os_mon_sup time to restart memsup - ?t:sleep(?t:seconds(3)), + ct:sleep({seconds,3}), {Total2,_Alloc2,_Worst2} = memsup:get_memory_data(), true = Total2>0, @@ -684,7 +684,7 @@ otp_5910(Config) when is_list(Config) -> ok = memsup:set_procmem_high_watermark(0.5 *ProcUsage) end, ok = force_collection(), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), lists:foreach(fun(AlarmId) -> case alarm_set(AlarmId) of {true, _} -> ok; @@ -700,7 +700,7 @@ otp_5910(Config) when is_list(Config) -> exit(whereis(memsup), faked_memsup_crash), %% Wait a little to make sure memsup has been restarted, %% then make sure the alarms are set once, but not twice - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), MemUsage = memsup:get_memory_data(), SetAlarms = alarm_handler:get_alarms(), case lists:foldl(fun(system_memory_high_watermark, {S, P}) -> @@ -720,7 +720,7 @@ otp_5910(Config) when is_list(Config) -> %% Stop OS_Mon and make sure all memsup alarms are cleared ok = application:stop(os_mon), - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), lists:foreach(fun(AlarmId) -> case alarm_set(AlarmId) of false -> ok; diff --git a/lib/os_mon/test/os_sup_SUITE.erl b/lib/os_mon/test/os_sup_SUITE.erl index fb30e479a7..8065b0b50c 100644 --- a/lib/os_mon/test/os_sup_SUITE.erl +++ b/lib/os_mon/test/os_sup_SUITE.erl @@ -77,7 +77,7 @@ message(Config) when is_list(Config) -> os_sup_server ! {faked_port, {data, Data}}, %% Check with message_receptor that it has been received - ?t:sleep(?t:seconds(1)), + ct:sleep({seconds,1}), Msg = case ?t:os_type() of {unix, sunos} -> @@ -138,7 +138,7 @@ port(Config) when is_list(Config) -> end, %% Give os_mon_sup time to restart os_sup - ?t:sleep(?t:seconds(3)), + ct:sleep({seconds,3}), true = is_pid(whereis(os_sup_server)), ok; -- cgit v1.2.3 From c36e45f8faa5ffb24479e4ab268ab151e305e779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 18:09:14 +0200 Subject: Eliminate use of doc and suite clauses Those clause are obsolete and never used by common_test. --- lib/os_mon/test/cpu_sup_SUITE.erl | 29 ++------- lib/os_mon/test/disksup_SUITE.erl | 30 +++------ lib/os_mon/test/memsup_SUITE.erl | 46 +++----------- lib/os_mon/test/os_mon_SUITE.erl | 10 +-- lib/os_mon/test/os_mon_mib_SUITE.erl | 115 ++++++----------------------------- lib/os_mon/test/os_sup_SUITE.erl | 15 +---- 6 files changed, 47 insertions(+), 198 deletions(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index dcd689407c..69c7414630 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -67,10 +67,7 @@ all() -> _OS -> [unavailable] end. -load_api(suite) -> - []; -load_api(doc) -> - ["Test of load API functions"]; +%% Test of load API functions load_api(Config) when is_list(Config) -> %% nprocs() @@ -96,10 +93,7 @@ load_api(Config) when is_list(Config) -> ok. -util_api(suite) -> - []; -util_api(doc) -> - ["Test of utilization API functions"]; +%% Test of utilization API functions util_api(Config) when is_list(Config) -> %% Some useful funs when testing util/1 BusyP = fun({user, _Share}) -> true; @@ -156,10 +150,7 @@ util_api(Config) when is_list(Config) -> -define(SPIN_TIME, 1000). -util_values(suite) -> - []; -util_values(doc) -> - ["Test utilization values"]; +%% Test utilization values util_values(Config) when is_list(Config) -> Tester = self(), @@ -204,10 +195,7 @@ util_values(Config) when is_list(Config) -> % Outdated % The portprogram is now restarted if killed, and not by os_mon... -port(suite) -> - []; -port(doc) -> - ["Test that cpu_sup handles a terminating port program"]; +%% Test that cpu_sup handles a terminating port program port(Config) when is_list(Config) -> case cpu_sup_os_pid() of {ok, PidStr} -> @@ -243,17 +231,12 @@ port(Config) when is_list(Config) -> {skip, os_pid_not_found } end. -terminate(suite) -> - []; terminate(Config) when is_list(Config) -> ok = application:set_env(os_mon, start_cpu_sup, false), _ = supervisor:terminate_child(os_mon_sup, cpu_sup), ok. -unavailable(suite) -> - []; -unavailable(doc) -> - ["Test correct behaviour when service is unavailable"]; +%% Test correct behaviour when service is unavailable unavailable(Config) when is_list(Config) -> %% Make sure all API functions return their dummy values @@ -269,8 +252,6 @@ unavailable(Config) when is_list(Config) -> ok. -restart(suite) -> - []; restart(Config) when is_list(Config) -> ok = application:set_env(os_mon, start_cpu_sup, true), {ok, _Pid} = supervisor:restart_child(os_mon_sup, cpu_sup), diff --git a/lib/os_mon/test/disksup_SUITE.erl b/lib/os_mon/test/disksup_SUITE.erl index 0f0561571a..871f7cb3d2 100644 --- a/lib/os_mon/test/disksup_SUITE.erl +++ b/lib/os_mon/test/disksup_SUITE.erl @@ -66,8 +66,7 @@ all() -> _OS -> [unavailable] end. -api(suite) -> []; -api(doc) -> ["Test of API functions"]; +%% Test of API functions api(Config) when is_list(Config) -> %% get_disk_data() @@ -96,8 +95,7 @@ api(Config) when is_list(Config) -> ok. -config(suite) -> []; -config(doc) -> ["Test configuration"]; +%% Test configuration config(Config) when is_list(Config) -> %% Change configuration parameters and make sure change is reflected @@ -133,8 +131,8 @@ config(Config) when is_list(Config) -> %% changes too much during its course, or if there are timing problems %% with the alarm_handler receiving the alarms too late %%---------------------------------------------------------------------- -alarm(suite) -> []; -alarm(doc) -> ["Test that alarms are set and cleared"]; + +%% Test that alarms are set and cleared alarm(Config) when is_list(Config) -> %% Find out how many disks exceed the threshold @@ -257,9 +255,7 @@ until(Fun, [H|T]) -> end; until(_Fun, []) -> false. -port(suite) -> []; -port(doc) -> - ["Test that disksup handles a terminating port program"]; +%% Test that disksup handles a terminating port program port(Config) when is_list(Config) -> Str = os:cmd("ps -ef | grep '[d]isksup'"), case io_lib:fread("~s ~s", Str) of @@ -300,15 +296,12 @@ port(Config) when is_list(Config) -> {skip, {os_pid_not_found, Str}} end. -terminate(suite) -> []; terminate(Config) when is_list(Config) -> ok = application:set_env(os_mon, start_disksup, false), ok = supervisor:terminate_child(os_mon_sup, disksup), ok. -unavailable(suite) -> []; -unavailable(doc) -> - ["Test correct behaviour when service is unavailable"]; +%% Test correct behaviour when service is unavailable unavailable(Config) when is_list(Config) -> %% Make sure all API functions return their dummy values @@ -319,18 +312,14 @@ unavailable(Config) when is_list(Config) -> ok = disksup:set_almost_full_threshold(0.9), ok. -restart(suite) -> - []; restart(Config) when is_list(Config) -> ok = application:set_env(os_mon, start_disksup, true), ok = application:set_env(os_mon, disksup_posix_only, false), {ok, _Pid} = supervisor:restart_child(os_mon_sup, disksup), ok. -otp_5910(suite) -> []; -otp_5910(doc) -> - ["Test that alarms are cleared if disksup crashes or " - "if OS_Mon is stopped"]; +%% Test that alarms are cleared if disksup crashes or +%% if OS_Mon is stopped otp_5910(Config) when is_list(Config) -> %% Make sure disksup sets at least one alarm @@ -389,8 +378,7 @@ otp_5910(Config) when is_list(Config) -> ok = application:start(os_mon), ok. -posix_only(suite) -> []; -posix_only(doc) -> ["Test disksup_posix_only option"]; +%% Test disksup_posix_only option posix_only(Config) when is_list(Config) -> %% Set option and restart disksup ok = application:set_env(os_mon, disksup_posix_only, true), diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index 8c31a8c39a..ed78b1ab1c 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -61,10 +61,7 @@ all() -> All ++ Bugs. -api(suite) -> - []; -api(doc) -> - ["Test of API functions"]; +%% Test of API functions api(Config) when is_list(Config) -> %% get_memory_data() @@ -154,10 +151,8 @@ api(Config) when is_list(Config) -> %% NOTE: The test case is a bit weak as it will fail if the memory %% usage changes too much during its course. %%---------------------------------------------------------------------- -alarm1(suite) -> - []; -alarm1(doc) -> - ["Test alarms when memsup_system_only==false"]; + +%% Test alarms when memsup_system_only==false alarm1(Config) when is_list(Config) -> %% If system memory usage is too high, the testcase cannot @@ -298,10 +293,7 @@ alarm1(_Config, SysUsage) -> ok = memsup:set_check_interval(1), ok. -alarm2(suite) -> - []; -alarm2(doc) -> - ["Test alarms when memsup_system_only==true"]; +%% Test alarms when memsup_system_only==true alarm2(Config) when is_list(Config) -> %% If system memory usage is too high, the testcase cannot @@ -406,10 +398,7 @@ alarm_set(Alarm, [_|T]) -> alarm_set(_Alarm, []) -> false. -process(suite) -> - []; -process(doc) -> - ["Make sure memsup discovers a process grown very large"]; +%% Make sure memsup discovers a process grown very large process(Config) when is_list(Config) -> %% Set a long memory check interval, we will force memory checks @@ -452,10 +441,7 @@ new_hog_1(List) -> _Any -> exit(List) end. -config(suite) -> - []; -config(doc) -> - ["Test configuration"]; +%% Test configuration config(Config) when is_list(Config) -> %% Change configuration parameters and make sure change is reflected @@ -504,10 +490,7 @@ config(Config) when is_list(Config) -> ok. -unavailable(suite) -> - []; -unavailable(doc) -> - ["Test correct behaviour when service is unavailable"]; +%% Test correct behaviour when service is unavailable unavailable(Config) when is_list(Config) -> %% Close memsup @@ -536,10 +519,7 @@ unavailable(Config) when is_list(Config) -> ok. -timeout(suite) -> - []; -timeout(doc) -> - ["Test stability of memsup when data collection times out"]; +%% Test stability of memsup when data collection times out timeout(Config) when is_list(Config) -> %% Set a long memory check interval and memsup_helper timeout, @@ -591,10 +571,7 @@ timeout(Config) when is_list(Config) -> ok. -port(suite) -> - []; -port(doc) -> - ["Test that memsup handles a terminating port program"]; +%% Test that memsup handles a terminating port program port(Config) when is_list(Config) -> Str = os:cmd("ps -e | grep '[m]emsup'"), case io_lib:fread("~s", Str) of @@ -636,10 +613,7 @@ port(Config) when is_list(Config) -> {skip, {os_pid_not_found, Str}} end. -otp_5910(suite) -> - []; -otp_5910(doc) -> - ["Test that alarms are cleared and not set twice"]; +%% Test that alarms are cleared and not set twice otp_5910(Config) when is_list(Config) -> Alarms = [system_memory_high_watermark, process_memory_high_watermark], diff --git a/lib/os_mon/test/os_mon_SUITE.erl b/lib/os_mon/test/os_mon_SUITE.erl index af70dc2a6c..ace06796d6 100644 --- a/lib/os_mon/test/os_mon_SUITE.erl +++ b/lib/os_mon/test/os_mon_SUITE.erl @@ -36,10 +36,7 @@ all() -> _OS -> [app_file, appup_file] end. -app_file(suite) -> - []; -app_file(doc) -> - ["Testing .app file"]; +%% Testing .app file app_file(Config) when is_list(Config) -> ok = test_server:app_test(os_mon), ok. @@ -47,10 +44,7 @@ app_file(Config) when is_list(Config) -> appup_file(Config) when is_list(Config) -> ok = test_server:appup_test(os_mon). -config(suite) -> - []; -config(doc) -> - ["Test OS_Mon configuration"]; +%% Test OS_Mon configuration config(Config) when is_list(Config) -> IsReg = fun(Name) -> is_pid(whereis(Name)) end, diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index 3f5d2210a4..84487cd751 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -138,19 +138,15 @@ end_per_suite(Config) -> %%--------------------------------------------------------------------- %% Test cases %%--------------------------------------------------------------------- -load_unload(doc) -> - ["Test to unload and the reload the OTP.mib "]; -load_unload(suite) -> []; + +%% Test to unload and the reload the OTP.mib load_unload(Config) when is_list(Config) -> os_mon_mib:unload(snmp_master_agent), os_mon_mib:load(snmp_master_agent), ok. %%--------------------------------------------------------------------- -update_load_table(doc) -> - ["check os_mon_mib:update_load_table error handling"]; -update_load_table(suite) -> - []; +%% check os_mon_mib:update_load_table error handling update_load_table(Config) when is_list(Config) -> Node = start_node(), ok = rpc:call(Node,application,start,[sasl]), @@ -161,10 +157,7 @@ update_load_table(Config) when is_list(Config) -> stop_node(Node), ok. -otp_6351(doc) -> - ["like update_load_table, when memsup_system_only==true"]; -otp_6351(suite) -> - []; +%% like update_load_table, when memsup_system_only==true otp_6351(Config) when is_list(Config) -> Node = start_node(), ok = rpc:call(Node,application,start,[sasl]), @@ -185,11 +178,8 @@ otp_6351(Config) when is_list(Config) -> %%--------------------------------------------------------------------- -get_mem_sys_mark(doc) -> - ["Simulates a get call to test the instrumentation function " - "for the loadMemorySystemWatermark variable."]; -get_mem_sys_mark(suite) -> - []; +%% Simulates a get call to test the instrumentation function +%% for the loadMemorySystemWatermark variable. get_mem_sys_mark(Config) when is_list(Config) -> case os_mon_mib:mem_sys_mark(get) of {value, SysMark} when is_integer(SysMark) -> @@ -198,11 +188,8 @@ get_mem_sys_mark(Config) when is_list(Config) -> ct:fail(sys_mark_value_not_integer) end. %%--------------------------------------------------------------------- -get_mem_proc_mark(doc) -> - ["Simulates a get call to test the instrumentation function " - "for the loadMemoryErlProcWatermark variable."]; -get_mem_proc_mark(suite) -> - []; +%% Simulates a get call to test the instrumentation function +%% for the loadMemoryErlProcWatermark variable. get_mem_proc_mark(Config) when is_list(Config) -> case os_mon_mib:mem_proc_mark(get) of {value, ProcMark} when is_integer(ProcMark) -> @@ -211,11 +198,8 @@ get_mem_proc_mark(Config) when is_list(Config) -> ct:fail(proc_mark_value_not_integer) end. %%--------------------------------------------------------------------- -get_disk_threshold(doc) -> - ["Simulates a get call to test the instrumentation function " - "for the diskAlmostFullThreshold variable."]; -get_disk_threshold(suite) -> - []; +%% Simulates a get call to test the instrumentation function +%% for the diskAlmostFullThreshold variable. get_disk_threshold(Config) when is_list(Config) -> case os_mon_mib:disk_threshold(get) of {value, ProcMark} when is_integer(ProcMark) -> @@ -231,11 +215,8 @@ get_disk_threshold(Config) when is_list(Config) -> %%% instrumentation functions directly as done in most test cases in %%% this test suite -get_load_table(doc) -> - ["Simulates get calls to test the instrumentation function " - "for the loadTable"]; -get_load_table(suite) -> - []; +%% Simulates get calls to test the instrumentation function +%% for the loadTable get_load_table(Config) when is_list(Config) -> NodeStr = atom_to_list(node()), @@ -297,10 +278,6 @@ get_load_table(Config) when is_list(Config) -> ok. %%--------------------------------------------------------------------- -sys_tot_mem(doc) -> - []; -sys_tot_mem(suite) -> - []; sys_tot_mem(Config) when is_list(Config) -> [{[?loadSystemTotalMemory, Len | NodeStr], Mem}] = os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory]), @@ -314,9 +291,6 @@ sys_tot_mem(Config) when is_list(Config) -> ct:fail(sys_tot_mem_value_not_integer) end. -sys_used_mem(doc) -> - []; -sys_used_mem(suite) -> []; sys_used_mem(Config) when is_list(Config) -> [{[?loadSystemUsedMemory, Len | NodeStr], Mem}] = os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory]), @@ -330,10 +304,6 @@ sys_used_mem(Config) when is_list(Config) -> ct:fail(sys_used_mem_value_not_integer) end. -large_erl_process(doc) -> - []; -large_erl_process(suite) -> - []; large_erl_process(Config) when is_list(Config) -> {_, _, {Pid, _}} = memsup:get_memory_data(), PidStr = lists:flatten(io_lib:format("~w", [Pid])), @@ -343,10 +313,6 @@ large_erl_process(Config) when is_list(Config) -> true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), ok. -large_erl_process_mem(doc) -> - []; -large_erl_process_mem(suite) -> - []; large_erl_process_mem(Config) when is_list(Config) -> [{[?loadLargestErlProcessUsedMemory, Len | NodeStr], Mem}] = @@ -362,10 +328,6 @@ large_erl_process_mem(Config) when is_list(Config) -> ct:fail(erl_pid_mem_value_not_integer) end. -cpu_load(doc) -> - []; -cpu_load(suite) -> - []; cpu_load(Config) when is_list(Config) -> [{[?loadCpuLoad, Len | NodeStr], Load}] = os_mon_mib:load_table(get_next,[], [?loadCpuLoad]), @@ -379,10 +341,6 @@ cpu_load(Config) when is_list(Config) -> ct:fail(cpu_load_value_not_integer) end. -cpu_load5(doc) -> - []; -cpu_load5(suite) -> - []; cpu_load5(Config) when is_list(Config) -> [{[?loadCpuLoad5, Len | NodeStr], Load}] = os_mon_mib:load_table(get_next,[], [?loadCpuLoad5]), @@ -396,10 +354,6 @@ cpu_load5(Config) when is_list(Config) -> ct:fail(cpu_load5_value_not_integer) end. -cpu_load15(doc) -> - []; -cpu_load15(suite) -> - []; cpu_load15(Config) when is_list(Config) -> [{[?loadCpuLoad15, Len | NodeStr], Load}] = os_mon_mib:load_table(get_next,[], [?loadCpuLoad15]), @@ -413,10 +367,6 @@ cpu_load15(Config) when is_list(Config) -> ct:fail(cpu_load15_value_not_integer) end. -os_wordsize(doc) -> - []; -os_wordsize(suite) -> - []; os_wordsize(Config) when is_list(Config) -> [{[?loadOsWordsize, Len | NodeStr], Wordsize}] = os_mon_mib:load_table(get_next,[], [?loadOsWordsize]), @@ -430,10 +380,6 @@ os_wordsize(Config) when is_list(Config) -> ct:fail(os_wordsize_value_not_integer) end. -sys_tot_mem64(doc) -> - []; -sys_tot_mem64(suite) -> - []; sys_tot_mem64(Config) when is_list(Config) -> [{[?loadSystemTotalMemory64, Len | NodeStr], Mem}] = os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory64]), @@ -447,9 +393,6 @@ sys_tot_mem64(Config) when is_list(Config) -> ct:fail(sys_tot_mem_value_not_integer) end. -sys_used_mem64(doc) -> - []; -sys_used_mem64(suite) -> []; sys_used_mem64(Config) when is_list(Config) -> [{[?loadSystemUsedMemory64, Len | NodeStr], Mem}] = os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory64]), @@ -463,10 +406,6 @@ sys_used_mem64(Config) when is_list(Config) -> ct:fail(sys_used_mem_value_not_integer) end. -large_erl_process_mem64(doc) -> - []; -large_erl_process_mem64(suite) -> - []; large_erl_process_mem64(Config) when is_list(Config) -> [{[?loadLargestErlProcessUsedMemory64, Len | NodeStr], Mem}] = @@ -482,11 +421,8 @@ large_erl_process_mem64(Config) when is_list(Config) -> ct:fail(erl_pid_mem_value_not_integer) end. %%--------------------------------------------------------------------- -get_disk_table(doc) -> - ["Simulates get calls to test the instrumentation function " - "for the diskTable."]; -get_disk_table(suite) -> - []; +%% Simulates get calls to test the instrumentation function +%% for the diskTable. get_disk_table(Config) when is_list(Config) -> DiskData = disksup:get_disk_data(), @@ -536,10 +472,6 @@ get_disk_table(Config) when is_list(Config) -> %%--------------------------------------------------------------------- -disk_descr(doc) -> - []; -disk_descr(suite) -> - []; disk_descr(Config) when is_list(Config) -> [{[?diskDescr, 1,1], Descr}] = os_mon_mib:disk_table(get_next, [], [?diskDescr]), @@ -551,9 +483,6 @@ disk_descr(Config) when is_list(Config) -> ct:fail(disk_descr_value_not_a_string) end. -disk_kbytes(doc) -> - []; -disk_kbytes(suite) -> []; disk_kbytes(Config) when is_list(Config) -> [{[?diskKBytes, 1,1], Kbytes}] = os_mon_mib:disk_table(get_next,[], [?diskKBytes]), @@ -566,9 +495,6 @@ disk_kbytes(Config) when is_list(Config) -> end. -disk_capacity(doc) -> - []; -disk_capacity(suite) -> []; disk_capacity(Config) when is_list(Config) -> [{[?diskCapacity, 1,1], Capacity}] = os_mon_mib:disk_table(get_next,[], [?diskCapacity]), @@ -581,10 +507,8 @@ disk_capacity(Config) when is_list(Config) -> end. %%--------------------------------------------------------------------- -real_snmp_request(doc) -> - ["Starts an snmp manager and sends a real snmp-request. i.e. " - "sends a udp message on the correct format."]; -real_snmp_request(suite) -> []; +%% Starts an snmp manager and sends a real snmp-request. i.e. +%% sends a udp message on the correct format. real_snmp_request(Config) when is_list(Config) -> NodStr = atom_to_list(node()), Len = length(NodStr), @@ -602,11 +526,8 @@ real_snmp_request(Config) when is_list(Config) -> s, "<0.101.0>", Config), ok. -otp_7441(doc) -> - ["Starts an snmp manager and requests total memory. Was previously - integer32 which was errornous on 64 bit machines."]; -otp_7441(suite) -> - []; +%% Starts an snmp manager and requests total memory. Was previously +%% integer32 which was errornous on 64 bit machines. otp_7441(Config) when is_list(Config) -> NodStr = atom_to_list(node()), Len = length(NodStr), diff --git a/lib/os_mon/test/os_sup_SUITE.erl b/lib/os_mon/test/os_sup_SUITE.erl index 8065b0b50c..82c04ceaae 100644 --- a/lib/os_mon/test/os_sup_SUITE.erl +++ b/lib/os_mon/test/os_sup_SUITE.erl @@ -66,10 +66,7 @@ all() -> end. -message(suite) -> - []; -message(doc) -> - ["Test OS message handling"]; +%% Test OS message handling message(Config) when is_list(Config) -> %% Fake an OS message @@ -95,10 +92,7 @@ message(Config) when is_list(Config) -> ok. -config(suite) -> - []; -config(doc) -> - ["Test configuration"]; +%% Test configuration config(Config) when is_list(Config) -> %% os_sup_enable==true and os_sup_own/os_sup_syslogconf cannot @@ -110,10 +104,7 @@ config(Config) when is_list(Config) -> ok. -port(suite) -> - []; -port(doc) -> - ["Test that os_sup handles a terminating port program"]; +%% Test that os_sup handles a terminating port program port(Config) when is_list(Config) -> Str = os:cmd("ps -e | grep '[f]errule'"), case io_lib:fread("~s", Str) of -- cgit v1.2.3 From 05a99a4631fee28e0a5a690db094a2d675aae456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 1 Apr 2016 18:21:04 +0200 Subject: Don't crash in end_per_testcase --- lib/os_mon/test/disksup_SUITE.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/os_mon') diff --git a/lib/os_mon/test/disksup_SUITE.erl b/lib/os_mon/test/disksup_SUITE.erl index 871f7cb3d2..bd90093d29 100644 --- a/lib/os_mon/test/disksup_SUITE.erl +++ b/lib/os_mon/test/disksup_SUITE.erl @@ -315,8 +315,10 @@ unavailable(Config) when is_list(Config) -> restart(Config) when is_list(Config) -> ok = application:set_env(os_mon, start_disksup, true), ok = application:set_env(os_mon, disksup_posix_only, false), - {ok, _Pid} = supervisor:restart_child(os_mon_sup, disksup), - ok. + case supervisor:restart_child(os_mon_sup, disksup) of + {ok, _Pid} -> ok; + {error, running} -> ok + end. %% Test that alarms are cleared if disksup crashes or %% if OS_Mon is stopped -- cgit v1.2.3