Skip to content

Commit

Permalink
kernel tests: modernize guard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorng committed Jan 29, 2010
1 parent 0cd1623 commit fc1ddbb
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 96 deletions.
34 changes: 17 additions & 17 deletions lib/kernel/test/bif_SUITE.erl
Expand Up @@ -66,7 +66,7 @@ spawn_opt_tests(suite) ->
spawn1(doc) -> ["Test spawn/1"];
spawn1(suite) ->
[];
spawn1(Config) when list(Config) ->
spawn1(Config) when is_list(Config) ->
?line Node = node(),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand All @@ -83,7 +83,7 @@ spawn1(Config) when list(Config) ->
spawn2(doc) -> ["Test spawn/2"];
spawn2(suite) ->
[];
spawn2(Config) when list(Config) ->
spawn2(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn2),

?line Parent = self(),
Expand All @@ -105,7 +105,7 @@ spawn2(Config) when list(Config) ->
spawn3(doc) -> ["Test spawn/3"];
spawn3(suite) ->
[];
spawn3(Config) when list(Config) ->
spawn3(Config) when is_list(Config) ->
?line Node = node(),

?line Parent = self(),
Expand All @@ -127,7 +127,7 @@ spawn3(Config) when list(Config) ->
spawn4(doc) -> ["Test spawn/4"];
spawn4(suite) ->
[];
spawn4(Config) when list(Config) ->
spawn4(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn4),

?line Parent = self(),
Expand All @@ -154,7 +154,7 @@ spawn4(Config) when list(Config) ->
spawn_link1(doc) -> ["Test spawn_link/1"];
spawn_link1(suite) ->
[];
spawn_link1(Config) when list(Config) ->
spawn_link1(Config) when is_list(Config) ->
?line Node = node(),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand All @@ -171,7 +171,7 @@ spawn_link1(Config) when list(Config) ->
spawn_link2(doc) -> ["Test spawn_link/2"];
spawn_link2(suite) ->
[];
spawn_link2(Config) when list(Config) ->
spawn_link2(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn_link2),

?line Parent = self(),
Expand All @@ -192,7 +192,7 @@ spawn_link2(Config) when list(Config) ->
spawn_link3(doc) -> ["Test spawn_link/3"];
spawn_link3(suite) ->
[];
spawn_link3(Config) when list(Config) ->
spawn_link3(Config) when is_list(Config) ->
?line Node = node(),

?line Parent = self(),
Expand All @@ -214,7 +214,7 @@ spawn_link3(Config) when list(Config) ->
spawn_link4(doc) -> ["Test spawn_link/4"];
spawn_link4(suite) ->
[];
spawn_link4(Config) when list(Config) ->
spawn_link4(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn_link4),

?line Parent = self(),
Expand All @@ -240,7 +240,7 @@ spawn_link4(Config) when list(Config) ->
spawn_opt2(doc) -> ["Test spawn_opt/2"];
spawn_opt2(suite) ->
[];
spawn_opt2(Config) when list(Config) ->
spawn_opt2(Config) when is_list(Config) ->
?line Node = node(),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand Down Expand Up @@ -275,7 +275,7 @@ spawn_opt2(Config) when list(Config) ->
spawn_opt3(doc) -> ["Test spawn_opt/3"];
spawn_opt3(suite) ->
[];
spawn_opt3(Config) when list(Config) ->
spawn_opt3(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn_opt3),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand Down Expand Up @@ -312,7 +312,7 @@ spawn_opt3(Config) when list(Config) ->
spawn_opt4(doc) -> ["Test spawn_opt/4"];
spawn_opt4(suite) ->
[];
spawn_opt4(Config) when list(Config) ->
spawn_opt4(Config) when is_list(Config) ->
?line Node = node(),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand Down Expand Up @@ -352,7 +352,7 @@ spawn_opt4(Config) when list(Config) ->
spawn_opt5(doc) -> ["Test spawn_opt/5"];
spawn_opt5(suite) ->
[];
spawn_opt5(Config) when list(Config) ->
spawn_opt5(Config) when is_list(Config) ->
?line {ok, Node} = start_node(spawn_opt5),
?line Parent = self(),
?line {_, _, FA, _} = fetch_proc_vals(self()),
Expand Down Expand Up @@ -396,7 +396,7 @@ spawn_failures(doc) ->
["Test failure behavior of spawn bifs"];
spawn_failures(suite) ->
[];
spawn_failures(Config) when list(Config) ->
spawn_failures(Config) when is_list(Config) ->
?line ThisNode = node(),
?line {ok, Node} = start_node(spawn_remote_failure),

