aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/src/test_server.erl132
-rw-r--r--lib/common_test/src/test_server_ctrl.erl63
-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_config_SUITE_data/config/test/config_dynamic_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_log_SUITE.erl328
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl266
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl17
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl166
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key13
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub11
-rw-r--r--lib/common_test/test/ct_repeat_testrun_SUITE.erl60
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl15
-rw-r--r--lib/common_test/test/telnet_server.erl16
-rw-r--r--lib/common_test/test_server/ts_install.erl9
19 files changed, 673 insertions, 486 deletions
diff --git a/lib/common_test/src/test_server.erl b/lib/common_test/src/test_server.erl
index ac81842583..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).
@@ -1830,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}
]).
@@ -2130,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 ->
@@ -2140,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,
@@ -2561,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.
@@ -2730,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 6bd7122c65..b52e4bef9b 100644
--- a/lib/common_test/src/test_server_ctrl.erl
+++ b/lib/common_test/src/test_server_ctrl.erl
@@ -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_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
index c64774cd4f..0b3f834732 100644
--- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
@@ -74,7 +74,7 @@ test_get_known_variable(_)->
test_localtime_update(_)->
Seconds = 5,
LT1 = ct:get_config(localtime),
- ct:sleep(Seconds*1000),
+ timer:sleep(Seconds*1000), % don't want scaling of this timer
LT2 = ct:reload_config(localtime),
case is_diff_ok(LT1, LT2, Seconds) of
{false, Actual, Exp}->
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_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index 065639dd36..f34969683c 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
@@ -123,41 +123,37 @@ init_per_testcase(_Case, Config) ->
end_per_testcase(_Case, _Config) ->
ok.
-init_per_suite() ->
- [{timetrap,2*?default_timeout}]. % making dsa files can be slow
init_per_suite(Config) ->
case catch ssh:start() of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("ssh started",[]),
- {ok, _} = netconfc_test_lib:get_id_keys(Config),
- netconfc_test_lib:make_dsa_files(Config),
- ct:log("dsa files created",[]),
- Server = ?NS:start(?config(data_dir,Config)),
+ SshDir = filename:join(filename:dirname(code:which(?MODULE)),
+ "ssh_dir"),
+ Server = ?NS:start(SshDir),
ct:log("netconf server started",[]),
- [{server,Server}|Config];
+ [{netconf_server,Server},{ssh_dir,SshDir}|Config];
Other ->
ct:log("could not start ssh: ~p",[Other]),
{skip, "SSH could not be started!"}
end.
end_per_suite(Config) ->
- ?NS:stop(?config(server,Config)),
+ ?NS:stop(?config(netconf_server,Config)),
ssh:stop(),
crypto:stop(),
- netconfc_test_lib:remove_id_keys(Config),
Config.
hello(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
hello_from_server_first(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1),
- {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(DataDir)),
+ {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(SshDir)),
ct:sleep(500),
?NS:expect(hello),
?ok = ct_netconfc:hello(Client, [{capability, ["urn:com:ericsson:ebase:1.1.0"]}], infinity),
@@ -166,8 +162,8 @@ hello_from_server_first(Config) ->
ok.
hello_named(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(any_name,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(any_name,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
@@ -175,8 +171,8 @@ hello_named(Config) ->
hello_configured() ->
[{require, netconf1}].
hello_configured(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_configured_success(netconf1,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_configured_success(netconf1,SshDir),
?NS:expect_do_reply('close-session',close,ok),
{error, {no_such_name,netconf1}} = ct_netconfc:close_session(netconf1),
?ok = ct_netconfc:close_session(Client),
@@ -185,10 +181,10 @@ hello_configured(Config) ->
hello_configured_extraopts() ->
[{require, netconf1}].
hello_configured_extraopts(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
%% Test that the cofiguration overwrites the ExtraOpts parameter
%% to ct_netconfc:open/2.
- {ok,Client} = open_configured_success(netconf1,DataDir,[{password,"faulty"}]),
+ {ok,Client} = open_configured_success(netconf1,SshDir,[{password,"faulty"}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
@@ -196,8 +192,8 @@ hello_configured_extraopts(Config) ->
hello_required() ->
[{require, my_named_connection, netconf1}].
hello_required(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,_Client} = open_configured_success(my_named_connection,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,_Client} = open_configured_success(my_named_connection,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ok.
@@ -205,69 +201,69 @@ hello_required(Config) ->
hello_required_exists() ->
[{require, my_named_connection, netconf1}].
hello_required_exists(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,_Client1} = open_configured_success(my_named_connection,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,_Client1} = open_configured_success(my_named_connection,SshDir),
%% Check that same name can not be used twice
{error,{connection_exists,_Client1}} =
- ct_netconfc:open(my_named_connection,[{user_dir,DataDir}]),
+ ct_netconfc:open(my_named_connection,[{user_dir,SshDir}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ct:sleep(500),
%% Then check that it can be used again after the first is closed
- {ok,_Client2} = open_configured_success(my_named_connection,DataDir),
+ {ok,_Client2} = open_configured_success(my_named_connection,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ok.
hello_global_pwd(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir,[{user,"any-user"},
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir,[{user,"any-user"},
{password,"global-xxx"}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
hello_no_session_id(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(no_session_id),
?NS:expect(no_session_id,hello),
- {error,{incorrect_hello,no_session_id_found}} = open(DataDir),
+ {error,{incorrect_hello,no_session_id_found}} = open(SshDir),
ok.
hello_incomp_base_vsn(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,{base,"1.1"}),
?NS:expect(hello),
- {error,{incompatible_base_capability_vsn,"1.1"}} = open(DataDir),
+ {error,{incompatible_base_capability_vsn,"1.1"}} = open(SshDir),
ok.
hello_no_base_cap(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,no_base),
?NS:expect(hello),
- {error,{incorrect_hello,no_base_capability_found}} = open(DataDir),
+ {error,{incorrect_hello,no_base_capability_found}} = open(SshDir),
ok.
hello_no_caps(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,no_caps),
?NS:expect(hello),
- {error,{incorrect_hello,capabilities_not_found}} = open(DataDir),
+ {error,{incorrect_hello,capabilities_not_found}} = open(SshDir),
ok.
no_server_hello(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:expect(undefined,hello),
- {error,{hello_session_failed,timeout}} = open(DataDir,[{timeout,2000}]),
+ {error,{hello_session_failed,timeout}} = open(SshDir,[{timeout,2000}]),
ok.
no_client_hello(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1),
- {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(DataDir)),
+ {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(SshDir)),
%% Allow server hello to arrive
ct:sleep(500),
@@ -280,8 +276,8 @@ no_client_hello(Config) ->
ok.
get_session_id(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
1 = ct_netconfc:get_session_id(Client),
@@ -290,8 +286,8 @@ get_session_id(Config) ->
ok.
get_capabilities(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Caps = ct_netconfc:get_capabilities(Client),
BaseCap = ?NETCONF_BASE_CAP ++ ?NETCONF_BASE_CAP_VSN,
@@ -302,49 +298,49 @@ get_capabilities(Config) ->
ok.
faulty_user(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,
"Unable to connect using the available authentication methods"}} =
- open(DataDir,[{user,"yyy"}]),
+ open(SshDir,[{user,"yyy"}]),
ok.
faulty_passwd(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,
"Unable to connect using the available authentication methods"}} =
- open(DataDir,[{password,"yyy"}]),
+ open(SshDir,[{password,"yyy"}]),
ok.
faulty_port(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,econnrefused}} =
- open(DataDir,[{port,2062}]),
+ open(SshDir,[{port,2062}]),
ok.
no_host(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts = lists:keydelete(ssh,1,?DEFAULT_SSH_OPTS(DataDir)),
+ SshDir = ?config(ssh_dir,Config),
+ Opts = lists:keydelete(ssh,1,?DEFAULT_SSH_OPTS(SshDir)),
{error,no_host_address} = ct_netconfc:open(Opts),
ok.
no_port(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts = lists:keydelete(port,1,?DEFAULT_SSH_OPTS(DataDir)),
+ SshDir = ?config(ssh_dir,Config),
+ Opts = lists:keydelete(port,1,?DEFAULT_SSH_OPTS(SshDir)),
{error,no_port} = ct_netconfc:open(Opts),
ok.
invalid_opt(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts1 = ?DEFAULT_SSH_OPTS(DataDir) ++ [{timeout,invalidvalue}],
+ SshDir = ?config(ssh_dir,Config),
+ Opts1 = ?DEFAULT_SSH_OPTS(SshDir) ++ [{timeout,invalidvalue}],
{error,{invalid_option,{timeout,invalidvalue}}} = ct_netconfc:open(Opts1),
- Opts2 = ?DEFAULT_SSH_OPTS(DataDir) ++ [{some_other_opt,true}],
+ Opts2 = ?DEFAULT_SSH_OPTS(SshDir) ++ [{some_other_opt,true}],
{error,{ssh,could_not_connect_to_server,{options,_}}} =
ct_netconfc:open(Opts2),
ok.
timeout_close_session(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect('close-session'),
true = erlang:is_process_alive(Client),
{error,timeout} = ct_netconfc:close_session(Client,1000),
@@ -352,8 +348,8 @@ timeout_close_session(Config) ->
ok.
get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get',{data,Data}),
{ok,Data} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]}),
@@ -362,8 +358,8 @@ get(Config) ->
ok.
get_a_lot(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Descr = lists:append(lists:duplicate(1000,"Description of myserver! ")),
Server = {server,[{xmlns,"myns"}],[{name,[],["myserver"]},
{description,[],[Descr]}]},
@@ -375,8 +371,8 @@ get_a_lot(Config) ->
ok.
timeout_get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect('get'),
{error,timeout} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]},1000),
?NS:expect_do_reply('close-session',close,ok),
@@ -392,8 +388,8 @@ timeout_get(Config) ->
%% Note that we can only hope that the test case triggers the problem
%% every now and then, as it is very timing dependent...
flush_timeout_get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get',{data,Data}),
timer:sleep(1000),
@@ -406,8 +402,8 @@ flush_timeout_get(Config) ->
ok.
get_xpath(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply({'get',xpath},{data,Data}),
{ok,Data} = ct_netconfc:get(Client,{xpath,"/server"}),
@@ -416,8 +412,8 @@ get_xpath(Config) ->
ok.
get_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get-config',{data,Data}),
{ok,Data} = ct_netconfc:get_config(Client,running,
@@ -427,8 +423,8 @@ get_config(Config) ->
ok.
get_config_xpath(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply({'get-config',xpath},{data,Data}),
{ok,Data} = ct_netconfc:get_config(Client,running,{xpath,"/server"}),
@@ -437,8 +433,8 @@ get_config_xpath(Config) ->
ok.
edit_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('edit-config',ok),
?ok = ct_netconfc:edit_config(Client,running,
{server,[{xmlns,"myns"}],
@@ -448,8 +444,8 @@ edit_config(Config) ->
ok.
edit_config_opt_params(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'edit-config',{'default-operation',"none"}},ok),
?ok = ct_netconfc:edit_config(Client,running,
{server,[{xmlns,"myns"}],
@@ -460,8 +456,8 @@ edit_config_opt_params(Config) ->
ok.
copy_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('copy-config',ok),
?ok = ct_netconfc:copy_config(Client,startup,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -469,8 +465,8 @@ copy_config(Config) ->
ok.
delete_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('delete-config',ok),
?ok = ct_netconfc:delete_config(Client,startup),
?NS:expect_do_reply('close-session',close,ok),
@@ -478,8 +474,8 @@ delete_config(Config) ->
ok.
lock(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('lock',ok),
?ok = ct_netconfc:lock(Client,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -487,8 +483,8 @@ lock(Config) ->
ok.
unlock(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('unlock',ok),
?ok = ct_netconfc:unlock(Client,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -496,12 +492,12 @@ unlock(Config) ->
ok.
kill_session(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:hello(2),
?NS:expect(2,hello),
- {ok,_OtherClient} = open(DataDir),
+ {ok,_OtherClient} = open(SshDir),
?NS:expect_do_reply('kill-session',{kill,2},ok),
?ok = ct_netconfc:kill_session(Client,2),
@@ -512,8 +508,8 @@ kill_session(Config) ->
ok.
get_no_such_client(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
@@ -529,8 +525,8 @@ get_no_such_client(Config) ->
ok.
action(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{myactionreturn,[{xmlns,"myns"}],["value"]}],
%% test either to receive {data,Data} or {ok,Data},
%% both need to be handled
@@ -549,8 +545,8 @@ action(Config) ->
ok.
send_any_rpc(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
GetConf = {'get-config',
[{source,["running"]},
@@ -571,8 +567,8 @@ send_any_rpc(Config) ->
ok.
send_any(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Correct get-config rpc
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
@@ -604,8 +600,8 @@ send_any(Config) ->
ok.
hide_password(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Password = "my_very_secret_password",
Data = [{passwords,[{xmlns,"myns"}],
[{password,[{xmlns,"pwdns"}],[Password]},
@@ -633,8 +629,8 @@ hide_password(Config) ->
ok.
not_proper_xml(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
NS = list_to_binary(?NETCONF_NAMESPACE),
NotProper = <<"<rpc-reply message-id=\"1\" xmlns=\"",
NS/binary,"\"><data></rpc-reply>">>,
@@ -646,8 +642,8 @@ not_proper_xml(Config) ->
ok.
prefixed_namespace(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
NS = list_to_binary(?NETCONF_NAMESPACE),
%% Test that data element can be properly decoded and that
@@ -679,8 +675,8 @@ prefixed_namespace(Config) ->
%% i.e. when the complete rpc-reply is not contained in one single ssh
%% data message.
receive_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -727,8 +723,8 @@ receive_chunked_data(Config) ->
%% Same as receive_chunked_data, but timeout waiting for last part.
timeout_receive_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -773,8 +769,8 @@ timeout_receive_chunked_data(Config) ->
%% Same as receive_chunked_data, but close while waiting for last part.
close_while_waiting_for_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -816,8 +812,8 @@ close_while_waiting_for_chunked_data(Config) ->
ok.
connection_crash(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Test that if the test survives killing the connection
%% process. Earlier this caused ct_util_server to terminate, and
@@ -828,8 +824,8 @@ connection_crash(Config) ->
ok.
get_event_streams(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
StreamNames = ["NETCONF","stream1","stream2"],
Streams = [{N,[{description,"descr of " ++ N}]} || N <- StreamNames],
StreamsXml = [{stream,[{name,[N]}|[{Tag,[Value]} || {Tag,Value} <- Data]]}
@@ -849,31 +845,31 @@ get_event_streams(Config) ->
ok.
create_subscription(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
%% All defaults
- {ok,Client1} = open_success(DataDir),
+ {ok,Client1} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client1),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1),
%% All defaults with timeout
- {ok,Client1a} = open_success(DataDir),
+ {ok,Client1a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client1a,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1a),
%% All defaults timing out
- {ok,Client1b} = open_success(DataDir),
+ {ok,Client1b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream]}),
{error,timeout} = ct_netconfc:create_subscription(Client1b,100),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1b),
%% Stream
- {ok,Client2} = open_success(DataDir),
+ {ok,Client2} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
Stream = "some_stream",
?ok = ct_netconfc:create_subscription(Client2,Stream),
@@ -881,7 +877,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client2),
%% Filter
- {ok,Client3} = open_success(DataDir),
+ {ok,Client3} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
Filter = {notification,?NETMOD_NOTIF_NAMESPACE_ATTR,
[eventTime]},
@@ -890,28 +886,28 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client3),
%% Filter with timeout
- {ok,Client3a} = open_success(DataDir),
+ {ok,Client3a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
?ok = ct_netconfc:create_subscription(Client3a,Filter,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client3a),
%% Filter timing out
- {ok,Client3b} = open_success(DataDir),
+ {ok,Client3b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream,filter]}),
{error,timeout}=ct_netconfc:create_subscription(Client3b,Filter,100),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client3b),
%% Stream and filter
- {ok,Client4} = open_success(DataDir),
+ {ok,Client4} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
?ok = ct_netconfc:create_subscription(Client4,Stream,Filter),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client4),
%% Start/stop time
- {ok,Client5} = open_success(DataDir),
+ {ok,Client5} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
StartTime = xs_datetime({D,{H,M,S}}= calendar:local_time()),
StopTime = xs_datetime({D,{H+2,M,S}}),
@@ -920,14 +916,14 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client5),
%% Start/stop time with timeout
- {ok,Client5a} = open_success(DataDir),
+ {ok,Client5a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
?ok = ct_netconfc:create_subscription(Client5a,StartTime,StopTime,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client5a),
%% Start/stop time timing out
- {ok,Client5b} = open_success(DataDir),
+ {ok,Client5b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream,startTime,stopTime]}),
{error,timeout} =
ct_netconfc:create_subscription(Client5b,StartTime,StopTime,100),
@@ -935,14 +931,14 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client5b),
%% Stream and start/stop time
- {ok,Client6} = open_success(DataDir),
+ {ok,Client6} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
?ok = ct_netconfc:create_subscription(Client6,Stream,StartTime,StopTime),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client6),
%% Filter and start/stop time
- {ok,Client7} = open_success(DataDir),
+ {ok,Client7} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter,startTime,stopTime]},
ok),
?ok = ct_netconfc:create_subscription(Client7,Filter,
@@ -951,7 +947,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client7),
%% Stream, filter and start/stop time
- {ok,Client8} = open_success(DataDir),
+ {ok,Client8} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter,startTime,stopTime]},
ok),
?ok = ct_netconfc:create_subscription(Client8,Stream,Filter,
@@ -960,7 +956,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client8),
%% Multiple filters
- {ok,Client9} = open_success(DataDir),
+ {ok,Client9} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
MultiFilters = [{event,[{xmlns,"http://my.namespaces.com/event"}],
[{eventClass,["fault"]},
@@ -975,8 +971,8 @@ create_subscription(Config) ->
ok.
receive_one_event(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1002,8 +998,8 @@ receive_one_event(Config) ->
ok.
receive_multiple_events(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1043,8 +1039,8 @@ receive_multiple_events(Config) ->
ok.
receive_event_and_rpc(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1103,8 +1099,8 @@ receive_event_and_rpc(Config) ->
receive_event_and_rpc_in_chunks(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
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 04bfe75187..0a49cdabbb 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
@@ -51,7 +51,7 @@ init_per_testcase(Case, Config) ->
stop_node(Case),
Config.
-end_per_testcase(Case, Config) ->
+end_per_testcase(Case, _Config) ->
stop_node(Case),
ok.
@@ -61,16 +61,13 @@ stop_node(Case) ->
rpc:call(Node,erlang,halt,[]).
-init_per_suite() ->
- [{timetrap,2*?default_timeout}]. % making dsa files can be slow
init_per_suite(Config) ->
case ssh:start() of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started locally",[]),
- {ok, _} = netconfc_test_lib:get_id_keys(Config),
- netconfc_test_lib:make_dsa_files(Config),
- ct:log("dsa files created",[]),
- Config;
+ SshDir = filename:join(filename:dirname(code:which(?MODULE)),
+ "ssh_dir"),
+ [{ssh_dir,SshDir}|Config];
Other ->
ct:log("could not start ssh locally: ~p",[Other]),
{skip, "SSH could not be started locally!"}
@@ -79,7 +76,6 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
ssh:stop(),
crypto:stop(),
- netconfc_test_lib:remove_id_keys(Config),
Config.
%% This test case is related to seq12645
@@ -93,7 +89,7 @@ remote_crash(Config) ->
case rpc:call(Node,ssh,start,[]) of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started remote",[]),
- Server = rpc:call(Node,?NS,start,[?config(data_dir,Config)]),
+ ns(Node,start,[?config(ssh_dir,Config)]),
ct:log("netconf server started remote",[]),
remote_crash(Node,Config);
Other ->
@@ -102,8 +98,7 @@ remote_crash(Config) ->
end.
remote_crash(Node,Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(Node,DataDir),
+ {ok,Client} = open_success(Node,?config(ssh_dir,Config)),
ns(Node,expect_reply,[{'create-subscription',[stream]},ok]),
?ok = ct_netconfc:create_subscription(Client),
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl
deleted file mode 100644
index e058bc7600..0000000000
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl
+++ /dev/null
@@ -1,166 +0,0 @@
--module(netconfc_test_lib).
-
--export([get_id_keys/1, remove_id_keys/1, make_dsa_files/1]).
--include_lib("common_test/include/ct.hrl").
--include_lib("public_key/include/public_key.hrl").
-
-%%%-----------------------------------------------------------------
-%%% BEGIN SSH key management
-%% copy private keys to given dir from ~/.ssh
-get_id_keys(Config) ->
- DstDir = ?config(priv_dir, Config),
- SrcDir = filename:join(os:getenv("HOME"), ".ssh"),
- RsaOk = copyfile(SrcDir, DstDir, "id_rsa"),
- DsaOk = copyfile(SrcDir, DstDir, "id_dsa"),
- case {RsaOk, DsaOk} of
- {{ok, _}, {ok, _}} -> {ok, both};
- {{ok, _}, _} -> {ok, rsa};
- {_, {ok, _}} -> {ok, dsa};
- {Error, _} -> Error
- end.
-
-%% Remove later on. Use make_dsa_files instead.
-remove_id_keys(Config) ->
- Dir = ?config(priv_dir, Config),
- file:delete(filename:join(Dir, "id_rsa")),
- file:delete(filename:join(Dir, "id_dsa")).
-
-
-make_dsa_files(Config) ->
- make_dsa_files(Config, rfc4716_public_key).
-make_dsa_files(Config, Type) ->
- {DSA, EncodedKey} = gen_dsa(128, 20),
- PKey = DSA#'DSAPrivateKey'.y,
- P = DSA#'DSAPrivateKey'.p,
- Q = DSA#'DSAPrivateKey'.q,
- G = DSA#'DSAPrivateKey'.g,
- Dss = #'Dss-Parms'{p=P, q=Q, g=G},
- {ok, Hostname} = inet:gethostname(),
- {ok, {A, B, C, D}} = inet:getaddr(Hostname, inet),
- IP = lists:concat([A, ".", B, ".", C, ".", D]),
- Attributes = [], % Could be [{comment,"user@" ++ Hostname}],
- HostNames = [{hostnames,[IP, IP]}],
- PublicKey = [{{PKey, Dss}, Attributes}],
- KnownHosts = [{{PKey, Dss}, HostNames}],
-
- KnownHostsEnc = public_key:ssh_encode(KnownHosts, known_hosts),
- KnownHosts = public_key:ssh_decode(KnownHostsEnc, known_hosts),
-
- PublicKeyEnc = public_key:ssh_encode(PublicKey, Type),
-
- SystemTmpDir = ?config(data_dir, Config),
- filelib:ensure_dir(SystemTmpDir),
- file:make_dir(SystemTmpDir),
-
- DSAFile = filename:join(SystemTmpDir, "ssh_host_dsa_key.pub"),
- file:delete(DSAFile),
-
- DSAPrivateFile = filename:join(SystemTmpDir, "ssh_host_dsa_key"),
- file:delete(DSAPrivateFile),
-
- KHFile = filename:join(SystemTmpDir, "known_hosts"),
- file:delete(KHFile),
-
- PemBin = public_key:pem_encode([EncodedKey]),
-
- file:write_file(DSAFile, PublicKeyEnc),
- file:write_file(KHFile, KnownHostsEnc),
- file:write_file(DSAPrivateFile, PemBin),
- ok.
-
-
-%%--------------------------------------------------------------------
-%% @doc Creates a dsa key (OBS: for testing only)
-%% the sizes are in bytes
-%% @spec (::integer()) -> {::atom(), ::binary(), ::opaque()}
-%% @end
-%%--------------------------------------------------------------------
-gen_dsa(LSize,NSize) when is_integer(LSize), is_integer(NSize) ->
- Key = gen_dsa2(LSize, NSize),
- {Key, encode_key(Key)}.
-
-encode_key(Key = #'DSAPrivateKey'{}) ->
- Der = public_key:der_encode('DSAPrivateKey', Key),
- {'DSAPrivateKey', Der, not_encrypted}.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% DSA key generation (OBS: for testing only)
-%% See http://en.wikipedia.org/wiki/Digital_Signature_Algorithm
-%% and the fips_186-3.pdf
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-gen_dsa2(LSize, NSize) ->
- Q = prime(NSize), %% Choose N-bit prime Q
- X0 = prime(LSize),
- P0 = prime((LSize div 2) +1),
-
- %% Choose L-bit prime modulus P such that p-1 is a multiple of q.
- case dsa_search(X0 div (2*Q*P0), P0, Q, 1000) of
- error ->
- gen_dsa2(LSize, NSize);
- P ->
- G = crypto:mod_pow(2, (P-1) div Q, P), % Choose G a number whose multiplicative order modulo p is q.
- %% such that This may be done by setting g = h^(p-1)/q mod p, commonly h=2 is used.
-
- X = prime(20), %% Choose x by some random method, where 0 < x < q.
- Y = crypto:mod_pow(G, X, P), %% Calculate y = g^x mod p.
-
- #'DSAPrivateKey'{version=0, p = P, q = Q,
- g = crypto:bytes_to_integer(G), y = crypto:bytes_to_integer(Y), x = X}
- end.
-
-%% See fips_186-3.pdf
-dsa_search(T, P0, Q, Iter) when Iter > 0 ->
- P = 2*T*Q*P0 + 1,
- case is_prime(P, 50) of
- true -> P;
- false -> dsa_search(T+1, P0, Q, Iter-1)
- end;
-dsa_search(_,_,_,_) ->
- error.
-
-
-%%%%%%% Crypto Math %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-prime(ByteSize) ->
- Rand = odd_rand(ByteSize),
- prime_odd(Rand, 0).
-
-prime_odd(Rand, N) ->
- case is_prime(Rand, 50) of
- true ->
- Rand;
- false ->
- prime_odd(Rand+2, N+1)
- end.
-
-%% see http://en.wikipedia.org/wiki/Fermat_primality_test
-is_prime(_, 0) -> true;
-is_prime(Candidate, Test) ->
- CoPrime = odd_rand(10000, Candidate),
- Result = crypto:mod_pow(CoPrime, Candidate, Candidate) ,
- is_prime(CoPrime, crypto:bytes_to_integer(Result), Candidate, Test).
-
-is_prime(CoPrime, CoPrime, Candidate, Test) ->
- is_prime(Candidate, Test-1);
-is_prime(_,_,_,_) ->
- false.
-
-odd_rand(Size) ->
- Min = 1 bsl (Size*8-1),
- Max = (1 bsl (Size*8))-1,
- odd_rand(Min, Max).
-
-odd_rand(Min,Max) ->
- Rand = crypto:rand_uniform(Min,Max),
- case Rand rem 2 of
- 0 ->
- Rand + 1;
- _ ->
- Rand
- end.
-
-copyfile(SrcDir, DstDir, Fn) ->
- file:copy(filename:join(SrcDir, Fn),
- filename:join(DstDir, Fn)).
-
-%%% END SSH key management
-%%%-----------------------------------------------------------------
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key
new file mode 100644
index 0000000000..4ee0b8657e
--- /dev/null
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key
@@ -0,0 +1,13 @@
+-----BEGIN DSA PRIVATE KEY-----
+MIIBvQIBAAKBgQDuGhXsDoUC/x98Q1KEgdf+pQjzBXFu0gMf6C2P47FILALVjvzt
+HvpXarT8Y0XZb4/i5XndcKazmRArEVmPzRT0Pp7gSJpOclY/f1YrplvtMjeQaZ/Y
+eD5JoQFpgIUduiifdRRt0r5gXYejCfACa+ZSFiXTvI+ZXpHC7rH+qRCRdwIVAL6Z
+VUd15Rm/C4NrLD/nIL8tnnE3AoGBAOo9qlMBtN1MdmvJZ+Pa/x8O5+VxQvAVNysb
+DDIZQtT58ko5r3sRA783zHtUft80FA8pUAhkrnRKnqn+bK42Xrm/IMXJd8Wi9LBy
+pN5Pg37B/k6pXs2qzLDYnCCBEW9EBBUn6fyZMK7DDs/BTU7Rf0dCh1/YsxRrm0yJ
+reFOd+1gAoGBAJTq0lPrrUB62NXllTbVNAusIQX870BHBHuo3K3OFYGYD85z1gwy
+e495snKyYOT9QfkBiuH/VGxP2BgIQH+cr5hTWsFZ/09mdhEC5sj/bVDrhwexklVx
+ZeHxpIVmpB97jXomdXVR2ZoP92Gco+qU8tXcBdopQQcybk5j4fUxa+KQAhUAmGWZ
+bHhbiRb/ip5oN6edhUe47TU=
+-----END DSA PRIVATE KEY-----
+
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub
new file mode 100644
index 0000000000..bca37299b0
--- /dev/null
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub
@@ -0,0 +1,11 @@
+---- BEGIN SSH2 PUBLIC KEY ----
+AAAAB3NzaC1kc3MAAACBAO4aFewOhQL/H3xDUoSB1/6lCPMFcW7SAx/oLY/jsUgsAtWO
+/O0e+ldqtPxjRdlvj+Lled1wprOZECsRWY/NFPQ+nuBImk5yVj9/ViumW+0yN5Bpn9h4
+PkmhAWmAhR26KJ91FG3SvmBdh6MJ8AJr5lIWJdO8j5lekcLusf6pEJF3AAAAFQC+mVVH
+deUZvwuDayw/5yC/LZ5xNwAAAIEA6j2qUwG03Ux2a8ln49r/Hw7n5XFC8BU3KxsMMhlC
+1PnySjmvexEDvzfMe1R+3zQUDylQCGSudEqeqf5srjZeub8gxcl3xaL0sHKk3k+DfsH+
+TqlezarMsNicIIERb0QEFSfp/JkwrsMOz8FNTtF/R0KHX9izFGubTImt4U537WAAAACB
+AJTq0lPrrUB62NXllTbVNAusIQX870BHBHuo3K3OFYGYD85z1gwye495snKyYOT9QfkB
+iuH/VGxP2BgIQH+cr5hTWsFZ/09mdhEC5sj/bVDrhwexklVxZeHxpIVmpB97jXomdXVR
+2ZoP92Gco+qU8tXcBdopQQcybk5j4fUxa+KQ
+---- END SSH2 PUBLIC KEY ----
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_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
index 9dc9095f47..985fa40ad2 100644
--- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
@@ -308,8 +308,19 @@ large_string(_) ->
VerifyStr = [C || C <- lists:flatten(Data1), C/=$ , C/=$\r, C/=$\n, C/=$>],
ok = ct_telnet:send(Handle, "echo_sep "++BigString),
- ct:sleep(50),
- {ok,Data2} = ct_telnet:get_data(Handle),
+ %% On some slow machines, 50 ms might not be enough to get the
+ %% first packet of data. We will therefore keep trying for a
+ %% second before we give up this...
+ F = fun RepeatUntilData(N) ->
+ ct:sleep(50),
+ case ct_telnet:get_data(Handle) of
+ {ok,[]} when N>1 ->
+ RepeatUntilData(N-1);
+ Other ->
+ Other
+ end
+ end,
+ {ok,Data2} = F(20),
ct:log("[GET DATA #2] Received ~w chars: ~s", [length(lists:flatten(Data2)),Data2]),
VerifyStr = [C || C <- lists:flatten(Data2), C/=$ , C/=$\r, C/=$\n, C/=$>],
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 107d98d72c..2c33cb268a 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -59,7 +59,7 @@ init(Opts) ->
accept(State),
ok = gen_tcp:close(LSock),
dbg("telnet_server closed the listen socket ~p\n", [LSock]),
- ct:sleep(1000),
+ timer:sleep(1000),
ok.
listen(0, _Port, _Opts) ->
@@ -68,7 +68,7 @@ listen(Retries, Port, Opts) ->
case gen_tcp:listen(Port, Opts) of
{error,eaddrinuse} ->
dbg("Listen port not released, trying again..."),
- ct:sleep(5000),
+ timer:sleep(5000),
listen(Retries-1, Port, Opts);
Ok = {ok,_LSock} ->
Ok;
@@ -193,6 +193,9 @@ handle_cmd([?AYT|T],State) ->
%% Used when testing 'newline' option in ct_telnet:send and ct_telnet:cmd.
send("yes\r\n> ",State),
handle_data(T,State);
+handle_cmd([?NOP|T],State) ->
+ %% Used for 'keep alive'
+ handle_data(T,State);
handle_cmd([_H|T],State) ->
%% Not responding to this command
handle_cmd(T,State);
@@ -203,6 +206,9 @@ handle_break_cmd([$q|T],State) ->
%% Dummy cmd allowed in break mode - quit break mode
send("\r\n> ",State),
handle_data(T,State#state{break=false});
+handle_break_cmd([_H|T],State) ->
+ %% Unknown command i break mode - ignore
+ handle_break_cmd(T,State);
handle_break_cmd([],State) ->
{ok,State}.
@@ -220,7 +226,7 @@ do_handle_data("echo_sep " ++ Data,State) ->
Msgs = string:tokens(Data," "),
lists:foreach(fun(Msg) ->
send(Msg,State),
- ct:sleep(10)
+ timer:sleep(10)
end, Msgs),
send("\r\n> ",State),
{ok,State};
@@ -245,7 +251,7 @@ do_handle_data("echo_loop " ++ Data,State) ->
do_handle_data("echo_delayed_prompt "++Data,State) ->
[MsStr|EchoData] = string:tokens(Data, " "),
send(string:join(EchoData,"\n"),State),
- ct:sleep(list_to_integer(MsStr)),
+ timer:sleep(list_to_integer(MsStr)),
send("\r\n> ",State),
{ok,State};
do_handle_data("disconnect_after " ++WaitStr,State) ->
@@ -298,7 +304,7 @@ send_loop(T0,T,Data,State) ->
ok;
true ->
send(Data,State),
- ct:sleep(500),
+ timer:sleep(500),
send_loop(T0,T,Data,State)
end.
diff --git a/lib/common_test/test_server/ts_install.erl b/lib/common_test/test_server/ts_install.erl
index b906eb21f5..5734bd0787 100644
--- a/lib/common_test/test_server/ts_install.erl
+++ b/lib/common_test/test_server/ts_install.erl
@@ -332,11 +332,12 @@ platform(Vars) ->
LC = lock_checking(),
MT = modified_timing(),
AsyncThreads = async_threads(),
+ OffHeapMsgQ = off_heap_msgq(),
Debug = debug(),
CpuBits = word_size(),
Common = lists:concat([Hostname,"/",OsType,"/",CpuType,CpuBits,LinuxDist,
Schedulers,BindType,KP,IOTHR,LC,MT,AsyncThreads,
- Debug,ExtraLabel]),
+ OffHeapMsgQ,Debug,ExtraLabel]),
PlatformId = lists:concat([ErlType, " ", Version, Common]),
PlatformLabel = ErlType ++ Common,
PlatformFilename = platform_as_filename(PlatformId),
@@ -400,6 +401,12 @@ async_threads() ->
_ -> ""
end.
+off_heap_msgq() ->
+ case catch erlang:system_info(message_queue_data) of
+ off_heap -> "/OffHeapMsgQ";
+ _ -> ""
+ end.
+
schedulers() ->
case catch erlang:system_info(smp_support) of
true ->