aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2013-08-07 09:21:30 +0200
committerPeter Andersson <[email protected]>2013-08-07 09:21:30 +0200
commitbba7712d2b507163bbde9a8c9c5858bb3ede9857 (patch)
treeba471811589b9e790945eaf4eeef3c4e8ceddea5
parent7a99d823c96d8db0504b574420c9537b3a154425 (diff)
parent6ed736d1d5e00b4264d2928c555a2c347941dc10 (diff)
downloadotp-bba7712d2b507163bbde9a8c9c5858bb3ede9857.tar.gz
otp-bba7712d2b507163bbde9a8c9c5858bb3ede9857.tar.bz2
otp-bba7712d2b507163bbde9a8c9c5858bb3ede9857.zip
Merge branch 'maint'
-rw-r--r--lib/common_test/src/ct_logs.erl30
-rw-r--r--lib/common_test/src/ct_util.erl15
-rw-r--r--lib/common_test/test/ct_test_support.erl14
-rw-r--r--lib/common_test/test/ct_verbosity_SUITE.erl26
4 files changed, 69 insertions, 16 deletions
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index f5355bfefe..bd37b690b6 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -446,6 +446,8 @@ tc_print(Category,Importance,Format,Args) ->
ct_util:get_verbosity('$unspecified');
{error,bad_invocation} ->
?MAX_VERBOSITY;
+ {error,_Failure} ->
+ ?MAX_VERBOSITY;
Val ->
Val
end,
@@ -690,14 +692,15 @@ logger_loop(State) ->
false ->
%% Group leader is dead, so write to the
%% CtLog or unexpected_io log instead
- unexpected_io(Pid,Category,List,State),
+ unexpected_io(Pid,Category,Importance,
+ List,State),
logger_loop(State)
end;
{ct_log,_Fd,TCGLs} ->
%% If category is ct_internal then write
%% to ct_log, else write to unexpected_io
%% log
- unexpected_io(Pid,Category,List,State),
+ unexpected_io(Pid,Category,Importance,List,State),
logger_loop(State#logger_state{
tc_groupleaders = TCGLs})
end;
@@ -798,7 +801,7 @@ print_to_log(sync, FromPid, Category, TCGL, List, State) ->
IoFun = create_io_fun(FromPid, State),
io:format(TCGL,"~ts", [lists:foldl(IoFun, [], List)]);
true ->
- unexpected_io(FromPid,Category,List,State)
+ unexpected_io(FromPid,Category,?MAX_IMPORTANCE,List,State)
end,
State;
@@ -814,7 +817,8 @@ print_to_log(async, FromPid, Category, TCGL, List, State) ->
end;
true ->
fun() ->
- unexpected_io(FromPid,Category,List,State)
+ unexpected_io(FromPid,Category,?MAX_IMPORTANCE,
+ List,State)
end
end,
case State#logger_state.async_print_jobs of
@@ -3066,10 +3070,20 @@ html_encoding(latin1) ->
html_encoding(utf8) ->
"utf-8".
-unexpected_io(Pid,ct_internal,List,#logger_state{ct_log_fd=Fd}=State) ->
+unexpected_io(Pid,ct_internal,_Importance,List,State) ->
IoFun = create_io_fun(Pid,State),
- io:format(Fd, "~ts", [lists:foldl(IoFun, [], List)]);
-unexpected_io(Pid,_Category,List,State) ->
+ io:format(State#logger_state.ct_log_fd, "~ts",
+ [lists:foldl(IoFun, [], List)]);
+unexpected_io(Pid,Category,Importance,List,State) ->
IoFun = create_io_fun(Pid,State),
Data = io_lib:format("~ts", [lists:foldl(IoFun, [], List)]),
- test_server_io:print_unexpected(Data).
+ %% if unexpected io comes in during startup or shutdown, test_server
+ %% might not be running - if so (noproc exit), simply print to
+ %% stdout instead (will result in double printouts when pal is used)
+ try test_server_io:print_unexpected(Data) of
+ _ ->
+ ok
+ catch
+ _:{noproc,_} -> tc_print(Category,Importance,Data,[]);
+ _:Reason -> exit(Reason)
+ end.
diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl
index 68e76c2396..abda87c2cd 100644
--- a/lib/common_test/src/ct_util.erl
+++ b/lib/common_test/src/ct_util.erl
@@ -286,14 +286,23 @@ get_start_dir() ->
%% handle verbosity outside ct_util_server (let the client read
%% the verbosity table) to avoid possible deadlock situations
set_verbosity(Elem = {_Category,_Level}) ->
- ets:insert(?verbosity_table, Elem),
- ok.
+ try ets:insert(?verbosity_table, Elem) of
+ _ ->
+ ok
+ catch
+ _:Reason ->
+ {error,Reason}
+ end.
+
get_verbosity(Category) ->
- case ets:lookup(?verbosity_table, Category) of
+ try ets:lookup(?verbosity_table, Category) of
[{Category,Level}] ->
Level;
_ ->
undefined
+ catch
+ _:Reason ->
+ {error,Reason}
end.
loop(Mode,TestData,StartDir) ->
diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl
index 6bcac12326..4132995bf6 100644
--- a/lib/common_test/test/ct_test_support.erl
+++ b/lib/common_test/test/ct_test_support.erl
@@ -36,6 +36,8 @@
verify_events/3, verify_events/4, reformat/2, log_events/4,
join_abs_dirs/2]).
+-export([start_slave/3, slave_stop/1]).
+
-export([ct_test_halt/1]).
-include_lib("kernel/include/file.hrl").
@@ -66,10 +68,14 @@ init_per_suite(Config, Level) ->
start_slave(Config, Level).
-start_slave(Config,Level) ->
+start_slave(Config, Level) ->
+ start_slave(ct, Config, Level).
+
+start_slave(NodeName, Config, Level) ->
[_,Host] = string:tokens(atom_to_list(node()), "@"),
- test_server:format(0, "Trying to start ~s~n", ["ct@"++Host]),
- case slave:start(Host, ct, []) of
+ test_server:format(0, "Trying to start ~s~n",
+ [atom_to_list(NodeName)++"@"++Host]),
+ case slave:start(Host, NodeName, []) of
{error,Reason} ->
test_server:fail(Reason);
{ok,CTNode} ->
@@ -77,7 +83,7 @@ start_slave(Config,Level) ->
IsCover = test_server:is_cover(),
if IsCover ->
cover:start(CTNode);
- true->
+ true ->
ok
end,
diff --git a/lib/common_test/test/ct_verbosity_SUITE.erl b/lib/common_test/test/ct_verbosity_SUITE.erl
index 32488b1db9..1aa71953ec 100644
--- a/lib/common_test/test/ct_verbosity_SUITE.erl
+++ b/lib/common_test/test/ct_verbosity_SUITE.erl
@@ -53,9 +53,19 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
ct_test_support:end_per_suite(Config).
+init_per_testcase(no_crashing, Config) ->
+ Opts = ct_test_support:start_slave(ctX, Config, 50),
+ XNode = proplists:get_value(ct_node, Opts),
+ ct:pal("Node ~p started!", [XNode]),
+ [{xnode,XNode} | Config];
init_per_testcase(TestCase, Config) ->
ct_test_support:init_per_testcase(TestCase, Config).
+end_per_testcase(no_crashing, Config) ->
+ XNode = proplists:get_value(xnode, Config),
+ ct_test_support:slave_stop(XNode),
+ ct:pal("Node ~p stopped!", [XNode]),
+ ok;
end_per_testcase(TestCase, Config) ->
ct_test_support:end_per_testcase(TestCase, Config).
@@ -72,7 +82,8 @@ all() ->
combine_categories,
testspec_only,
merge_with_testspec,
- possible_deadlock
+ possible_deadlock,
+ no_crashing
].
%%--------------------------------------------------------------------
@@ -189,6 +200,19 @@ possible_deadlock(Config) ->
%%%-----------------------------------------------------------------
+%%%
+no_crashing(Config) ->
+ XNode = proplists:get_value(xnode, Config),
+ ok = rpc:call(XNode, ct, print, ["hello",[]]),
+ ok = rpc:call(XNode, ct, pal, ["hello",[]]),
+ ok = rpc:call(XNode, ct, log, ["hello",[]]),
+ Data = io_lib:format("hello", []),
+ {badrpc,{'EXIT',{noproc,_}}} =
+ (catch rpc:call(XNode, test_server_io, print_unexpected, [Data])),
+ ok.
+
+
+%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------