Expand Down Expand Up @@ -556,7 +556,7 @@ wilderness(doc) ->
"wilderness of the heap are interpreted correct by the emulator "];
wilderness(suite) ->
[];
wilderness(Config) when list(Config) ->
wilderness(Config) when is_list(Config) ->
?line Dog = ?t:timetrap(?default_timeout),
?line OKParams = {512, 8},
?line Alloc = erlang:system_info(allocator),
Expand Down Expand Up @@ -604,11 +604,11 @@ run_wilderness_test({Set_tt, Set_tp}, {Exp_tt, Exp_tp}) ->
end,
stop_node(Node).

to_string(X) when integer(X) ->
to_string(X) when is_integer(X) ->
integer_to_list(X);
to_string(X) when atom(X) ->
to_string(X) when is_atom(X) ->
atom_to_list(X);
to_string(X) when list(X) ->
to_string(X) when is_list(X) ->
X.

get_nodenames(N, T) ->
Expand Down
2 changes: 1 addition & 1 deletion lib/kernel/test/cleanup.erl
Expand Up @@ -31,7 +31,7 @@ cleanup(_) ->
?line case nodes() of
[] ->
ok;
Nodes when list(Nodes) ->
Nodes when is_list(Nodes) ->
Kill = fun(Node) -> spawn(Node, erlang, halt, []) end,
?line lists:foreach(Kill, Nodes),
?line test_server:fail({nodes_left, Nodes})
Expand Down
36 changes: 18 additions & 18 deletions lib/kernel/test/erl_distribution_SUITE.erl
Expand Up @@ -62,7 +62,7 @@ all(suite) ->
table_waste, net_setuptime,
monitor_nodes].

init_per_testcase(Func, Config) when atom(Func), list(Config) ->
init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
Dog=?t:timetrap(?t:minutes(4)),
[{watchdog, Dog}|Config].

Expand All @@ -72,7 +72,7 @@ fin_per_testcase(_Func, Config) ->

tick(suite) -> [];
tick(doc) -> [];
tick(Config) when list(Config) ->
tick(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(120)),
PaDir = filename:dirname(code:which(erl_distribution_SUITE)),

Expand Down Expand Up @@ -119,7 +119,7 @@ tick(Config) when list(Config) ->
monitor_node(Node, true),

receive
{tick_test, T} when integer(T) ->
{tick_test, T} when is_integer(T) ->
stop_node(ServNode),
stop_node(Node),
T;
Expand All @@ -141,7 +141,7 @@ table_waste(doc) ->
["Checks that pinging nonexistyent nodes does not waste space in distribution table"];
table_waste(suite) ->
[];
table_waste(Config) when list(Config) ->
table_waste(Config) when is_list(Config) ->
?line {ok, HName} = inet:gethostname(),
F = fun(0,_F) -> [];
(N,F) ->
Expand All @@ -161,7 +161,7 @@ illegal_nodenames(doc) ->
["Test that pinging an illegal nodename does not kill the node"];
illegal_nodenames(suite) ->
[];
illegal_nodenames(Config) when list(Config) ->
illegal_nodenames(Config) when is_list(Config) ->
?line Dog=?t:timetrap(?t:minutes(2)),
PaDir = filename:dirname(code:which(erl_distribution_SUITE)),
?line {ok, Node}=start_node(illegal_nodenames, "-pa " ++ PaDir),
Expand Down Expand Up @@ -269,12 +269,12 @@ tick_cli_test1(Node) ->

tick_change(doc) -> ["OTP-4255"];
tick_change(suite) -> [];
tick_change(Config) when list(Config) ->
tick_change(Config) when is_list(Config) ->
?line PaDir = filename:dirname(code:which(?MODULE)),
?line [BN, CN] = get_nodenames(2, tick_change),
?line DefaultTT = net_kernel:get_net_ticktime(),
?line case DefaultTT of
I when integer(I) -> ?line ok;
I when is_integer(I) -> ?line ok;
_ -> ?line ?t:fail(DefaultTT)
end,

