Skip to content

Commit

Permalink
Merge branch 'dgud/testcasecuddling'
Browse files Browse the repository at this point in the history
* dgud/testcasecuddling:
  os_mon: test tweaks
  kernel: tweak tests
  mnesia: test harder sync
  mnesia: Dialyzer fixes
  stdlib: loosen testcases
  wx: loosen testcase
  • Loading branch information
dgud committed Mar 28, 2014
2 parents 5b9ffc7 + 4f63cca commit 95ffe7e
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 124 deletions.
15 changes: 10 additions & 5 deletions lib/kernel/test/gen_tcp_misc_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%% Copyright Ericsson AB 1998-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -74,6 +74,9 @@ init_per_testcase(accept_system_limit, Config) when is_list(Config) ->
Dog = test_server:timetrap(test_server:seconds(240)),
[{watchdog,Dog}|Config]
end;
init_per_testcase(wrapping_oct, Config) when is_list(Config) ->
Dog = test_server:timetrap(test_server:seconds(600)),
[{watchdog, Dog}|Config];
init_per_testcase(_Func, Config) when is_list(Config) ->
Dog = test_server:timetrap(test_server:seconds(240)),
[{watchdog, Dog}|Config].
Expand Down Expand Up @@ -553,7 +556,6 @@ otp_3924(Config) when is_list(Config) ->
otp_3924_1(MaxDelay).

otp_3924_1(MaxDelay) ->
Dog = test_server:timetrap(test_server:seconds(240)),
?line {ok, Node} = start_node(otp_3924),
?line DataLen = 100*1024,
?line Data = otp_3924_data(DataLen),
Expand All @@ -564,7 +566,6 @@ otp_3924_1(MaxDelay) ->
?line ok = otp_3924(MaxDelay, Node, Data, DataLen, N)
end),
?line test_server:stop_node(Node),
test_server:timetrap_cancel(Dog),
ok.

otp_3924(MaxDelay, Node, Data, DataLen, N) ->
Expand Down Expand Up @@ -1969,7 +1970,9 @@ accept_system_limit(doc) ->
accept_system_limit(Config) when is_list(Config) ->
?line {ok, LS} = gen_tcp:listen(0, []),
?line {ok, TcpPort} = inet:port(LS),
?line Connector = spawn_link(fun () -> connector(TcpPort) end),
Me = self(),
?line Connector = spawn_link(fun () -> connector(TcpPort, Me) end),
receive {Connector, sync} -> Connector ! {self(), continue} end,
?line ok = acceptor(LS, false, []),
?line Connector ! stop,
ok.
Expand All @@ -1986,8 +1989,10 @@ acceptor(LS, GotSL, A) ->
error
end.

connector(TcpPort) ->
connector(TcpPort, Tester) ->
ManyPorts = open_ports([]),
Tester ! {self(), sync},
receive {Tester, continue} -> timer:sleep(100) end,
ConnF = fun (Port) ->
case catch gen_tcp:connect({127,0,0,1}, TcpPort, []) of
{ok, Sock} ->
Expand Down
8 changes: 4 additions & 4 deletions lib/kernel/test/heart_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -93,10 +93,10 @@ start_check(Type, Name) ->
start_check(Type, Name, []).
start_check(Type, Name, Envs) ->
Args = case ?t:os_type() of
{win32,_} ->
"-heart " ++ env_encode([{"HEART_COMMAND", no_reboot}|Envs]);
{win32,_} ->
"+t50000 -heart " ++ env_encode([{"HEART_COMMAND", no_reboot}|Envs]);
_ ->
"-heart " ++ env_encode(Envs)
"+t50000 -heart " ++ env_encode(Envs)
end,
{ok, Node} = case Type of
loose ->
Expand Down
4 changes: 2 additions & 2 deletions lib/mnesia/src/mnesia.hrl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -35,7 +35,7 @@
-define(ets_last(Tab), ets:last(Tab)).
-define(ets_prev(Tab, Key), ets:prev(Tab, Key)).
-define(ets_slot(Tab, Pos), ets:slot(Tab, Pos)).
-define(ets_new_table(Tab, Props), ets:new(Tab, Props)).
-define(ets_new_table(Tab, Props), _ = ets:new(Tab, Props)).
-define(ets_delete_table(Tab), ets:delete(Tab)).
-define(ets_fixtable(Tab, Bool), ets:fixtable(Tab, Bool)).

Expand Down
6 changes: 5 additions & 1 deletion lib/mnesia/src/mnesia_index.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@

val(Var) ->
case ?catch_val(Var) of
{'EXIT', _ReASoN_} -> mnesia_lib:other_val(Var, _ReASoN_);
{'EXIT', _ReASoN_} ->
case mnesia_lib:other_val(Var) of
error -> mnesia_lib:pr_other(Var, _ReASoN_);
Val -> Val
end;
_VaLuE_ -> _VaLuE_
end.

