aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/doc/src/ct.xml2
-rw-r--r--lib/common_test/src/ct.erl2
-rw-r--r--lib/common_test/src/ct_config.erl47
-rw-r--r--lib/common_test/src/ct_framework.erl10
-rw-r--r--lib/common_test/src/ct_ftp.erl2
-rw-r--r--lib/common_test/src/ct_groups.erl16
-rw-r--r--lib/common_test/src/ct_hooks.erl3
-rw-r--r--lib/common_test/src/ct_hooks_lock.erl2
-rw-r--r--lib/common_test/src/ct_logs.erl77
-rw-r--r--lib/common_test/src/ct_master.erl24
-rw-r--r--lib/common_test/src/ct_master_logs.erl43
-rw-r--r--lib/common_test/src/ct_property_test.erl8
-rw-r--r--lib/common_test/src/ct_release_test.erl38
-rw-r--r--lib/common_test/src/ct_repeat.erl6
-rw-r--r--lib/common_test/src/ct_rpc.erl6
-rw-r--r--lib/common_test/src/ct_run.erl98
-rw-r--r--lib/common_test/src/ct_slave.erl6
-rw-r--r--lib/common_test/src/ct_snmp.erl80
-rw-r--r--lib/common_test/src/ct_ssh.erl4
-rw-r--r--lib/common_test/src/ct_telnet.erl6
-rw-r--r--lib/common_test/src/ct_telnet_client.erl4
-rw-r--r--lib/common_test/src/ct_util.erl23
-rw-r--r--lib/common_test/src/ct_webtool.erl39
-rw-r--r--lib/common_test/src/cth_conn_log.erl2
-rw-r--r--lib/common_test/src/cth_log_redirect.erl9
-rw-r--r--lib/common_test/src/erl2html2.erl18
-rw-r--r--lib/common_test/src/test_server.erl135
-rw-r--r--lib/common_test/src/test_server_ctrl.erl67
-rw-r--r--lib/common_test/src/test_server_gl.erl5
-rw-r--r--lib/common_test/src/test_server_io.erl17
-rw-r--r--lib/common_test/src/test_server_node.erl12
-rw-r--r--lib/common_test/src/test_server_sup.erl5
-rw-r--r--lib/common_test/src/vts.erl19
-rw-r--r--lib/common_test/test/Makefile3
-rw-r--r--lib/common_test/test/ct_gen_conn_SUITE_data/conn_SUITE.erl68
-rw-r--r--lib/common_test/test/ct_hooks_SUITE_data/cth/tests/cth_log_SUITE.erl10
-rw-r--r--lib/common_test/test/ct_log_SUITE.erl328
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE.erl32
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl9
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl15
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ns.erl2
-rw-r--r--lib/common_test/test/ct_repeat_testrun_SUITE.erl60
-rw-r--r--lib/common_test/test/ct_test_support.erl6
-rw-r--r--lib/common_test/test/telnet_server.erl42
44 files changed, 967 insertions, 443 deletions
diff --git a/lib/common_test/doc/src/ct.xml b/lib/common_test/doc/src/ct.xml
index 5231ef24a4..264bcff251 100644
--- a/lib/common_test/doc/src/ct.xml
+++ b/lib/common_test/doc/src/ct.xml
@@ -935,7 +935,7 @@
</func>
<func>
- <name>reload_config(Required) -&gt; ValueOrElement</name>
+ <name>reload_config(Required) -&gt; ValueOrElement | {error, Reason}</name>
<fsummary>Reloads configuration file containing specified configuration
key.</fsummary>
<type>
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index cae7bea406..d7ae81a5ce 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -282,7 +282,7 @@ step(TestDir,Suite,Case,Opts) ->
%%% <c>&gt; ct_telnet:cmd(unix_telnet, "ls .").</c><br/>
%%% <c>{ok,["ls","file1 ...",...]}</c></p>
start_interactive() ->
- ct_util:start(interactive),
+ _ = ct_util:start(interactive),
ok.
%%%-----------------------------------------------------------------
diff --git a/lib/common_test/src/ct_config.erl b/lib/common_test/src/ct_config.erl
index b499bc8b05..99de311570 100644
--- a/lib/common_test/src/ct_config.erl
+++ b/lib/common_test/src/ct_config.erl
@@ -119,7 +119,8 @@ call(Msg) ->
end.
return({To,Ref},Result) ->
- To ! {Ref, Result}.
+ To ! {Ref, Result},
+ ok.
loop(StartDir) ->
receive
@@ -128,11 +129,11 @@ loop(StartDir) ->
return(From,Result),
loop(StartDir);
{{set_default_config,{Config,Scope}},From} ->
- set_config(Config,{true,Scope}),
+ _ = set_config(Config,{true,Scope}),
return(From,ok),
loop(StartDir);
{{set_default_config,{Name,Config,Scope}},From} ->
- set_config(Name,Config,{true,Scope}),
+ _ = set_config(Name,Config,{true,Scope}),
return(From,ok),
loop(StartDir);
{{delete_default_config,Scope},From} ->
@@ -149,7 +150,7 @@ loop(StartDir) ->
loop(StartDir);
{{stop},From} ->
ets:delete(?attr_table),
- file:set_cwd(StartDir),
+ ok = file:set_cwd(StartDir),
return(From,ok)
end.
@@ -257,7 +258,7 @@ read_config_files(Opts) ->
read_config_files_int([{Callback, File}|Files], FunToSave) ->
case Callback:read_config(File) of
{ok, Config} ->
- FunToSave(Config, Callback, File),
+ _ = FunToSave(Config, Callback, File),
read_config_files_int(Files, FunToSave);
{error, {ErrorName, ErrorDetail}} ->
{user_error, {ErrorName, File, ErrorDetail}};
@@ -267,6 +268,15 @@ read_config_files_int([{Callback, File}|Files], FunToSave) ->
read_config_files_int([], _FunToSave) ->
ok.
+
+read_config_files(ConfigFiles, FunToSave) ->
+ case read_config_files_int(ConfigFiles, FunToSave) of
+ {user_error, Error} ->
+ {error, Error};
+ ok ->
+ ok
+ end.
+
store_config(Config, Callback, File) when is_tuple(Config) ->
store_config([Config], Callback, File);
@@ -455,8 +465,12 @@ reload_conf(KeyOrName) ->
undefined;
HandlerList ->
HandlerList2 = lists:usort(HandlerList),
- read_config_files_int(HandlerList2, fun rewrite_config/3),
- get_config(KeyOrName)
+ case read_config_files(HandlerList2, fun rewrite_config/3) of
+ ok ->
+ get_config(KeyOrName);
+ Error ->
+ Error
+ end
end.
release_allocated() ->
@@ -490,16 +504,16 @@ associate(Name,_Key,Configs) ->
associate_int(Name,Configs,os:getenv("COMMON_TEST_ALIAS_TOP")).
associate_int(Name,Configs,"true") ->
- lists:map(fun({K,_Config}) ->
+ lists:foreach(fun({K,_Config}) ->
Cs = ets:match_object(
?attr_table,
#ct_conf{key=element(1,K),
name='_UNDEF',_='_'}),
[ets:insert(?attr_table,C#ct_conf{name=Name})
|| C <- Cs]
- end,Configs);
+ end,Configs);
associate_int(Name,Configs,_) ->
- lists:map(fun({K,Config}) ->
+ lists:foreach(fun({K,Config}) ->
Key = if is_tuple(K) -> element(1,K);
is_atom(K) -> K
end,
@@ -511,7 +525,7 @@ associate_int(Name,Configs,_) ->
[ets:insert(?attr_table,C#ct_conf{name=Name,
value=Config})
|| C <- Cs]
- end,Configs).
+ end,Configs).
@@ -576,7 +590,7 @@ encrypt_config_file(SrcFileName, EncryptFileName, {file,KeyFile}) ->
end;
encrypt_config_file(SrcFileName, EncryptFileName, {key,Key}) ->
- crypto:start(),
+ _ = crypto:start(),
{Key,IVec} = make_crypto_key(Key),
case file:read_file(SrcFileName) of
{ok,Bin0} ->
@@ -615,7 +629,7 @@ decrypt_config_file(EncryptFileName, TargetFileName, {file,KeyFile}) ->
end;
decrypt_config_file(EncryptFileName, TargetFileName, {key,Key}) ->
- crypto:start(),
+ _ = crypto:start(),
{Key,IVec} = make_crypto_key(Key),
case file:read_file(EncryptFileName) of
{ok,Bin} ->
@@ -778,14 +792,13 @@ prepare_config_list(Args) ->
% TODO: add logging of the loaded configuration file to the CT FW log!!!
add_config(Callback, []) ->
- read_config_files_int([{Callback, []}], fun store_config/3);
+ read_config_files([{Callback, []}], fun store_config/3);
add_config(Callback, [File|_Files]=Config) when is_list(File) ->
lists:foreach(fun(CfgStr) ->
- read_config_files_int([{Callback, CfgStr}], fun store_config/3) end,
+ read_config_files([{Callback, CfgStr}], fun store_config/3) end,
Config);
add_config(Callback, [C|_]=Config) when is_integer(C) ->
- read_config_files_int([{Callback, Config}], fun store_config/3),
- ok.
+ read_config_files([{Callback, Config}], fun store_config/3).
remove_config(Callback, Config) ->
ets:match_delete(?attr_table,
diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl
index eb32f7f3fc..104515e57e 100644
--- a/lib/common_test/src/ct_framework.erl
+++ b/lib/common_test/src/ct_framework.erl
@@ -128,7 +128,7 @@ init_tc1(?MODULE,_,error_in_suite,_,[Config0]) when is_list(Config0) ->
ct_event:notify(#event{name=tc_start,
node=node(),
data={?MODULE,error_in_suite}}),
- ct_suite_init(?MODULE,error_in_suite,[],Config0),
+ _ = ct_suite_init(?MODULE,error_in_suite,[],Config0),
case ?val(error,Config0) of
undefined ->
{fail,"unknown_error_in_suite"};
@@ -212,7 +212,7 @@ init_tc2(Mod,Suite,Func,HookFunc,SuiteInfo,MergeResult,Config) ->
%% timetrap must be handled before require
MergedInfo = timetrap_first(MergeResult, [], []),
%% tell logger to use specified style sheet
- case lists:keysearch(stylesheet,1,MergeResult++Config) of
+ _ = case lists:keysearch(stylesheet,1,MergeResult++Config) of
{value,{stylesheet,SSFile}} ->
ct_logs:set_stylesheet(Func,add_data_dir(SSFile,Config));
_ ->
@@ -632,10 +632,10 @@ try_set_default(Name,Key,Info,Where) ->
{_,[]} ->
no_default;
{'_UNDEF',_} ->
- [ct_config:set_default_config([CfgVal],Where) || CfgVal <- CfgElems],
+ _ = [ct_config:set_default_config([CfgVal],Where) || CfgVal <- CfgElems],
ok;
_ ->
- [ct_config:set_default_config(Name,[CfgVal],Where) || CfgVal <- CfgElems],
+ _ = [ct_config:set_default_config(Name,[CfgVal],Where) || CfgVal <- CfgElems],
ok
end.
@@ -1315,7 +1315,7 @@ report(What,Data) ->
%% top level test index page needs to be refreshed
TestName = filename:basename(?val(topdir, Data), ".logs"),
RunDir = ?val(rundir, Data),
- ct_logs:make_all_suites_index({TestName,RunDir}),
+ _ = ct_logs:make_all_suites_index({TestName,RunDir}),
ok;
tests_start ->
ok;
diff --git a/lib/common_test/src/ct_ftp.erl b/lib/common_test/src/ct_ftp.erl
index 48914864e4..84e664b387 100644
--- a/lib/common_test/src/ct_ftp.erl
+++ b/lib/common_test/src/ct_ftp.erl
@@ -292,7 +292,7 @@ init(KeyOrName,{IP,Port},{Username,Password}) ->
end.
ftp_connect(IP,Port,Username,Password) ->
- inets:start(),
+ _ = inets:start(),
case inets:start(ftpc,[{host,IP},{port,Port}]) of
{ok,FtpPid} ->
case ftp:user(FtpPid,Username,Password) of
diff --git a/lib/common_test/src/ct_groups.erl b/lib/common_test/src/ct_groups.erl
index dd04c5410a..1375e7dcc7 100644
--- a/lib/common_test/src/ct_groups.erl
+++ b/lib/common_test/src/ct_groups.erl
@@ -402,12 +402,7 @@ expand(Mod, Name, Defs) ->
end.
make_all_conf(Dir, Mod, Props, TestSpec) ->
- case code:is_loaded(Mod) of
- false ->
- code:load_abs(filename:join(Dir,atom_to_list(Mod)));
- _ ->
- ok
- end,
+ _ = load_abs(Dir, Mod),
make_all_conf(Mod, Props, TestSpec).
make_all_conf(Mod, Props, TestSpec) ->
@@ -428,16 +423,19 @@ make_all_conf(Mod, Props, TestSpec) ->
end.
make_conf(Dir, Mod, Name, Props, TestSpec) ->
+ _ = load_abs(Dir, Mod),
+ make_conf(Mod, Name, Props, TestSpec).
+
+load_abs(Dir, Mod) ->
case code:is_loaded(Mod) of
false ->
code:load_abs(filename:join(Dir,atom_to_list(Mod)));
_ ->
ok
- end,
- make_conf(Mod, Name, Props, TestSpec).
+ end.
make_conf(Mod, Name, Props, TestSpec) ->
- case code:is_loaded(Mod) of
+ _ = case code:is_loaded(Mod) of
false ->
code:load_file(Mod);
_ ->
diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl
index 5422d449fd..c9a4abb5ee 100644
--- a/lib/common_test/src/ct_hooks.erl
+++ b/lib/common_test/src/ct_hooks.erl
@@ -408,7 +408,8 @@ catch_apply(M,F,A, Default) ->
maybe_start_locker(Mod,GroupName,Opts) ->
case lists:member(parallel,Opts) of
true ->
- {ok, _Pid} = ct_hooks_lock:start({Mod,GroupName});
+ {ok, _Pid} = ct_hooks_lock:start({Mod,GroupName}),
+ ok;
false ->
ok
end.
diff --git a/lib/common_test/src/ct_hooks_lock.erl b/lib/common_test/src/ct_hooks_lock.erl
index f41f259f7b..fea298e535 100644
--- a/lib/common_test/src/ct_hooks_lock.erl
+++ b/lib/common_test/src/ct_hooks_lock.erl
@@ -82,7 +82,7 @@ init(Id) ->
%% @doc Handling call messages
handle_call({stop,Id}, _From, #state{ id = Id, requests = Reqs } = State) ->
- [gen_server:reply(Req, locker_stopped) || {Req,_ReqId} <- Reqs],
+ _ = [gen_server:reply(Req, locker_stopped) || {Req,_ReqId} <- Reqs],
{stop, normal, stopped, State};
handle_call({stop,_Id}, _From, State) ->
{reply, stopped, State};
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index e6d683c8a9..53245c596a 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -137,7 +137,8 @@ close(Info, StartDir) ->
%% so we need to use a local copy of the log cache data
LogCacheBin =
case make_last_run_index() of
- {error,_} -> % log server not responding
+ {error, Reason} -> % log server not responding
+ io:format("Warning! ct_logs not responding: ~p~n", [Reason]),
undefined;
LCB ->
LCB
@@ -149,7 +150,7 @@ close(Info, StartDir) ->
ok;
CacheBin ->
%% save final version of the log cache to file
- file:write_file(?log_cache_name,CacheBin),
+ _ = file:write_file(?log_cache_name,CacheBin),
put(ct_log_cache,undefined)
end
end,
@@ -175,12 +176,12 @@ close(Info, StartDir) ->
Error ->
io:format("Warning! Cleanup failed: ~p~n", [Error])
end,
- make_all_suites_index(stop),
+ _ = make_all_suites_index(stop),
make_all_runs_index(stop),
Cache2File();
true ->
- file:set_cwd(".."),
- make_all_suites_index(stop),
+ ok = file:set_cwd(".."),
+ _ = make_all_suites_index(stop),
make_all_runs_index(stop),
Cache2File(),
case ct_util:get_profile_data(browser, StartDir) of
@@ -240,7 +241,7 @@ call(Msg) ->
Pid ->
MRef = erlang:monitor(process,Pid),
Ref = make_ref(),
- ?MODULE ! {Msg,{self(),Ref}},
+ Pid ! {Msg,{self(),Ref}},
receive
{Ref, Result} ->
erlang:demonitor(MRef, [flush]),
@@ -251,16 +252,30 @@ call(Msg) ->
end.
return({To,Ref},Result) ->
- To ! {Ref, Result}.
+ To ! {Ref, Result},
+ ok.
cast(Msg) ->
case whereis(?MODULE) of
undefined ->
- {error,does_not_exist};
+ io:format("Warning: ct_logs not started~n"),
+ {_,_,_,_,_,_,Content,_} = Msg,
+ FormatArgs = get_format_args(Content),
+ _ = [io:format(Format, Args) || {Format, Args} <- FormatArgs],
+ ok;
_Pid ->
- ?MODULE ! Msg
+ ?MODULE ! Msg,
+ ok
end.
+get_format_args(Content) ->
+ lists:map(fun(C) ->
+ case C of
+ {_, FA, _} -> FA;
+ {_, _} -> C
+ end
+ end, Content).
+
%%%-----------------------------------------------------------------
%%% @spec init_tc(RefreshLog) -> ok
%%%
@@ -631,7 +646,7 @@ logger(Parent, Mode, Verbosity) ->
end,
%%! <---
- file:make_dir(Dir),
+ _ = file:make_dir(Dir),
AbsDir = ?abs(Dir),
put(ct_run_dir, AbsDir),
@@ -671,7 +686,7 @@ logger(Parent, Mode, Verbosity) ->
end
end,
- test_server_io:start_link(),
+ _ = test_server_io:start_link(),
MiscIoName = filename:join(Dir, ?misc_io_log),
{ok,MiscIoFd} = file:open(MiscIoName,
[write,{encoding,utf8}]),
@@ -701,13 +716,13 @@ logger(Parent, Mode, Verbosity) ->
ct_event:notify(#event{name=start_logging,node=node(),
data=AbsDir}),
make_all_runs_index(start),
- make_all_suites_index(start),
+ _ = make_all_suites_index(start),
case Mode of
interactive -> interactive_link();
_ -> ok
end,
- file:set_cwd(Dir),
- make_last_run_index(Time),
+ ok = file:set_cwd(Dir),
+ _ = make_last_run_index(Time),
CtLogFd = open_ctlog(?misc_io_log),
io:format(CtLogFd,int_header()++int_footer(),
[log_timestamp(?now),"Common Test Logger started"]),
@@ -721,13 +736,13 @@ logger(Parent, Mode, Verbosity) ->
GenLvl -> io:format(CtLogFd, "~-25s~3w~n",
["general level",GenLvl])
end,
- [begin put({verbosity,Cat},VLvl),
- if Cat == '$unspecified' ->
+ _ = [begin put({verbosity,Cat},VLvl),
+ if Cat == '$unspecified' ->
ok;
- true ->
+ true ->
io:format(CtLogFd, "~-25w~3w~n", [Cat,VLvl])
- end
- end || {Cat,VLvl} <- Verbosity],
+ end
+ end || {Cat,VLvl} <- Verbosity],
io:nl(CtLogFd),
TcEscChars = case application:get_env(common_test, esc_chars) of
{ok,ECBool} -> ECBool;
@@ -804,7 +819,7 @@ logger_loop(State) ->
print_style(GL, IoFormat, State#logger_state.stylesheet),
set_evmgr_gl(GL),
TCGLs = add_tc_gl(TCPid,GL,State),
- if not RefreshLog ->
+ _ = if not RefreshLog ->
ok;
true ->
make_last_run_index(State#logger_state.start_time)
@@ -831,7 +846,7 @@ logger_loop(State) ->
return(From,{ok,filename:basename(State#logger_state.log_dir)}),
logger_loop(State);
{make_last_run_index,From} ->
- make_last_run_index(State#logger_state.start_time),
+ _ = make_last_run_index(State#logger_state.start_time),
return(From,get(ct_log_cache)),
logger_loop(State);
{set_stylesheet,_,SSFile} when State#logger_state.stylesheet ==
@@ -1169,7 +1184,7 @@ print_style_error(Fd, IoFormat, StyleSheet, Reason) ->
close_ctlog(Fd) ->
io:format(Fd, "\n</pre>\n", []),
io:format(Fd, [xhtml("<br><br>\n", "<br /><br />\n") | footer()], []),
- file:close(Fd).
+ ok = file:close(Fd).
%%%-----------------------------------------------------------------
%%% tc_io_format/3
@@ -1773,7 +1788,7 @@ count_cases(Dir) ->
%% file yet.
{0,0,0,0};
Summary ->
- write_summary(SumFile, Summary),
+ _ = write_summary(SumFile, Summary),
Summary
end;
{error, Reason} ->
@@ -2088,7 +2103,7 @@ interactive_link() ->
"</body>\n",
"</html>\n"
],
- file:write_file("last_interactive.html",unicode:characters_to_binary(Body)),
+ _ = file:write_file("last_interactive.html",unicode:characters_to_binary(Body)),
io:format("~n~nUpdated ~ts\n"
"Any CT activities will be logged here\n",
[?abs("last_interactive.html")]).
@@ -2219,9 +2234,9 @@ runentry(Dir, _, _) ->
write_totals_file(Name,Label,Logs,Totals) ->
AbsName = ?abs(Name),
notify_and_lock_file(AbsName),
- force_write_file(AbsName,
- term_to_binary({atom_to_list(node()),
- Label,Logs,Totals})),
+ _ = force_write_file(AbsName,
+ term_to_binary({atom_to_list(node()),
+ Label,Logs,Totals})),
notify_and_unlock_file(AbsName).
%% this function needs to convert from old formats to new so that old
@@ -2266,7 +2281,7 @@ read_totals_file(Name) ->
Result.
force_write_file(Name,Contents) ->
- force_delete(Name),
+ _ = force_delete(Name),
file:write_file(Name,Contents).
force_delete(Name) ->
@@ -2817,18 +2832,18 @@ get_cache_data({ok,CacheBin}) ->
true ->
{ok,CacheRec};
false ->
- file:delete(?log_cache_name),
+ _ = file:delete(?log_cache_name),
{error,old_cache_file}
end;
_ ->
- file:delete(?log_cache_name),
+ _ = file:delete(?log_cache_name),
{error,invalid_cache_file}
end;
get_cache_data(NoCache) ->
NoCache.
cache_vsn() ->
- application:load(common_test),
+ _ = application:load(common_test),
case application:get_key(common_test,vsn) of
{ok,VSN} ->
VSN;
diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl
index c4905b316f..4eef27d2a5 100644
--- a/lib/common_test/src/ct_master.erl
+++ b/lib/common_test/src/ct_master.erl
@@ -376,7 +376,7 @@ init_master(Parent,NodeOptsList,EvHandlers,MasterLogDir,LogDirs,
end,
%% start master event manager and add default handler
- ct_master_event:start_link(),
+ {ok, _} = start_ct_master_event(),
ct_master_event:add_handler(),
%% add user handlers for master event manager
Add = fun({H,Args}) ->
@@ -398,6 +398,14 @@ init_master(Parent,NodeOptsList,EvHandlers,MasterLogDir,LogDirs,
end,
init_master1(Parent,NodeOptsList,InitOptions,LogDirs).
+start_ct_master_event() ->
+ case ct_master_event:start_link() of
+ {error, {already_started, Pid}} ->
+ {ok, Pid};
+ Else ->
+ Else
+ end.
+
init_master1(Parent,NodeOptsList,InitOptions,LogDirs) ->
{Inaccessible,NodeOptsList1,InitOptions1} = init_nodes(NodeOptsList,
InitOptions),
@@ -658,7 +666,7 @@ refresh_logs([D|Dirs],Refreshed) ->
{ok,Cwd} = file:get_cwd(),
case catch ct_run:refresh_logs(D) of
{'EXIT',Reason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
refresh_logs(Dirs,[{D,{error,Reason}}|Refreshed]);
Result ->
refresh_logs(Dirs,[{D,Result}|Refreshed])
@@ -701,7 +709,7 @@ init_node_ctrl(MasterPid,Cookie,Opts) ->
end,
%% start a local event manager
- ct_event:start_link(),
+ {ok, _} = start_ct_event(),
ct_event:add_handler([{master,MasterPid}]),
%% log("Running test with options: ~p~n", [Opts]),
@@ -721,6 +729,14 @@ init_node_ctrl(MasterPid,Cookie,Opts) ->
"Can't report result!~n~n", [MasterNode])
end.
+start_ct_event() ->
+ case ct_event:start_link() of
+ {error, {already_started, Pid}} ->
+ {ok, Pid};
+ Else ->
+ Else
+ end.
+
%%%-----------------------------------------------------------------
%%% Event handling
%%%-----------------------------------------------------------------
@@ -778,7 +794,7 @@ reply(Result,To) ->
ok.
init_nodes(NodeOptions, InitOptions)->
- ping_nodes(NodeOptions),
+ _ = ping_nodes(NodeOptions),
start_nodes(InitOptions),
eval_on_nodes(InitOptions),
{Inaccessible, NodeOptions1}=ping_nodes(NodeOptions),
diff --git a/lib/common_test/src/ct_master_logs.erl b/lib/common_test/src/ct_master_logs.erl
index 39f87a7f09..a2542171f8 100644
--- a/lib/common_test/src/ct_master_logs.erl
+++ b/lib/common_test/src/ct_master_logs.erl
@@ -91,8 +91,8 @@ init(Parent,LogDir,Nodes) ->
Time = calendar:local_time(),
RunDir = make_dirname(Time),
RunDirAbs = filename:join(LogDir,RunDir),
- file:make_dir(RunDirAbs),
- write_details_file(RunDirAbs,{node(),Nodes}),
+ ok = make_dir(RunDirAbs),
+ _ = write_details_file(RunDirAbs,{node(),Nodes}),
case basic_html() of
true ->
@@ -128,7 +128,7 @@ init(Parent,LogDir,Nodes) ->
end
end,
- make_all_runs_index(LogDir),
+ _ = make_all_runs_index(LogDir),
CtLogFd = open_ct_master_log(RunDirAbs),
NodeStr =
lists:flatten(lists:map(fun(N) ->
@@ -181,7 +181,7 @@ loop(State) ->
lists:foreach(Fun,List),
loop(State);
{make_all_runs_index,From} ->
- make_all_runs_index(State#state.logdir),
+ _ = make_all_runs_index(State#state.logdir),
return(From,State#state.logdir),
loop(State);
{{nodedir,Node,RunDir},From} ->
@@ -189,12 +189,12 @@ loop(State) ->
return(From,ok),
loop(State);
stop ->
- make_all_runs_index(State#state.logdir),
+ _ = make_all_runs_index(State#state.logdir),
io:format(State#state.log_fd,
int_header()++int_footer(),
[log_timestamp(?now),"Finished!"]),
- close_ct_master_log(State#state.log_fd),
- close_nodedir_index(State#state.nodedir_ix_fd),
+ _ = close_ct_master_log(State#state.log_fd),
+ _ = close_nodedir_index(State#state.nodedir_ix_fd),
ok
end.
@@ -496,7 +496,7 @@ make_relative(Dir) ->
ct_logs:make_relative(Dir).
force_write_file(Name,Contents) ->
- force_delete(Name),
+ _ = force_delete(Name),
file:write_file(Name,Contents).
force_delete(Name) ->
@@ -534,13 +534,34 @@ call(Msg) ->
end.
return({To,Ref},Result) ->
- To ! {Ref, Result}.
+ To ! {Ref, Result},
+ ok.
cast(Msg) ->
case whereis(?MODULE) of
undefined ->
- {error,does_not_exist};
+ io:format("Warning: ct_master_logs not started~n"),
+ {_,_,Content} = Msg,
+ FormatArgs = get_format_args(Content),
+ _ = [io:format(Format, Args) || {Format, Args} <- FormatArgs],
+ ok;
_Pid ->
- ?MODULE ! Msg
+ ?MODULE ! Msg,
+ ok
end.
+get_format_args(Content) ->
+ lists:map(fun(C) ->
+ case C of
+ {_, FA, _} -> FA;
+ _ -> C
+ end
+ end, Content).
+
+make_dir(Dir) ->
+ case file:make_dir(Dir) of
+ {error, exist} ->
+ ok;
+ Else ->
+ Else
+ end.
diff --git a/lib/common_test/src/ct_property_test.erl b/lib/common_test/src/ct_property_test.erl
index 7dc78e949a..12c3d726d3 100644
--- a/lib/common_test/src/ct_property_test.erl
+++ b/lib/common_test/src/ct_property_test.erl
@@ -161,7 +161,9 @@ property_tests_path(Dir, Config) ->
add_code_pathz(Dir) ->
case lists:member(Dir, code:get_path()) of
true -> ok;
- false -> code:add_pathz(Dir)
+ false ->
+ true = code:add_pathz(Dir),
+ ok
end.
compile_tests(Path, ToolModule) ->
@@ -171,10 +173,10 @@ compile_tests(Path, ToolModule) ->
{ok,FileNames} = file:list_dir("."),
BeamFiles = [F || F<-FileNames,
filename:extension(F) == ".beam"],
- [file:delete(F) || F<-BeamFiles],
+ _ = [file:delete(F) || F<-BeamFiles],
ct:pal("Compiling in ~p:~n Deleted ~p~n MacroDefs=~p",[Path,BeamFiles,MacroDefs]),
Result = make:all([load|MacroDefs]),
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
Result.
diff --git a/lib/common_test/src/ct_release_test.erl b/lib/common_test/src/ct_release_test.erl
index 4e0f88cf5f..d783f8d04e 100644
--- a/lib/common_test/src/ct_release_test.erl
+++ b/lib/common_test/src/ct_release_test.erl
@@ -342,7 +342,7 @@ cleanup(Config) ->
end
end,
AllNodes),
- [rpc:call(Node,erlang,halt,[]) || Node <- Nodes],
+ _ = [rpc:call(Node,erlang,halt,[]) || Node <- Nodes],
Config.
%%-----------------------------------------------------------------
@@ -552,14 +552,14 @@ target_system(Apps,CreateDir,InstallDir,{FromVsn,_,AllAppsVsns,Path}) ->
%% Add bin and log dirs
BinDir = filename:join([InstallDir, "bin"]),
- file:make_dir(BinDir),
- file:make_dir(filename:join(InstallDir,"log")),
+ ok = make_dir(BinDir),
+ ok = make_dir(filename:join(InstallDir,"log")),
%% Delete start scripts - they will be added later
ErtsBinDir = filename:join([InstallDir, "erts-" ++ ErtsVsn, "bin"]),
- file:delete(filename:join([ErtsBinDir, "erl"])),
- file:delete(filename:join([ErtsBinDir, "start"])),
- file:delete(filename:join([ErtsBinDir, "start_erl"])),
+ ok = delete_file(filename:join([ErtsBinDir, "erl"])),
+ ok = delete_file(filename:join([ErtsBinDir, "start"])),
+ ok = delete_file(filename:join([ErtsBinDir, "start_erl"])),
%% Copy .boot to bin/start.boot
copy_file(RelName++".boot",filename:join([BinDir, "start.boot"])),
@@ -680,7 +680,7 @@ do_upgrade({Cb,InitState},FromVsn,FromAppsVsns,ToRel,ToAppsVsns,InstallDir) ->
%% even if install_release returned {ok,...} there might be an
%% emulator restart (instruction restart_emulator), so we must
%% always make sure the node is running.
- wait_node_up(current,ToVsn,ToAppsVsns),
+ {ok, _} = wait_node_up(current,ToVsn,ToAppsVsns),
[{"OTP upgrade test",ToVsn,_,current},
{"OTP upgrade test",FromVsn,_,permanent}] =
@@ -703,7 +703,7 @@ do_upgrade({Cb,InitState},FromVsn,FromAppsVsns,ToRel,ToAppsVsns,InstallDir) ->
%% even if install_release returned {ok,...} there might be an
%% emulator restart (instruction restart_emulator), so we must
%% always make sure the node is running.
- wait_node_up(current,FromVsn,FromAppsVsns),
+ {ok, _} = wait_node_up(current,FromVsn,FromAppsVsns),
[{"OTP upgrade test",ToVsn,_,permanent},
{"OTP upgrade test",FromVsn,_,current}] =
@@ -854,7 +854,7 @@ copy_file(Src, Dest, Opts) ->
case lists:member(preserve, Opts) of
true ->
{ok, FileInfo} = file:read_file_info(Src),
- file:write_file_info(Dest, FileInfo);
+ ok = file:write_file_info(Dest, FileInfo);
false ->
ok
end.
@@ -862,8 +862,8 @@ copy_file(Src, Dest, Opts) ->
write_file(FName, Conts) ->
Enc = file:native_name_encoding(),
{ok, Fd} = file:open(FName, [write]),
- file:write(Fd, unicode:characters_to_binary(Conts,Enc,Enc)),
- file:close(Fd).
+ ok = file:write(Fd, unicode:characters_to_binary(Conts,Enc,Enc)),
+ ok = file:close(Fd).
%% Substitute all occurrences of %Var% for Val in the given scripts
subst_src_scripts(Scripts, SrcDir, DestDir, Vars, Opts) ->
@@ -944,3 +944,19 @@ rm_rf(Dir) ->
_ ->
ok
end.
+
+delete_file(FileName) ->
+ case file:delete(FileName) of
+ {error, enoent} ->
+ ok;
+ Else ->
+ Else
+ end.
+
+make_dir(Dir) ->
+ case file:make_dir(Dir) of
+ {error, eexist} ->
+ ok;
+ Else ->
+ Else
+ end.
diff --git a/lib/common_test/src/ct_repeat.erl b/lib/common_test/src/ct_repeat.erl
index 31c5755c7e..dac596a135 100644
--- a/lib/common_test/src/ct_repeat.erl
+++ b/lib/common_test/src/ct_repeat.erl
@@ -44,13 +44,13 @@ loop_test(If,Args) when is_list(Args) ->
false;
E = {error,_} ->
io:format("Common Test error: ~p\n\n",[E]),
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
E;
{repeat,N} ->
io:format("\nCommon Test: Will repeat tests ~w times.\n\n",[N]),
Args1 = [{loop_info,[{repeat,1,N}]} | Args],
Result = loop(If,repeat,0,N,undefined,Args1,undefined,[]),
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
Result;
{stop_time,StopTime} ->
Result =
@@ -76,7 +76,7 @@ loop_test(If,Args) when is_list(Args) ->
Args1 = [{loop_info,[{stop_time,Secs,StopTime,1}]} | Args],
loop(If,stop_time,0,Secs,StopTime,Args1,TPid,[])
end,
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
Result
end.
diff --git a/lib/common_test/src/ct_rpc.erl b/lib/common_test/src/ct_rpc.erl
index cbcc212bb8..b4a0bc9d74 100644
--- a/lib/common_test/src/ct_rpc.erl
+++ b/lib/common_test/src/ct_rpc.erl
@@ -81,7 +81,7 @@ app_node(App, [], _, _) ->
app_node(App, _Candidates = [CandidateNode | Nodes], FailOnBadRPC, Cookie) ->
Cookie0 = set_the_cookie(Cookie),
Result = rpc:call(CandidateNode, application, which_applications, []),
- set_the_cookie(Cookie0),
+ _ = set_the_cookie(Cookie0),
case Result of
{badrpc,Reason} when FailOnBadRPC == true ->
ct:fail({Reason,CandidateNode});
@@ -145,7 +145,7 @@ call({Fun, FunArgs}, Module, Function, Args, TimeOut, Cookie) ->
call(Node, Module, Function, Args, TimeOut, Cookie) when is_atom(Node) ->
Cookie0 = set_the_cookie(Cookie),
Result = rpc:call(Node, Module, Function, Args, TimeOut),
- set_the_cookie(Cookie0),
+ _ = set_the_cookie(Cookie0),
Result.
%%% @spec cast(Node, Module, Function, Args) -> ok
@@ -190,7 +190,7 @@ cast({Fun, FunArgs}, Module, Function, Args, Cookie) ->
cast(Node, Module, Function, Args, Cookie) when is_atom(Node) ->
Cookie0 = set_the_cookie(Cookie),
true = rpc:cast(Node, Module, Function, Args),
- set_the_cookie(Cookie0),
+ _ = set_the_cookie(Cookie0),
ok.
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index 1e5f935198..fbb9c7ab60 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -400,21 +400,21 @@ run_or_refresh(Opts = #opts{logdir = LogDir}, Args) ->
[RefreshDir] -> ?abs(RefreshDir)
end,
{ok,Cwd} = file:get_cwd(),
- file:set_cwd(LogDir1),
+ ok = file:set_cwd(LogDir1),
%% give the shell time to print version etc
timer:sleep(500),
io:nl(),
case catch ct_logs:make_all_runs_index(refresh) of
{'EXIT',ARReason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
{error,{all_runs_index,ARReason}};
_ ->
case catch ct_logs:make_all_suites_index(refresh) of
{'EXIT',ASReason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
{error,{all_suites_index,ASReason}};
_ ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
io:format("Logs in ~ts refreshed!~n~n",
[LogDir1]),
timer:sleep(500), % time to flush io before quitting
@@ -756,8 +756,8 @@ script_start4(#opts{label = Label, profile = Profile,
{ct_hooks, CTHooks},
{enable_builtin_hooks,EnableBuiltinHooks}]) of
ok ->
- ct_util:start(interactive, LogDir,
- add_verbosity_defaults(Verbosity)),
+ _ = ct_util:start(interactive, LogDir,
+ add_verbosity_defaults(Verbosity)),
ct_util:set_testdata({logopts, LogOpts}),
log_ts_names(Specs),
io:nl(),
@@ -901,9 +901,8 @@ install(Opts, LogDir) ->
VarFile = variables_file_name(LogDir),
case file:open(VarFile, [write]) of
{ok,Fd} ->
- [io:format(Fd, "~p.\n", [Opt]) || Opt <- ConfOpts ],
- file:close(Fd),
- ok;
+ _ = [io:format(Fd, "~p.\n", [Opt]) || Opt <- ConfOpts],
+ ok = file:close(Fd);
{error,Reason} ->
io:format("CT failed to install configuration data. Please "
"verify that the log directory exists and that "
@@ -960,7 +959,7 @@ run_test1(StartOpts) when is_list(StartOpts) ->
false ->
case catch run_test2(StartOpts) of
{'EXIT',Reason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
{error,Reason};
Result ->
Result
@@ -971,7 +970,7 @@ run_test1(StartOpts) when is_list(StartOpts) ->
stop_trace(Tracing),
exit(Res);
RefreshDir ->
- refresh_logs(?abs(RefreshDir)),
+ ok = refresh_logs(?abs(RefreshDir)),
exit(done)
end.
@@ -1209,7 +1208,6 @@ run_all_specs([], _, _, TotResult) ->
end;
run_all_specs([{Specs,TS} | TSs], Opts, StartOpts, TotResult) ->
- log_ts_names(Specs),
Combined = #opts{config = TSConfig} = combine_test_opts(TS, Specs, Opts),
AllConfig = merge_vals([Opts#opts.config, TSConfig]),
try run_one_spec(TS,
@@ -1430,7 +1428,7 @@ run_testspec1(TestSpec) ->
io:format("~nCommon Test starting (cwd is ~ts)~n~n", [Cwd]),
case catch run_testspec2(TestSpec) of
{'EXIT',Reason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
exit({error,Reason});
Result ->
exit(Result)
@@ -1562,15 +1560,15 @@ refresh_logs(LogDir) ->
_ ->
case catch ct_logs:make_all_suites_index(refresh) of
{'EXIT',ASReason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
{error,{all_suites_index,ASReason}};
_ ->
case catch ct_logs:make_all_runs_index(refresh) of
{'EXIT',ARReason} ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
{error,{all_runs_index,ARReason}};
_ ->
- file:set_cwd(Cwd),
+ ok = file:set_cwd(Cwd),
io:format("Logs in ~ts refreshed!~n",[LogDir]),
ok
end
@@ -1610,22 +1608,34 @@ delistify(E) -> E.
%%% @hidden
%%% @equiv ct:run/3
run(TestDir, Suite, Cases) ->
- install([]),
- reformat_result(catch do_run(tests(TestDir, Suite, Cases), [])).
+ case install([]) of
+ ok ->
+ reformat_result(catch do_run(tests(TestDir, Suite, Cases), []));
+ Error ->
+ Error
+ end.
%%%-----------------------------------------------------------------
%%% @hidden
%%% @equiv ct:run/2
run(TestDir, Suite) when is_list(TestDir), is_integer(hd(TestDir)) ->
- install([]),
- reformat_result(catch do_run(tests(TestDir, Suite), [])).
+ case install([]) of
+ ok ->
+ reformat_result(catch do_run(tests(TestDir, Suite), []));
+ Error ->
+ Error
+ end.
%%%-----------------------------------------------------------------
%%% @hidden
%%% @equiv ct:run/1
run(TestDirs) ->
- install([]),
- reformat_result(catch do_run(tests(TestDirs), [])).
+ case install([]) of
+ ok ->
+ reformat_result(catch do_run(tests(TestDirs), []));
+ Error ->
+ Error
+ end.
reformat_result({'EXIT',{user_error,Reason}}) ->
{error,Reason};
@@ -2017,7 +2027,7 @@ save_make_errors(Errors) ->
"Error compiling or locating the "
"following suites: ~n~p",[Suites]),
%% save the info for logger
- file:write_file(?missing_suites_info,term_to_binary(Errors)),
+ ok = file:write_file(?missing_suites_info,term_to_binary(Errors)),
Errors.
get_bad_suites([{{_TestDir,_Suite},Failed}|Errors], BadSuites) ->
@@ -2234,7 +2244,7 @@ do_run_test(Tests, Skip, Opts0) ->
end,
application:set_env(test_server, esc_chars, EscChars),
- test_server_ctrl:start_link(local),
+ {ok, _} = test_server_ctrl:start_link(local),
%% let test_server expand the test tuples and count no of cases
{Suites,NoOfCases} = count_test_cases(Tests, Skip),
@@ -2295,7 +2305,7 @@ do_run_test(Tests, Skip, Opts0) ->
lists:foreach(fun(Suite) ->
maybe_cleanup_interpret(Suite, Opts#opts.step)
end, CleanUp),
- [code:del_path(Dir) || Dir <- AddedToPath],
+ _ = [code:del_path(Dir) || Dir <- AddedToPath],
%% If a severe error has occurred in the test_server,
%% we will generate an exception here.
@@ -2422,7 +2432,7 @@ count_test_cases(Tests, Skip) ->
SendResult = fun(Me, Result) -> Me ! {no_of_cases,Result} end,
TSPid = test_server_ctrl:start_get_totals(SendResult),
Ref = erlang:monitor(process, TSPid),
- add_jobs(Tests, Skip, #opts{}, []),
+ _ = add_jobs(Tests, Skip, #opts{}, []),
Counted = (catch count_test_cases1(length(Tests), 0, [], Ref)),
erlang:demonitor(Ref, [flush]),
case Counted of
@@ -2776,14 +2786,14 @@ maybe_interpret1(Suite, Cases, StepOpts) when is_list(Cases) ->
maybe_interpret2(Suite, Cases, StepOpts) ->
set_break_on_config(Suite, StepOpts),
- [begin try i:ib(Suite, Case, 1) of
+ _ = [begin try i:ib(Suite, Case, 1) of
_ -> ok
catch
_:_Error ->
io:format(user, "Invalid breakpoint: ~w:~w/1~n",
[Suite,Case])
end
- end || Case <- Cases, is_atom(Case)],
+ end || Case <- Cases, is_atom(Case)],
test_server_ctrl:multiply_timetraps(infinity),
WinOp = case lists:member(keep_inactive, ensure_atom(StepOpts)) of
true -> no_kill;
@@ -2802,12 +2812,12 @@ set_break_on_config(Suite, StepOpts) ->
false -> ok
end
end,
- SetBPIfExists(init_per_suite, 1),
- SetBPIfExists(init_per_group, 2),
- SetBPIfExists(init_per_testcase, 2),
- SetBPIfExists(end_per_testcase, 2),
- SetBPIfExists(end_per_group, 2),
- SetBPIfExists(end_per_suite, 1);
+ ok = SetBPIfExists(init_per_suite, 1),
+ ok = SetBPIfExists(init_per_group, 2),
+ ok = SetBPIfExists(init_per_testcase, 2),
+ ok = SetBPIfExists(end_per_testcase, 2),
+ ok = SetBPIfExists(end_per_group, 2),
+ ok = SetBPIfExists(end_per_suite, 1);
false ->
ok
end.
@@ -2984,31 +2994,31 @@ add_verbosity_defaults(VLvls) ->
%% relative dirs "post run_test erl_args" is not kept!
rel_to_abs(CtArgs) ->
{PA,PZ} = get_pa_pz(CtArgs, [], []),
- [begin
+ _ = [begin
Dir = rm_trailing_slash(D),
Abs = make_abs(Dir),
- if Dir /= Abs ->
- code:del_path(Dir),
- code:del_path(Abs),
+ _ = if Dir /= Abs ->
+ _ = code:del_path(Dir),
+ _ = code:del_path(Abs),
io:format(user, "Converting ~p to ~p and re-inserting "
"with add_pathz/1~n",
[Dir, Abs]);
true ->
- code:del_path(Dir)
+ _ = code:del_path(Dir)
end,
code:add_pathz(Abs)
end || D <- PZ],
- [begin
+ _ = [begin
Dir = rm_trailing_slash(D),
Abs = make_abs(Dir),
- if Dir /= Abs ->
- code:del_path(Dir),
- code:del_path(Abs),
+ _ = if Dir /= Abs ->
+ _ = code:del_path(Dir),
+ _ = code:del_path(Abs),
io:format(user, "Converting ~p to ~p and re-inserting "
"with add_patha/1~n",
[Dir, Abs]);
true ->
- code:del_path(Dir)
+ _ = code:del_path(Dir)
end,
code:add_patha(Abs)
end || D <- PA],
diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl
index 3ad3937548..571958ca03 100644
--- a/lib/common_test/src/ct_slave.erl
+++ b/lib/common_test/src/ct_slave.erl
@@ -325,7 +325,7 @@ do_start(Host, Node, Options) ->
Functions
end,
MasterHost = gethostname(),
- if
+ _ = if
MasterHost == Host ->
spawn_local_node(Node, Options);
true->
@@ -359,7 +359,7 @@ do_start(Host, Node, Options) ->
pang->
{error, boot_timeout, ENode}
end,
- case Result of
+ _ = case Result of
{ok, ENode}->
ok;
{error, Timeout, ENode}
@@ -422,7 +422,7 @@ spawn_remote_node(Host, Node, Options) ->
{_, _}->
[{user, Username}, {password, Password}]
end ++ [{silently_accept_hosts, true}] ++ SSHOpts,
- application:ensure_all_started(ssh),
+ {ok, _} = application:ensure_all_started(ssh),
{ok, SSHConnRef} = ssh:connect(atom_to_list(Host), SSHPort, SSHOptions),
{ok, SSHChannelId} = ssh_connection:session_channel(SSHConnRef, infinity),
ssh_setenv(SSHConnRef, SSHChannelId, Env),
diff --git a/lib/common_test/src/ct_snmp.erl b/lib/common_test/src/ct_snmp.erl
index bb0167eb22..2c59b19196 100644
--- a/lib/common_test/src/ct_snmp.erl
+++ b/lib/common_test/src/ct_snmp.erl
@@ -221,9 +221,17 @@ start(Config, MgrAgentConfName, SnmpAppConfName) ->
Config, SysName, AgentManagerIP, IP),
setup_manager(StartManager, MgrAgentConfName, SnmpAppConfName,
Config, AgentManagerIP),
- application:start(snmp),
+ ok = start_application(snmp),
manager_register(StartManager, MgrAgentConfName).
+
+start_application(App) ->
+ case application:start(App) of
+ {error, {already_started, App}} ->
+ ok;
+ Else ->
+ Else
+ end.
%%% @spec stop(Config) -> ok
%%% Config = [{Key, Value}]
@@ -233,8 +241,8 @@ start(Config, MgrAgentConfName, SnmpAppConfName) ->
%%% @doc Stops the snmp manager and/or agent removes all files created.
stop(Config) ->
PrivDir = ?config(priv_dir, Config),
- application:stop(snmp),
- application:stop(mnesia),
+ ok = application:stop(snmp),
+ ok = application:stop(mnesia),
MgrDir = filename:join(PrivDir,"mgr"),
ConfDir = filename:join(PrivDir, "conf"),
DbDir = filename:join(PrivDir,"db"),
@@ -311,7 +319,7 @@ set_info(Config) ->
SetLogFile = filename:join(PrivDir, ?CT_SNMP_LOG_FILE),
case file:consult(SetLogFile) of
{ok, SetInfo} ->
- file:delete(SetLogFile),
+ ok = delete_file(SetLogFile),
lists:reverse(SetInfo);
_ ->
[]
@@ -513,7 +521,7 @@ unload_mibs(Mibs) ->
prepare_snmp_env() ->
%% To make sure application:set_env is not overwritten by any
%% app-file settings.
- application:load(snmp),
+ _ = application:load(snmp),
%% Fix for older versions of snmp where there are some
%% inappropriate default values for alway starting an
@@ -533,7 +541,7 @@ setup_manager(true, MgrConfName, SnmpConfName, Config, IP) ->
Users = [],
Agents = [],
Usms = [],
- file:make_dir(MgrDir),
+ ok = make_dir(MgrDir),
snmp_config:write_manager_snmp_files(MgrDir, IP, Port, MaxMsgSize,
EngineID, Users, Agents, Usms),
@@ -549,7 +557,7 @@ setup_agent(false,_, _, _, _, _, _) ->
ok;
setup_agent(true, AgentConfName, SnmpConfName,
Config, SysName, ManagerIP, AgentIP) ->
- application:start(mnesia),
+ ok = start_application(mnesia),
PrivDir = ?config(priv_dir, Config),
Vsns = ct:get_config({AgentConfName, agent_vsns}, ?CONF_FILE_VER),
TrapUdp = ct:get_config({AgentConfName, agent_trap_udp}, ?TRAP_UDP),
@@ -565,8 +573,8 @@ setup_agent(true, AgentConfName, SnmpConfName,
ConfDir = filename:join(PrivDir, "conf"),
DbDir = filename:join(PrivDir,"db"),
- file:make_dir(ConfDir),
- file:make_dir(DbDir),
+ ok = make_dir(ConfDir),
+ ok = make_dir(DbDir),
snmp_config:write_agent_snmp_files(ConfDir, Vsns, ManagerIP, TrapUdp,
AgentIP, AgentUdp, SysName,
NotifType, SecType, Passwd,
@@ -684,7 +692,7 @@ log(PrivDir, Agent, {_, _, Varbinds}, NewVarsAndVals) ->
File = filename:join(PrivDir, ?CT_SNMP_LOG_FILE),
{ok, Fd} = file:open(File, [write, append]),
io:format(Fd, "~p.~n", [{Agent, OldVarsAndVals, NewVarsAndVals}]),
- file:close(Fd),
+ ok = file:close(Fd),
ok.
%%%---------------------------------------------------------------------------
del_dir(Dir) ->
@@ -692,7 +700,7 @@ del_dir(Dir) ->
FullPathFiles = lists:map(fun(File) -> filename:join(Dir, File) end,
Files),
lists:foreach(fun file:delete/1, FullPathFiles),
- file:del_dir(Dir),
+ ok = delete_dir(Dir),
ok.
%%%---------------------------------------------------------------------------
agent_conf(Agent, MgrAgentConfName) ->
@@ -738,8 +746,8 @@ override_contexts(Config, {data_dir_file, File}) ->
override_contexts(Config, Contexts) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"context.conf"),
- file:delete(File),
- snmp_config:write_agent_context_config(Dir, "", Contexts).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_context_config(Dir, "", Contexts).
%%%---------------------------------------------------------------------------
override_sysinfo(_, undefined) ->
@@ -754,8 +762,8 @@ override_sysinfo(Config, {data_dir_file, File}) ->
override_sysinfo(Config, SysInfo) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"standard.conf"),
- file:delete(File),
- snmp_config:write_agent_standard_config(Dir, "", SysInfo).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_standard_config(Dir, "", SysInfo).
%%%---------------------------------------------------------------------------
override_target_address(_, undefined) ->
@@ -769,8 +777,8 @@ override_target_address(Config, {data_dir_file, File}) ->
override_target_address(Config, TargetAddressConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"target_addr.conf"),
- file:delete(File),
- snmp_config:write_agent_target_addr_config(Dir, "", TargetAddressConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_target_addr_config(Dir, "", TargetAddressConf).
%%%---------------------------------------------------------------------------
@@ -785,8 +793,8 @@ override_target_params(Config, {data_dir_file, File}) ->
override_target_params(Config, TargetParamsConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"target_params.conf"),
- file:delete(File),
- snmp_config:write_agent_target_params_config(Dir, "", TargetParamsConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_target_params_config(Dir, "", TargetParamsConf).
%%%---------------------------------------------------------------------------
override_notify(_, undefined) ->
@@ -800,8 +808,8 @@ override_notify(Config, {data_dir_file, File}) ->
override_notify(Config, NotifyConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"notify.conf"),
- file:delete(File),
- snmp_config:write_agent_notify_config(Dir, "", NotifyConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_notify_config(Dir, "", NotifyConf).
%%%---------------------------------------------------------------------------
override_usm(_, undefined) ->
@@ -815,8 +823,8 @@ override_usm(Config, {data_dir_file, File}) ->
override_usm(Config, UsmConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"usm.conf"),
- file:delete(File),
- snmp_config:write_agent_usm_config(Dir, "", UsmConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_usm_config(Dir, "", UsmConf).
%%%--------------------------------------------------------------------------
override_community(_, undefined) ->
@@ -830,8 +838,8 @@ override_community(Config, {data_dir_file, File}) ->
override_community(Config, CommunityConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"community.conf"),
- file:delete(File),
- snmp_config:write_agent_community_config(Dir, "", CommunityConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_community_config(Dir, "", CommunityConf).
%%%---------------------------------------------------------------------------
@@ -846,8 +854,8 @@ override_vacm(Config, {data_dir_file, File}) ->
override_vacm(Config, VacmConf) ->
Dir = filename:join(?config(priv_dir, Config),"conf"),
File = filename:join(Dir,"vacm.conf"),
- file:delete(File),
- snmp_config:write_agent_vacm_config(Dir, "", VacmConf).
+ ok = delete_file(File),
+ ok = snmp_config:write_agent_vacm_config(Dir, "", VacmConf).
%%%---------------------------------------------------------------------------
@@ -861,3 +869,21 @@ while_ok(Fun,[H|T]) ->
end;
while_ok(_Fun,[]) ->
ok.
+
+delete_file(FileName) ->
+ case file:delete(FileName) of
+ {error, enoent} -> ok;
+ Else -> Else
+ end.
+
+make_dir(Dir) ->
+ case file:make_dir(Dir) of
+ {error, eexist} -> ok;
+ Else -> Else
+ end.
+
+delete_dir(Dir) ->
+ case file:del_dir(Dir) of
+ {error, enoent} -> ok;
+ Else -> Else
+ end.
diff --git a/lib/common_test/src/ct_ssh.erl b/lib/common_test/src/ct_ssh.erl
index 92d912052e..6ab3bf036c 100644
--- a/lib/common_test/src/ct_ssh.erl
+++ b/lib/common_test/src/ct_ssh.erl
@@ -962,8 +962,8 @@ init(KeyOrName, {ConnType,Addr,Port}, AllOpts) ->
end, [], AllOpts1),
FinalOptions = [{silently_accept_hosts,true},
{user_interaction,false} | Options],
- crypto:start(),
- ssh:start(),
+ _ = crypto:start(),
+ _ = ssh:start(),
Result = case ConnType of
ssh ->
ssh:connect(Addr, Port, FinalOptions);
diff --git a/lib/common_test/src/ct_telnet.erl b/lib/common_test/src/ct_telnet.erl
index f5f4f648f4..8fb411ec4f 100644
--- a/lib/common_test/src/ct_telnet.erl
+++ b/lib/common_test/src/ct_telnet.erl
@@ -605,7 +605,7 @@ init(Name,{Ip,Port,Type},{TargetMod,KeepAlive,Extra}) ->
set_telnet_defaults(Settings,#state{})
end,
%% Handle old user versions of TargetMod
- code:ensure_loaded(TargetMod),
+ _ = code:ensure_loaded(TargetMod),
try
case erlang:function_exported(TargetMod,connect,7) of
true ->
@@ -688,7 +688,7 @@ handle_msg({cmd,Cmd,Opts},State) ->
debug_cont_gen_log("Throwing Buffer:",[]),
debug_log_lines(State#state.buffer),
- case {State#state.type,State#state.prompt} of
+ _ = case {State#state.type,State#state.prompt} of
{ts,_} ->
silent_teln_expect(State#state.name,
State#state.teln_pid,
@@ -735,7 +735,7 @@ handle_msg({send,Cmd,Opts},State) ->
debug_cont_gen_log("Throwing Buffer:",[]),
debug_log_lines(State#state.buffer),
- case {State#state.type,State#state.prompt} of
+ _ = case {State#state.type,State#state.prompt} of
{ts,_} ->
silent_teln_expect(State#state.name,
State#state.teln_pid,
diff --git a/lib/common_test/src/ct_telnet_client.erl b/lib/common_test/src/ct_telnet_client.erl
index 1f1311776f..5df7e279ac 100644
--- a/lib/common_test/src/ct_telnet_client.erl
+++ b/lib/common_test/src/ct_telnet_client.erl
@@ -272,7 +272,7 @@ send(Data, Sock, ConnName) ->
_:_ -> ok
end
end,
- gen_tcp:send(Sock, Data),
+ ok = gen_tcp:send(Sock, Data),
ok.
%% [IAC,IAC] = buffer data value 255
@@ -284,7 +284,7 @@ check_msg(Sock, [?IAC | Cs], Acc) ->
case get_cmd(Cs) of
{Cmd,Cs1} ->
cmd_dbg("Got",Cmd),
- respond_cmd(Cmd, Sock),
+ ok = respond_cmd(Cmd, Sock),
check_msg(Sock, Cs1, Acc);
error ->
Acc
diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl
index d5a8e3fbc0..82a8743cf0 100644
--- a/lib/common_test/src/ct_util.erl
+++ b/lib/common_test/src/ct_util.erl
@@ -131,14 +131,14 @@ do_start(Parent, Mode, LogDir, Verbosity) ->
create_table(?suite_table,#suite_data.key),
create_table(?verbosity_table,1),
- [ets:insert(?verbosity_table,{Cat,Lvl}) || {Cat,Lvl} <- Verbosity],
+ _ = [ets:insert(?verbosity_table,{Cat,Lvl}) || {Cat,Lvl} <- Verbosity],
{ok,StartDir} = file:get_cwd(),
case file:set_cwd(LogDir) of
ok -> ok;
E -> exit(E)
end,
- DoExit = fun(Reason) -> file:set_cwd(StartDir), exit(Reason) end,
+ DoExit = fun(Reason) -> ok = file:set_cwd(StartDir), exit(Reason) end,
Opts = case read_opts() of
{ok,Opts1} ->
Opts1;
@@ -169,7 +169,7 @@ do_start(Parent, Mode, LogDir, Verbosity) ->
end,
%% add user event handlers
- case lists:keysearch(event_handler,1,Opts) of
+ _ = case lists:keysearch(event_handler,1,Opts) of
{value,{_,Handlers}} ->
Add = fun({H,Args}) ->
case catch gen_event:add_handler(?CT_EVMGR_REF,H,Args) of
@@ -195,7 +195,7 @@ do_start(Parent, Mode, LogDir, Verbosity) ->
data={StartTime,
lists:flatten(TestLogDir)}}),
%% Initialize ct_hooks
- try ct_hooks:init(Opts) of
+ _ = try ct_hooks:init(Opts) of
ok ->
Parent ! {self(),started};
{fail,CTHReason} ->
@@ -228,7 +228,8 @@ create_table(TableName,KeyPos) ->
create_table(TableName,set,KeyPos).
create_table(TableName,Type,KeyPos) ->
catch ets:delete(TableName),
- ets:new(TableName,[Type,named_table,public,{keypos,KeyPos}]).
+ _ = ets:new(TableName,[Type,named_table,public,{keypos,KeyPos}]),
+ ok.
read_opts() ->
case file:consult(ct_run:variables_file_name("./")) of
@@ -473,7 +474,7 @@ loop(Mode,TestData,StartDir) ->
ct_logs:close(Info, StartDir),
ct_event:stop(),
ct_config:stop(),
- file:set_cwd(StartDir),
+ ok = file:set_cwd(StartDir),
return(From, Info);
{Ref, _Msg} when is_reference(Ref) ->
%% This clause is used when doing cast operations.
@@ -505,7 +506,7 @@ loop(Mode,TestData,StartDir) ->
%% Let process crash in case of error, this shouldn't happen!
io:format("\n\nct_util_server got EXIT "
"from ~w: ~p\n\n", [Pid,Reason]),
- file:set_cwd(StartDir),
+ ok = file:set_cwd(StartDir),
exit(Reason)
end
end.
@@ -1035,10 +1036,12 @@ call(Msg, Timeout) ->
end.
return({To,Ref},Result) ->
- To ! {Ref, Result}.
+ To ! {Ref, Result},
+ ok.
cast(Msg) ->
- ct_util_server ! {Msg, {ct_util_server, make_ref()}}.
+ ct_util_server ! {Msg, {ct_util_server, make_ref()}},
+ ok.
seconds(T) ->
test_server:seconds(T).
@@ -1074,7 +1077,7 @@ abs_name2([],Acc) ->
open_url(iexplore, Args, URL) ->
{ok,R} = win32reg:open([read]),
ok = win32reg:change_key(R,"applications\\iexplore.exe\\shell\\open\\command"),
- case win32reg:values(R) of
+ _ = case win32reg:values(R) of
{ok, Paths} ->
Path = proplists:get_value(default, Paths),
[Cmd | _] = string:tokens(Path, "%"),
diff --git a/lib/common_test/src/ct_webtool.erl b/lib/common_test/src/ct_webtool.erl
index 6cbcd98cc3..87af442fd3 100644
--- a/lib/common_test/src/ct_webtool.erl
+++ b/lib/common_test/src/ct_webtool.erl
@@ -84,27 +84,27 @@
%% Function = {FunctionName,Arity} | FunctionName |
%% {Module, FunctionName, Arity} | {Module,FunctionName}
debug(F) ->
- ttb:tracer(all,[{file,"webtool.trc"}]), % tracing all nodes
- ttb:p(all,[call,timestamp]),
+ {ok, _} = ttb:tracer(all,[{file,"webtool.trc"}]), % tracing all nodes
+ {ok, _} = ttb:p(all,[call,timestamp]),
MS = [{'_',[],[{return_trace},{message,{caller}}]}],
- tp(F,MS),
- ttb:ctp(?MODULE,stop_debug), % don't want tracing of the stop_debug func
+ _ = tp(F,MS),
+ {ok, _} = ttb:ctp(?MODULE,stop_debug), % don't want tracing of the stop_debug func
ok.
tp(local,MS) -> % all functions
ttb:tpl(?MODULE,MS);
tp(global,MS) -> % all exported functions
ttb:tp(?MODULE,MS);
tp([{M,F,A}|T],MS) -> % Other module
- ttb:tpl(M,F,A,MS),
+ {ok, _} = ttb:tpl(M,F,A,MS),
tp(T,MS);
tp([{M,F}|T],MS) when is_atom(F) -> % Other module
- ttb:tpl(M,F,MS),
+ {ok, _} = ttb:tpl(M,F,MS),
tp(T,MS);
tp([{F,A}|T],MS) -> % function/arity
- ttb:tpl(?MODULE,F,A,MS),
+ {ok, _} = ttb:tpl(?MODULE,F,A,MS),
tp(T,MS);
tp([F|T],MS) -> % function
- ttb:tpl(?MODULE,F,MS),
+ {ok, _} = ttb:tpl(?MODULE,F,MS),
tp(T,MS);
tp([],_MS) ->
ok.
@@ -112,10 +112,10 @@ stop_debug() ->
ttb:stop([format]).
debug_app(Mod) ->
- ttb:tracer(all,[{file,"webtool_app.trc"},{handler,{fun out/4,true}}]),
- ttb:p(all,[call,timestamp]),
+ {ok, _} = ttb:tracer(all,[{file,"webtool_app.trc"},{handler,{fun out/4,true}}]),
+ {ok, _} = ttb:p(all,[call,timestamp]),
MS = [{'_',[],[{return_trace},{message,{caller}}]}],
- ttb:tp(Mod,MS),
+ {ok, _} = ttb:tp(Mod,MS),
ok.
out(_,{trace_ts,Pid,call,MFA={M,F,A},{W,_,_},TS},_,S)
@@ -145,7 +145,7 @@ script_start([App]) ->
script_start([App,DefaultBrowser]);
script_start([App,Browser]) ->
io:format("Starting webtool...\n"),
- start(),
+ {ok, _} = start(),
AvailableApps = get_applications(),
{OSType,_} = os:type(),
case lists:keysearch(App,1,AvailableApps) of
@@ -159,14 +159,14 @@ script_start([App,Browser]) ->
_ ->
"http://localhost:" ++ PortStr ++ "/" ++ StartPage
end,
- case Browser of
+ _ = case Browser of
none ->
ok;
iexplore when OSType == win32->
io:format("Starting internet explorer...\n"),
{ok,R} = win32reg:open(""),
Key="\\local_machine\\SOFTWARE\\Microsoft\\IE Setup\\Setup",
- win32reg:change_key(R,Key),
+ ok = win32reg:change_key(R,Key),
{ok,Val} = win32reg:value(R,"Path"),
IExplore=filename:join(win32reg:expand(Val),"iexplore.exe"),
os:cmd("\"" ++ IExplore ++ "\" " ++ Url);
@@ -186,7 +186,7 @@ script_start([App,Browser]) ->
{Port,{exit_status,_Error}} ->
io:format(" not running, starting ~w...\n",
[Browser]),
- os:cmd(BStr ++ " " ++ Url),
+ _ = os:cmd(BStr ++ " " ++ Url),
ok
after ?SEND_URL_TIMEOUT ->
io:format(" failed, starting ~w...\n",[Browser]),
@@ -206,7 +206,7 @@ script_start([App,Browser]) ->
usage() ->
io:format("Starting webtool...\n"),
- start(),
+ {ok, _} = start(),
Apps = lists:map(fun({A,_}) -> A end,get_applications()),
io:format(
"\nUsage: start_webtool application [ browser ]\n"
@@ -254,7 +254,12 @@ start(Path,Port) when is_integer(Port)->
start(Path,Data0)->
Data = Data0 ++ rest_of_standard_data(),
- gen_server:start({local,ct_web_tool},ct_webtool,{Path,Data},[]).
+ case gen_server:start({local,ct_web_tool},ct_webtool,{Path,Data},[]) of
+ {error, {already_started, Pid}} ->
+ {ok, Pid};
+ Else ->
+ Else
+ end.
stop()->
gen_server:call(ct_web_tool,stoppit).
diff --git a/lib/common_test/src/cth_conn_log.erl b/lib/common_test/src/cth_conn_log.erl
index 0501c6ed1c..883da0da0a 100644
--- a/lib/common_test/src/cth_conn_log.erl
+++ b/lib/common_test/src/cth_conn_log.erl
@@ -170,7 +170,7 @@ post_end_per_testcase(TestCase,_Config,Return,CthState) ->
end,
case ct_util:update_testdata(?MODULE, Update) of
deleted ->
- [ct_util:delete_testdata({?MODULE,ConnMod}) ||
+ _ = [ct_util:delete_testdata({?MODULE,ConnMod}) ||
{ConnMod,_} <- CthState],
error_logger:delete_report_handler(ct_conn_log_h);
{error,no_response} ->
diff --git a/lib/common_test/src/cth_log_redirect.erl b/lib/common_test/src/cth_log_redirect.erl
index 33a3813a16..6d77d7ee9e 100644
--- a/lib/common_test/src/cth_log_redirect.erl
+++ b/lib/common_test/src/cth_log_redirect.erl
@@ -127,7 +127,7 @@ handle_event(Event, #eh_state{log_func = LogFunc} = State) ->
_Else ->
{ok, ErrLogType} = application:get_env(sasl, errlog_type),
SReport = sasl_report:format_report(group_leader(), ErrLogType,
- tag_event(Event)),
+ tag_event(Event, local)),
if is_list(SReport) ->
SaslHeader = format_header(State),
case LogFunc of
@@ -142,8 +142,9 @@ handle_event(Event, #eh_state{log_func = LogFunc} = State) ->
ignore
end
end,
+ %% note that error_logger (unlike sasl) expects UTC time
EReport = error_logger_tty_h:write_event(
- tag_event(Event),io_lib),
+ tag_event(Event, utc), io_lib),
if is_list(EReport) ->
ErrHeader = format_header(State),
case LogFunc of
@@ -220,7 +221,9 @@ terminate(_) ->
terminate(_Arg, _State) ->
ok.
-tag_event(Event) ->
+tag_event(Event, utc) ->
+ {calendar:universal_time(), Event};
+tag_event(Event, _) ->
{calendar:local_time(), Event}.
set_curr_func(CurrFunc, Config) ->
diff --git a/lib/common_test/src/erl2html2.erl b/lib/common_test/src/erl2html2.erl
index a1e0bf3879..e819f345de 100644
--- a/lib/common_test/src/erl2html2.erl
+++ b/lib/common_test/src/erl2html2.erl
@@ -62,15 +62,15 @@ convert(File, Dest, InclPath, Header) ->
{ok,SFd} ->
case file:open(Dest,[write,raw]) of
{ok,DFd} ->
- file:write(DFd,[Header,"<pre>\n"]),
+ ok = file:write(DFd,[Header,"<pre>\n"]),
_Lines = build_html(SFd,DFd,encoding(File),Functions),
- file:write(DFd,["</pre>\n",footer(),
+ ok = file:write(DFd,["</pre>\n",footer(),
"</body>\n</html>\n"]),
%% {_, Time2} = statistics(runtime),
%% io:format("Converted ~p lines in ~.2f Seconds.~n",
%% [_Lines, Time2/1000]),
- file:close(SFd),
- file:close(DFd),
+ ok = file:close(SFd),
+ ok = file:close(DFd),
ok;
Error ->
Error
@@ -138,7 +138,7 @@ parse_non_preprocessed_file(File) ->
case file:open(File, []) of
{ok,Epp} ->
Forms = parse_non_preprocessed_file(Epp, File, 1),
- file:close(Epp),
+ ok = file:close(Epp),
{ok,Forms};
Error = {error,_E} ->
Error
@@ -205,14 +205,14 @@ build_html(SFd,DFd,Encoding,FuncsAndCs) ->
%% line of last expression in function found
build_html(SFd,DFd,Enc,{ok,Str},LastL,FuncsAndCs,_IsFuncDef,{F,LastL}) ->
LastLineLink = test_server_ctrl:uri_encode(F++"-last_expr",utf8),
- file:write(DFd,["<a name=\"",
- to_raw_list(LastLineLink,Enc),"\"/>"]),
+ ok = file:write(DFd,["<a name=\"",
+ to_raw_list(LastLineLink,Enc),"\"/>"]),
build_html(SFd,DFd,Enc,{ok,Str},LastL,FuncsAndCs,true,undefined);
%% function start line found
build_html(SFd,DFd,Enc,{ok,Str},L0,[{F,A,L0,LastL}|FuncsAndCs],
_IsFuncDef,_FAndLastL) ->
FALink = test_server_ctrl:uri_encode(F++"-"++integer_to_list(A),utf8),
- file:write(DFd,["<a name=\"",to_raw_list(FALink,Enc),"\"/>"]),
+ ok = file:write(DFd,["<a name=\"",to_raw_list(FALink,Enc),"\"/>"]),
build_html(SFd,DFd,Enc,{ok,Str},L0,FuncsAndCs,true,{F,LastL});
build_html(SFd,DFd,Enc,{ok,Str},L,[{clause,L}|FuncsAndCs],
_IsFuncDef,FAndLastL) ->
@@ -220,7 +220,7 @@ build_html(SFd,DFd,Enc,{ok,Str},L,[{clause,L}|FuncsAndCs],
build_html(SFd,DFd,Enc,{ok,Str},L,FuncsAndCs,IsFuncDef,FAndLastL) ->
LStr = line_number(L),
Str1 = line(Str,IsFuncDef),
- file:write(DFd,[LStr,Str1]),
+ ok = file:write(DFd,[LStr,Str1]),
build_html(SFd,DFd,Enc,file:read_line(SFd),L+1,FuncsAndCs,false,FAndLastL);
build_html(_SFd,_DFd,_Enc,eof,L,_FuncsAndCs,_IsFuncDef,_FAndLastL) ->
L.
diff --git a/lib/common_test/src/test_server.erl b/lib/common_test/src/test_server.erl
index 919526c5d7..924086f2bd 100644
--- a/lib/common_test/src/test_server.erl
+++ b/lib/common_test/src/test_server.erl
@@ -21,7 +21,7 @@
-define(DEFAULT_TIMETRAP_SECS, 60).
%%% TEST_SERVER_CTRL INTERFACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--export([run_test_case_apply/1,init_target_info/0,init_purify/0]).
+-export([run_test_case_apply/1,init_target_info/0]).
-export([cover_compile/1,cover_analyse/2]).
%%% TEST_SERVER_SUP INTERFACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -49,10 +49,6 @@
-export([break/1,break/2,break/3,continue/0,continue/1]).
-%%% DEBUGGER INTERFACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--export([purify_new_leaks/0, purify_format/2, purify_new_fds_inuse/0,
- purify_is_running/0]).
-
%%% PRIVATE EXPORTED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-export([]).
@@ -73,10 +69,6 @@ init_target_info() ->
username=test_server_sup:get_username(),
cookie=atom_to_list(erlang:get_cookie())}.
-init_purify() ->
- purify_new_leaks().
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% cover_compile(#cover{app=App,incl=Include,excl=Exclude,cross=Cross}) ->
%% {ok,#cover{mods=AnalyseModules}} | {error,Reason}
@@ -100,7 +92,7 @@ cover_compile(CoverInfo=#cover{app=none,incl=Include,cross=Cross}) ->
case length(CompileMods) of
0 ->
io:fwrite("WARNING: No modules to cover compile!\n\n",[]),
- cover:start(), % start cover server anyway
+ {ok, _} = start_cover(), % start cover server anyway
{ok,CoverInfo#cover{mods=[]}};
N ->
io:fwrite("Cover compiling ~w modules - "
@@ -115,7 +107,7 @@ cover_compile(CoverInfo=#cover{app=App,excl=all,incl=Include,cross=Cross}) ->
case length(CompileMods) of
0 ->
io:fwrite("WARNING: No modules to cover compile!\n\n",[]),
- cover:start(), % start cover server anyway
+ {ok, _} = start_cover(), % start cover server anyway
{ok,CoverInfo#cover{mods=[]}};
N ->
io:fwrite("Cover compiling '~w' (~w files) - "
@@ -158,7 +150,7 @@ cover_compile(CoverInfo=#cover{app=App,excl=Exclude,
case length(CompileMods) of
0 ->
io:fwrite("WARNING: No modules to cover compile!\n\n",[]),
- cover:start(), % start cover server anyway
+ {ok, _} = start_cover(), % start cover server anyway
{ok,CoverInfo#cover{mods=[]}};
N ->
io:fwrite("Cover compiling '~w' (~w files) - "
@@ -175,11 +167,11 @@ module_names(Beams) ->
do_cover_compile(Modules) ->
- cover:start(),
+ {ok, _} = start_cover(),
Sticky = prepare_cover_compile(Modules,[]),
R = cover:compile_beam(Modules),
- [warn_compile(Error) || Error <- R,element(1,Error)=/=ok],
- [code:stick_mod(M) || M <- Sticky],
+ _ = [warn_compile(Error) || Error <- R,element(1,Error)=/=ok],
+ _ = [code:stick_mod(M) || M <- Sticky],
ok.
warn_compile({error,{Reason,Module}}) ->
@@ -366,9 +358,7 @@ stick_all_sticky(Node,Sticky) ->
%% compensate timetraps for runtime delays introduced by e.g. tools like
%% cover.
-run_test_case_apply({CaseNum,Mod,Func,Args,Name,
- RunInit,TimetrapData}) ->
- purify_format("Test case #~w ~w:~w/1", [CaseNum, Mod, Func]),
+run_test_case_apply({Mod,Func,Args,Name,RunInit,TimetrapData}) ->
case os:getenv("TS_RUN_VALGRIND") of
false ->
ok;
@@ -380,7 +370,6 @@ run_test_case_apply({CaseNum,Mod,Func,Args,Name,
Result = run_test_case_apply(Mod, Func, Args, Name, RunInit,
TimetrapData),
ProcAft = erlang:system_info(process_count),
- purify_new_leaks(),
DetFail = get(test_server_detected_fail),
{Result,DetFail,ProcBef,ProcAft}.
@@ -585,7 +574,8 @@ run_test_case_msgloop(#st{ref=Ref,pid=Pid,end_conf_pid=EndConfPid0}=St0) ->
{user_timetrap,Pid,_TrapTime,StartTime,E={user_timetrap_error,_},_} ->
case update_user_timetraps(Pid, StartTime) of
proceed ->
- self() ! {abort_current_testcase,E,Pid};
+ self() ! {abort_current_testcase,E,Pid},
+ ok;
ignore ->
ok
end,
@@ -600,7 +590,8 @@ run_test_case_msgloop(#st{ref=Ref,pid=Pid,end_conf_pid=EndConfPid0}=St0) ->
true ->
TrapTime
end,
- timetrap(TrapTime, TotalTime, Pid, Scale);
+ _ = timetrap(TrapTime, TotalTime, Pid, Scale),
+ ok;
ignore ->
ok
end,
@@ -724,7 +715,7 @@ do_call_end_conf(Starter,Mod,Func,Data,TCExitReason,Conf,TVal) ->
Supervisor = self(),
EndConfApply =
fun() ->
- timetrap(TVal),
+ _ = timetrap(TVal),
%% We can't handle fails or skips here
%% (neither input nor output). The error can
%% be read from Conf though (tc_status).
@@ -775,7 +766,8 @@ print_end_conf_result(Mod,Func,Conf,Cause,Error) ->
" ~s!\n\tReason: ~ts\n",
[Mod,Func,Conf,Cause,ErrorStr])
end,
- group_leader() ! {printout,12,Str2Print}.
+ group_leader() ! {printout,12,Str2Print},
+ ok.
spawn_fw_call(Mod,IPTC={init_per_testcase,Func},CurrConf,Pid,
@@ -1287,7 +1279,9 @@ user_callback({CBMod,CBFunc}, Mod, Func, InitOrEnd, Args) ->
init_per_testcase(Mod, Func, Args) ->
case code:is_loaded(Mod) of
- false -> code:load_file(Mod);
+ false ->
+ _ = code:load_file(Mod),
+ ok;
_ -> ok
end,
case erlang:function_exported(Mod, init_per_testcase, 2) of
@@ -1355,7 +1349,8 @@ print_init_conf_result(Line,Cause,Reason) ->
"\tLocation: ~ts\n\tReason: ~ts\n",
[Cause,FormattedLoc,ReasonStr])
end,
- group_leader() ! {printout,12,Str2Print}.
+ group_leader() ! {printout,12,Str2Print},
+ ok.
end_per_testcase(Mod, Func, Conf) ->
@@ -1426,7 +1421,8 @@ print_end_tc_warning(EndFunc,Reason,Cause,Loc) ->
"Reason: ~ts\nLine: ~ts\n",
[EndFunc,Cause,ReasonStr,FormattedLoc])
end,
- group_leader() ! {printout,12,Str2Print}.
+ group_leader() ! {printout,12,Str2Print},
+ ok.
get_loc() ->
get(test_server_loc).
@@ -1657,7 +1653,8 @@ messages_get() ->
%%
%% Make sure proceeding IO from FromPid won't get rejected
permit_io(GroupLeader, FromPid) ->
- GroupLeader ! {permit_io,FromPid}.
+ GroupLeader ! {permit_io,FromPid},
+ ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% sleep(Time) -> ok
@@ -1829,7 +1826,6 @@ timetrap_scale_factor() ->
timetrap_scale_factor([
{ 2, fun() -> has_lock_checking() end},
{ 3, fun() -> has_superfluous_schedulers() end},
- { 5, fun() -> purify_is_running() end},
{ 6, fun() -> is_debug() end},
{10, fun() -> is_cover() end}
]).
@@ -2129,7 +2125,8 @@ timetrap_cancel_all(TCPid, SendToServer) ->
ok;
Timers ->
[timetrap_cancel_one(Handle, false) ||
- {Handle,Pid,_} <- Timers, Pid == TCPid]
+ {Handle,Pid,_} <- Timers, Pid == TCPid],
+ ok
end,
case get(test_server_user_timetrap) of
undefined ->
@@ -2139,13 +2136,15 @@ timetrap_cancel_all(TCPid, SendToServer) ->
{UserTTSup,_StartTime} ->
remove_user_timetrap(UserTTSup),
put(test_server_user_timetrap,
- proplists:delete(TCPid, UserTTs));
+ proplists:delete(TCPid, UserTTs)),
+ ok;
undefined ->
ok
end
end,
if SendToServer == true ->
- group_leader() ! {timetrap_cancel_all,TCPid,self()};
+ group_leader() ! {timetrap_cancel_all,TCPid,self()},
+ ok;
true ->
ok
end,
@@ -2560,10 +2559,11 @@ run_on_shielded_node(Fun, CArgs) when is_function(Fun), is_list(CArgs) ->
-spec start_job_proxy_fun(_, _) -> fun(() -> no_return()).
start_job_proxy_fun(Master, Fun) ->
fun () ->
- start_job_proxy(),
+ _ = start_job_proxy(),
receive
Ref ->
- Master ! {Ref, Fun()}
+ Master ! {Ref, Fun()},
+ ok
end,
receive after infinity -> infinity end
end.
@@ -2729,64 +2729,25 @@ is_commercial() ->
_ -> true
end.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% DEBUGGER INTERFACE %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% purify_is_running() -> false|true
-%%
-%% Tests if Purify is currently running.
-
-purify_is_running() ->
- case catch erlang:system_info({error_checker, running}) of
- {'EXIT', _} -> false;
- Res -> Res
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% purify_new_leaks() -> false|BytesLeaked
-%% BytesLeaked = integer()
-%%
-%% Checks for new memory leaks if Purify is active.
-%% Returns the number of bytes leaked, or false if Purify
-%% is not running.
-purify_new_leaks() ->
- case catch erlang:system_info({error_checker, memory}) of
- {'EXIT', _} -> false;
- Leaked when is_integer(Leaked) -> Leaked
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% purify_new_fds_inuse() -> false|FdsInuse
-%% FdsInuse = integer()
-%%
-%% Checks for new file descriptors in use.
-%% Returns the number of new file descriptors in use, or false
-%% if Purify is not running.
-purify_new_fds_inuse() ->
- case catch erlang:system_info({error_checker, fd}) of
- {'EXIT', _} -> false;
- Inuse when is_integer(Inuse) -> Inuse
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% purify_format(Format, Args) -> ok
-%% Format = string()
-%% Args = lists()
-%%
-%% Outputs the formatted string to Purify's logfile,if Purify is active.
-purify_format(Format, Args) ->
- (catch erlang:system_info({error_checker, io_lib:format(Format, Args)})),
- ok.
-
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Apply given function and reply to caller or proxy.
%%
do_sync_apply(Proxy, From, {M,F,A}) ->
Result = apply(M, F, A),
- if is_pid(Proxy) -> Proxy ! {sync_result_proxy,From,Result};
- true -> From ! {sync_result,Result}
+ if is_pid(Proxy) ->
+ Proxy ! {sync_result_proxy,From,Result},
+ ok;
+ true ->
+ From ! {sync_result,Result},
+ ok
end.
+
+start_cover() ->
+ case cover:start() of
+ {error, {already_started, Pid}} ->
+ {ok, Pid};
+ Else ->
+ Else
+ end.
+
diff --git a/lib/common_test/src/test_server_ctrl.erl b/lib/common_test/src/test_server_ctrl.erl
index ff960c22a5..b52e4bef9b 100644
--- a/lib/common_test/src/test_server_ctrl.erl
+++ b/lib/common_test/src/test_server_ctrl.erl
@@ -294,7 +294,7 @@ start_link(_) ->
start() ->
case gen_server:start({local,?MODULE}, ?MODULE, [], []) of
- {ok, Pid} ->
+ {error, {already_started, Pid}} ->
{ok, Pid};
Other ->
Other
@@ -302,7 +302,7 @@ start() ->
start_link() ->
case gen_server:start_link({local,?MODULE}, ?MODULE, [], []) of
- {ok, Pid} ->
+ {error, {already_started, Pid}} ->
{ok, Pid};
Other ->
Other
@@ -512,7 +512,7 @@ init([]) ->
TI = TI0#target_info{host=TargetHost,
naming=naming(),
master=TargetHost},
- ets:new(slave_tab, [named_table,set,public,{keypos,2}]),
+ _ = ets:new(slave_tab, [named_table,set,public,{keypos,2}]),
set_hosts([TI#target_info.host]),
{ok,State#state{target_info=TI}}.
@@ -867,7 +867,7 @@ handle_call({create_priv_dir,Value}, _From, State) ->
handle_call({testcase_callback,ModFunc}, _From, State) ->
case ModFunc of
{Mod,Func} ->
- case code:is_loaded(Mod) of
+ _ = case code:is_loaded(Mod) of
{file,_} ->
ok;
false ->
@@ -1079,8 +1079,8 @@ terminate(_Reason, State) ->
false -> ok;
Sock -> test_server_node:stop_tracer_node(Sock)
end,
- kill_all_jobs(State#state.jobs),
- test_server_node:kill_nodes(),
+ ok = kill_all_jobs(State#state.jobs),
+ _ = test_server_node:kill_nodes(),
ok.
kill_all_jobs([{_Name,JobPid}|Jobs]) ->
@@ -1125,7 +1125,7 @@ spawn_tester(Mod, Func, Args, Dir, Name, Levels, RejectIoReqs,
init_tester(Mod, Func, Args, Dir, Name, {_,_,MinLev}=Levels,
RejectIoReqs, CreatePrivDir, TCCallback, ExtraTools) ->
process_flag(trap_exit, true),
- test_server_io:start_link(),
+ _ = test_server_io:start_link(),
put(test_server_name, Name),
put(test_server_dir, Dir),
put(test_server_total_time, 0),
@@ -1199,8 +1199,7 @@ init_tester(Mod, Func, Args, Dir, Name, {_,_,MinLev}=Levels,
{UnexpectedIoName,UnexpectedIoFooter} = get(test_server_unexpected_footer),
{ok,UnexpectedIoFd} = open_html_file(UnexpectedIoName, [append]),
io:put_chars(UnexpectedIoFd, "\n</pre>\n"++UnexpectedIoFooter),
- file:close(UnexpectedIoFd),
- ok.
+ ok = file:close(UnexpectedIoFd).
report_severe_error(Reason) ->
test_server_sup:framework_call(report, [severe_error,Reason]).
@@ -1927,7 +1926,7 @@ html_convert_modules([Mod|Mods]) ->
Name = atom_to_list(Mod),
DestFile = filename:join(DestDir,
downcase(Name)++?src_listing_ext),
- html_possibly_convert(SrcFile1, SrcFileInfo, DestFile),
+ _ = html_possibly_convert(SrcFile1, SrcFileInfo, DestFile),
html_convert_modules(Mods)
end;
_Other ->
@@ -2066,7 +2065,7 @@ add_init_and_end_per_suite([], LastMod, LastRef, FwMod) ->
end.
do_add_init_and_end_per_suite(LastMod, LastRef, Mod, FwMod) ->
- case code:is_loaded(Mod) of
+ _ = case code:is_loaded(Mod) of
false -> code:load_file(Mod);
_ -> ok
end,
@@ -2140,7 +2139,6 @@ do_add_end_per_suite_and_skip(LastMod, LastRef, Mod, FwMod) ->
%% Runs the specified tests, then displays/logs the summary.
run_test_cases(TestSpec, Config, TimetrapData) ->
- test_server:init_purify(),
case lists:member(no_src, get(test_server_logopts)) of
true ->
ok;
@@ -2323,7 +2321,7 @@ run_test_cases_loop([{SkipTag,{Type,Ref,Case,Comment},SkipMode}|Cases],
Config, TimetrapData, Mode, Status) when
((SkipTag==auto_skip_case) or (SkipTag==skip_case)) and
((Type==conf) or (Type==make)) ->
- file:set_cwd(filename:dirname(get(test_server_dir))),
+ ok = file:set_cwd(filename:dirname(get(test_server_dir))),
CurrIOHandler = get(test_server_common_io_handler),
ParentMode = tl(Mode),
@@ -2339,7 +2337,7 @@ run_test_cases_loop([{SkipTag,{Type,Ref,Case,Comment},SkipMode}|Cases],
false ->
%% this is a skipped end conf for a top level parallel
%% group, buffered io can be flushed
- handle_test_case_io_and_status(),
+ _ = handle_test_case_io_and_status(),
set_io_buffering(undefined),
{Mod,Func} = skip_case(AutoOrUser, Ref, 0, Case, Comment,
false, SkipMode),
@@ -2351,7 +2349,7 @@ run_test_cases_loop([{SkipTag,{Type,Ref,Case,Comment},SkipMode}|Cases],
_ ->
%% this is a skipped end conf for a parallel group nested
%% under a parallel group (io buffering is active)
- wait_for_cases(Ref),
+ _ = wait_for_cases(Ref),
{Mod,Func} = skip_case(AutoOrUser, Ref, 0, Case, Comment,
true, SkipMode),
ConfData = {Mod,{Func,get_name(SkipMode)},Comment},
@@ -2459,7 +2457,7 @@ run_test_cases_loop([{auto_skip_case,{Case,Comment},SkipMode}|Cases],
run_test_cases_loop([{skip_case,{{Mod,all}=Case,Comment},SkipMode}|Cases],
Config, TimetrapData, Mode, Status) ->
- skip_case(user, undefined, 0, Case, Comment, false, SkipMode),
+ _ = skip_case(user, undefined, 0, Case, Comment, false, SkipMode),
test_server_sup:framework_call(report, [tc_user_skip,
{Mod,{all,get_name(SkipMode)},
Comment}]),
@@ -2489,7 +2487,7 @@ run_test_cases_loop([{conf,Ref,Props,{Mod,Func}}|_Cases]=Cs0,
%% collect results from the test case processes
%% and calc total time
OkSkipFail = handle_test_case_io_and_status(),
- file:set_cwd(filename:dirname(get(test_server_dir))),
+ ok = file:set_cwd(filename:dirname(get(test_server_dir))),
After = ?now,
Before = get(test_server_parallel_start_time),
Elapsed = timer:now_diff(After, Before)/1000000,
@@ -3582,7 +3580,7 @@ handle_io_and_exit_loop([], [{undefined,CurrPid,CaseNum,Mod,Func}|Ps] = Cases, O
handle_io_and_exit_loop(Refs, [{Ref,CurrPid,CaseNum,Mod,Func}|Ps] = Cases, Ok,Skip,Fail) ->
receive
{started,_,CurrPid,CaseNum,Mod,Func} ->
- handle_io_and_exits(self(), CurrPid, CaseNum, Mod, Func, Cases),
+ _ = handle_io_and_exits(self(), CurrPid, CaseNum, Mod, Func, Cases),
Refs1 =
case Refs of
[Ref|Rs] -> % must be end conf case for subgroup
@@ -3658,7 +3656,7 @@ handle_io_and_exits(Main, CurrPid, CaseNum, Mod, Func, Cases) ->
%% about the execution time and the return value of the test case function.
run_test_case(Ref, Num, Mod, Func, Args, RunInit, TimetrapData) ->
- file:set_cwd(filename:dirname(get(test_server_dir))),
+ ok = file:set_cwd(filename:dirname(get(test_server_dir))),
run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
TimetrapData, [], self()).
@@ -3668,7 +3666,7 @@ run_test_case(Ref, Num, Mod, Func, Args, skip_init, TimetrapData, Mode) ->
TimetrapData, Mode, self());
run_test_case(Ref, Num, Mod, Func, Args, RunInit, TimetrapData, Mode) ->
- file:set_cwd(filename:dirname(get(test_server_dir))),
+ ok = file:set_cwd(filename:dirname(get(test_server_dir))),
Main = self(),
case check_prop(parallel, Mode) of
false ->
@@ -3682,7 +3680,7 @@ run_test_case(Ref, Num, Mod, Func, Args, RunInit, TimetrapData, Mode) ->
spawn_link(
fun() ->
process_flag(trap_exit, true),
- [put(Key, Val) || {Key,Val} <- Dictionary],
+ _ = [put(Key, Val) || {Key,Val} <- Dictionary],
set_io_buffering({tc,Main}),
run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
TimetrapData, Mode, Main)
@@ -3699,7 +3697,8 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
false -> ok;
true ->
test_server_io:start_transaction(),
- Main ! {started,Ref,self(),Num,Mod,Func}
+ Main ! {started,Ref,self(),Num,Mod,Func},
+ ok
end,
TSDir = get(test_server_dir),
@@ -3774,7 +3773,7 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
%% run the test case
{Result,DetectedFail,ProcsBefore,ProcsAfter} =
- run_test_case_apply(Num, Mod, Func, [UpdatedArgs], GrName,
+ run_test_case_apply(Mod, Func, [UpdatedArgs], GrName,
RunInit, TimetrapData),
{Time,RetVal,Loc,Opts,Comment} =
case Result of
@@ -3906,7 +3905,8 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
true ->
test_server_io:end_transaction(),
Main ! {finished,Ref,self(),Num,Mod,Func,
- ?mod_result(Status),{Time,RetVal,Opts}}
+ ?mod_result(Status),{Time,RetVal,Opts}},
+ ok
end,
{Time,RetVal,Opts}.
@@ -4329,7 +4329,7 @@ do_format_exception(Reason={Error,Stack}) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% run_test_case_apply(CaseNum, Mod, Func, Args, Name, RunInit,
+%% run_test_case_apply(Mod, Func, Args, Name, RunInit,
%% TimetrapData) ->
%% {{Time,RetVal,Loc,Opts,Comment},DetectedFail,ProcessesBefore,ProcessesAfter} |
%% {{died,Reason,unknown,Comment},DetectedFail,ProcessesBefore,ProcessesAfter}
@@ -4343,9 +4343,9 @@ do_format_exception(Reason={Error,Stack}) ->
%% ProcessesBefore = ProcessesAfter = integer()
%%
-run_test_case_apply(CaseNum, Mod, Func, Args, Name, RunInit,
+run_test_case_apply(Mod, Func, Args, Name, RunInit,
TimetrapData) ->
- test_server:run_test_case_apply({CaseNum,Mod,Func,Args,Name,RunInit,
+ test_server:run_test_case_apply({Mod,Func,Args,Name,RunInit,
TimetrapData}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5276,7 +5276,8 @@ check_cross([]) ->
%% This per application analysis writes the file cover.html in the
%% application's run.<timestamp> directory.
stop_cover(#cover{}=CoverInfo, TestDir) ->
- cover_analyse(CoverInfo, TestDir);
+ cover_analyse(CoverInfo, TestDir),
+ ok;
stop_cover(_CoverInfo, _TestDir) ->
%% Cover is probably controlled by the framework
ok.
@@ -5315,7 +5316,7 @@ cover_analyse(CoverInfo, TestDir) ->
[?cross_coverlog_name]),
io:fwrite(CoverLog, "<p>CoverFile: <code>~tp</code>\n", [CoverFile]),
- write_cross_cover_info(TestDir,Cross),
+ ok = write_cross_cover_info(TestDir,Cross),
case length(cover:imported_modules()) of
Imps when Imps > 0 ->
@@ -5329,7 +5330,7 @@ cover_analyse(CoverInfo, TestDir) ->
io:fwrite(CoverLog, "<p>Excluded module(s): <code>~tp</code>\n", [Excluded]),
Coverage = test_server:cover_analyse(TestDir, CoverInfo),
- write_binary_file(filename:join(TestDir,?raw_coverlog_name),
+ ok = write_binary_file(filename:join(TestDir,?raw_coverlog_name),
term_to_binary(Coverage)),
case lists:filter(fun({_M,{_,_,_}}) -> false;
@@ -5344,8 +5345,8 @@ cover_analyse(CoverInfo, TestDir) ->
end,
TotPercent = write_cover_result_table(CoverLog, Coverage),
- write_binary_file(filename:join(TestDir, ?cover_total),
- term_to_binary(TotPercent)).
+ ok = write_binary_file(filename:join(TestDir, ?cover_total),
+ term_to_binary(TotPercent)).
%% Cover analysis - accumulated over multiple tests
%% This can be executed on any node after all tests are finished.
@@ -5395,7 +5396,7 @@ write_cross_cover_info(Dir,Cross) ->
write_cross_cover_logs([{Tag,Coverage}|T],TagDirMods) ->
case lists:keyfind(Tag,1,TagDirMods) of
{_,Dir,Mods} when Mods=/=[] ->
- write_binary_file(filename:join(Dir,?raw_cross_coverlog_name),
+ ok = write_binary_file(filename:join(Dir,?raw_cross_coverlog_name),
term_to_binary(Coverage)),
CoverLogName = filename:join(Dir,?cross_coverlog_name),
{ok,CoverLog} = open_html_file(CoverLogName),
diff --git a/lib/common_test/src/test_server_gl.erl b/lib/common_test/src/test_server_gl.erl
index 333c8fc06e..7d6fe64b92 100644
--- a/lib/common_test/src/test_server_gl.erl
+++ b/lib/common_test/src/test_server_gl.erl
@@ -185,7 +185,7 @@ handle_info({capture,Cap0}, St) ->
end,
{noreply,St#st{capture=Cap}};
handle_info({io_request,From,ReplyAs,Req}=IoReq, St) ->
- try io_req(Req, From, St) of
+ _ = try io_req(Req, From, St) of
passthrough ->
group_leader() ! IoReq;
{EscapeHtml,Data} ->
@@ -197,7 +197,8 @@ handle_info({io_request,From,ReplyAs,Req}=IoReq, St) ->
#st{capture=none} ->
ok;
#st{capture=CapturePid} ->
- CapturePid ! {captured,Data}
+ CapturePid ! {captured,Data},
+ ok
end,
case EscapeHtml andalso St#st.escape_chars of
true ->
diff --git a/lib/common_test/src/test_server_io.erl b/lib/common_test/src/test_server_io.erl
index 8c5c0aef35..3d5238052b 100644
--- a/lib/common_test/src/test_server_io.erl
+++ b/lib/common_test/src/test_server_io.erl
@@ -215,7 +215,7 @@ handle_call({set_fd,Tag,Fd}, _From, #st{fds=Fds0,tags=Tags0,
true ->
%% Fd ready, print anything buffered for associated Tag
lists:filtermap(fun({T,From,Str}) when T == Tag ->
- output(From, Tag, Str, St1),
+ _ = output(From, Tag, Str, St1),
false;
(_) ->
true
@@ -274,14 +274,15 @@ handle_call(reset_state, _From, #st{fds=Fds,tags=Tags,gls=Gls,
end
end, Tags),
GlList = gb_sets:to_list(Gls),
- [test_server_gl:stop(GL) || GL <- GlList],
+ _ = [test_server_gl:stop(GL) || GL <- GlList],
timer:sleep(100),
case lists:filter(fun(GlPid) -> is_process_alive(GlPid) end, GlList) of
[] ->
ok;
_ ->
timer:sleep(2000),
- [exit(GL, kill) || GL <- GlList]
+ [exit(GL, kill) || GL <- GlList],
+ ok
end,
Empty = gb_trees:empty(),
{ok,Shared} = test_server_gl:start_link(),
@@ -304,7 +305,7 @@ handle_call({stop,FdTags}, From, #st{fds=Fds0,tags=Tags0,
none ->
{Fds,Tags};
{value,Fd} ->
- file:close(Fd),
+ _ = file:close(Fd),
{gb_trees:delete(Tag, Fds),
lists:delete(Tag, Tags)}
end
@@ -333,7 +334,7 @@ handle_info({'EXIT',_Pid,Reason}, _St) ->
handle_info(stop_group_leaders, #st{gls=Gls}=St) ->
%% Stop the remaining group leaders.
GlPids = gb_sets:to_list(Gls),
- [test_server_gl:stop(GL) || GL <- GlPids],
+ _ = [test_server_gl:stop(GL) || GL <- GlPids],
timer:sleep(100),
Wait =
case lists:filter(fun(GlPid) -> is_process_alive(GlPid) end, GlPids) of
@@ -344,7 +345,7 @@ handle_info(stop_group_leaders, #st{gls=Gls}=St) ->
{noreply,St};
handle_info(kill_group_leaders, #st{gls=Gls,stopping=From,
pending_ops=Ops}=St) ->
- [exit(GL, kill) || GL <- gb_sets:to_list(Gls)],
+ _ = [exit(GL, kill) || GL <- gb_sets:to_list(Gls)],
if From /= undefined ->
gen_server:reply(From, ok);
true -> % reply has been sent already
@@ -434,7 +435,7 @@ do_print_buffered(Q0, St) ->
eot ->
Q;
{Tag,Str} ->
- do_output(Tag, Str, undefined, St),
+ _ = do_output(Tag, Str, undefined, St),
do_print_buffered(Q, St)
end.
@@ -448,5 +449,5 @@ gc(#st{gls=Gls0}) ->
InUse = ordsets:from_list(InUse0),
Gls = gb_sets:to_list(Gls0),
NotUsed = ordsets:subtract(Gls, InUse),
- [test_server_gl:stop(Pid) || Pid <- NotUsed],
+ _ = [test_server_gl:stop(Pid) || Pid <- NotUsed],
ok.
diff --git a/lib/common_test/src/test_server_node.erl b/lib/common_test/src/test_server_node.erl
index c64399e485..0b406c54cc 100644
--- a/lib/common_test/src/test_server_node.erl
+++ b/lib/common_test/src/test_server_node.erl
@@ -198,9 +198,9 @@ trc_loop(Sock,Patterns,Type) ->
gen_tcp:close(Sock)
end.
add_nodes(Nodes,Patterns,_Type) ->
- ttb:tracer(Nodes,[{file,{local, test_server}},
- {handler, {{?MODULE,handle_debug},initial}}]),
- ttb:p(all,[call,timestamp]),
+ {ok, _} = ttb:tracer(Nodes,[{file,{local, test_server}},
+ {handler, {{?MODULE,handle_debug},initial}}]),
+ {ok, _} = ttb:p(all,[call,timestamp]),
lists:foreach(fun({TP,M,F,A,Pat}) -> ttb:TP(M,F,A,Pat);
({CTP,M,F,A}) -> ttb:CTP(M,F,A)
end,
@@ -360,8 +360,8 @@ start_node_peer(SlaveName, OptList, From, TI) ->
-spec wait_for_node_started_fun(_, _, _, _, _) -> fun(() -> no_return()).
wait_for_node_started_fun(LSock, Tmo, Cleanup, TI, Self) ->
fun() ->
- wait_for_node_started(LSock,Tmo,undefined,
- Cleanup,TI,Self),
+ {{ok, _}, _} = wait_for_node_started(LSock,Tmo,undefined,
+ Cleanup,TI,Self),
receive after infinity -> ok end
end.
@@ -432,7 +432,7 @@ wait_for_node_started(LSock,Timeout,Client,Cleanup,TI,CtrlPid) ->
client=Client});
false -> ok
end,
- gen_tcp:controlling_process(Sock,CtrlPid),
+ ok = gen_tcp:controlling_process(Sock,CtrlPid),
test_server_ctrl:node_started(Nodename),
{{ok,Nodename},W}
end;
diff --git a/lib/common_test/src/test_server_sup.erl b/lib/common_test/src/test_server_sup.erl
index fa2bb33c2d..6922e01fcc 100644
--- a/lib/common_test/src/test_server_sup.erl
+++ b/lib/common_test/src/test_server_sup.erl
@@ -755,7 +755,7 @@ framework_call(FW,_Func,_Args,DefaultReturn)
DefaultReturn;
framework_call(Callback,Func,Args,DefaultReturn) ->
Mod = list_to_atom(Callback),
- case code:is_loaded(Mod) of
+ _ = case code:is_loaded(Mod) of
false -> code:load_file(Mod);
_ -> ok
end,
@@ -851,7 +851,8 @@ util_start() ->
spawn_link(fun() ->
register(?MODULE, self()),
util_loop(#util_state{starter=Starter})
- end);
+ end),
+ ok;
_Pid ->
ok
end.
diff --git a/lib/common_test/src/vts.erl b/lib/common_test/src/vts.erl
index e1c16fbda4..f1c5051164 100644
--- a/lib/common_test/src/vts.erl
+++ b/lib/common_test/src/vts.erl
@@ -64,7 +64,7 @@
%%%-----------------------------------------------------------------
%%% User API
start() ->
- ct_webtool:start(),
+ {ok, _} = ct_webtool:start(),
ct_webtool:start_tools([],"app=vts").
init_data(ConfigFiles,EvHandlers,LogDir,LogOpts,Tests) ->
@@ -169,7 +169,7 @@ loop(State) ->
NewState = State#state{config=Config,event_handler=EvHandlers,
current_log_dir=LogDir,
logopts=LogOpts,tests=Tests},
- ct_install(NewState),
+ _ = ct_install(NewState),
return(From,ok),
loop(NewState);
{start_page,From} ->
@@ -192,12 +192,12 @@ loop(State) ->
loop(State);
{{add_config_file,Input},From} ->
{Return,State1} = add_config_file1(Input,State),
- ct_install(State1),
+ _ = ct_install(State1),
return(From,Return),
loop(State1);
{{remove_config_file,Input},From} ->
{Return,State1} = remove_config_file1(Input,State),
- ct_install(State1),
+ _ = ct_install(State1),
return(From,Return),
loop(State1);
{run_frame,From} ->
@@ -233,7 +233,7 @@ loop(State) ->
return(From,result_summary_frame1(State)),
loop(State);
stop_reload_results ->
- file:set_cwd(State#state.start_dir),
+ ok = file:set_cwd(State#state.start_dir),
loop(State#state{reload_results=false});
{no_result_log_frame,From} ->
return(From,no_result_log_frame1()),
@@ -277,8 +277,8 @@ call(Msg) ->
end.
return({To,Ref},Result) ->
- To ! {Ref, Result}.
-
+ To ! {Ref, Result},
+ ok.
run_test1(State=#state{tests=Tests,current_log_dir=LogDir,
logopts=LogOpts}) ->
@@ -311,7 +311,6 @@ run_test1(State=#state{tests=Tests,current_log_dir=LogDir,
ct_install(#state{config=Config,event_handler=EvHandlers,
current_log_dir=LogDir}) ->
ct_run:install([{config,Config},{event_handler,EvHandlers}],LogDir).
-
%%%-----------------------------------------------------------------
%%% HTML
start_page1() ->
@@ -549,7 +548,7 @@ case_select(Dir,Suite,Case,N) ->
end,
case MakeResult of
ok ->
- code:add_pathz(Dir),
+ true = code:add_pathz(Dir),
case catch apply(Suite,all,[]) of
{'EXIT',Reason} ->
io:format("\n~p\n",[Reason]),
@@ -755,7 +754,7 @@ report1(tests_start,{TestName,_N},State) ->
end,
State#state{testruns=TestRuns};
report1(tests_done,{_Ok,_Fail,_Skip},State) ->
- timer:send_after(5000, self(),stop_reload_results),
+ {ok, _} = timer:send_after(5000, self(),stop_reload_results),
State#state{running=State#state.running-1,reload_results=true};
report1(tc_start,{_Suite,_Case},State) ->
State;
diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile
index 1532b6c1f7..b1eddfedd7 100644
--- a/lib/common_test/test/Makefile
+++ b/lib/common_test/test/Makefile
@@ -69,7 +69,8 @@ MODULES= \
erl2html2_SUITE \
test_server_SUITE \
test_server_test_lib \
- ct_release_test_SUITE
+ ct_release_test_SUITE \
+ ct_log_SUITE
ERL_FILES= $(MODULES:%=%.erl)
HRL_FILES= test_server_test_lib.hrl
diff --git a/lib/common_test/test/ct_gen_conn_SUITE_data/conn_SUITE.erl b/lib/common_test/test/ct_gen_conn_SUITE_data/conn_SUITE.erl
index 1404df6410..19eb1211fa 100644
--- a/lib/common_test/test/ct_gen_conn_SUITE_data/conn_SUITE.erl
+++ b/lib/common_test/test/ct_gen_conn_SUITE_data/conn_SUITE.erl
@@ -73,24 +73,28 @@ handles_to_multi_conn_pids(_Config) ->
ConnPid3 = ct_gen_conn:get_conn_pid(Handle3),
{true,true} = {is_process_alive(Handle3),is_process_alive(ConnPid3)},
+ monitor_procs([Handle1,ConnPid1,Handle2,ConnPid2,Handle3,ConnPid3]),
+
ok = proto:close(Handle1),
- ct:sleep(100),
+ ok = wait_procs_down([Handle1,ConnPid1]),
{false,false} = {is_process_alive(Handle1),is_process_alive(ConnPid1)},
{true,true} = {is_process_alive(Handle2),is_process_alive(ConnPid2)},
ok = proto:kill_conn_proc(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([ConnPid2]),
{true,false} = {is_process_alive(Handle2),is_process_alive(ConnPid2)},
ConnPid2x = ct_gen_conn:get_conn_pid(Handle2),
true = is_process_alive(ConnPid2x),
+ monitor_procs([ConnPid2x]),
+
ok = proto:close(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([Handle2,ConnPid2x]),
{false,false} = {is_process_alive(Handle2),is_process_alive(ConnPid2x)},
application:set_env(ct_test, reconnect, false),
ok = proto:kill_conn_proc(Handle3),
- ct:sleep(100),
+ ok = wait_procs_down([Handle3,ConnPid3]),
{false,false} = {is_process_alive(Handle3),is_process_alive(ConnPid3)},
ok.
@@ -116,24 +120,28 @@ handles_to_single_conn_pids(_Config) ->
{undefined,Handle3,_,_}] = lists:sort(ct_util:get_connections(ConnPid)),
ct:pal("CONNS = ~n~p", [Conns]),
+ monitor_procs([Handle1,Handle2,Handle3,ConnPid]),
ok = proto:close(Handle1),
- ct:sleep(100),
+ ok = wait_procs_down([Handle1]),
{false,true} = {is_process_alive(Handle1),is_process_alive(ConnPid)},
ok = proto:kill_conn_proc(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([ConnPid]),
NewConnPid = ct_gen_conn:get_conn_pid(Handle2),
NewConnPid = ct_gen_conn:get_conn_pid(Handle3),
true = is_process_alive(Handle2),
true = is_process_alive(Handle3),
+ false = is_process_alive(ConnPid),
+
+ monitor_procs([NewConnPid]),
ok = proto:close(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([Handle2]),
{false,true} = {is_process_alive(Handle2),is_process_alive(NewConnPid)},
application:set_env(ct_test, reconnect, false),
ok = proto:kill_conn_proc(Handle3),
- ct:sleep(100),
+ ok = wait_procs_down([Handle3,NewConnPid]),
{false,false} = {is_process_alive(Handle3),is_process_alive(NewConnPid)},
ok.
@@ -158,30 +166,37 @@ names_to_multi_conn_pids(_Config) ->
Handle1 = proto:open(mconn1),
+ monitor_procs([Handle1,ConnPid1,Handle2,ConnPid2,Handle3,ConnPid3]),
+
ok = proto:close(mconn1),
- ct:sleep(100),
+ ok = wait_procs_down([Handle1,ConnPid1]),
{false,false} = {is_process_alive(Handle1),is_process_alive(ConnPid1)},
ok = proto:kill_conn_proc(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([ConnPid2]),
Handle2 = proto:open(mconn2), % should've been reconnected already
{true,false} = {is_process_alive(Handle2),is_process_alive(ConnPid2)},
ConnPid2x = ct_gen_conn:get_conn_pid(Handle2),
true = is_process_alive(ConnPid2x),
+ monitor_procs([ConnPid2x]),
+
ok = proto:close(mconn2),
- ct:sleep(100),
+ ok = wait_procs_down([Handle2,ConnPid2x]),
{false,false} = {is_process_alive(Handle2),is_process_alive(ConnPid2x)},
Handle2y = proto:open(mconn2),
ConnPid2y = ct_gen_conn:get_conn_pid(Handle2y),
{true,true} = {is_process_alive(Handle2y),is_process_alive(ConnPid2y)},
+
+ monitor_procs([Handle2y,ConnPid2y]),
+
ok = proto:close(mconn2),
- ct:sleep(100),
+ ok = wait_procs_down([Handle2y,ConnPid2y]),
{false,false} = {is_process_alive(Handle2y),is_process_alive(ConnPid2y)},
application:set_env(ct_test, reconnect, false),
ok = proto:kill_conn_proc(Handle3),
- ct:sleep(100),
+ ok = wait_procs_down([Handle3,ConnPid3]),
{false,false} = {is_process_alive(Handle3),is_process_alive(ConnPid3)},
ok.
@@ -211,16 +226,20 @@ names_to_single_conn_pids(_Config) ->
{sconn3,Handle3,_,_}] = lists:sort(ct_util:get_connections(ConnPid)),
ct:pal("CONNS on ~p = ~n~p", [ConnPid,Conns]),
+ monitor_procs([Handle1,Handle2,Handle3,ConnPid]),
+
ok = proto:close(sconn1),
- ct:sleep(100),
+ ok = wait_procs_down([Handle1]),
{false,true} = {is_process_alive(Handle1),is_process_alive(ConnPid)},
ok = proto:kill_conn_proc(Handle2),
- ct:sleep(100),
+ ok = wait_procs_down([ConnPid]),
{true,false} = {is_process_alive(Handle2),is_process_alive(ConnPid)},
Handle2 = proto:open(sconn2), % should've been reconnected already
NewConnPid = ct_gen_conn:get_conn_pid(Handle2),
true = is_process_alive(NewConnPid),
+
+ monitor_procs([NewConnPid]),
Conns1 = [{sconn2,Handle2,_,_},
{sconn3,Handle3,_,_}] =
@@ -228,14 +247,29 @@ names_to_single_conn_pids(_Config) ->
ct:pal("CONNS on ~p = ~n~p", [NewConnPid,Conns1]),
ok = proto:close(sconn2),
- ct:sleep(100),
+ ok = wait_procs_down([Handle2]),
{false,true} = {is_process_alive(Handle2),is_process_alive(NewConnPid)},
application:set_env(ct_test, reconnect, false),
ok = proto:kill_conn_proc(Handle3),
- ct:sleep(100),
+ ok = wait_procs_down([Handle3,NewConnPid]),
{false,false} = {is_process_alive(Handle3),is_process_alive(NewConnPid)},
ok.
+%%%-----------------------------------------------------------------
+monitor_procs(Pids) ->
+ [erlang:monitor(process,Pid) || Pid <- Pids],
+ ok.
+
+wait_procs_down([]) ->
+ ok;
+wait_procs_down(Pids) ->
+ receive
+ {'DOWN',_,process,Pid,_} ->
+ wait_procs_down(lists:delete(Pid,Pids))
+ after 2000 ->
+ timeout
+ end.
+
diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/cth_log_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/cth_log_SUITE.erl
index 7b9b5687e5..bd1ac54781 100644
--- a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/cth_log_SUITE.erl
+++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/cth_log_SUITE.erl
@@ -40,6 +40,7 @@ suite() ->
%% @end
%%--------------------------------------------------------------------
init_per_suite(Config) ->
+ application:start(sasl),
Gen = spawn(fun() -> gen() end),
[{gen,Gen}|Config].
@@ -52,6 +53,7 @@ end_per_suite(Config) ->
Gen = proplists:get_value(gen, Config),
exit(Gen, kill),
ct:sleep(100),
+ application:stop(sasl),
ok.
%%--------------------------------------------------------------------
@@ -90,7 +92,8 @@ end_per_testcase(_TestCase, _Config) ->
%% @end
%%--------------------------------------------------------------------
groups() ->
- [{g1,[parallel,{repeat,10}],[tc1,tc2,tc3]}].
+ [{g1,[parallel,{repeat,10}],[tc1,tc2,tc3]},
+ {g2,[{repeat,10}],[tc1,tc2,tc3]}].
%%--------------------------------------------------------------------
%% @spec all() -> GroupsAndTestCases | {skip,Reason}
@@ -101,7 +104,7 @@ groups() ->
%% @end
%%--------------------------------------------------------------------
all() ->
- [{group,g1}].
+ [{group,g1},{group,g2}].
tc1(_) ->
ct:sleep(100),
@@ -121,5 +124,6 @@ gen() ->
gen_loop(N) ->
ct:log("Logger iteration: ~p", [N]),
error_logger:error_report(N),
- ct:sleep(200),
+ error_logger:info_report(progress, N),
+ ct:sleep(150),
gen_loop(N+1).
diff --git a/lib/common_test/test/ct_log_SUITE.erl b/lib/common_test/test/ct_log_SUITE.erl
new file mode 100644
index 0000000000..9bdd44cbdf
--- /dev/null
+++ b/lib/common_test/test/ct_log_SUITE.erl
@@ -0,0 +1,328 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2009-2016. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%%-------------------------------------------------------------------
+%%% File: ct_log_SUITE
+%%%
+%%% Description: Test that ct:log, ct:pal and io:format print to
+%%% the test case log file as expected, with or without special HTML
+%%% characters being escaped.
+%%%
+%%%-------------------------------------------------------------------
+-module(ct_log_SUITE).
+
+-compile(export_all).
+
+-include_lib("common_test/include/ct.hrl").
+-include_lib("common_test/include/ct_event.hrl").
+
+-define(eh, ct_test_support_eh).
+
+%%--------------------------------------------------------------------
+%% TEST SERVER CALLBACK FUNCTIONS
+%%--------------------------------------------------------------------
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_testcase(_TestCase, Config) ->
+ Config.
+
+end_per_testcase(_TestCase, _Config) ->
+ ok.
+
+suite() -> [{ct_hooks,[ts_install_cth]}].
+
+all() ->
+ [{group,print_and_verify}].
+
+groups() ->
+ [{print_and_verify,[sequence],[print,verify]}].
+
+init_per_group(_GroupName, Config) ->
+ Config.
+
+end_per_group(_GroupName, Config) ->
+ Config.
+
+%%--------------------------------------------------------------------
+%% TEST CASES
+%%--------------------------------------------------------------------
+
+%%%-----------------------------------------------------------------
+%%%
+print(Config) ->
+ TcLogFile = proplists:get_value(tc_logfile, Config),
+ Pid = self(),
+ String = atom_to_list(?MODULE),
+
+ %% START mark
+ io:format("LOGGING START~n"),
+
+ %% io:format
+ io:format("1. Printing nothing~n", []),
+ io:format("2. Printing a string: ~s~n", [String]),
+ io:format("3. Printing a string: ~p~n", [String]),
+ io:format("4. Printing a tuple: ~w~n", [{module,?MODULE}]),
+ io:format("5. Printing a pid: ~w~n", [Pid]),
+ io:format("6. Printing HTML: <pre>~s</pre>~n", [String]),
+
+ %% --- API ---
+ %% pal(Format) ->
+ %% = ct:pal(default, 50, Format, []).
+ %% pal(X1, X2) -> ok
+ %% X1 = Category | Importance | Format
+ %% X2 = Format | FormatArgs
+ %% pal(X1, X2, X3) -> ok
+ %% X1 = Category | Importance
+ %% X2 = Importance | Format
+ %% X3 = Format | FormatArgs
+ %% pal(Category, Importance, Format, FormatArgs) -> ok
+ %% ------
+ ct:pal("1. Printing nothing"),
+ ct:pal("2. Printing nothing", []),
+ ct:pal("3. Printing a string: ~s", [String]),
+ ct:pal("4. Printing a string: ~p", [String]),
+ ct:pal("5. Printing a tuple: ~w", [{module,?MODULE}]),
+ ct:pal("6. Printing a pid: ~w", [Pid]),
+ ct:pal("7. Printing HTML: <pre>~s</pre>", [String]),
+ ct:pal(ct_internal, "8. Printing with category"),
+ ct:pal(ct_internal, "9. Printing with ~s", ["category"]),
+ ct:pal(50, "10. Printing with importance"),
+ ct:pal(50, "11. Printing with ~s", ["importance"]),
+ ct:pal(ct_internal, 50, "12. Printing with ~s", ["category and importance"]),
+
+ %% --- API ---
+ %% log(Format) -> ok
+ %% = ct:log(default, 50, Format, [], []).
+ %% log(X1, X2) -> ok
+ %% X1 = Category | Importance | Format
+ %% X2 = Format | FormatArgs
+ %% log(X1, X2, X3) -> ok
+ %% X1 = Category | Importance
+ %% X2 = Importance | Format
+ %% X3 = Format | FormatArgs | Opts
+ %% log(X1, X2, X3, X4) -> ok
+ %% X1 = Category | Importance
+ %% X2 = Importance | Format
+ %% X3 = Format | FormatArgs
+ %% X4 = FormatArgs | Opts
+ %% log(Category, Importance, Format, FormatArgs, Opts) -> ok
+ %% ------
+ ct:log("1. Printing nothing"),
+ ct:log("2. Printing nothing", []),
+ ct:log("3. Printing a string: ~s", [String]),
+ ct:log("4. Printing a string: ~p", [String]),
+ ct:log("5. Printing a tuple: ~w", [{module,?MODULE}]),
+ ct:log("6. Printing a pid: ~w", [Pid]),
+ ct:log("7. Printing HTML: <pre>~s</pre>", [String]),
+ ct:log("8. Printing a pid escaped: ~w", [Pid], [esc_chars]),
+ ct:log("9. Printing a string escaped: ~p", [String], [esc_chars]),
+ ct:log("10. Printing HTML escaped: <pre>~s</pre>", [String], [esc_chars]),
+ ct:log("11. Printing a string, no css: ~s", [String], [no_css]),
+ ct:log("12. Printing a pid escaped, no css: ~w", [Pid],
+ [esc_chars, no_css]),
+ ct:log(ct_internal, "13. Printing with category"),
+ ct:log(ct_internal, "14. Printing with ~s", ["category"]),
+ ct:log(ct_internal, "15. Printing with ~s, no_css", ["category"],
+ [no_css]),
+ ct:log(50, "16. Printing with importance"),
+ ct:log(50, "17. Printing with ~s", ["importance"]),
+ ct:log(50, "18. Printing with ~s, no_css", ["importance"], [no_css]),
+ ct:log(ct_internal, 50, "19. Printing with category and importance"),
+ ct:log(ct_internal, 50, "20. Printing with ~s", ["category and importance"]),
+ ct:log(ct_internal, 50, "21. Printing a pid escaped with ~s, no_css: ~w",
+ ["category and importance",Pid], [esc_chars,no_css]),
+
+ %% END mark
+ ct:log("LOGGING END", [], [no_css]),
+ {save_config,[{the_logfile,TcLogFile},{the_pid,Pid},{the_string,String}]}.
+
+
+verify(Config) ->
+ {print,SavedCfg} = proplists:get_value(saved_config, Config),
+ TcLogFile = proplists:get_value(the_logfile, SavedCfg),
+ Pid = proplists:get_value(the_pid, SavedCfg),
+ StrPid = lists:flatten(io_lib:format("~p",[Pid])),
+ EscPid = "&lt;" ++ string:substr(StrPid, 2, length(StrPid)-2) ++ "&gt;",
+ String = proplists:get_value(the_string, SavedCfg),
+ ct:log("Read from prev testcase: ~p & ~p", [TcLogFile,Pid]),
+ {ok,Dev} = file:open(TcLogFile, [read]),
+ ok = read_until(Dev, "LOGGING START\n"),
+
+ %% io:format
+ match_line(Dev, "1. Printing nothing", []),
+ read_nl(Dev),
+ match_line(Dev, "2. Printing a string: ~s", [String]),
+ read_nl(Dev),
+ match_line(Dev, "3. Printing a string: ~p", [String]),
+ read_nl(Dev),
+ match_line(Dev, "4. Printing a tuple: ~w", [{module,?MODULE}]),
+ read_nl(Dev),
+ match_line(Dev, "5. Printing a pid: ~s", [EscPid]),
+ read_nl(Dev),
+ match_line(Dev, "6. Printing HTML: &lt;pre&gt;~s&lt;/pre&gt;", [String]),
+ read_nl(Dev),
+ %% ct:pal
+ read_header(Dev),
+ match_line(Dev, "1. Printing nothing", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "2. Printing nothing", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "3. Printing a string: ~s", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "4. Printing a string: ~p", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "5. Printing a tuple: ~w", [{module,?MODULE}]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "6. Printing a pid: ~s", [EscPid]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "7. Printing HTML: &lt;pre&gt;~s&lt;/pre&gt;", [String]),
+ read_footer(Dev),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "8. Printing with category", []),
+ read_footer(Dev),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "9. Printing with ~s", ["category"]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "10. Printing with importance", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "11. Printing with ~s", ["importance"]),
+ read_footer(Dev),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "12. Printing with ~s", ["category and importance"]),
+ read_footer(Dev),
+ %% ct:log
+ read_header(Dev),
+ match_line(Dev, "1. Printing nothing", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "2. Printing nothing", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "3. Printing a string: ~s", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "4. Printing a string: ~p", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "5. Printing a tuple: ~w", [{module,?MODULE}]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "6. Printing a pid: ~w", [Pid]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "7. Printing HTML: <pre>~s</pre>", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "8. Printing a pid escaped: ~s", [EscPid]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "9. Printing a string escaped: ~p", [String]),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "10. Printing HTML escaped: &lt;pre&gt;~s&lt;/pre&gt;",
+ [String]),
+ read_footer(Dev),
+ match_line(Dev, "11. Printing a string, no css: ~s", [String]),
+ match_line(Dev, "12. Printing a pid escaped, no css: ~s", [EscPid]),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "13. Printing with category", []),
+ read_footer(Dev),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "14. Printing with ~s", ["category"]),
+ read_footer(Dev),
+ match_line(Dev, "15. Printing with ~s, no_css", ["category"]),
+ read_header(Dev),
+ match_line(Dev, "16. Printing with importance", []),
+ read_footer(Dev),
+ read_header(Dev),
+ match_line(Dev, "17. Printing with ~s", ["importance"]),
+ read_footer(Dev),
+ match_line(Dev, "18. Printing with ~s, no_css", ["importance"]),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "19. Printing with category and importance", []),
+ read_footer(Dev),
+ read_header(Dev, "\"ct_internal\""),
+ match_line(Dev, "20. Printing with ~s", ["category and importance"]),
+ read_footer(Dev),
+ match_line(Dev, "21. Printing a pid escaped with ~s, no_css: ~s",
+ ["category and importance",EscPid]),
+
+ file:close(Dev),
+ ok.
+
+%%%-----------------------------------------------------------------
+%%% HELP FUNCTIONS
+%%%-----------------------------------------------------------------
+
+read_until(Dev, Pat) ->
+ case file:read_line(Dev) of
+ {ok,Pat} ->
+ file:read_line(Dev), % \n
+ ok;
+ eof ->
+ file:close(Dev),
+ {error,{not_found,Pat}};
+ _ ->
+ read_until(Dev, Pat)
+ end.
+
+match_line(Dev, Format, Args) ->
+ Pat = lists:flatten(io_lib:format(Format, Args)),
+ Line = element(2, file:read_line(Dev)),
+ case re:run(Line, Pat) of
+ {match,_} ->
+ ok;
+ nomatch ->
+ ct:pal("ERROR! No match for ~p.\nLine = ~p", [Pat,Line]),
+ file:close(Dev),
+ ct:fail({mismatch,Pat,Line})
+ end.
+
+read_header(Dev) ->
+ read_header(Dev, "\"default\"").
+
+read_header(Dev, Cat) ->
+ file:read_line(Dev), % \n
+ "</pre>\n" = element(2, file:read_line(Dev)),
+ {match,_} =
+ re:run(element(2, file:read_line(Dev)), "<div class="++Cat++"><pre><b>"
+ "\\*\\*\\* User \\d{4}-\\d{2}-\\d{2} "
+ "\\d{2}:\\d{2}:\\d{2}.\\d{1,} \\*\\*\\*</b>").
+
+read_footer(Dev) ->
+ "</pre></div>\n" = element(2, file:read_line(Dev)),
+ "<pre>\n" = element(2, file:read_line(Dev)).
+
+read_nl(Dev) ->
+ file:read_line(Dev).
+
+
diff --git a/lib/common_test/test/ct_netconfc_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE.erl
index 03fbc17bd2..2919f01605 100644
--- a/lib/common_test/test/ct_netconfc_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE.erl
@@ -44,16 +44,28 @@
%% there will be clashes with logging processes etc).
%%--------------------------------------------------------------------
init_per_suite(Config) ->
- case application:load(crypto) of
- {error,Reason} when Reason=/={already_loaded,crypto} ->
- {skip, Reason};
- _ ->
- case application:load(ssh) of
- {error,Reason} when Reason=/={already_loaded,ssh} ->
- {skip, Reason};
- _ ->
- ct_test_support:init_per_suite(Config)
- end
+ case check_crypto_and_ssh() of
+ ok ->
+ ct_test_support:init_per_suite(Config);
+ Skip ->
+ Skip
+ end.
+
+check_crypto_and_ssh() ->
+ (catch code:load_file(crypto)),
+ case code:is_loaded(crypto) of
+ {file,_} ->
+ case ssh:start() of
+ Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
+ ct:log("ssh started",[]),
+ ok;
+ Other ->
+ ct:log("could not start ssh: ~p",[Other]),
+ {skip, "SSH could not be started!"}
+ end;
+ Other ->
+ ct:log("could not load crypto: ~p",[Other]),
+ {skip, "crypto could not be loaded!"}
end.
end_per_suite(Config) ->
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index f34969683c..2aa6c4d354 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
@@ -124,8 +124,9 @@ end_per_testcase(_Case, _Config) ->
ok.
init_per_suite(Config) ->
- case catch ssh:start() of
- Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
+ (catch code:load_file(crypto)),
+ case {ssh:start(),code:is_loaded(crypto)} of
+ {Ok,{file,_}} when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("ssh started",[]),
SshDir = filename:join(filename:dirname(code:which(?MODULE)),
"ssh_dir"),
@@ -133,7 +134,7 @@ init_per_suite(Config) ->
ct:log("netconf server started",[]),
[{netconf_server,Server},{ssh_dir,SshDir}|Config];
Other ->
- ct:log("could not start ssh: ~p",[Other]),
+ ct:log("could not start ssh or load crypto: ~p",[Other]),
{skip, "SSH could not be started!"}
end.
@@ -360,7 +361,7 @@ get(Config) ->
get_a_lot(Config) ->
SshDir = ?config(ssh_dir,Config),
{ok,Client} = open_success(SshDir),
- Descr = lists:append(lists:duplicate(1000,"Description of myserver! ")),
+ Descr = lists:append(lists:duplicate(100,"Description of myserver! ")),
Server = {server,[{xmlns,"myns"}],[{name,[],["myserver"]},
{description,[],[Descr]}]},
Data = lists:duplicate(100,Server),
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
index 0a49cdabbb..a65275da43 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
@@ -62,14 +62,15 @@ stop_node(Case) ->
init_per_suite(Config) ->
- case ssh:start() of
- Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
+ (catch code:load_file(crypto)),
+ case {ssh:start(),code:is_loaded(crypto)} of
+ {Ok,{file,_}} when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started locally",[]),
SshDir = filename:join(filename:dirname(code:which(?MODULE)),
"ssh_dir"),
[{ssh_dir,SshDir}|Config];
Other ->
- ct:log("could not start ssh locally: ~p",[Other]),
+ ct:log("could not start ssh or load crypto locally: ~p",[Other]),
{skip, "SSH could not be started locally!"}
end.
@@ -85,15 +86,15 @@ remote_crash(Config) ->
{ok,Node} = ct_slave:start(nc_remote_crash),
Pa = filename:dirname(code:which(?NS)),
true = rpc:call(Node,code,add_patha,[Pa]),
-
- case rpc:call(Node,ssh,start,[]) of
- Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
+ rpc:call(Node,code,load_file,[crypto]),
+ case {rpc:call(Node,ssh,start,[]),rpc:call(Node,code,is_loaded,[crypto])} of
+ {Ok,{file,_}} when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started remote",[]),
ns(Node,start,[?config(ssh_dir,Config)]),
ct:log("netconf server started remote",[]),
remote_crash(Node,Config);
Other ->
- ct:log("could not start ssh remote: ~p",[Other]),
+ ct:log("could not start ssh or load crypto remote: ~p",[Other]),
{skip, "SSH could not be started remote!"}
end.
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
index 9fb1fb6547..e62bc617fa 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl
@@ -279,7 +279,7 @@ send({CM,Ch},Data) ->
%%% Split into many small parts and send to client
send_frag({CM,Ch},Data) ->
- Sz = rand:uniform(2000),
+ Sz = rand:uniform(1000),
case Data of
<<Chunk:Sz/binary,Rest/binary>> ->
ssh_connection:send(CM, Ch, Chunk),
diff --git a/lib/common_test/test/ct_repeat_testrun_SUITE.erl b/lib/common_test/test/ct_repeat_testrun_SUITE.erl
index 632597c214..f8b6a379f6 100644
--- a/lib/common_test/test/ct_repeat_testrun_SUITE.erl
+++ b/lib/common_test/test/ct_repeat_testrun_SUITE.erl
@@ -66,25 +66,47 @@
%% there will be clashes with logging processes etc).
%%--------------------------------------------------------------------
init_per_suite(Config0) ->
- Config = ct_test_support:init_per_suite(Config0),
- DataDir = ?config(data_dir, Config),
- Suite1 = filename:join([DataDir,"a_test","r1_SUITE"]),
- Suite2 = filename:join([DataDir,"b_test","r2_SUITE"]),
- Opts0 = ct_test_support:get_opts(Config),
- Opts1 = Opts0 ++ [{suite,Suite1},{testcase,tc2},{label,timing1}],
- Opts2 = Opts0 ++ [{suite,Suite2},{testcase,tc2},{label,timing2}],
-
- %% Make sure both suites are compiled
- {1,0,{0,0}} = ct_test_support:run(ct,run_test,[Opts1],Config),
- {1,0,{0,0}} = ct_test_support:run(ct,run_test,[Opts2],Config),
-
- %% Time the shortest testcase to use for offset
- {_T0,{1,0,{0,0}}} = timer:tc(ct_test_support,run,[ct,run_test,[Opts1],Config]),
-
- %% -2 is to ensure we hit inside the target test case and not after
-% T = round(T0/1000000)-2,
- T=0,
- [{offset,T}|Config].
+ TTInfo = {_T,{_Scaled,ScaleVal}} = ct:get_timetrap_info(),
+ ct:pal("Timetrap info = ~w", [TTInfo]),
+ if ScaleVal > 1 ->
+ {skip,"Skip on systems running e.g. cover or debug!"};
+ ScaleVal =< 1 ->
+ Config = ct_test_support:init_per_suite(Config0),
+ DataDir = ?config(data_dir, Config),
+ Suite1 = filename:join([DataDir,"a_test","r1_SUITE"]),
+ Suite2 = filename:join([DataDir,"b_test","r2_SUITE"]),
+ Opts0 = ct_test_support:get_opts(Config),
+ Opts1 = Opts0 ++ [{suite,Suite1},{testcase,tc2},{label,timing1}],
+ Opts2 = Opts0 ++ [{suite,Suite2},{testcase,tc2},{label,timing2}],
+
+ %% Make sure both suites are compiled
+ {1,0,{0,0}} = ct_test_support:run(ct,run_test,[Opts1],Config),
+ {1,0,{0,0}} = ct_test_support:run(ct,run_test,[Opts2],Config),
+
+ %% Check if file i/o is too slow for correct measurements
+ Opts3 = Opts0 ++ [{suite,Suite1},{testcase,tc1},{label,timing3}],
+ {T,_} =
+ timer:tc(
+ fun() ->
+ {1,0,{0,0}} = ct_test_support:run(ct,run_test,
+ [Opts3],Config),
+ {1,0,{0,0}} = ct_test_support:run(ct,run_test,
+ [Opts3],Config)
+ end),
+ %% The time to compare with here must match the timeout value
+ %% in the test suite. Accept 30% logging overhead (26 sec total).
+ if T > 26000000 ->
+ ct:pal("Timing test took ~w sec (< 27 sec expected). "
+ "Skipping the suite!",
+ [trunc(T/1000000)]),
+ ct_test_support:end_per_suite(Config),
+ {skip,"File I/O too slow for this suite"};
+ true ->
+ ct:pal("Timing test took ~w sec. Proceeding...",
+ [trunc(T/1000000)]),
+ [{offset,0}|Config]
+ end
+ end.
end_per_suite(Config) ->
ct_test_support:end_per_suite(Config).
diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl
index 477fcb8a26..e926abd885 100644
--- a/lib/common_test/test/ct_test_support.erl
+++ b/lib/common_test/test/ct_test_support.erl
@@ -484,7 +484,8 @@ get_events(_, Config) ->
{event_receiver,CTNode} ! {self(),get_events},
Events = receive {event_receiver,Evs} -> Evs end,
test_server:format(Level, "Stopping event receiver!~n", []),
- {event_receiver,CTNode} ! stop,
+ {event_receiver,CTNode} ! {self(),stop},
+ receive {event_receiver,stopped} -> ok end,
Events.
er() ->
@@ -499,8 +500,9 @@ er_loop(Evs) ->
{From,get_events} ->
From ! {event_receiver,lists:reverse(Evs)},
er_loop(Evs);
- stop ->
+ {From,stop} ->
unregister(event_receiver),
+ From ! {event_receiver,stopped},
ok
end.
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 2c33cb268a..65300b0bdf 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -117,38 +117,64 @@ init_client(#state{client=Sock}=State) ->
dbg("Server sending: ~p~n",["login: "]),
R = case gen_tcp:send(Sock,"login: ") of
ok ->
- loop(State, 1);
+ loop(State);
Error ->
Error
end,
_ = gen_tcp:close(Sock),
R.
-loop(State, N) ->
+loop(State=#state{client=Sock}) ->
receive
- {tcp,_,Data} ->
+ {tcp,Sock,Data} ->
try handle_data(Data,State) of
{ok,State1} ->
- loop(State1, N);
+ loop(State1);
closed ->
+ _ = flush(State),
closed
catch
throw:Error ->
+ _ = flush(State),
Error
end;
- {tcp_closed, _} ->
+ {tcp_closed,Sock} ->
closed;
- {tcp_error,_,Error} ->
+ {tcp_error,Sock,Error} ->
{error,tcp,Error};
disconnect ->
- Sock = State#state.client,
dbg("Server closing connection on socket ~p~n", [Sock]),
+ timer:sleep(1000),
ok = gen_tcp:close(Sock),
- closed;
+ _ = flush(State);
stop ->
+ _ = flush(State),
stopped
end.
+flush(State=#state{client=Sock}) ->
+ receive
+ {tcp,Sock,Data} = M->
+ dbg("Message flushed after close or error: ~p~n", [M]),
+ try handle_data(Data,State) of
+ {ok,State1} ->
+ flush(State1);
+ closed ->
+ flush(State)
+ catch
+ throw:Error ->
+ Error
+ end;
+ {tcp_closed,Sock} = M ->
+ dbg("Message flushed after close or error: ~p~n", [M]),
+ ok;
+ {tcp_error,Sock,Error} = M ->
+ dbg("Message flushed after close or error: ~p~n", [M]),
+ {error,tcp,Error}
+ after 100 ->
+ ok
+ end.
+
handle_data(Cmd,#state{break=true}=State) ->
dbg("Server got data when in break mode: ~p~n",[Cmd]),
handle_break_cmd(Cmd,State);