Expand Down Expand Up @@ -445,7 +445,7 @@ hidden_node(doc) ->
["Basic test of hidden node"];
hidden_node(suite) ->
[];
hidden_node(Config) when list(Config) ->
hidden_node(Config) when is_list(Config) ->
?line Dog = ?t:timetrap(?t:seconds(40)),
PaDir = filename:dirname(code:which(?MODULE)),
VArgs = "-pa " ++ PaDir,
Expand Down Expand Up @@ -548,7 +548,7 @@ monitor_nodes(suite) ->

monitor_nodes_nodedown_reason(doc) -> [];
monitor_nodes_nodedown_reason(suite) -> [];
monitor_nodes_nodedown_reason(Config) when list(Config) ->
monitor_nodes_nodedown_reason(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line ok = net_kernel:monitor_nodes(true),
?line ok = net_kernel:monitor_nodes(true, [nodedown_reason]),
Expand Down Expand Up @@ -603,7 +603,7 @@ monitor_nodes_nodedown_reason(Config) when list(Config) ->

monitor_nodes_complex_nodedown_reason(doc) -> [];
monitor_nodes_complex_nodedown_reason(suite) -> [];
monitor_nodes_complex_nodedown_reason(Config) when list(Config) ->
monitor_nodes_complex_nodedown_reason(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line Me = self(),
?line ok = net_kernel:monitor_nodes(true, [nodedown_reason]),
Expand Down Expand Up @@ -885,7 +885,7 @@ monitor_nodes_errors(doc) ->
[];
monitor_nodes_errors(suite) ->
[];
monitor_nodes_errors(Config) when list(Config) ->
monitor_nodes_errors(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line error = net_kernel:monitor_nodes(asdf),
?line {error,
Expand Down Expand Up @@ -922,7 +922,7 @@ monitor_nodes_combinations(doc) ->
[];
monitor_nodes_combinations(suite) ->
[];
monitor_nodes_combinations(Config) when list(Config) ->
monitor_nodes_combinations(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line monitor_nodes_all_comb(true),
?line [VisibleName, HiddenName] = get_nodenames(2,
Expand Down Expand Up @@ -1044,7 +1044,7 @@ monitor_nodes_cleanup(doc) ->
[];
monitor_nodes_cleanup(suite) ->
[];
monitor_nodes_cleanup(Config) when list(Config) ->
monitor_nodes_cleanup(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line Me = self(),
?line No = monitor_nodes_all_comb(true),
Expand Down Expand Up @@ -1076,7 +1076,7 @@ monitor_nodes_many(doc) ->
[];
monitor_nodes_many(suite) ->
[];
monitor_nodes_many(Config) when list(Config) ->
monitor_nodes_many(Config) when is_list(Config) ->
?line MonNodeState = monitor_node_state(),
?line [Name] = get_nodenames(1, monitor_nodes_many),
%% We want to perform more than 2^16 net_kernel:monitor_nodes
Expand Down Expand Up @@ -1139,10 +1139,10 @@ start_node(Name, Param, this) ->
start_node(Name, Param, "this") ->
NewParam = Param ++ " -pa " ++ filename:dirname(code:which(?MODULE)),
?t:start_node(Name, peer, [{args, NewParam}, {erl, [this]}]);
start_node(Name, Param, Rel) when atom(Rel) ->
start_node(Name, Param, Rel) when is_atom(Rel) ->
NewParam = Param ++ " -pa " ++ filename:dirname(code:which(?MODULE)),
?t:start_node(Name, peer, [{args, NewParam}, {erl, [{release, atom_to_list(Rel)}]}]);
start_node(Name, Param, Rel) when list(Rel) ->
start_node(Name, Param, Rel) when is_list(Rel) ->
NewParam = Param ++ " -pa " ++ filename:dirname(code:which(?MODULE)),
?t:start_node(Name, peer, [{args, NewParam}, {erl, [{release, Rel}]}]).

Expand Down Expand Up @@ -1216,9 +1216,9 @@ wait_until(Fun) ->
end
end.

repeat(Fun, 0) when function(Fun) ->
repeat(Fun, 0) when is_function(Fun) ->
ok;
repeat(Fun, N) when function(Fun), integer(N), N > 0 ->
repeat(Fun, N) when is_function(Fun), is_integer(N), N > 0 ->
Fun(),
repeat(Fun, N-1).

Expand Down
22 changes: 11 additions & 11 deletions lib/kernel/test/error_logger_SUITE.erl
Expand Up @@ -45,7 +45,7 @@ all(suite) ->

error_report(suite) -> [];
error_report(doc) -> [];
error_report(Config) when list(Config) ->
error_report(Config) when is_list(Config) ->
?line error_logger:add_report_handler(?MODULE, self()),
Rep1 = [{tag1,"data1"},{tag2,data2},{tag3,3}],
Rep2 = [testing,"testing",{tag1,"tag1"}],
Expand Down Expand Up @@ -85,7 +85,7 @@ error_report(Config) when list(Config) ->

info_report(suite) -> [];
info_report(doc) -> [];
info_report(Config) when list(Config) ->
info_report(Config) when is_list(Config) ->
?line error_logger:add_report_handler(?MODULE, self()),
Rep1 = [{tag1,"data1"},{tag2,data2},{tag3,3}],
Rep2 = [testing,"testing",{tag1,"tag1"}],
Expand Down Expand Up @@ -125,7 +125,7 @@ info_report(Config) when list(Config) ->

error(suite) -> [];
error(doc) -> [];
error(Config) when list(Config) ->
error(Config) when is_list(Config) ->
?line error_logger:add_report_handler(?MODULE, self()),
Msg1 = "This is a plain text string~n",
Msg2 = "This is a text with arguments ~p~n",
Expand Down Expand Up @@ -160,7 +160,7 @@ error(Config) when list(Config) ->

info(suite) -> [];
info(doc) -> [];
info(Config) when list(Config) ->
info(Config) when is_list(Config) ->
?line error_logger:add_report_handler(?MODULE, self()),
Msg1 = "This is a plain text string~n",
Msg2 = "This is a text with arguments ~p~n",
Expand Down Expand Up @@ -188,7 +188,7 @@ info(Config) when list(Config) ->

emulator(suite) -> [];
emulator(doc) -> [];
emulator(Config) when list(Config) ->
emulator(Config) when is_list(Config) ->
?line error_logger:add_report_handler(?MODULE, self()),
spawn(?MODULE, generate_error, []),
reported(emulator),
Expand All @@ -215,7 +215,7 @@ tty(Config) when is_list(Config) ->

logfile(suite) -> [];
logfile(doc) -> [];
logfile(Config) when list(Config) ->
logfile(Config) when is_list(Config) ->
?line case error_logger:logfile(filename) of
{error, no_log_file} -> % Ok, we continues.
do_logfile();
Expand All @@ -236,7 +236,7 @@ do_logfile() ->

add(suite) -> [];
add(doc) -> [];
add(Config) when list(Config) ->
add(Config) when is_list(Config) ->
?line {'EXIT',_} = (catch error_logger:add_report_handler("dummy")),
?line {'EXIT',_} = error_logger:add_report_handler(non_existing),
?line my_error = error_logger:add_report_handler(?MODULE, [error]),
Expand All @@ -246,7 +246,7 @@ add(Config) when list(Config) ->

delete(suite) -> [];
delete(doc) -> [];
delete(Config) when list(Config) ->
delete(Config) when is_list(Config) ->
?line {'EXIT',_} = (catch error_logger:delete_report_handler("dummy")),
?line {error,_} = error_logger:delete_report_handler(non_existing),
ok.
Expand All @@ -265,7 +265,7 @@ reported(Tag, Type, Report) ->

reported(emulator) ->
receive
{error, "~s~n", String} when list(String) ->
{error, "~s~n", String} when is_list(String) ->
test_server:messages_get(),
ok
after 1000 ->
Expand All @@ -277,9 +277,9 @@ reported(emulator) ->
%% Sends a notification to the Tester process about the events
%% generated by the Tester process.
%%-----------------------------------------------------------------
init(Tester) when pid(Tester) ->
init(Tester) when is_pid(Tester) ->
{ok, Tester};
init(Config) when list(Config) ->
init(Config) when is_list(Config) ->
my_error.

handle_event({Tag, _GL, {_EPid, Type, Report}}, Tester) ->
Expand Down

0 comments on commit fc1ddbb

Please sign in to comment.