Expand Down
13 changes: 9 additions & 4 deletions lib/mnesia/src/mnesia_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
mkcore/1,
not_active_here/1,
other_val/2,
other_val/1,
pr_other/2,
overload_read/0,
overload_read/1,
overload_set/2,
Expand Down Expand Up @@ -389,16 +391,19 @@ unset(Var) ->
?ets_delete(mnesia_gvar, Var).

other_val(Var, Other) ->
case other_val(Var) of
error -> pr_other(Var, Other);
Val -> Val
end.

other_val(Var) ->
case Var of
{_, where_to_read} -> nowhere;
{_, where_to_write} -> [];
{_, active_replicas} -> [];
_ ->
pr_other(Var, Other)
_ -> error
end.

-spec pr_other(_,_) -> no_return().

pr_other(Var, Other) ->
Why =
case is_running() of
Expand Down
3 changes: 2 additions & 1 deletion lib/mnesia/src/mnesia_locker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ try_sticky_lock(Tid, Op, Pid, {Tab, _} = Oid) ->
try_lock(Tid, Op, Pid, Oid);
[{_,N}] ->
Req = {Pid, {Op, Tid, Oid}},
Pid ! {?MODULE, node(), {switch, N, Req}}
Pid ! {?MODULE, node(), {switch, N, Req}},
true
end.

try_lock(Tid, read_write, Pid, Oid) ->
Expand Down
6 changes: 5 additions & 1 deletion lib/mnesia/src/mnesia_recover.erl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ log_decision(D) ->

val(Var) ->
case ?catch_val(Var) of
{'EXIT', Reason} -> mnesia_lib:other_val(Var, Reason);
{'EXIT', Reason} ->
case mnesia_lib:other_val(Var) of
error -> mnesia_lib:pr_other(Var, Reason);
Val -> Val
end;
Value -> Value
end.

Expand Down
8 changes: 6 additions & 2 deletions lib/mnesia/src/mnesia_snmp_hook.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -32,7 +32,11 @@

val(Var) ->
case ?catch_val(Var) of
{'EXIT', _ReASoN_} -> mnesia_lib:other_val(Var, _ReASoN_);
{'EXIT', _ReASoN_} ->
case mnesia_lib:other_val(Var) of
error -> mnesia_lib:pr_other(Var, _ReASoN_);
Val -> Val
end;
_VaLuE_ -> _VaLuE_
end.

Expand Down
7 changes: 4 additions & 3 deletions lib/mnesia/test/mnesia_config_test.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%% Copyright Ericsson AB 1997-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -639,10 +639,10 @@ send_compressed(Config) ->
end,

?match([], mnesia_test_lib:kill_mnesia([N2])),

sys:get_status(mnesia_monitor), %% sync N1
?match([], mnesia_test_lib:kill_mnesia([N1])),
?match(ok, mnesia:start([{send_compressed, 9}])),
?match(ok, mnesia:wait_for_tables([t0,t1,t2], 5000)),
?match(ok, mnesia:wait_for_tables([t0,t1,t2], 25000)),

?match({atomic, ok}, mnesia:transaction(Create, [t0])),
?match({atomic, ok}, mnesia:transaction(Create, [t1])),
Expand Down Expand Up @@ -1158,6 +1158,7 @@ dynamic_basic(Config) when is_list(Config) ->

%%% SYNC!!!
timer:sleep(1000),
sys:get_status(mnesia_monitor),

?match([N3,N1], sort(rpc:call(N1, mnesia, system_info, [running_db_nodes]))),
?match([N3,N1], sort(rpc:call(N3, mnesia, system_info, [running_db_nodes]))),
Expand Down
11 changes: 7 additions & 4 deletions lib/mnesia/test/mnesia_evil_coverage_test.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -671,13 +671,16 @@ add_copy_when_going_down(Config) ->
?acquire_nodes(2, Config ++ [{tc_timeout, timer:minutes(2)}]),
?match({atomic, ok}, mnesia:create_table(a, [{ram_copies, [Node1]}])),
%% Grab a write lock
Tester = self(),
WriteAndWait = fun() ->
mnesia:write({a,1,1}),
receive continue -> ok
Tester ! {self(), got_lock},
receive continue -> ok
end
end,
_Lock = spawn(fun() -> mnesia:transaction(WriteAndWait) end),
Tester = self(),
Locker = spawn(fun() -> mnesia:transaction(WriteAndWait) end),
receive {Locker, got_lock} -> ok end,

spawn_link(fun() -> Res = rpc:call(Node2, mnesia, add_table_copy,
[a, Node2, ram_copies]),
Tester ! {test, Res}
Expand Down
6 changes: 3 additions & 3 deletions lib/os_mon/test/cpu_sup_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%% Copyright Ericsson AB 2002-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -257,8 +257,8 @@ port(Config) when is_list(Config) ->
terminate(suite) ->
[];
terminate(Config) when is_list(Config) ->
?line ok = application:set_env(os_mon, start_cpu_sup, false),
?line ok = supervisor:terminate_child(os_mon_sup, cpu_sup),
ok = application:set_env(os_mon, start_cpu_sup, false),
_ = supervisor:terminate_child(os_mon_sup, cpu_sup),
ok.

unavailable(suite) ->
Expand Down
17 changes: 9 additions & 8 deletions lib/os_mon/test/disksup_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -350,15 +350,16 @@ otp_5910(doc) ->
otp_5910(Config) when is_list(Config) ->

%% Make sure disksup sets at least one alarm
Data = disksup:get_disk_data(),
Data = lists:sort(disksup:get_disk_data()),
Threshold0 = disksup:get_almost_full_threshold(),
Threshold = case over_threshold(Data, Threshold0) of
0 ->
[{_Id,_Kbyte,Cap}|_] = Data,
ok = disksup:set_almost_full_threshold((Cap-1)/100),
Cap-1;
_N -> Threshold0
end,
0 ->
[{_Id,_Kbyte,Cap}|_] = Data,
io:format("Data ~p Threshold ~p ~n",[Data, Cap-1]),
ok = disksup:set_almost_full_threshold((Cap-1)/100),
Cap-1;
_N -> Threshold0
end,
ok = application:set_env(os_mon, disk_almost_full_threshold, Threshold/100),
disksup ! timeout, % force a disk check
Data2 = disksup:get_disk_data(),
Expand Down
4 changes: 2 additions & 2 deletions lib/stdlib/test/binary_module_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%% Copyright Ericsson AB 1997-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -40,7 +40,7 @@
-export([init_per_testcase/2, end_per_testcase/2]).
% Default timetrap timeout (set in init_per_testcase).
% Some of these testcases are really heavy...
-define(default_timeout, ?t:minutes(20)).
-define(default_timeout, ?t:minutes(30)).

-endif.

Expand Down
41 changes: 19 additions & 22 deletions lib/stdlib/test/dets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3953,15 +3953,6 @@ otp_11709(Config) when is_list(Config) ->
%% Parts common to several test cases
%%

start_node_rel(Name, Rel, How) ->
Release = [{release, atom_to_list(Rel)}],
Pa = filename:dirname(code:which(?MODULE)),
test_server:start_node(Name, How,
[{args,
" -kernel net_setuptime 100 "
" -pa " ++ Pa},
{erl, Release}]).

crash(File, Where) ->
crash(File, Where, 10).

Expand Down Expand Up @@ -4352,7 +4343,7 @@ check_badarg({'EXIT', {badarg, [{M,F,Args,_} | _]}}, M, F, Args) ->
check_badarg({'EXIT', {badarg, [{M,F,A,_} | _]}}, M, F, Args) ->
true = test_server:is_native(M) andalso length(Args) =:= A.

check_pps(P0) ->
check_pps({Ports0,Procs0} = P0) ->
case pps() of
P0 ->
ok;
Expand All @@ -4364,22 +4355,28 @@ check_pps(P0) ->
case pps() of
P0 ->
ok;
P1 ->
io:format("failure, got ~p~n, expected ~p\n", [P1, P0]),
{Ports0,Procs0} = P0,
{Ports1,Procs1} = P1,
show("Old ports", Ports0 -- Ports1),
show("New ports", Ports1 -- Ports0),
show("Old procs", Procs0 -- Procs1),
show("New procs", Procs1 -- Procs0),
?t:fail()
end
{Ports1,Procs1} = P1 ->
case {Ports1 -- Ports0, Procs1 -- Procs0} of
{[], []} -> ok;
{PortsDiff,ProcsDiff} ->
io:format("failure, got ~p~n, expected ~p\n", [P1, P0]),
show("Old port", Ports0 -- Ports1),
show("New port", PortsDiff),
show("Old proc", Procs0 -- Procs1),
show("New proc", ProcsDiff),
?t:fail()
end
end
end.

show(_S, []) ->
ok;
show(S, L) ->
io:format("~s: ~p~n", [S, L]).
show(S, [Pid|Pids]) when is_pid(Pid) ->
io:format("~s: ~p~n", [S, erlang:process_info(Pid)]),
show(S, Pids);
show(S, [Port|Ports]) when is_port(Port)->
io:format("~s: ~p~n", [S, erlang:port_info(Port)]),
show(S, Ports).

pps() ->
dets:start(),
Expand Down
Loading

0 comments on commit 95ffe7e

Please sign in to comment.