diff options
Diffstat (limited to 'lib/inets')
32 files changed, 1021 insertions, 3874 deletions
diff --git a/lib/inets/src/ftp/ftp.erl b/lib/inets/src/ftp/ftp.erl index db6260c7af..c2ca511795 100644 --- a/lib/inets/src/ftp/ftp.erl +++ b/lib/inets/src/ftp/ftp.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2015. All Rights Reserved. +%% Copyright Ericsson AB 1997-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. @@ -2177,7 +2177,7 @@ handle_caller(#state{caller = {transfer_data, {Cmd, Bin, RemoteFile}}} = %% Connect to FTP server at Host (default is TCP port 21) %% in order to establish a control connection. setup_ctrl_connection(Host, Port, Timeout, State) -> - MsTime = inets_time_compat:monotonic_time(), + MsTime = erlang:monotonic_time(), case connect(Host, Port, Timeout, State) of {ok, IpFam, CSock} -> NewState = State#state{csock = {tcp, CSock}, ipfamily = IpFam}, diff --git a/lib/inets/src/http_server/httpd_response.erl b/lib/inets/src/http_server/httpd_response.erl index c0b5f09faf..1374b7e85e 100644 --- a/lib/inets/src/http_server/httpd_response.erl +++ b/lib/inets/src/http_server/httpd_response.erl @@ -390,8 +390,7 @@ send_response_old(#mod{socket_type = Type, send_header(ModData, StatusCode, [{content_length, content_length(NewResponse)}]), httpd_socket:deliver(Type, Sock, NewResponse); - - {error, _Reason} -> + _ -> send_status(ModData, 500, "Internal Server Error") end. diff --git a/lib/inets/src/http_server/mod_htaccess.erl b/lib/inets/src/http_server/mod_htaccess.erl index 2bc0d79218..7b742bba24 100644 --- a/lib/inets/src/http_server/mod_htaccess.erl +++ b/lib/inets/src/http_server/mod_htaccess.erl @@ -412,8 +412,8 @@ getAuthenticatingDataFromHeader(Info)-> case httpd_util:split(UnCodedString,":",2) of {ok,[User,PassWord]}-> {user,User,PassWord}; - {error,Error}-> - {error,Error} + Other -> + {error, Other} end end; BadCredentials -> diff --git a/lib/inets/src/inets_app/Makefile b/lib/inets/src/inets_app/Makefile index a294381f67..eb0098dbee 100644 --- a/lib/inets/src/inets_app/Makefile +++ b/lib/inets/src/inets_app/Makefile @@ -48,9 +48,7 @@ MODULES = \ inets_app \ inets_sup \ inets_trace \ - inets_lib \ - inets_time_compat \ - inets_regexp + inets_lib INTERNAL_HRL_FILES = inets_internal.hrl EXTERNAL_HRL_FILES = ../../include/httpd.hrl \ diff --git a/lib/inets/src/inets_app/inets.app.src b/lib/inets/src/inets_app/inets.app.src index abf8c0cdea..eb4be932ac 100644 --- a/lib/inets/src/inets_app/inets.app.src +++ b/lib/inets/src/inets_app/inets.app.src @@ -28,8 +28,6 @@ inets_service, inets_trace, inets_lib, - inets_time_compat, - inets_regexp, %% FTP ftp, diff --git a/lib/inets/src/inets_app/inets_lib.erl b/lib/inets/src/inets_app/inets_lib.erl index 6e16f5ef6e..8993be29e4 100644 --- a/lib/inets/src/inets_app/inets_lib.erl +++ b/lib/inets/src/inets_app/inets_lib.erl @@ -27,7 +27,7 @@ %% Help function, elapsed milliseconds since T0 millisec_passed({_,_,_} = T0 ) -> %% OTP 17 and earlier - timer:now_diff(inets_time_compat:timestamp(), T0) div 1000; + timer:now_diff(erlang:timestamp(), T0) div 1000; millisec_passed(T0) -> %% OTP 18 diff --git a/lib/inets/src/inets_app/inets_regexp.erl b/lib/inets/src/inets_app/inets_regexp.erl deleted file mode 100644 index fc1608bc5a..0000000000 --- a/lib/inets/src/inets_app/inets_regexp.erl +++ /dev/null @@ -1,414 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. 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% -%% - --module(inets_regexp). - --export([parse/1, match/2, first_match/2, split/2, sub/3, gsub/3]). - - -%%%========================================================================= -%%% API -%%%========================================================================= - -%% parse(RegExp) -> {ok, RE} | {error, E}. -%% Parse the regexp described in the string RegExp. - -parse(S) -> - case (catch reg(S)) of - {R, []} -> - {ok, R}; - {_R, [C|_]} -> - {error, {illegal, [C]}}; - {error, E} -> - {error, E} - end. - - -%% Find the longest match of RegExp in String. - -match(S, RegExp) when is_list(RegExp) -> - case parse(RegExp) of - {ok,RE} -> match(S, RE); - {error,E} -> {error,E} - end; -match(S, RE) -> - case match(RE, S, 1, 0, -1) of - {Start,Len} when Len >= 0 -> - {match, Start, Len}; - {_Start,_Len} -> - nomatch - end. - -%% Find the first match of RegExp in String. - -first_match(S, RegExp) when is_list(RegExp) -> - case parse(RegExp) of - {ok, RE} -> - first_match(S, RE); - {error, E} -> - {error, E} - end; -first_match(S, RE) -> - case first_match(RE, S, 1) of - {Start,Len} when Len >= 0 -> - {match, Start,Len}; - nomatch -> - nomatch - end. - -first_match(RE, S, St) when S =/= [] -> - case re_apply(S, St, RE) of - {match, P, _Rest} -> - {St, P-St}; - nomatch -> - first_match(RE, tl(S), St+1) - end; -first_match(_RE, [], _St) -> - nomatch. - - -match(RE, S, St, Pos, L) -> - case first_match(RE, S, St) of - {St1, L1} -> - Nst = St1 + 1, - if L1 > L -> - match(RE, lists:nthtail(Nst-St, S), Nst, St1, L1); - true -> - match(RE, lists:nthtail(Nst-St, S), Nst, Pos, L) - end; - nomatch -> - {Pos, L} - end. - - -%% Split a string into substrings where the RegExp describes the -%% field seperator. The RegExp " " is specially treated. - -split(String, " ") -> %This is really special - {ok, RE} = parse("[ \t]+"), - case split_apply(String, RE, true) of - [[]|Ss] -> - {ok,Ss}; - Ss -> - {ok,Ss} - end; -split(String, RegExp) when is_list(RegExp) -> - case parse(RegExp) of - {ok, RE} -> - {ok, split_apply(String, RE, false)}; - {error, E} -> - {error,E} - end; -split(String, RE) -> - {ok, split_apply(String, RE, false)}. - - -%% Substitute the first match of the regular expression RegExp -%% with the string Replace in String. Accept pre-parsed regular -%% expressions. - -sub(String, RegExp, Rep) when is_list(RegExp) -> - case parse(RegExp) of - {ok, RE} -> - sub(String, RE, Rep); - {error, E} -> - {error, E} - end; -sub(String, RE, Rep) -> - Ss = sub_match(String, RE, 1), - {ok, sub_repl(Ss, Rep, String, 1), length(Ss)}. - - -%% Substitute every match of the regular expression RegExp with -%% the string New in String. Accept pre-parsed regular expressions. - -gsub(String, RegExp, Rep) when is_list(RegExp) -> - case parse(RegExp) of - {ok, RE} -> - gsub(String, RE, Rep); - {error, E} -> - {error, E} - end; -gsub(String, RE, Rep) -> - Ss = matches(String, RE, 1), - {ok, sub_repl(Ss, Rep, String, 1), length(Ss)}. - - -%%%======================================================================== -%%% Internal functions -%%%======================================================================== - -%% This is the regular expression grammar used. It is equivalent to the -%% one used in AWK, except that we allow ^ $ to be used anywhere and fail -%% in the matching. -%% -%% reg -> reg1 : '$1'. -%% reg1 -> reg1 "|" reg2 : {'or','$1','$2'}. -%% reg1 -> reg2 : '$1'. -%% reg2 -> reg2 reg3 : {concat,'$1','$2'}. -%% reg2 -> reg3 : '$1'. -%% reg3 -> reg3 "*" : {kclosure,'$1'}. -%% reg3 -> reg3 "+" : {pclosure,'$1'}. -%% reg3 -> reg3 "?" : {optional,'$1'}. -%% reg3 -> reg4 : '$1'. -%% reg4 -> "(" reg ")" : '$2'. -%% reg4 -> "\\" char : '$2'. -%% reg4 -> "^" : bos. -%% reg4 -> "$" : eos. -%% reg4 -> "." : char. -%% reg4 -> "[" class "]" : {char_class,char_class('$2')} -%% reg4 -> "[" "^" class "]" : {comp_class,char_class('$3')} -%% reg4 -> "\"" chars "\"" : char_string('$2') -%% reg4 -> char : '$1'. -%% reg4 -> empty : epsilon. -%% The grammar of the current regular expressions. The actual parser -%% is a recursive descent implementation of the grammar. - -reg(S) -> reg1(S). - -%% reg1 -> reg2 reg1' -%% reg1' -> "|" reg2 -%% reg1' -> empty - -reg1(S0) -> - {L,S1} = reg2(S0), - reg1p(S1, L). - -reg1p([$||S0], L) -> - {R,S1} = reg2(S0), - reg1p(S1, {'or',L,R}); -reg1p(S, L) -> {L,S}. - -%% reg2 -> reg3 reg2' -%% reg2' -> reg3 -%% reg2' -> empty - -reg2(S0) -> - {L,S1} = reg3(S0), - reg2p(S1, L). - -reg2p([C|S0], L) when (C =/= $|) andalso (C =/= $)) -> - {R,S1} = reg3([C|S0]), - reg2p(S1, {concat,L,R}); -reg2p(S, L) -> {L,S}. - -%% reg3 -> reg4 reg3' -%% reg3' -> "*" reg3' -%% reg3' -> "+" reg3' -%% reg3' -> "?" reg3' -%% reg3' -> empty - -reg3(S0) -> - {L,S1} = reg4(S0), - reg3p(S1, L). - -reg3p([$*|S], L) -> reg3p(S, {kclosure,L}); -reg3p([$+|S], L) -> reg3p(S, {pclosure,L}); -reg3p([$?|S], L) -> reg3p(S, {optional,L}); -reg3p(S, L) -> {L,S}. - -reg4([$(|S0]) -> - case reg(S0) of - {R,[$)|S1]} -> {R,S1}; - {_R,_S} -> throw({error,{unterminated,"("}}) - end; -reg4([$\\,O1,O2,O3|S]) - when ((O1 >= $0) andalso - (O1 =< $7) andalso - (O2 >= $0) andalso - (O2 =< $7) andalso - (O3 >= $0) andalso - (O3 =< $7)) -> - {(O1*8 + O2)*8 + O3 - 73*$0,S}; -reg4([$\\,C|S]) -> - {escape_char(C),S}; -reg4([$\\]) -> - throw({error, {unterminated,"\\"}}); -reg4([$^|S]) -> - {bos,S}; -reg4([$$|S]) -> - {eos,S}; -reg4([$.|S]) -> - {{comp_class,"\n"},S}; -reg4("[^" ++ S0) -> - case char_class(S0) of - {Cc,[$]|S1]} -> {{comp_class,Cc},S1}; - {_Cc,_S} -> throw({error,{unterminated,"["}}) - end; -reg4([$[|S0]) -> - case char_class(S0) of - {Cc,[$]|S1]} -> {{char_class,Cc},S1}; - {_Cc,_S1} -> throw({error,{unterminated,"["}}) - end; -reg4([C|S]) - when (C =/= $*) andalso (C =/= $+) andalso (C =/= $?) andalso (C =/= $]) -> - {C, S}; -reg4([C|_S]) -> - throw({error,{illegal,[C]}}); -reg4([]) -> - {epsilon,[]}. - -escape_char($n) -> $\n; %\n = LF -escape_char($r) -> $\r; %\r = CR -escape_char($t) -> $\t; %\t = TAB -escape_char($v) -> $\v; %\v = VT -escape_char($b) -> $\b; %\b = BS -escape_char($f) -> $\f; %\f = FF -escape_char($e) -> $\e; %\e = ESC -escape_char($s) -> $\s; %\s = SPACE -escape_char($d) -> $\d; %\d = DEL -escape_char(C) -> C. - -char_class([$]|S]) -> char_class(S, [$]]); -char_class(S) -> char_class(S, []). - -char($\\, [O1,O2,O3|S]) when - O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 -> - {(O1*8 + O2)*8 + O3 - 73*$0,S}; -char($\\, [C|S]) -> {escape_char(C),S}; -char(C, S) -> {C,S}. - -char_class([C1|S0], Cc) when C1 =/= $] -> - case char(C1, S0) of - {Cf,[$-,C2|S1]} when C2 =/= $] -> - case char(C2, S1) of - {Cl,S2} when Cf < Cl -> char_class(S2, [{Cf,Cl}|Cc]); - {Cl,_S2} -> throw({error,{char_class,[Cf,$-,Cl]}}) - end; - {C,S1} -> char_class(S1, [C|Cc]) - end; -char_class(S, Cc) -> {Cc,S}. - - -%% re_apply(String, StartPos, RegExp) -> re_app_res(). -%% -%% Apply the (parse of the) regular expression RegExp to String. If -%% there is a match return the position of the remaining string and -%% the string if else return 'nomatch'. BestMatch specifies if we want -%% the longest match, or just a match. -%% -%% StartPos should be the real start position as it is used to decide -%% if we ae at the beginning of the string. -%% -%% Pass two functions to re_apply_or so it can decide, on the basis -%% of BestMatch, whether to just any take any match or try both to -%% find the longest. This is slower but saves duplicatng code. - -re_apply(S, St, RE) -> re_apply(RE, [], S, St). - -re_apply(epsilon, More, S, P) -> %This always matches - re_apply_more(More, S, P); -re_apply({'or',RE1,RE2}, More, S, P) -> - re_apply_or(re_apply(RE1, More, S, P), - re_apply(RE2, More, S, P)); -re_apply({concat,RE1,RE2}, More, S0, P) -> - re_apply(RE1, [RE2|More], S0, P); -re_apply({kclosure,CE}, More, S, P) -> - %% Be careful with the recursion, explicitly do one call before - %% looping. - re_apply_or(re_apply_more(More, S, P), - re_apply(CE, [{kclosure,CE}|More], S, P)); -re_apply({pclosure,CE}, More, S, P) -> - re_apply(CE, [{kclosure,CE}|More], S, P); -re_apply({optional,CE}, More, S, P) -> - re_apply_or(re_apply_more(More, S, P), - re_apply(CE, More, S, P)); -re_apply(bos, More, S, 1) -> re_apply_more(More, S, 1); -re_apply(eos, More, [$\n|S], P) -> re_apply_more(More, S, P); -re_apply(eos, More, [], P) -> re_apply_more(More, [], P); -re_apply({char_class,Cc}, More, [C|S], P) -> - case in_char_class(C, Cc) of - true -> re_apply_more(More, S, P+1); - false -> nomatch - end; -re_apply({comp_class,Cc}, More, [C|S], P) -> - case in_char_class(C, Cc) of - true -> nomatch; - false -> re_apply_more(More, S, P+1) - end; -re_apply(C, More, [C|S], P) when is_integer(C) -> - re_apply_more(More, S, P+1); -re_apply(_RE, _More, _S, _P) -> nomatch. - -%% re_apply_more([RegExp], String, Length) -> re_app_res(). - -re_apply_more([RE|More], S, P) -> re_apply(RE, More, S, P); -re_apply_more([], S, P) -> {match,P,S}. - -%% in_char_class(Char, Class) -> bool(). - -in_char_class(C, [{C1,C2}|_Cc]) when C >= C1, C =< C2 -> true; -in_char_class(C, [C|_Cc]) -> true; -in_char_class(C, [_|Cc]) -> in_char_class(C, Cc); -in_char_class(_C, []) -> false. - -%% re_apply_or(Match1, Match2) -> re_app_res(). -%% If we want the best match then choose the longest match, else just -%% choose one by trying sequentially. - -re_apply_or({match,P1,S1}, {match,P2,_S2}) when P1 >= P2 -> {match,P1,S1}; -re_apply_or({match,_P1,_S1}, {match,P2,S2}) -> {match,P2,S2}; -re_apply_or(nomatch, R2) -> R2; -re_apply_or(R1, nomatch) -> R1. - - -matches(S, RE, St) -> - case first_match(RE, S, St) of - {St1,0} -> - [{St1,0}|matches(string:substr(S, St1+2-St), RE, St1+1)]; - {St1,L1} -> - [{St1,L1}|matches(string:substr(S, St1+L1+1-St), RE, St1+L1)]; - nomatch -> - [] - end. - -sub_match(S, RE, St) -> - case first_match(RE, S, St) of - {St1,L1} -> [{St1,L1}]; - nomatch -> [] - end. - -sub_repl([{St,L}|Ss], Rep, S, Pos) -> - Rs = sub_repl(Ss, Rep, S, St+L), - string:substr(S, Pos, St-Pos) ++ - sub_repl(Rep, string:substr(S, St, L), Rs); -sub_repl([], _Rep, S, Pos) -> - string:substr(S, Pos). - -sub_repl([$&|Rep], M, Rest) -> M ++ sub_repl(Rep, M, Rest); -sub_repl("\\&" ++ Rep, M, Rest) -> [$&|sub_repl(Rep, M, Rest)]; -sub_repl([C|Rep], M, Rest) -> [C|sub_repl(Rep, M, Rest)]; -sub_repl([], _M, Rest) -> Rest. - -split_apply(S, RE, Trim) -> split_apply(S, 1, RE, Trim, []). - -split_apply([], _P, _RE, true, []) -> - []; -split_apply([], _P, _RE, _T, Sub) -> - [lists:reverse(Sub)]; -split_apply(S, P, RE, T, Sub) -> - case re_apply(S, P, RE) of - {match,P,_Rest} -> - split_apply(tl(S), P+1, RE, T, [hd(S)|Sub]); - {match,P1,Rest} -> - [lists:reverse(Sub)|split_apply(Rest, P1, RE, T, [])]; - nomatch -> - split_apply(tl(S), P+1, RE, T, [hd(S)|Sub]) - end. diff --git a/lib/inets/src/inets_app/inets_time_compat.erl b/lib/inets/src/inets_app/inets_time_compat.erl deleted file mode 100644 index 475f0685dc..0000000000 --- a/lib/inets/src/inets_app/inets_time_compat.erl +++ /dev/null @@ -1,72 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2015-2015. 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% -%% - -%% This module is created to be able to execute on ERTS versions both -%% earlier and later than 7.0. - --module(inets_time_compat). - -%% We don't want warnings about the use of erlang:now/0 in -%% this module. --compile(nowarn_deprecated_function). - --export([monotonic_time/0, - timestamp/0, - unique_integer/0, - unique_integer/1]). - -monotonic_time() -> - try - erlang:monotonic_time() - catch - error:undef -> - %% Use Erlang system time as monotonic time - erlang_system_time_fallback() - end. - -timestamp() -> - try - erlang:timestamp() - catch - error:undef -> - erlang:now() - end. - -unique_integer() -> - try - erlang:unique_integer() - catch - error:undef -> - erlang_system_time_fallback() - end. - -unique_integer(Modifiers) -> - try - erlang:unique_integer(Modifiers) - catch - error:badarg -> - erlang:error(badarg, [Modifiers]); - error:undef -> - erlang_system_time_fallback() - end. - -erlang_system_time_fallback() -> - {MS, S, US} = erlang:now(), - (MS*1000000+S)*1000000+US. diff --git a/lib/inets/src/tftp/tftp_logger.erl b/lib/inets/src/tftp/tftp_logger.erl index 5e5d1d56c7..a869958484 100644 --- a/lib/inets/src/tftp/tftp_logger.erl +++ b/lib/inets/src/tftp/tftp_logger.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2015. All Rights Reserved. +%% Copyright Ericsson AB 2008-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. @@ -85,7 +85,7 @@ info_msg(Format, Data) -> %%------------------------------------------------------------------- add_timestamp(Format, Data) -> - Time = inets_time_compat:timestamp(), + Time = erlang:timestamp(), {{_Y, _Mo, _D}, {H, Mi, S}} = calendar:now_to_universal_time(Time), %% {"~p-~s-~sT~s:~s:~sZ,~6.6.0w tftp: " ++ Format ++ "\n", %% [Y, t(Mo), t(D), t(H), t(Mi), t(S), MicroSecs | Data]}. diff --git a/lib/inets/src/tftp/tftp_sup.erl b/lib/inets/src/tftp/tftp_sup.erl index 98b92cc87c..40b67c499c 100644 --- a/lib/inets/src/tftp/tftp_sup.erl +++ b/lib/inets/src/tftp/tftp_sup.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2005-2015. All Rights Reserved. +%% Copyright Ericsson AB 2005-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. @@ -94,7 +94,7 @@ unique_name(Options) -> {value, {_, Port}} when is_integer(Port), Port > 0 -> {tftpd, Port}; _ -> - {tftpd, inets_time_compat:unique_integer([positive])} + {tftpd, erlang:unique_integer([positive])} end. default_kill_after() -> diff --git a/lib/inets/test/Makefile b/lib/inets/test/Makefile index 65983c528d..ffc512050a 100644 --- a/lib/inets/test/Makefile +++ b/lib/inets/test/Makefile @@ -151,7 +151,6 @@ MODULES = \ inets_test_lib \ erl_make_certs \ ftp_SUITE \ - ftp_suite_lib \ ftp_format_SUITE \ http_format_SUITE \ httpc_SUITE \ @@ -169,8 +168,6 @@ MODULES = \ httpd_test_lib \ inets_sup_SUITE \ inets_SUITE \ - inets_app_test \ - inets_appup_test \ tftp_test_lib \ tftp_SUITE \ uri_SUITE \ diff --git a/lib/inets/test/ftp_SUITE.erl b/lib/inets/test/ftp_SUITE.erl index cc40377ebf..08295d4e3c 100644 --- a/lib/inets/test/ftp_SUITE.erl +++ b/lib/inets/test/ftp_SUITE.erl @@ -42,8 +42,10 @@ -define(BAD_USER, "baduser"). -define(BAD_DIR, "baddirectory"). -go() -> ct:run_test([{suite,"ftp_SUITE"}, {logdir,"LOG"}]). -gos() -> ct:run_test([{suite,"ftp_SUITE"}, {group,ftps_passive}, {logdir,"LOG"}]). +-record(progress, { + current = 0, + total + }). %%-------------------------------------------------------------------- %% Common Test interface functions ----------------------------------- @@ -90,7 +92,14 @@ ftp_tests()-> recv_chunk, type, quote, - ip_v6_disabled + ip_v6_disabled, + progress_report_send, + progress_report_recv, + not_owner, + unexpected_call, + unexpected_cast, + unexpected_bang, + clean_shutdown ]. %%-------------------------------------------------------------------- @@ -117,9 +126,9 @@ ftp_tests()-> -define(default_ftp_servers, [{"vsftpd", fun(__CONF__) -> - DataDir = ?config(data_dir,__CONF__), + DataDir = proplists:get_value(data_dir,__CONF__), ConfFile = filename:join(DataDir, "vsftpd.conf"), - PrivDir = ?config(priv_dir,__CONF__), + PrivDir = proplists:get_value(priv_dir,__CONF__), AnonRoot = PrivDir, Cmd = ["vsftpd "++filename:join(DataDir,"vsftpd.conf"), " -oftpd_banner=erlang_otp_testing", @@ -145,7 +154,7 @@ ftp_tests()-> fun(_StartResult) -> os:cmd("kill `ps ax | grep erlang_otp_testing | awk '/vsftpd/{print $1}'`") end, fun(__CONF__) -> - AnonRoot = ?config(priv_dir,__CONF__), + AnonRoot = proplists:get_value(priv_dir,__CONF__), [{id2ftp, fun(Id) -> filename:join(AnonRoot,Id) end}, {id2ftp_result,fun(Id) -> filename:join(AnonRoot,Id) end} | __CONF__] end, @@ -161,9 +170,9 @@ init_per_suite(Config) -> false -> {skip, "No ftp server found"}; {ok,Data} -> - TstDir = filename:join(?config(priv_dir,Config), "test"), + TstDir = filename:join(proplists:get_value(priv_dir,Config), "test"), file:make_dir(TstDir), - make_cert_files(dsa, rsa, "server-", ?config(data_dir,Config)), + make_cert_files(dsa, rsa, "server-", proplists:get_value(data_dir,Config)), start_ftpd([{test_dir,TstDir}, {ftpd_data,Data} | Config]) @@ -181,8 +190,16 @@ init_per_group(_Group, Config) -> Config. end_per_group(_Group, Config) -> Config. %%-------------------------------------------------------------------- -init_per_testcase(Case, Config0) -> - Group = proplists:get_value(name,?config(tc_group_properties,Config0)), + +init_per_testcase(Case, Config) when (Case =:= progress_report_send) orelse + (Case =:= progress_report_recv) -> + common_init_per_testcase(Case, [{progress, {?MODULE, progress, #progress{}}} | Config]); + +init_per_testcase(Case, Config) -> + common_init_per_testcase(Case, Config). + +common_init_per_testcase(Case, Config0) -> + Group = proplists:get_value(name,proplists:get_value(tc_group_properties,Config0)), try ?MODULE:Case(doc) of Msg -> ct:comment(Msg) catch @@ -203,9 +220,9 @@ init_per_testcase(Case, Config0) -> user -> Config; bad_user -> Config; _ -> - Pid = ?config(ftp,Config), + Pid = proplists:get_value(ftp,Config), ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS(atom_to_list(Group)++"-"++atom_to_list(Case)) ), - ok = ftp:cd(Pid, ?config(priv_dir,Config)), + ok = ftp:cd(Pid, proplists:get_value(priv_dir,Config)), Config end. @@ -213,10 +230,10 @@ init_per_testcase(Case, Config0) -> end_per_testcase(user, _Config) -> ok; end_per_testcase(bad_user, _Config) -> ok; end_per_testcase(_Case, Config) -> - case ?config(tc_status,Config) of + case proplists:get_value(tc_status,Config) of ok -> ok; _ -> - try ftp:latest_ctrl_response(?config(ftp,Config)) + try ftp:latest_ctrl_response(proplists:get_value(ftp,Config)) of {ok,S} -> ct:log("***~n*** Latest ctrl channel response:~n*** ~p~n***",[S]) catch @@ -228,38 +245,43 @@ end_per_testcase(_Case, Config) -> %%-------------------------------------------------------------------- %% Test Cases -------------------------------------------------------- %%-------------------------------------------------------------------- -user(doc) -> ["Open an ftp connection to a host, and logon as anonymous ftp, then logoff"]; +user() -> [ + {doc, "Open an ftp connection to a host, and logon as anonymous ftp," + " then logoff"}]. user(Config) -> - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS("")),% logon ok = ftp:close(Pid), % logoff {error,eclosed} = ftp:pwd(Pid), % check logoff result ok. %%------------------------------------------------------------------------- -bad_user(doc) -> ["Open an ftp connection to a host, and logon with bad user."]; +bad_user() -> + [{doc, "Open an ftp connection to a host, and logon with bad user."}]. bad_user(Config) -> - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {error, euser} = ftp:user(Pid, ?BAD_USER, ?FTP_PASS("")), ok. %%------------------------------------------------------------------------- -pwd(doc) -> ["Test ftp:pwd/1 & ftp:lpwd/1"]; +pwd() -> + [{doc, "Test ftp:pwd/1 & ftp:lpwd/1"}]. pwd(Config0) -> Config = set_state([reset], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {ok, PWD} = ftp:pwd(Pid), {ok, PathLpwd} = ftp:lpwd(Pid), PWD = id2ftp_result("", Config), PathLpwd = id2ftp_result("", Config). %%------------------------------------------------------------------------- -cd(doc) -> ["Open an ftp connection, log on as anonymous ftp, and cd to a" - "directory and to a non-existent directory."]; +cd() -> + ["Open an ftp connection, log on as anonymous ftp, and cd to a" + "directory and to a non-existent directory."]. cd(Config0) -> Dir = "test", Config = set_state([reset,{mkdir,Dir}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:cd(Pid, id2ftp(Dir,Config)), {ok, PWD} = ftp:pwd(Pid), ExpectedPWD = id2ftp_result(Dir, Config), @@ -267,12 +289,12 @@ cd(Config0) -> {error, epath} = ftp:cd(Pid, ?BAD_DIR). %%------------------------------------------------------------------------- -lcd(doc) -> - ["Test api function ftp:lcd/2"]; +lcd() -> + [{doc, "Test api function ftp:lcd/2"}]. lcd(Config0) -> Dir = "test", Config = set_state([reset,{mkdir,Dir}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:lcd(Pid, id2ftp(Dir,Config)), {ok, PWD} = ftp:lpwd(Pid), ExpectedPWD = id2ftp_result(Dir, Config), @@ -280,19 +302,20 @@ lcd(Config0) -> {error, epath} = ftp:lcd(Pid, ?BAD_DIR). %%------------------------------------------------------------------------- -ls(doc) -> ["Open an ftp connection; ls the current directory, and the " - "\"test\" directory. We assume that ls never fails, since " - "it's output is meant to be read by humans. "]; +ls() -> + [{doc, "Open an ftp connection; ls the current directory, and the " + "\"test\" directory. We assume that ls never fails, since " + "it's output is meant to be read by humans. "}]. ls(Config0) -> Config = set_state([reset,{mkdir,"test"}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {ok, _R1} = ftp:ls(Pid), {ok, _R2} = ftp:ls(Pid, id2ftp("test",Config)), %% neither nlist nor ls operates on a directory %% they operate on a pathname, which *can* be a %% directory, but can also be a filename or a group %% of files (including wildcards). - case ?config(wildcard_support, Config) of + case proplists:get_value(wildcard_support, Config) of true -> {ok, _R3} = ftp:ls(Pid, id2ftp("te*",Config)); _ -> @@ -300,20 +323,21 @@ ls(Config0) -> end. %%------------------------------------------------------------------------- -nlist(doc) -> ["Open an ftp connection; nlist the current directory, and the " +nlist() -> + [{doc,"Open an ftp connection; nlist the current directory, and the " "\"test\" directory. Nlist does not behave consistenly over " "operating systems. On some it is an error to have an empty " - "directory."]; + "directory."}]. nlist(Config0) -> Config = set_state([reset,{mkdir,"test"}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {ok, _R1} = ftp:nlist(Pid), {ok, _R2} = ftp:nlist(Pid, id2ftp("test",Config)), %% neither nlist nor ls operates on a directory %% they operate on a pathname, which *can* be a %% directory, but can also be a filename or a group %% of files (including wildcards). - case ?config(wildcard_support, Config) of + case proplists:get_value(wildcard_support, Config) of true -> {ok, _R3} = ftp:nlist(Pid, id2ftp("te*",Config)); _ -> @@ -321,13 +345,14 @@ nlist(Config0) -> end. %%------------------------------------------------------------------------- -rename(doc) -> ["Rename a file."]; +rename() -> + [{doc, "Rename a file."}]. rename(Config0) -> Contents = <<"ftp_SUITE test ...">>, OldFile = "old.txt", NewFile = "new.txt", Config = set_state([reset,{mkfile,OldFile,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:rename(Pid, id2ftp(OldFile,Config), @@ -338,13 +363,14 @@ rename(Config0) -> %%------------------------------------------------------------------------- -send(doc) -> ["Transfer a file with ftp using send/2."]; +send() -> + [{doc, "Transfer a file with ftp using send/2."}]. send(Config0) -> Contents = <<"ftp_SUITE test ...">>, SrcDir = "data", File = "file.txt", Config = set_state([reset,{mkfile,[SrcDir,File],Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), chk_no_file([File],Config), chk_file([SrcDir,File],Contents,Config), @@ -356,14 +382,15 @@ chk_file([SrcDir,File],Contents,Config), chk_file(File, Contents, Config). %%------------------------------------------------------------------------- -send_3(doc) -> ["Transfer a file with ftp using send/3."]; +send_3() -> + [{doc, "Transfer a file with ftp using send/3."}]. send_3(Config0) -> Contents = <<"ftp_SUITE test ...">>, Dir = "incoming", File = "file.txt", RemoteFile = "remfile.txt", Config = set_state([reset,{mkfile,File,Contents},{mkdir,Dir}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:cd(Pid, id2ftp(Dir,Config)), ok = ftp:lcd(Pid, id2ftp("",Config)), @@ -372,23 +399,25 @@ send_3(Config0) -> chk_file([Dir,RemoteFile], Contents, Config). %%------------------------------------------------------------------------- -send_bin(doc) -> ["Send a binary."]; +send_bin() -> + [{doc, "Send a binary."}]. send_bin(Config0) -> BinContents = <<"ftp_SUITE test ...">>, File = "file.txt", Config = set_state([reset], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {error, enotbinary} = ftp:send_bin(Pid, "some string", id2ftp(File,Config)), ok = ftp:send_bin(Pid, BinContents, id2ftp(File,Config)), chk_file(File, BinContents, Config). %%------------------------------------------------------------------------- -send_chunk(doc) -> ["Send a binary using chunks."]; +send_chunk() -> + [{doc, "Send a binary using chunks."}]. send_chunk(Config0) -> Contents = <<"ftp_SUITE test ...">>, File = "file.txt", Config = set_state([reset,{mkdir,"incoming"}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:send_chunk_start(Pid, id2ftp(File,Config)), {error, echunk} = ftp:cd(Pid, "incoming"), @@ -399,63 +428,69 @@ send_chunk(Config0) -> chk_file(File, <<Contents/binary,Contents/binary>>, Config). %%------------------------------------------------------------------------- -delete(doc) -> ["Delete a file."]; +delete() -> + [{doc, "Delete a file."}]. delete(Config0) -> Contents = <<"ftp_SUITE test ...">>, File = "file.txt", Config = set_state([reset,{mkfile,File,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:delete(Pid, id2ftp(File,Config)), chk_no_file([File], Config). %%------------------------------------------------------------------------- -mkdir(doc) -> ["Make a remote directory."]; +mkdir() -> + [{doc, "Make a remote directory."}]. mkdir(Config0) -> NewDir = "new_dir", Config = set_state([reset], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:mkdir(Pid, id2ftp(NewDir,Config)), chk_dir([NewDir], Config). %%------------------------------------------------------------------------- -rmdir(doc) -> ["Remove a directory."]; +rmdir() -> + [{doc, "Remove a directory."}]. rmdir(Config0) -> Dir = "dir", Config = set_state([reset,{mkdir,Dir}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:rmdir(Pid, id2ftp(Dir,Config)), chk_no_dir([Dir], Config). %%------------------------------------------------------------------------- -append(doc) -> ["Append a local file twice to a remote file"]; +append() -> + [{doc, "Append a local file twice to a remote file"}]. append(Config0) -> SrcFile = "f_src.txt", DstFile = "f_dst.txt", Contents = <<"ftp_SUITE test ...">>, Config = set_state([reset,{mkfile,SrcFile,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:append(Pid, id2ftp(SrcFile,Config), id2ftp(DstFile,Config)), ok = ftp:append(Pid, id2ftp(SrcFile,Config), id2ftp(DstFile,Config)), chk_file(DstFile, <<Contents/binary,Contents/binary>>, Config). %%------------------------------------------------------------------------- -append_bin(doc) -> ["Append a local file twice to a remote file using append_bin"]; +append_bin() -> + [{doc, "Append a local file twice to a remote file using append_bin"}]. append_bin(Config0) -> DstFile = "f_dst.txt", Contents = <<"ftp_SUITE test ...">>, Config = set_state([reset], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:append_bin(Pid, Contents, id2ftp(DstFile,Config)), ok = ftp:append_bin(Pid, Contents, id2ftp(DstFile,Config)), chk_file(DstFile, <<Contents/binary,Contents/binary>>, Config). %%------------------------------------------------------------------------- -append_chunk(doc) -> ["Append chunks."]; +append_chunk() -> + [{doc, "Append chunks."}]. append_chunk(Config0) -> File = "f_dst.txt", Contents = [<<"ER">>,<<"LE">>,<<"RL">>], Config = set_state([reset], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:append_chunk_start(Pid, id2ftp(File,Config)), {error, enotbinary} = ftp:append_chunk(Pid, binary_to_list(lists:nth(1,Contents))), ok = ftp:append_chunk(Pid,lists:nth(1,Contents)), @@ -465,53 +500,58 @@ append_chunk(Config0) -> chk_file(File, <<"ERLERL">>, Config). %%------------------------------------------------------------------------- -recv(doc) -> ["Receive a file using recv/2"]; +recv() -> + [{doc, "Receive a file using recv/2"}]. recv(Config0) -> File = "f_dst.txt", SrcDir = "a_dir", Contents = <<"ftp_SUITE test ...">>, Config = set_state([reset, {mkfile,[SrcDir,File],Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:cd(Pid, id2ftp(SrcDir,Config)), ok = ftp:lcd(Pid, id2ftp("",Config)), ok = ftp:recv(Pid, File), chk_file(File, Contents, Config). %%------------------------------------------------------------------------- -recv_3(doc) -> ["Receive a file using recv/3"]; +recv_3() -> + [{doc,"Receive a file using recv/3"}]. recv_3(Config0) -> DstFile = "f_src.txt", SrcFile = "f_dst.txt", Contents = <<"ftp_SUITE test ...">>, Config = set_state([reset, {mkfile,SrcFile,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:cd(Pid, id2ftp("",Config)), ok = ftp:recv(Pid, SrcFile, id2abs(DstFile,Config)), chk_file(DstFile, Contents, Config). %%------------------------------------------------------------------------- -recv_bin(doc) -> ["Receive a file as a binary."]; +recv_bin() -> + [{doc, "Receive a file as a binary."}]. recv_bin(Config0) -> File = "f_dst.txt", Contents = <<"ftp_SUITE test ...">>, Config = set_state([reset, {mkfile,File,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {ok,Received} = ftp:recv_bin(Pid, id2ftp(File,Config)), find_diff(Received, Contents). %%------------------------------------------------------------------------- -recv_chunk(doc) -> ["Receive a file using chunk-wise."]; +recv_chunk() -> + [{doc, "Receive a file using chunk-wise."}]. recv_chunk(Config0) -> File = "big_file.txt", Contents = list_to_binary( lists:duplicate(1000, lists:seq(0,255)) ), Config = set_state([reset, {mkfile,File,Contents}], Config0), - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), {{error, "ftp:recv_chunk_start/2 not called"},_} = recv_chunk(Pid, <<>>), ok = ftp:recv_chunk_start(Pid, id2ftp(File,Config)), {ok, ReceivedContents, _Ncunks} = recv_chunk(Pid, <<>>), find_diff(ReceivedContents, Contents). -recv_chunk(Pid, Acc) -> recv_chunk(Pid, Acc, 0). +recv_chunk(Pid, Acc) -> + recv_chunk(Pid, Acc, 0). recv_chunk(Pid, Acc, N) -> case ftp:recv_chunk(Pid) of @@ -521,18 +561,18 @@ recv_chunk(Pid, Acc, N) -> end. %%------------------------------------------------------------------------- -type(doc) -> ["Test that we can change btween ASCCI and binary transfer mode"]; +type() -> + [{doc,"Test that we can change btween ASCCI and binary transfer mode"}]. type(Config) -> - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ok = ftp:type(Pid, ascii), ok = ftp:type(Pid, binary), ok = ftp:type(Pid, ascii), {error, etype} = ftp:type(Pid, foobar). %%------------------------------------------------------------------------- -quote(doc) -> [""]; quote(Config) -> - Pid = ?config(ftp, Config), + Pid = proplists:get_value(ftp, Config), ["257 \""++_Rest] = ftp:quote(Pid, "pwd"), %% 257 [_| _] = ftp:quote(Pid, "help"), %% This negativ test causes some ftp servers to hang. This test @@ -541,48 +581,6 @@ quote(Config) -> %% = ftp:quote(Pid, "list"), ok. - -%%------------------------------------------------------------------------- -ip_v6_disabled(doc) -> ["Test ipv4 command PORT"]; -ip_v6_disabled(_Config) -> - %%% FIXME!!!! What is this??? - ok.%% send(Config). - -%%------------------------------------------------------------------------- -%% big_one(doc) -> -%% ["Create a local file and transfer it to the remote host into the " -%% "the \"incoming\" directory, remove " -%% "the local file. Then open a new connection; cd to \"incoming\", " -%% "lcd to the private directory; receive the file; delete the " -%% "remote file; close connection; check that received file is in " -%% "the correct directory; cleanup." ]; -%% big_one(Config) -> -%% Pid = ?config(ftp, Config), -%% do_recv(Pid, Config). - -%% do_recv(Pid, Config) -> -%% PrivDir = ?config(priv_dir, Config), -%% File = ?config(file, Config), -%% Newfile = ?config(new_file, Config), -%% AbsFile = filename:absname(File, PrivDir), -%% Contents = "ftp_SUITE:recv test ...", -%% ok = file:write_file(AbsFile, list_to_binary(Contents)), -%% ok = ftp:cd(Pid, "incoming"), -%% ftp:delete(Pid, File), % reset -%% ftp:lcd(Pid, PrivDir), -%% ok = ftp:send(Pid, File), -%% ok = file:delete(AbsFile), % cleanup -%% test_server:sleep(100), -%% ok = ftp:lcd(Pid, PrivDir), -%% ok = ftp:recv(Pid, File), -%% {ok, Files} = file:list_dir(PrivDir), -%% true = lists:member(File, Files), -%% ok = file:delete(AbsFile), % cleanup -%% ok = ftp:recv(Pid, File, Newfile), -%% ok = ftp:delete(Pid, File), % cleanup -%% ok. - - %%-------------------------------------------------------------------- %% Internal functions ----------------------------------------------- %%-------------------------------------------------------------------- @@ -676,13 +674,114 @@ chk_no_dir(PathList, Config) -> ct:fail("Unexpected error for ~p: ~p",[Path,Error]) end. +%%------------------------------------------------------------------------- +progress_report_send() -> + [{doc, "Test the option progress for ftp:send/[2,3]"}]. +progress_report_send(Config) when is_list(Config) -> + ReportPid = + spawn_link(?MODULE, progress_report_receiver_init, [self(), 1]), + send(Config), + receive + {ReportPid, ok} -> + ok + end. +%%------------------------------------------------------------------------- +progress_report_recv() -> + [{doc, "Test the option progress for ftp:recv/[2,3]"}]. +progress_report_recv(Config) when is_list(Config) -> + ReportPid = + spawn_link(?MODULE, progress_report_receiver_init, [self(), 3]), + recv(Config), + receive + {ReportPid, ok} -> + ok + end. + +%%------------------------------------------------------------------------- + +not_owner() -> + [{doc, "Test what happens if a process that not owns the connection tries " + "to use it"}]. +not_owner(Config) when is_list(Config) -> + Pid = proplists:get_value(ftp, Config), + OtherPid = spawn_link(?MODULE, not_owner, [Pid, self()]), + + receive + {OtherPid, ok} -> + {ok, _} = ftp:pwd(Pid) + end. + + +%%------------------------------------------------------------------------- + + +unexpected_call()-> + [{doc, "Test that behaviour of the ftp process if the api is abused"}]. +unexpected_call(Config) when is_list(Config) -> + Flag = process_flag(trap_exit, true), + Pid = proplists:get_value(ftp, Config), + + %% Serious programming fault, connetion will be shut down + case (catch gen_server:call(Pid, {self(), foobar, 10}, infinity)) of + {error, {connection_terminated, 'API_violation'}} -> + ok; + Unexpected1 -> + exit({unexpected_result, Unexpected1}) + end, + ct:sleep(500), + undefined = process_info(Pid, status), + process_flag(trap_exit, Flag). +%%------------------------------------------------------------------------- + +unexpected_cast()-> + [{doc, "Test that behaviour of the ftp process if the api is abused"}]. +unexpected_cast(Config) when is_list(Config) -> + Flag = process_flag(trap_exit, true), + Pid = proplists:get_value(ftp, Config), + %% Serious programming fault, connetion will be shut down + gen_server:cast(Pid, {self(), foobar, 10}), + ct:sleep(500), + undefined = process_info(Pid, status), + process_flag(trap_exit, Flag). +%%------------------------------------------------------------------------- + +unexpected_bang()-> + [{doc, "Test that connection ignores unexpected bang"}]. +unexpected_bang(Config) when is_list(Config) -> + Flag = process_flag(trap_exit, true), + Pid = proplists:get_value(ftp, Config), + %% Could be an innocent misstake the connection lives. + Pid ! foobar, + ct:sleep(500), + {status, _} = process_info(Pid, status), + process_flag(trap_exit, Flag). + +%%------------------------------------------------------------------------- + +clean_shutdown() -> + [{doc, "Test that owning process that exits with reason " + "'shutdown' does not cause an error message. OTP 6035"}]. + +clean_shutdown(Config) -> + PrivDir = proplists:get_value(priv_dir, Config), + LogFile = filename:join([PrivDir,"ticket_6035.log"]), + Host = proplists:get_value(ftpd_host,Config), + try + Pid = spawn(?MODULE, open_wait_6035, [Host, self()]), + error_logger:logfile({open, LogFile}), + true = kill_ftp_proc_6035(Pid, LogFile), + error_logger:logfile(close) + catch + throw:{error, not_found} -> + {skip, "No available FTP servers"} + end. %%-------------------------------------------------------------------- +%% Internal functions %%-------------------------------------------------------------------- -%% find a suitable ftpd -%% + find_executable(Config) -> - FTPservers = case ?config(ftpservers,Config) of + FTPservers = case proplists:get_value(ftpservers,Config) of undefined -> ?default_ftp_servers; L -> L end, @@ -694,11 +793,9 @@ find_executable(Config) -> not_available({Name,_StartCmd,_ChkUp,_StopCommand,_ConfigUpd,_Host,_Port}) -> os:find_executable(Name) == false. -%%-------------------------------------------------------------------- -%% start/stop of ftpd -%% + start_ftpd(Config) -> - {Name,StartCmd,_ChkUp,_StopCommand,ConfigRewrite,Host,Port} = ?config(ftpd_data, Config), + {Name,StartCmd,_ChkUp,_StopCommand,ConfigRewrite,Host,Port} = proplists:get_value(ftpd_data, Config), case StartCmd(Config) of {ok,StartResult} -> [{ftpd_host,Host}, @@ -709,38 +806,31 @@ start_ftpd(Config) -> end. stop_ftpd(Config) -> - {_Name,_StartCmd,_ChkUp,StopCommand,_ConfigUpd,_Host,_Port} = ?config(ftpd_data, Config), - StopCommand(?config(ftpd_start_result,Config)). + {_Name,_StartCmd,_ChkUp,StopCommand,_ConfigUpd,_Host,_Port} = proplists:get_value(ftpd_data, Config), + StopCommand(proplists:get_value(ftpd_start_result,Config)). ps_ftpd(Config) -> - {_Name,_StartCmd,ChkUp,_StopCommand,_ConfigUpd,_Host,_Port} = ?config(ftpd_data, Config), - ct:log( ChkUp(?config(ftpd_start_result,Config)) ). + {_Name,_StartCmd,ChkUp,_StopCommand,_ConfigUpd,_Host,_Port} = proplists:get_value(ftpd_data, Config), + ct:log( ChkUp(proplists:get_value(ftpd_start_result,Config)) ). ftpd_running(Config) -> - {_Name,_StartCmd,ChkUp,_StopCommand,_ConfigUpd,_Host,_Port} = ?config(ftpd_data, Config), - ChkUp(?config(ftpd_start_result,Config)). + {_Name,_StartCmd,ChkUp,_StopCommand,_ConfigUpd,_Host,_Port} = proplists:get_value(ftpd_data, Config), + ChkUp(proplists:get_value(ftpd_start_result,Config)). -%%-------------------------------------------------------------------- -%% start/stop of ftpc -%% ftp__open(Config, Options) -> - Host = ?config(ftpd_host,Config), - Port = ?config(ftpd_port,Config), + Host = proplists:get_value(ftpd_host,Config), + Port = proplists:get_value(ftpd_port,Config), ct:log("Host=~p, Port=~p",[Host,Port]), {ok,Pid} = ftp:open(Host, [{port,Port} | Options]), [{ftp,Pid}|Config]. ftp__close(Config) -> - ok = ftp:close(?config(ftp,Config)), + ok = ftp:close(proplists:get_value(ftp,Config)), Config. -%%-------------------------------------------------------------------- -%% split(Cs) -> string:tokens(Cs, "\r\n"). -%%-------------------------------------------------------------------- -%% find_diff(Bin1, Bin2) -> case find_diff(Bin1, Bin2, 1) of {error, {diff,Pos,RC,LC}} -> @@ -753,15 +843,14 @@ find_diff(Bin1, Bin2) -> find_diff(A, A, _) -> true; find_diff(<<H,T1/binary>>, <<H,T2/binary>>, Pos) -> find_diff(T1, T2, Pos+1); find_diff(RC, LC, Pos) -> {error, {diff, Pos, RC, LC}}. -%%-------------------------------------------------------------------- -%% + set_state(Ops, Config) when is_list(Ops) -> lists:foldl(fun set_state/2, Config, Ops); set_state(reset, Config) -> rm('*', id2abs("",Config)), - PrivDir = ?config(priv_dir,Config), + PrivDir = proplists:get_value(priv_dir,Config), file:set_cwd(PrivDir), - ftp:lcd(?config(ftp,Config),PrivDir), + ftp:lcd(proplists:get_value(ftp,Config),PrivDir), set_state({mkdir,""},Config); set_state({mkdir,Id}, Config) -> Abs = id2abs(Id, Config), @@ -787,7 +876,6 @@ mk_path(F, Pfx) -> AbsName end. - rm('*', Pfx) -> {ok,Fs} = file:list_dir(Pfx), lists:foreach(fun(F) -> rm(F, Pfx) end, Fs); @@ -805,17 +893,115 @@ rm(F, Pfx) -> ok end. -%%-------------------------------------------------------------------- -%% +not_owner(FtpPid, Pid) -> + {error, not_connection_owner} = ftp:pwd(FtpPid), + ftp:close(FtpPid), + ct:sleep(100), + Pid ! {self(), ok}. -id2abs(Id, Conf) -> filename:join(?config(priv_dir,Conf),ids(Id)). -id2ftp(Id, Conf) -> (?config(id2ftp,Conf))(ids(Id)). -id2ftp_result(Id, Conf) -> (?config(id2ftp_result,Conf))(ids(Id)). +id2abs(Id, Conf) -> filename:join(proplists:get_value(priv_dir,Conf),ids(Id)). +id2ftp(Id, Conf) -> (proplists:get_value(id2ftp,Conf))(ids(Id)). +id2ftp_result(Id, Conf) -> (proplists:get_value(id2ftp_result,Conf))(ids(Id)). ids([[_|_]|_]=Ids) -> filename:join(Ids); ids(Id) -> Id. -is_expected_absName(Id, File, Conf) -> File = (?config(id2abs,Conf))(Id). -is_expected_ftpInName(Id, File, Conf) -> File = (?config(id2ftp,Conf))(Id). -is_expected_ftpOutName(Id, File, Conf) -> File = (?config(id2ftp_result,Conf))(Id). +is_expected_absName(Id, File, Conf) -> File = (proplists:get_value(id2abs,Conf))(Id). +is_expected_ftpInName(Id, File, Conf) -> File = (proplists:get_value(id2ftp,Conf))(Id). +is_expected_ftpOutName(Id, File, Conf) -> File = (proplists:get_value(id2ftp_result,Conf))(Id). + + +progress(#progress{} = Progress , _File, {file_size, Total}) -> + progress_report_receiver ! start, + Progress#progress{total = Total}; + +progress(#progress{total = Total, current = Current} + = Progress, _File, {transfer_size, 0}) -> + progress_report_receiver ! finish, + case Total of + unknown -> + ok; + Current -> + ok; + _ -> + ct:fail({error, {progress, {total, Total}, + {current, Current}}}) + end, + Progress; +progress(#progress{current = Current} = Progress, _File, + {transfer_size, Size}) -> + progress_report_receiver ! update, + Progress#progress{current = Current + Size}. + +progress_report_receiver_init(Pid, N) -> + register(progress_report_receiver, self()), + receive + start -> + ok + end, + progress_report_receiver_loop(Pid, N-1). + +progress_report_receiver_loop(Pid, N) -> + receive + update -> + progress_report_receiver_loop(Pid, N); + finish when N =:= 0 -> + Pid ! {self(), ok}; + finish -> + Pid ! {self(), ok}, + receive + start -> + ok + end, + progress_report_receiver_loop(Pid, N-1) + end. + +kill_ftp_proc_6035(Pid, LogFile) -> + receive + open -> + exit(Pid, shutdown), + kill_ftp_proc_6035(Pid, LogFile); + {open_failed, Reason} -> + exit({skip, {failed_openening_server_connection, Reason}}) + after + 5000 -> + is_error_report_6035(LogFile) + end. + +open_wait_6035({_Tag, FtpServer}, From) -> + case ftp:open(FtpServer, [{timeout, timer:seconds(15)}]) of + {ok, Pid} -> + _LoginResult = ftp:user(Pid,"anonymous","kldjf"), + From ! open, + receive + dummy -> + ok + after + 10000 -> + ok + end, + ok; + {error, Reason} -> + From ! {open_failed, {Reason, FtpServer}}, + ok + end. + +is_error_report_6035(LogFile) -> + Res = + case file:read_file(LogFile) of + {ok, Bin} -> + Txt = binary_to_list(Bin), + read_log_6035(Txt); + _ -> + false + end, + %% file:delete(LogFile), + Res. + +read_log_6035("=ERROR REPORT===="++_Rest) -> + true; +read_log_6035([_|T]) -> + read_log_6035(T); +read_log_6035([]) -> + false. diff --git a/lib/inets/test/ftp_format_SUITE.erl b/lib/inets/test/ftp_format_SUITE.erl index cbe12e566b..2c17e2657c 100644 --- a/lib/inets/test/ftp_format_SUITE.erl +++ b/lib/inets/test/ftp_format_SUITE.erl @@ -24,18 +24,13 @@ -include_lib("common_test/include/ct.hrl"). -include("ftp_internal.hrl"). -%% Test server specific exports --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, - init_per_testcase/2, end_per_testcase/2]). +%% Note: This directive should only be used in test suites. +-compile(export_all). -%% Test cases must be exported. --export([ ftp_150/1, - ftp_200/1, ftp_220/1, ftp_226/1, ftp_257/1, ftp_331/1, ftp_425/1, - ftp_other_status_codes/1, ftp_multiple_lines/1, - ftp_multipel_ctrl_messages/1, format_error/1]). - -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds,5}} + ]. all() -> [{group, ftp_response}, format_error]. @@ -60,23 +55,16 @@ end_per_group(_GroupName, Config) -> init_per_testcase(_, Config) -> - Dog = test_server:timetrap(?t:minutes(1)), - NewConfig = lists:keydelete(watchdog, 1, Config), - [{watchdog, Dog} | NewConfig]. - -end_per_testcase(_, Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), + Config. +end_per_testcase(_, _) -> ok. %%------------------------------------------------------------------------- %% Test cases starts here. %%------------------------------------------------------------------------- -ftp_150(doc) -> - ["Especially check that respons can be devided in a random place."]; -ftp_150(suite) -> - []; +ftp_150() -> + [{doc, "Especially check that respons can be devided in a random place."}]. ftp_150(Config) when is_list(Config) -> FtpResponse = ["150 ASCII data conn", "ection for /bin/ls ", "(134.138.177", ".89,50434) (0 bytes).\r\n"], @@ -84,14 +72,11 @@ ftp_150(Config) when is_list(Config) -> "150 ASCII data connection for /bin/ls " "(134.138.177.89,50434) (0 bytes).\r\n" = Msg = parse(ftp_response, parse_lines, [[], start], FtpResponse), - {pos_prel, _} = ftp_response:interpret(Msg), - ok. - -ftp_200(doc) -> - ["Especially check that respons can be devided after the first status " - "code character and in the end delimiter."]; -ftp_200(suite) -> - []; + {pos_prel, _} = ftp_response:interpret(Msg). + +ftp_200() -> + [{doc, "Especially check that respons can be devided after the first status " + "code character and in the end delimiter."}]. ftp_200(Config) when is_list(Config) -> FtpResponse = ["2", "00 PORT command successful.", [?CR], [?LF]], @@ -100,11 +85,9 @@ ftp_200(Config) when is_list(Config) -> {pos_compl, _} = ftp_response:interpret(Msg), ok. -ftp_220(doc) -> - ["Especially check that respons can be devided after the " - "first with space "]; -ftp_220(suite) -> - []; +ftp_220() -> + [{doc, "Especially check that respons can be devided after the " + "first with space "}]. ftp_220(Config) when is_list(Config) -> FtpResponse = ["220 ","fingon FTP server (SunOS 5.8) ready.\r\n"], @@ -113,11 +96,9 @@ ftp_220(Config) when is_list(Config) -> {pos_compl, _} = ftp_response:interpret(Msg), ok. -ftp_226(doc) -> - ["Especially check that respons can be devided after second status code" - " character and in the end delimiter."]; -ftp_226(suite) -> - []; +ftp_226() -> + [{doc, "Especially check that respons can be devided after second status code" + " character and in the end delimiter."}]. ftp_226(Config) when is_list(Config) -> FtpResponse = ["22" "6 Transfer complete.\r", [?LF]], @@ -126,10 +107,8 @@ ftp_226(Config) when is_list(Config) -> {pos_compl, _} = ftp_response:interpret(Msg), ok. -ftp_257(doc) -> - ["Especially check that quoted chars do not cause a problem."]; -ftp_257(suite) -> - []; +ftp_257() -> + [{doc, "Especially check that quoted chars do not cause a problem."}]. ftp_257(Config) when is_list(Config) -> FtpResponse = ["257 \"/\" is current directory.\r\n"], @@ -138,11 +117,9 @@ ftp_257(Config) when is_list(Config) -> {pos_compl, _} = ftp_response:interpret(Msg), ok. -ftp_331(doc) -> - ["Especially check that respons can be devided after the third status " - " status code character."]; -ftp_331(suite) -> - []; +ftp_331() -> + [{doc, "Especially check that respons can be devided after the third status " + " status code character."}]. ftp_331(Config) when is_list(Config) -> %% Brake before white space after code FtpResponse = @@ -153,10 +130,8 @@ ftp_331(Config) when is_list(Config) -> {pos_interm, _} = ftp_response:interpret(Msg), ok. -ftp_425(doc) -> - ["Especially check a message that was received in only one part."]; -ftp_425(suite) -> - []; +ftp_425() -> + [{doc, "Especially check a message that was received in only one part."}]. ftp_425(Config) when is_list(Config) -> FtpResponse = ["425 Can't build data connection: Connection refused.\r\n"], @@ -166,10 +141,8 @@ ftp_425(Config) when is_list(Config) -> {trans_neg_compl, _} = ftp_response:interpret(Msg), ok. -ftp_multiple_lines(doc) -> - ["Especially check multiple lines devided in significant places"]; -ftp_multiple_lines(suite) -> - []; +ftp_multiple_lines() -> + [{doc, "Especially check multiple lines devided in significant places"}]. ftp_multiple_lines(Config) when is_list(Config) -> FtpResponse = ["21", "4","-The", " following commands are recognized:\r\n" @@ -247,13 +220,11 @@ ftp_multiple_lines(Config) when is_list(Config) -> FtpResponse2), ok. -ftp_other_status_codes(doc) -> - ["Check that other valid status codes, than the ones above, are handled" +ftp_other_status_codes() -> + [{doc, "Check that other valid status codes, than the ones above, are handled" "by ftp_response:interpret/1. Note there are som ftp status codes" "that will not be received with the current ftp instruction support," - "they are not included here."]; -ftp_other_status_codes(suite) -> - []; + "they are not included here."}]. ftp_other_status_codes(Config) when is_list(Config) -> %% 1XX @@ -289,11 +260,9 @@ ftp_other_status_codes(Config) when is_list(Config) -> {efnamena, _ } = ftp_response:interpret("553 Foobar\r\n"), ok. -ftp_multipel_ctrl_messages(doc) -> - ["The ftp server may send more than one control message as a reply," - "check that they are handled one at the time."]; -ftp_multipel_ctrl_messages(suite) -> - []; +ftp_multipel_ctrl_messages() -> + [{doc, "The ftp server may send more than one control message as a reply," + "check that they are handled one at the time."}]. ftp_multipel_ctrl_messages(Config) when is_list(Config) -> FtpResponse = ["200 PORT command successful.\r\n200 Foobar\r\n"], @@ -306,10 +275,6 @@ ftp_multipel_ctrl_messages(Config) when is_list(Config) -> %%------------------------------------------------------------------------- -format_error(doc) -> - [""]; -format_error(suite) -> - []; format_error(Config) when is_list(Config) -> "Synchronisation error during chunk sending." = ftp:formaterror(echunk), @@ -346,7 +311,7 @@ parse(Module, Function, [AccLines, StatusCode], [Data | Rest]) -> {continue, {NewData, NewAccLines, NewStatusCode}} -> case Rest of [] -> - test_server:fail({wrong_input, Data, Rest}); + ct:fail({wrong_input, Data, Rest}); [_ | _] -> parse(Module, Function, [NewAccLines, NewStatusCode], [binary_to_list(NewData) ++ hd(Rest) | tl(Rest)]) diff --git a/lib/inets/test/ftp_suite_lib.erl b/lib/inets/test/ftp_suite_lib.erl deleted file mode 100644 index 71985df877..0000000000 --- a/lib/inets/test/ftp_suite_lib.erl +++ /dev/null @@ -1,1695 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-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% -%% -%% - --module(ftp_suite_lib). - - --include_lib("common_test/include/ct.hrl"). --include("inets_test_lib.hrl"). - -%% Test server specific exports -% -export([init_per_testcase/2, end_per_testcase/2]). - --compile(export_all). - - --record(progress, { - current = 0, - total - }). - - - --define(FTP_USER, "anonymous"). --define(FTP_PASS, passwd()). --define(FTP_PORT, 21). - --define(BAD_HOST, "badhostname"). --define(BAD_USER, "baduser"). --define(BAD_DIR, "baddirectory"). - --ifdef(ftp_debug_client). --define(ftp_open(Host, Flags), - do_ftp_open(Host, [{debug, debug}, - {timeout, timer:seconds(15)} | Flags])). --else. --ifdef(ftp_trace_client). --define(ftp_open(Host, Flags), - do_ftp_open(Host, [{debug, trace}, - {timeout, timer:seconds(15)} | Flags])). --else. --define(ftp_open(Host, Flags), - do_ftp_open(Host, [{verbose, true}, - {timeout, timer:seconds(15)} | Flags])). --endif. --endif. - -%% -- Tickets -- - -tickets(doc) -> - "Test cases for reported bugs"; -tickets(suite) -> - [ticket_6035]. - -%% -- - -ftpd_init(FtpdTag, Config) -> - %% Get the host name(s) of FTP server - Hosts = - case ct:get_config(ftpd_hosts) of - undefined -> - ftpd_hosts(data_dir(Config)); - H -> - H - end, - p("ftpd_init -> " - "~n Hosts: ~p" - "~n Config: ~p" - "~n FtpdTag: ~p", [Hosts, Config, FtpdTag]), - %% Get the first host that actually have a running FTP server - case lists:keysearch(FtpdTag, 1, Hosts) of - {value, {_, TagHosts}} when is_list(TagHosts) -> - inets:start(), - case (catch get_ftpd_host(TagHosts)) of - {ok, Host} -> - inets:stop(), - [{ftp_remote_host, Host}|Config]; - _ -> - inets:stop(), - Reason = lists:flatten( - io_lib:format("Could not find a valid " - "FTP server for ~p (~p)", - [FtpdTag, TagHosts])), - {skip, Reason} - end; - _ -> - Reason = lists:flatten( - io_lib:format("No host(s) running FTPD server " - "for ~p", [FtpdTag])), - {skip, Reason} - end. - -ftpd_fin(Config) -> - lists:keydelete(ftp_remote_host, 1, Config). - -get_ftpd_host([]) -> - {error, no_host}; -get_ftpd_host([Host|Hosts]) -> - p("get_ftpd_host -> entry with" - "~n Host: ~p" - "~n", [Host]), - case (catch ftp:open(Host, [{port, ?FTP_PORT}, {timeout, 20000}])) of - {ok, Pid} -> - (catch ftp:close(Pid)), - {ok, Host}; - _ -> - get_ftpd_host(Hosts) - end. - - -%%-------------------------------------------------------------------- - -dirty_select_ftpd_host(Config) -> - Hosts = - case ct:get_config(ftpd_hosts) of - undefined -> - ftpd_hosts(data_dir(Config)); - H -> - H - end, - dirty_select_ftpd_host2(Hosts). - -dirty_select_ftpd_host2([]) -> - throw({error, not_found}); -dirty_select_ftpd_host2([{PlatformTag, Hosts} | PlatformHosts]) -> - case dirty_select_ftpd_host3(Hosts) of - none -> - dirty_select_ftpd_host2(PlatformHosts); - {ok, Host} -> - {PlatformTag, Host} - end. - -dirty_select_ftpd_host3([]) -> - none; -dirty_select_ftpd_host3([Host|Hosts]) when is_list(Host) -> - case dirty_select_ftpd_host4(Host) of - true -> - {ok, Host}; - false -> - dirty_select_ftpd_host3(Hosts) - end; -dirty_select_ftpd_host3([_|Hosts]) -> - dirty_select_ftpd_host3(Hosts). - -%% This is a very simple and dirty test that there is a -%% (FTP) deamon on the other end. -dirty_select_ftpd_host4(Host) -> - Port = 21, - IpFam = inet, - Opts = [IpFam, binary, {packet, 0}, {active, false}], - Timeout = ?SECS(5), - case gen_tcp:connect(Host, Port, Opts, Timeout) of - {ok, Sock} -> - gen_tcp:close(Sock), - true; - _Error -> - false - end. - - -%%-------------------------------------------------------------------- - -test_filenames() -> - {ok, Host} = inet:gethostname(), - File = Host ++ "_ftp_test.txt", - NewFile = "new_" ++ File, - {File, NewFile}. - -%%-------------------------------------------------------------------- -%% Function: init_per_testcase(Case, Config) -> Config -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Description: Initiation before each test case -%% -%% Note: This function is free to add any key/value pairs to the Config -%% variable, but should NOT alter/remove any existing entries. -%%-------------------------------------------------------------------- -init_per_testcase(Case, Config) - when (Case =:= open) orelse - (Case =:= open_port) -> - put(ftp_testcase, Case), - io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), - inets:start(), - NewConfig = data_dir(Config), - watch_dog(NewConfig); - -init_per_testcase(Case, Config) -> - put(ftp_testcase, Case), - do_init_per_testcase(Case, Config). - -do_init_per_testcase(Case, Config) - when (Case =:= passive_user) -> - io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE,Case]), - inets:start(), - NewConfig = close_connection(watch_dog(Config)), - Host = ftp_host(Config), - case (catch ?ftp_open(Host, [{mode, passive}])) of - {ok, Pid} -> - [{ftp, Pid} | data_dir(NewConfig)]; - {skip, _} = SKIP -> - SKIP - end; - -do_init_per_testcase(Case, Config) - when (Case =:= active_user) -> - io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), - inets:start(), - NewConfig = close_connection(watch_dog(Config)), - Host = ftp_host(Config), - case (catch ?ftp_open(Host, [{mode, active}])) of - {ok, Pid} -> - [{ftp, Pid} | data_dir(NewConfig)]; - {skip, _} = SKIP -> - SKIP - end; - -do_init_per_testcase(Case, Config) - when (Case =:= progress_report_send) orelse - (Case =:= progress_report_recv) -> - inets:start(), - io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), - NewConfig = close_connection(watch_dog(Config)), - Host = ftp_host(Config), - Opts = [{port, ?FTP_PORT}, - {verbose, true}, - {progress, {?MODULE, progress, #progress{}}}], - case ftp:open(Host, Opts) of - {ok, Pid} -> - ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), - [{ftp, Pid} | data_dir(NewConfig)]; - {skip, _} = SKIP -> - SKIP - end; - -do_init_per_testcase(Case, Config) -> - io:format(user,"~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), - inets:start(), - NewConfig = close_connection(watch_dog(Config)), - Host = ftp_host(Config), - Opts1 = - if - ((Case =:= passive_ip_v6_disabled) orelse - (Case =:= active_ip_v6_disabled)) -> - [{ipfamily, inet}]; - true -> - [] - end, - Opts2 = - case string:tokens(atom_to_list(Case), [$_]) of - ["active" | _] -> - [{mode, active} | Opts1]; - _ -> - [{mode, passive} | Opts1] - end, - case (catch ?ftp_open(Host, Opts2)) of - {ok, Pid} -> - ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), - [{ftp, Pid} | data_dir(NewConfig)]; - {skip, _} = SKIP -> - SKIP - end. - - -%%-------------------------------------------------------------------- -%% Function: end_per_testcase(Case, Config) -> _ -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% Description: Cleanup after each test case -%%-------------------------------------------------------------------- -end_per_testcase(_, Config) -> - NewConfig = close_connection(Config), - Dog = ?config(watchdog, NewConfig), - inets:stop(), - test_server:timetrap_cancel(Dog), - ok. - - -%%------------------------------------------------------------------------- -%% Suites similar for all hosts. -%%------------------------------------------------------------------------- - -passive(suite) -> - [ - passive_user, - passive_pwd, - passive_cd, - passive_lcd, - passive_ls, - passive_nlist, - passive_rename, - passive_delete, - passive_mkdir, - passive_send, - passive_send_bin, - passive_send_chunk, - passive_append, - passive_append_bin, - passive_append_chunk, - passive_recv, - passive_recv_bin, - passive_recv_chunk, - passive_type, - passive_quote, - passive_ip_v6_disabled - ]. - -active(suite) -> - [ - active_user, - active_pwd, - active_cd, - active_lcd, - active_ls, - active_nlist, - active_rename, - active_delete, - active_mkdir, - active_send, - active_send_bin, - active_send_chunk, - active_append, - active_append_bin, - active_append_chunk, - active_recv, - active_recv_bin, - active_recv_chunk, - active_type, - active_quote, - active_ip_v6_disabled - ]. - - - -%%------------------------------------------------------------------------- -%% Test cases starts here. -%%------------------------------------------------------------------------- - -open(doc) -> - ["Open an ftp connection to a host and close the connection." - "Also check that !-messages does not disturbe the connection"]; -open(suite) -> - []; -open(Config) when is_list(Config) -> - Host = ftp_host(Config), - (catch tc_open(Host)). - - -tc_open(Host) -> - p("tc_open -> entry with" - "~n Host: ~p", [Host]), - {ok, Pid} = ?ftp_open(Host, []), - ok = ftp:close(Pid), - p("tc_open -> try (ok) open 1"), - {ok, Pid1} = - ftp:open({option_list, [{host,Host}, - {port, ?FTP_PORT}, - {flags, [verbose]}, - {timeout, 30000}]}), - ok = ftp:close(Pid1), - - p("tc_open -> try (fail) open 2"), - {error, ehost} = - ftp:open({option_list, [{port, ?FTP_PORT}, {flags, [verbose]}]}), - {ok, Pid2} = ftp:open(Host), - ok = ftp:close(Pid2), - - p("tc_open -> try (ok) open 3"), - {ok, NewHost} = inet:getaddr(Host, inet), - {ok, Pid3} = ftp:open(NewHost), - ftp:user(Pid3, ?FTP_USER, ?FTP_PASS), - Pid3 ! foobar, - test_server:sleep(5000), - {message_queue_len, 0} = process_info(self(), message_queue_len), - ["200" ++ _] = ftp:quote(Pid3, "NOOP"), - ok = ftp:close(Pid3), - - %% Bad input that has default values are ignored and the defult - %% is used. - p("tc_open -> try (ok) open 4"), - {ok, Pid4} = - ftp:open({option_list, [{host, Host}, - {port, badarg}, - {flags, [verbose]}, - {timeout, 30000}]}), - test_server:sleep(100), - ok = ftp:close(Pid4), - - p("tc_open -> try (ok) open 5"), - {ok, Pid5} = - ftp:open({option_list, [{host, Host}, - {port, ?FTP_PORT}, - {flags, [verbose]}, - {timeout, -42}]}), - test_server:sleep(100), - ok = ftp:close(Pid5), - - p("tc_open -> try (ok) open 6"), - {ok, Pid6} = - ftp:open({option_list, [{host, Host}, - {port, ?FTP_PORT}, - {flags, [verbose]}, - {mode, cool}]}), - test_server:sleep(100), - ok = ftp:close(Pid6), - - p("tc_open -> try (ok) open 7"), - {ok, Pid7} = - ftp:open(Host, [{port, ?FTP_PORT}, {verbose, true}, {timeout, 30000}]), - ok = ftp:close(Pid7), - - p("tc_open -> try (ok) open 8"), - {ok, Pid8} = - ftp:open(Host, ?FTP_PORT), - ok = ftp:close(Pid8), - - p("tc_open -> try (ok) open 9"), - {ok, Pid9} = - ftp:open(Host, [{port, ?FTP_PORT}, - {verbose, true}, - {timeout, 30000}, - {dtimeout, -99}]), - ok = ftp:close(Pid9), - - p("tc_open -> try (ok) open 10"), - {ok, Pid10} = - ftp:open(Host, [{port, ?FTP_PORT}, - {verbose, true}, - {timeout, 30000}, - {dtimeout, "foobar"}]), - ok = ftp:close(Pid10), - - p("tc_open -> try (ok) open 11"), - {ok, Pid11} = - ftp:open(Host, [{port, ?FTP_PORT}, - {verbose, true}, - {timeout, 30000}, - {dtimeout, 1}]), - ok = ftp:close(Pid11), - - p("tc_open -> done"), - ok. - - -%%------------------------------------------------------------------------- - -open_port(doc) -> - ["Open an ftp connection to a host with given port number " - "and close the connection."]; % See also OTP-3892 -open_port(suite) -> - []; -open_port(Config) when is_list(Config) -> - Host = ftp_host(Config), - {ok, Pid} = ftp:open(Host, [{port, ?FTP_PORT}]), - ok = ftp:close(Pid), - {error, ehost} = ftp:open(?BAD_HOST, []), - ok. - - -%%------------------------------------------------------------------------- - -passive_user(doc) -> - ["Open an ftp connection to a host, and logon as anonymous ftp."]; -passive_user(suite) -> - []; -passive_user(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - p("Pid: ~p",[Pid]), - do_user(Pid). - - -%%------------------------------------------------------------------------- - -passive_pwd(doc) -> - ["Test ftp:pwd/1 & ftp:lpwd/1"]; -passive_pwd(suite) -> - []; -passive_pwd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_pwd(Pid). - - -%%------------------------------------------------------------------------- - -passive_cd(doc) -> - ["Open an ftp connection, log on as anonymous ftp, and cd to the" - "directory \"/pub\" and the to the non-existent directory."]; -passive_cd(suite) -> - []; -passive_cd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_cd(Pid). - - -%%------------------------------------------------------------------------- - -passive_lcd(doc) -> - ["Test api function ftp:lcd/2"]; -passive_lcd(suite) -> - []; -passive_lcd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - PrivDir = ?config(priv_dir, Config), - do_lcd(Pid, PrivDir). - - -%%------------------------------------------------------------------------- - -passive_ls(doc) -> - ["Open an ftp connection; ls the current directory, and the " - "\"incoming\" directory. We assume that ls never fails, since " - "it's output is meant to be read by humans. "]; -passive_ls(suite) -> - []; -passive_ls(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_ls(Pid). - - -%%------------------------------------------------------------------------- - -passive_nlist(doc) -> - ["Open an ftp connection; nlist the current directory, and the " - "\"incoming\" directory. Nlist does not behave consistenly over " - "operating systems. On some it is an error to have an empty " - "directory."]; -passive_nlist(suite) -> - []; -passive_nlist(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - WildcardSupport = ?config(wildcard_support, Config), - do_nlist(Pid, WildcardSupport). - - -%%------------------------------------------------------------------------- - -passive_rename(doc) -> - ["Transfer a file to the server, and rename it; then remove it."]; -passive_rename(suite) -> - []; -passive_rename(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_rename(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_delete(doc) -> - ["Transfer a file to the server, and then delete it"]; -passive_delete(suite) -> - []; -passive_delete(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_delete(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_mkdir(doc) -> - ["Make a remote directory, cd to it, go to parent directory, and " - "remove the directory."]; -passive_mkdir(suite) -> - []; -passive_mkdir(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_mkdir(Pid). - - -%%------------------------------------------------------------------------- - -passive_send(doc) -> - ["Create a local file in priv_dir; open an ftp connection to a host; " - "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " - "priv_dir; send the file; get a directory listing and check that " - "the file is on the list;, delete the remote file; get another listing " - "and check that the file is not on the list; close the session; " - "delete the local file."]; -passive_send(suite) -> - []; -passive_send(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_append(doc) -> - ["Create a local file in priv_dir; open an ftp connection to a host; " - "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " - "priv_dir; append the file to a file at the remote side that not exits" - "this will create the file at the remote side. Then it append the file " - "again. When this is done it recive the remote file and control that" - "the content is doubled in it.After that it will remove the files"]; -passive_append(suite) -> - []; -passive_append(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_send_bin(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "send a binary; remove file; close the connection."]; -passive_send_bin(suite) -> - []; -passive_send_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send_bin(Pid, Config). - -%%------------------------------------------------------------------------- - -passive_append_bin(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "append a binary twice; get the file and compare the content" - "remove file; close the connection."]; -passive_append_bin(suite) -> - []; -passive_append_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append_bin(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_send_chunk(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "send chunks; remove file; close the connection."]; -passive_send_chunk(suite) -> - []; -passive_send_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_append_chunk(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "append chunks;control content remove file; close the connection."]; -passive_append_chunk(suite) -> - []; -passive_append_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_recv(doc) -> - ["Create a local file and transfer it to the remote host into the " - "the \"incoming\" directory, remove " - "the local file. Then open a new connection; cd to \"incoming\", " - "lcd to the private directory; receive the file; delete the " - "remote file; close connection; check that received file is in " - "the correct directory; cleanup." ]; -passive_recv(suite) -> - []; -passive_recv(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_recv_bin(doc) -> - ["Send a binary to the remote host; and retreive " - "the file; then remove the file."]; -passive_recv_bin(suite) -> - []; -passive_recv_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv_bin(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_recv_chunk(doc) -> - ["Send a binary to the remote host; Connect again, and retreive " - "the file; then remove the file."]; -passive_recv_chunk(suite) -> - []; -passive_recv_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -passive_type(doc) -> - ["Test that we can change btween ASCCI and binary transfer mode"]; -passive_type(suite) -> - []; -passive_type(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_type(Pid). - - -%%------------------------------------------------------------------------- - -passive_quote(doc) -> - [""]; -passive_quote(suite) -> - []; -passive_quote(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_quote(Pid). - - -%%------------------------------------------------------------------------- - -passive_ip_v6_disabled(doc) -> - ["Test ipv4 command PASV"]; -passive_ip_v6_disabled(suite) -> - []; -passive_ip_v6_disabled(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_user(doc) -> - ["Open an ftp connection to a host, and logon as anonymous ftp."]; -active_user(suite) -> - []; -active_user(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_user(Pid). - - -%%------------------------------------------------------------------------- - -active_pwd(doc) -> - ["Test ftp:pwd/1 & ftp:lpwd/1"]; -active_pwd(suite) -> - []; -active_pwd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_pwd(Pid). - - -%%------------------------------------------------------------------------- - -active_cd(doc) -> - ["Open an ftp connection, log on as anonymous ftp, and cd to the" - "directory \"/pub\" and to a non-existent directory."]; -active_cd(suite) -> - []; -active_cd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_cd(Pid). - - -%%------------------------------------------------------------------------- - -active_lcd(doc) -> - ["Test api function ftp:lcd/2"]; -active_lcd(suite) -> - []; -active_lcd(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - PrivDir = ?config(priv_dir, Config), - do_lcd(Pid, PrivDir). - - -%%------------------------------------------------------------------------- - -active_ls(doc) -> - ["Open an ftp connection; ls the current directory, and the " - "\"incoming\" directory. We assume that ls never fails, since " - "it's output is meant to be read by humans. "]; -active_ls(suite) -> - []; -active_ls(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_ls(Pid). - - -%%------------------------------------------------------------------------- - -active_nlist(doc) -> - ["Open an ftp connection; nlist the current directory, and the " - "\"incoming\" directory. Nlist does not behave consistenly over " - "operating systems. On some it is an error to have an empty " - "directory."]; -active_nlist(suite) -> - []; -active_nlist(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - WildcardSupport = ?config(wildcard_support, Config), - do_nlist(Pid, WildcardSupport). - - -%%------------------------------------------------------------------------- - -active_rename(doc) -> - ["Transfer a file to the server, and rename it; then remove it."]; -active_rename(suite) -> - []; -active_rename(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_rename(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_delete(doc) -> - ["Transfer a file to the server, and then delete it"]; -active_delete(suite) -> - []; -active_delete(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_delete(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_mkdir(doc) -> - ["Make a remote directory, cd to it, go to parent directory, and " - "remove the directory."]; -active_mkdir(suite) -> - []; -active_mkdir(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_mkdir(Pid). - - -%%------------------------------------------------------------------------- - -active_send(doc) -> - ["Create a local file in priv_dir; open an ftp connection to a host; " - "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " - "priv_dir; send the file; get a directory listing and check that " - "the file is on the list;, delete the remote file; get another listing " - "and check that the file is not on the list; close the session; " - "delete the local file."]; -active_send(suite) -> - []; -active_send(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_append(doc) -> - ["Create a local file in priv_dir; open an ftp connection to a host; " - "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " - "priv_dir; append the file to a file at the remote side that not exits" - "this will create the file at the remote side. Then it append the file " - "again. When this is done it recive the remote file and control that" - "the content is doubled in it.After that it will remove the files"]; -active_append(suite) -> - []; -active_append(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_send_bin(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "send a binary; remove file; close the connection."]; -active_send_bin(suite) -> - []; -active_send_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send_bin(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_append_bin(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "append a binary twice; get the file and compare the content" - "remove file; close the connection."]; -active_append_bin(suite) -> - []; -active_append_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append_bin(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_send_chunk(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "send chunks; remove file; close the connection."]; -active_send_chunk(suite) -> - []; -active_send_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_append_chunk(doc) -> - ["Open a connection to a host; cd to the directory \"incoming\"; " - "append chunks;control content remove file; close the connection."]; -active_append_chunk(suite) -> - []; -active_append_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_append_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_recv(doc) -> - ["Create a local file and transfer it to the remote host into the " - "the \"incoming\" directory, remove " - "the local file. Then open a new connection; cd to \"incoming\", " - "lcd to the private directory; receive the file; delete the " - "remote file; close connection; check that received file is in " - "the correct directory; cleanup." ]; -active_recv(suite) -> - []; -active_recv(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_recv_bin(doc) -> - ["Send a binary to the remote host; and retreive " - "the file; then remove the file."]; -active_recv_bin(suite) -> - []; -active_recv_bin(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv_bin(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_recv_chunk(doc) -> - ["Send a binary to the remote host; Connect again, and retreive " - "the file; then remove the file."]; -active_recv_chunk(suite) -> - []; -active_recv_chunk(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_recv_chunk(Pid, Config). - - -%%------------------------------------------------------------------------- - -active_type(doc) -> - ["Test that we can change btween ASCCI and binary transfer mode"]; -active_type(suite) -> - []; -active_type(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_type(Pid). - - -%%------------------------------------------------------------------------- - -active_quote(doc) -> - [""]; -active_quote(suite) -> - []; -active_quote(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_quote(Pid). - - -%%------------------------------------------------------------------------- - -active_ip_v6_disabled(doc) -> - ["Test ipv4 command PORT"]; -active_ip_v6_disabled(suite) -> - []; -active_ip_v6_disabled(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - do_send(Pid, Config). - - -%%------------------------------------------------------------------------- - -api_missuse(doc)-> - ["Test that behaviour of the ftp process if the api is abused"]; -api_missuse(suite) -> []; -api_missuse(Config) when is_list(Config) -> - p("api_missuse -> entry"), - Flag = process_flag(trap_exit, true), - Pid = ?config(ftp, Config), - Host = ftp_host(Config), - - %% Serious programming fault, connetion will be shut down - p("api_missuse -> verify bad call termination (~p)", [Pid]), - case (catch gen_server:call(Pid, {self(), foobar, 10}, infinity)) of - {error, {connection_terminated, 'API_violation'}} -> - ok; - Unexpected1 -> - exit({unexpected_result, Unexpected1}) - end, - test_server:sleep(500), - undefined = process_info(Pid, status), - - p("api_missuse -> start new client"), - {ok, Pid2} = ?ftp_open(Host, []), - %% Serious programming fault, connetion will be shut down - p("api_missuse -> verify bad cast termination"), - gen_server:cast(Pid2, {self(), foobar, 10}), - test_server:sleep(500), - undefined = process_info(Pid2, status), - - p("api_missuse -> start new client"), - {ok, Pid3} = ?ftp_open(Host, []), - %% Could be an innocent misstake the connection lives. - p("api_missuse -> verify bad bang"), - Pid3 ! foobar, - test_server:sleep(500), - {status, _} = process_info(Pid3, status), - process_flag(trap_exit, Flag), - p("api_missuse -> done"), - ok. - - -%%------------------------------------------------------------------------- - -not_owner(doc) -> - ["Test what happens if a process that not owns the connection tries " - "to use it"]; -not_owner(suite) -> - []; -not_owner(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - OtherPid = spawn_link(?MODULE, not_owner, [Pid, self()]), - - receive - {OtherPid, ok} -> - {ok, _} = ftp:pwd(Pid) - end, - ok. - -not_owner(FtpPid, Pid) -> - {error, not_connection_owner} = ftp:pwd(FtpPid), - ftp:close(FtpPid), - test_server:sleep(100), - Pid ! {self(), ok}. - - -%%------------------------------------------------------------------------- - - -progress_report(doc) -> - ["Solaris 8 sparc test the option progress."]; -progress_report(suite) -> - [progress_report_send, progress_report_recv]. - - -%% -- - -progress_report_send(doc) -> - ["Test the option progress for ftp:send/[2,3]"]; -progress_report_send(suite) -> - []; -progress_report_send(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - ReportPid = - spawn_link(?MODULE, progress_report_receiver_init, [self(), 1]), - do_send(Pid, Config), - receive - {ReportPid, ok} -> - ok - end. - - -%% -- - -progress_report_recv(doc) -> - ["Test the option progress for ftp:recv/[2,3]"]; -progress_report_recv(suite) -> - []; -progress_report_recv(Config) when is_list(Config) -> - Pid = ?config(ftp, Config), - ReportPid = - spawn_link(?MODULE, progress_report_receiver_init, [self(), 3]), - do_recv(Pid, Config), - receive - {ReportPid, ok} -> - ok - end, - ok. - -progress(#progress{} = Progress , _File, {file_size, Total}) -> - progress_report_receiver ! start, - Progress#progress{total = Total}; -progress(#progress{total = Total, current = Current} - = Progress, _File, {transfer_size, 0}) -> - progress_report_receiver ! finish, - case Total of - unknown -> - ok; - Current -> - ok; - _ -> - test_server:fail({error, {progress, {total, Total}, - {current, Current}}}) - end, - Progress; -progress(#progress{current = Current} = Progress, _File, - {transfer_size, Size}) -> - progress_report_receiver ! update, - Progress#progress{current = Current + Size}. - -progress_report_receiver_init(Pid, N) -> - register(progress_report_receiver, self()), - receive - start -> - ok - end, - progress_report_receiver_loop(Pid, N-1). - -progress_report_receiver_loop(Pid, N) -> - receive - update -> - progress_report_receiver_loop(Pid, N); - finish when N =:= 0 -> - Pid ! {self(), ok}; - finish -> - Pid ! {self(), ok}, - receive - start -> - ok - end, - progress_report_receiver_loop(Pid, N-1) - end. - - -%%------------------------------------------------------------------------- -%% Ticket test cases -%%------------------------------------------------------------------------- - -ticket_6035(doc) -> ["Test that owning process that exits with reason " - "'shutdown' does not cause an error message."]; -ticket_6035(suite) -> []; -ticket_6035(Config) -> - p("ticket_6035 -> entry with" - "~n Config: ~p", [Config]), - PrivDir = ?config(priv_dir, Config), - LogFile = filename:join([PrivDir,"ticket_6035.log"]), - try - begin - p("ticket_6035 -> select ftpd host"), - Host = dirty_select_ftpd_host(Config), - p("ticket_6035 -> ftpd host selected (~p) => now spawn ftp owner", [Host]), - Pid = spawn(?MODULE, open_wait_6035, [Host, self()]), - p("ticket_6035 -> waiter spawned: ~p => now open error logfile (~p)", - [Pid, LogFile]), - error_logger:logfile({open, LogFile}), - p("ticket_6035 -> error logfile open => now kill waiter process"), - true = kill_ftp_proc_6035(Pid, LogFile), - p("ticket_6035 -> waiter process killed => now close error logfile"), - error_logger:logfile(close), - p("ticket_6035 -> done", []), - ok - end - catch - throw:{error, not_found} -> - {skip, "No available FTP servers"} - end. - -kill_ftp_proc_6035(Pid, LogFile) -> - p("kill_ftp_proc_6035 -> entry"), - receive - open -> - p("kill_ftp_proc_6035 -> received open => now issue shutdown"), - exit(Pid, shutdown), - kill_ftp_proc_6035(Pid, LogFile); - {open_failed, Reason} -> - p("kill_ftp_proc_6035 -> received open_failed" - "~n Reason: ~p", [Reason]), - exit({skip, {failed_openening_server_connection, Reason}}) - after - 5000 -> - p("kill_ftp_proc_6035 -> timeout"), - is_error_report_6035(LogFile) - end. - -open_wait_6035({Tag, FtpServer}, From) -> - p("open_wait_6035 -> try connect to [~p] ~s for ~p", [Tag, FtpServer, From]), - case ftp:open(FtpServer, [{timeout, timer:seconds(15)}]) of - {ok, Pid} -> - p("open_wait_6035 -> connected (~p), now login", [Pid]), - LoginResult = ftp:user(Pid,"anonymous","kldjf"), - p("open_wait_6035 -> login result: ~p", [LoginResult]), - From ! open, - receive - dummy -> - p("open_wait_6035 -> received dummy"), - ok - after - 10000 -> - p("open_wait_6035 -> timeout"), - ok - end, - p("open_wait_6035 -> done(ok)"), - ok; - {error, Reason} -> - p("open_wait_6035 -> open failed" - "~n Reason: ~p", [Reason]), - From ! {open_failed, {Reason, FtpServer}}, - p("open_wait_6035 -> done(error)"), - ok - end. - -is_error_report_6035(LogFile) -> - p("is_error_report_6035 -> entry"), - Res = - case file:read_file(LogFile) of - {ok, Bin} -> - Txt = binary_to_list(Bin), - p("is_error_report_6035 -> logfile read: ~n~p", [Txt]), - read_log_6035(Txt); - _ -> - false - end, - p("is_error_report_6035 -> logfile read result: " - "~n ~p", [Res]), - %% file:delete(LogFile), - Res. - -read_log_6035("=ERROR REPORT===="++_Rest) -> - p("read_log_6035 -> ERROR REPORT detected"), - true; -read_log_6035([H|T]) -> - p("read_log_6035 -> OTHER: " - "~p", [H]), - read_log_6035(T); -read_log_6035([]) -> - p("read_log_6035 -> done"), - false. - - -%%-------------------------------------------------------------------- -%% Internal functions -%%-------------------------------------------------------------------- -do_user(Pid) -> - {error, euser} = ftp:user(Pid, ?BAD_USER, ?FTP_PASS), - {error, euser} = ftp:user(Pid, ?FTP_USER++"\r\nPASS "++?FTP_PASS, ?FTP_PASS), - {error, euser} = ftp:user(Pid, ?FTP_USER, ?FTP_PASS++"\r\nCWD ."), - ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), - ok. - -do_pwd(Pid) -> - {ok, "/"} = ftp:pwd(Pid), - {ok, Path} = ftp:lpwd(Pid), - {ok, Path} = file:get_cwd(), - ok. - -do_cd(Pid) -> - ok = ftp:cd(Pid, "/pub"), - {error, epath} = ftp:cd(Pid, ?BAD_DIR), - {error, efnamena} = ftp:cd(Pid, "/pub\r\nCWD ."), - ok. - -do_lcd(Pid, Dir) -> - ok = ftp:lcd(Pid, Dir), - {error, epath} = ftp:lcd(Pid, ?BAD_DIR), - ok. - - -do_ls(Pid) -> - {ok, _} = ftp:ls(Pid), - {ok, _} = ftp:ls(Pid, "incoming"), - %% neither nlist nor ls operates on a directory - %% they operate on a pathname, which *can* be a - %% directory, but can also be a filename or a group - %% of files (including wildcards). - {ok, _} = ftp:ls(Pid, "incom*"), - %% but \r\n can't be in the wildcard - {error, efnamena} = ftp:ls(Pid, "incoming\r\nCWD ."), - ok. - -do_nlist(Pid, WildcardSupport) -> - {ok, _} = ftp:nlist(Pid), - {ok, _} = ftp:nlist(Pid, "incoming"), - {error, efnamena} = ftp:ls(Pid, "incoming\r\nCWD ."), - %% neither nlist nor ls operates on a directory - %% they operate on a pathname, which *can* be a - %% directory, but can also be a filename or a group - %% of files (including wildcards). - case WildcardSupport of - true -> - {ok, _} = ftp:nlist(Pid, "incom*"), - ok; - _ -> - ok - end. - -do_rename(Pid, Config) -> - PrivDir = ?config(priv_dir, Config), - LFile = ?config(file, Config), - NewLFile = ?config(new_file, Config), - AbsLFile = filename:absname(LFile, PrivDir), - Contents = "ftp_SUITE test ...", - ok = file:write_file(AbsLFile, list_to_binary(Contents)), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:lcd(Pid, PrivDir), - ftp:delete(Pid, LFile), % reset - ftp:delete(Pid, NewLFile), % reset - ok = ftp:send(Pid, LFile), - {error, epath} = ftp:rename(Pid, NewLFile, LFile), - {error, efnamena} = ftp:rename(Pid, NewLFile++"\r\nRNTO "++LFile++"\r\nRNFR "++NewLFile, LFile), - {error, efnamena} = ftp:rename(Pid, NewLFile, LFile++"\r\nCWD ."), - ok = ftp:rename(Pid, LFile, NewLFile), - ftp:delete(Pid, LFile), % cleanup - ftp:delete(Pid, NewLFile), % cleanup - ok. - -do_delete(Pid, Config) -> - PrivDir = ?config(priv_dir, Config), - LFile = ?config(file, Config), - AbsLFile = filename:absname(LFile, PrivDir), - Contents = "ftp_SUITE test ...", - ok = file:write_file(AbsLFile, list_to_binary(Contents)), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:lcd(Pid, PrivDir), - ftp:delete(Pid,LFile), % reset - {error, efnamena} = ftp:delete(Pid,LFile++"\r\nCWD ."), - ok = ftp:send(Pid, LFile), - ok = ftp:delete(Pid,LFile), - ok. - -do_mkdir(Pid) -> - NewDir = "earl_" ++ - integer_to_list(inets_time_compat:unique_integer([positive])), - - ok = ftp:cd(Pid, "incoming"), - {ok, CurrDir} = ftp:pwd(Pid), - {error, efnamena} = ftp:mkdir(Pid, NewDir++"\r\nCWD ."), - {error, efnamena} = ftp:rmdir(Pid, NewDir++"\r\nCWD ."), - ok = ftp:mkdir(Pid, NewDir), - ok = ftp:cd(Pid, NewDir), - ok = ftp:cd(Pid, CurrDir), - ok = ftp:rmdir(Pid, NewDir), - ok. - -do_send(Pid, Config) -> - PrivDir = ?config(priv_dir, Config), - LFile = ?config(file, Config), - RFile = LFile ++ ".remote", - AbsLFile = filename:absname(LFile, PrivDir), - Contents = "ftp_SUITE test ...", - ok = file:write_file(AbsLFile, list_to_binary(Contents)), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:lcd(Pid, PrivDir), - {error, efnamena} = ftp:send(Pid, LFile, RFile++"1\r\nCWD ."), - ok = ftp:send(Pid, LFile, RFile), - {ok, RFilesString} = ftp:nlist(Pid), - RFiles = split(RFilesString), - true = lists:member(RFile, RFiles), - ok = ftp:delete(Pid, RFile), - case ftp:nlist(Pid) of - {error, epath} -> - ok; % No files - {ok, RFilesString1} -> - RFiles1 = split(RFilesString1), - false = lists:member(RFile, RFiles1) - end, - ok = file:delete(AbsLFile). - -do_append(Pid, Config) -> - PrivDir = ?config(priv_dir, Config), - LFile = ?config(file, Config), - RFile = ?config(new_file, Config), - AbsLFile = filename:absname(LFile, PrivDir), - Contents = "ftp_SUITE test:appending\r\n", - - ok = file:write_file(AbsLFile, list_to_binary(Contents)), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:lcd(Pid, PrivDir), - - %% remove files from earlier failed test case - ftp:delete(Pid, RFile), - ftp:delete(Pid, LFile), - - {error, efnamena} = ftp:append(Pid, LFile, RFile++"1\r\nCWD ."), - ok = ftp:append(Pid, LFile, RFile), - ok = ftp:append(Pid, LFile, RFile), - ok = ftp:append(Pid, LFile), - - %% Control the contents of the file - {ok, Bin1} = ftp:recv_bin(Pid, RFile), - ok = ftp:delete(Pid, RFile), - ok = file:delete(AbsLFile), - ok = check_content(binary_to_list(Bin1), Contents, double), - - {ok, Bin2} = ftp:recv_bin(Pid, LFile), - ok = ftp:delete(Pid, LFile), - ok = check_content(binary_to_list(Bin2), Contents, singel), - ok. - -do_send_bin(Pid, Config) -> - File = ?config(file, Config), - Contents = "ftp_SUITE test ...", - Bin = list_to_binary(Contents), - ok = ftp:cd(Pid, "incoming"), - {error, enotbinary} = ftp:send_bin(Pid, Contents, File), - {error, efnamena} = ftp:send_bin(Pid, Bin, File++"1\r\nCWD ."), - ok = ftp:send_bin(Pid, Bin, File), - {ok, RFilesString} = ftp:nlist(Pid), - RFiles = split(RFilesString), - true = lists:member(File, RFiles), - ok = ftp:delete(Pid, File), - ok. - -do_append_bin(Pid, Config) -> - File = ?config(file, Config), - Contents = "ftp_SUITE test ...", - Bin = list_to_binary(Contents), - ok = ftp:cd(Pid, "incoming"), - {error, enotbinary} = ftp:append_bin(Pid, Contents, File), - {error, efnamena} = ftp:append_bin(Pid, Bin, File++"1\r\nCWD ."), - ok = ftp:append_bin(Pid, Bin, File), - ok = ftp:append_bin(Pid, Bin, File), - %% Control the contents of the file - {ok, Bin2} = ftp:recv_bin(Pid, File), - ok = ftp:delete(Pid,File), - ok = check_content(binary_to_list(Bin2),binary_to_list(Bin), double). - -do_send_chunk(Pid, Config) -> - File = ?config(file, Config), - Contents = "ftp_SUITE test ...", - Bin = list_to_binary(Contents), - ok = ftp:cd(Pid, "incoming"), - {error, efnamena} = ftp:send_chunk_start(Pid, File++"1\r\nCWD ."), - ok = ftp:send_chunk_start(Pid, File), - {error, echunk} = ftp:cd(Pid, "incoming"), - {error, enotbinary} = ftp:send_chunk(Pid, Contents), - ok = ftp:send_chunk(Pid, Bin), - ok = ftp:send_chunk(Pid, Bin), - ok = ftp:send_chunk_end(Pid), - {ok, RFilesString} = ftp:nlist(Pid), - RFiles = split(RFilesString), - true = lists:member(File, RFiles), - ok = ftp:delete(Pid, File), - ok. - -do_append_chunk(Pid, Config) -> - File = ?config(file, Config), - Contents = ["ER","LE","RL"], - ok = ftp:cd(Pid, "incoming"), - {error, efnamena} = ftp:append_chunk_start(Pid, File++"1\r\nCWD ."), - ok = ftp:append_chunk_start(Pid, File), - {error, enotbinary} = ftp:append_chunk(Pid, lists:nth(1,Contents)), - ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(1,Contents))), - ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(2,Contents))), - ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(3,Contents))), - ok = ftp:append_chunk_end(Pid), - %%Control the contents of the file - {ok, Bin2} = ftp:recv_bin(Pid, File), - ok = check_content(binary_to_list(Bin2),"ERL", double), - ok = ftp:delete(Pid, File), - ok. - -do_recv(Pid, Config) -> - PrivDir = ?config(priv_dir, Config), - File = ?config(file, Config), - Newfile = ?config(new_file, Config), - AbsFile = filename:absname(File, PrivDir), - Contents = "ftp_SUITE:recv test ...", - ok = file:write_file(AbsFile, list_to_binary(Contents)), - ok = ftp:cd(Pid, "incoming"), - ftp:delete(Pid, File), % reset - ftp:lcd(Pid, PrivDir), - ok = ftp:send(Pid, File), - ok = file:delete(AbsFile), % cleanup - test_server:sleep(100), - ok = ftp:lcd(Pid, PrivDir), - {error, efnamena} = ftp:recv(Pid, File++"\r\nCWD ."), - ok = ftp:recv(Pid, File), - {ok, Files} = file:list_dir(PrivDir), - true = lists:member(File, Files), - ok = file:delete(AbsFile), % cleanup - ok = ftp:recv(Pid, File, Newfile), - ok = ftp:delete(Pid, File), % cleanup - ok. - -do_recv_bin(Pid, Config) -> - File = ?config(file, Config), - Contents1 = "ftp_SUITE test ...", - Bin1 = list_to_binary(Contents1), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:send_bin(Pid, Bin1, File), - test_server:sleep(100), - {error, efnamena} = ftp:recv_bin(Pid, File++"\r\nCWD ."), - {ok, Bin2} = ftp:recv_bin(Pid, File), - ok = ftp:delete(Pid, File), % cleanup - Contents2 = binary_to_list(Bin2), - Contents1 = Contents2, - ok. - -do_recv_chunk(Pid, Config) -> - File = ?config(file, Config), - Data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" - "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" - "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" - "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG" - "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" - "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII", - - Contents1 = lists:flatten(lists:duplicate(10, Data)), - Bin1 = list_to_binary(Contents1), - ok = ftp:cd(Pid, "incoming"), - ok = ftp:type(Pid, binary), - ok = ftp:send_bin(Pid, Bin1, File), - test_server:sleep(100), - {error, "ftp:recv_chunk_start/2 not called"} = recv_chunk(Pid, <<>>), - {error, efnamena} = ftp:recv_chunk_start(Pid, File++"\r\nCWD ."), - ok = ftp:recv_chunk_start(Pid, File), - {ok, Contents2} = recv_chunk(Pid, <<>>), - ok = ftp:delete(Pid, File), % cleanup - ok = find_diff(Contents2, Contents1, 1), - ok. - -do_type(Pid) -> - ok = ftp:type(Pid, ascii), - ok = ftp:type(Pid, binary), - ok = ftp:type(Pid, ascii), - {error, etype} = ftp:type(Pid, foobar), - ok. - -do_quote(Pid) -> - ["257 \"/\""++_Rest] = ftp:quote(Pid, "pwd"), %% 257 - [_| _] = ftp:quote(Pid, "help"), - %% This negativ test causes some ftp servers to hang. This test - %% is not important for the client, so we skip it for now. - %%["425 Can't build data connection: Connection refused."] - %% = ftp:quote(Pid, "list"), - ok. - - watch_dog(Config) -> - Dog = test_server:timetrap(inets_test_lib:minutes(1)), - NewConfig = lists:keydelete(watchdog, 1, Config), - [{watchdog, Dog} | NewConfig]. - - close_connection(Config) -> - case ?config(ftp, Config) of - Pid when is_pid(Pid) -> - ok = ftp:close(Pid), - lists:delete({ftp, Pid}, Config); - _ -> - Config - end. - -ftp_host(Config) -> - case ?config(ftp_remote_host, Config) of - undefined -> - exit({skip, "No host specified"}); - Host -> - Host - end. - -check_content(RContent, LContent, Amount) -> - LContent2 = case Amount of - double -> - LContent ++ LContent; - singel -> - LContent - end, - case string:equal(RContent, LContent2) of - true -> - ok; - false -> - %% Find where the diff is - Where = find_diff(RContent, LContent2, 1), - Where - end. - -find_diff(A, A, _) -> - ok; -find_diff([H|T1], [H|T2], Pos) -> - find_diff(T1, T2, Pos+1); -find_diff(RC, LC, Pos) -> - {error, {diff, Pos, RC, LC}}. - -recv_chunk(Pid, Acc) -> - case ftp:recv_chunk(Pid) of - ok -> - {ok, binary_to_list(Acc)}; - {ok, Bin} -> - recv_chunk(Pid, <<Acc/binary, Bin/binary>>); - Error -> - Error - end. - -split(Cs) -> - split(Cs, [], []). - -split([$\r, $\n| Cs], I, Is) -> - split(Cs, [], [lists:reverse(I)| Is]); -split([C| Cs], I, Is) -> - split(Cs, [C| I], Is); -split([], I, Is) -> - lists:reverse([lists:reverse(I)| Is]). - -do_ftp_open(Host, Opts) -> - p("do_ftp_open -> entry with" - "~n Host: ~p" - "~n Opts: ~p", [Host, Opts]), - case ftp:open(Host, Opts) of - {ok, _} = OK -> - OK; - {error, Reason} -> - Str = - lists:flatten( - io_lib:format("Unable to reach test FTP server ~p (~p)", - [Host, Reason])), - throw({skip, Str}) - end. - - -passwd() -> - Host = - case inet:gethostname() of - {ok, H} -> - H; - _ -> - "localhost" - end, - "ftp_SUITE@" ++ Host. - -ftpd_hosts(Config) -> - DataDir = ?config(data_dir, Config), - FileName = filename:join([DataDir, "../ftp_SUITE_data/", ftpd_hosts]), - p("FileName: ~p", [FileName]), - case file:consult(FileName) of - {ok, [Hosts]} when is_list(Hosts) -> - Hosts; - _ -> - [] - end. - -wrapper(Prefix,doc,Func) -> - Prefix++Func(doc); -wrapper(_,X,Func) -> - Func(X). - -data_dir(Config) -> - case ?config(data_dir, Config) of - List when (length(List) > 0) -> - PathList = filename:split(List), - {NewPathList,_} = lists:split((length(PathList)-1), PathList), - DataDir = filename:join(NewPathList ++ [ftp_SUITE_data]), - NewConfig = - lists:keyreplace(data_dir,1,Config, {data_dir,DataDir}), - NewConfig; - _ -> Config - end. - - - -p(F) -> - p(F, []). - -p(F, A) -> - case get(ftp_testcase) of - undefined -> - io:format("~w [~w] " ++ F ++ "~n", [?MODULE, self() | A]); - TC when is_atom(TC) -> - io:format("~w [~w] ~w:" ++ F ++ "~n", [?MODULE, self(), TC | A]) - end. diff --git a/lib/inets/test/http_format_SUITE.erl b/lib/inets/test/http_format_SUITE.erl index e977bd1b9b..a2b463e98c 100644 --- a/lib/inets/test/http_format_SUITE.erl +++ b/lib/inets/test/http_format_SUITE.erl @@ -55,13 +55,9 @@ end_per_group(_GroupName, Config) -> init_per_testcase(_, Config) -> - Dog = test_server:timetrap(?t:minutes(1)), - NewConfig = lists:keydelete(watchdog, 1, Config), - [{watchdog, Dog} | NewConfig]. + Config. -end_per_testcase(_, Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), +end_per_testcase(_, _) -> ok. %%------------------------------------------------------------------------- diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index f9b3aa5b59..42772923e4 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -42,7 +42,8 @@ %% Common Test interface functions ----------------------------------- %%-------------------------------------------------------------------- suite() -> - [{ct_hooks,[ts_install_cth]}]. + [{ct_hooks,[ts_install_cth]} + ]. all() -> [ @@ -137,8 +138,9 @@ misc() -> %%-------------------------------------------------------------------- init_per_suite(Config) -> - PrivDir = ?config(priv_dir, Config), - DataDir = ?config(data_dir, Config), + ct:timetrap({seconds, 30}), + PrivDir = proplists:get_value(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), inets_test_lib:start_apps([inets]), ServerRoot = filename:join(PrivDir, "server_root"), DocRoot = filename:join(ServerRoot, "htdocs"), @@ -147,7 +149,7 @@ init_per_suite(Config) -> end_per_suite(Config) -> inets_test_lib:stop_apps([inets]), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), inets_test_lib:del_dirs(PrivDir), ok. @@ -159,6 +161,7 @@ init_per_group(misc = Group, Config) -> Config; init_per_group(Group, Config0) when Group =:= sim_https; Group =:= https-> + ct:timetrap({seconds, 30}), start_apps(Group), StartSsl = try ssl:start() catch @@ -199,7 +202,15 @@ init_per_testcase(persistent_connection, Config) -> {max_keep_alive_length, 3}], persistent_connection), Config; - +init_per_testcase(wait_for_whole_response, Config) -> + ct:timetrap({seconds, 60*3}), + Config; +init_per_testcase(Case, Config) when Case == post; + Case == delete; + Case == post_delete; + Case == post_stream -> + ct:timetrap({seconds, 30}), + Config; init_per_testcase(_Case, Config) -> Config. @@ -356,7 +367,7 @@ pipeline(Config) when is_list(Config) -> {ok, _} = httpc:request(get, Request, [], [], pipeline), %% Make sure pipeline session is registerd - test_server:sleep(4000), + ct:sleep(4000), keep_alive_requests(Request, pipeline). %%-------------------------------------------------------------------- @@ -366,7 +377,7 @@ persistent_connection(Config) when is_list(Config) -> {ok, _} = httpc:request(get, Request, [], [], persistent), %% Make sure pipeline session is registerd - test_server:sleep(4000), + ct:sleep(4000), keep_alive_requests(Request, persistent). %%------------------------------------------------------------------------- @@ -394,7 +405,7 @@ async(Config) when is_list(Config) -> save_to_file() -> [{doc, "Test to save the http body to a file"}]. save_to_file(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), FilePath = filename:join(PrivDir, "dummy.html"), URL = url(group_name(Config), "/dummy.html", Config), Request = {URL, []}, @@ -408,7 +419,7 @@ save_to_file(Config) when is_list(Config) -> save_to_file_async() -> [{doc,"Test to save the http body to a file"}]. save_to_file_async(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), FilePath = filename:join(PrivDir, "dummy.html"), URL = url(group_name(Config), "/dummy.html", Config), Request = {URL, []}, @@ -868,7 +879,7 @@ headers() -> headers(Config) when is_list(Config) -> URL = url(group_name(Config), "/dummy.html", Config), - DocRoot = ?config(doc_root, Config), + DocRoot = proplists:get_value(doc_root, Config), {ok, FileInfo} = file:read_file_info(filename:join([DocRoot,"dummy.html"])), @@ -1212,11 +1223,11 @@ not_streamed_test(Request, To) -> end. url(http, End, Config) -> - Port = ?config(port, Config), + Port = proplists:get_value(port, Config), {ok,Host} = inet:gethostname(), ?URL_START ++ Host ++ ":" ++ integer_to_list(Port) ++ End; url(https, End, Config) -> - Port = ?config(port, Config), + Port = proplists:get_value(port, Config), {ok,Host} = inet:gethostname(), ?TLS_URL_START ++ Host ++ ":" ++ integer_to_list(Port) ++ End; url(sim_http, End, Config) -> @@ -1224,10 +1235,10 @@ url(sim_http, End, Config) -> url(sim_https, End, Config) -> url(https, End, Config). url(http, UserInfo, End, Config) -> - Port = ?config(port, Config), + Port = proplists:get_value(port, Config), ?URL_START ++ UserInfo ++ integer_to_list(Port) ++ End; url(https, UserInfo, End, Config) -> - Port = ?config(port, Config), + Port = proplists:get_value(port, Config), ?TLS_URL_START ++ UserInfo ++ integer_to_list(Port) ++ End; url(sim_http, UserInfo, End, Config) -> url(http, UserInfo, End, Config); @@ -1235,7 +1246,7 @@ url(sim_https, UserInfo, End, Config) -> url(https, UserInfo, End, Config). group_name(Config) -> - GroupProp = ?config(tc_group_properties, Config), + GroupProp = proplists:get_value(tc_group_properties, Config), proplists:get_value(name, GroupProp). server_start(sim_http, _) -> @@ -1257,11 +1268,11 @@ server_start(_, HttpdConfig) -> proplists:get_value(port, Info). server_config(http, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), [{port, 0}, {server_name,"httpc_test"}, {server_root, ServerRoot}, - {document_root, ?config(doc_root, Config)}, + {document_root, proplists:get_value(doc_root, Config)}, {bind_address, any}, {ipfamily, inet_version()}, {mime_type, "text/plain"}, @@ -1283,7 +1294,7 @@ start_apps(_) -> ok. ssl_config(Config) -> - DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), [{certfile, filename:join(DataDir, "ssl_server_cert.pem")}, {verify, verify_none} ]. @@ -1931,9 +1942,9 @@ handle_uri(_,"/once.html",_,_,Socket,_) -> "Content-Length:32\r\n\r\n", send(Socket, Head), send(Socket, "<HTML><BODY>fo"), - test_server:sleep(1000), + ct:sleep(1000), send(Socket, "ob"), - test_server:sleep(1000), + ct:sleep(1000), send(Socket, "ar</BODY></HTML>"); handle_uri(_,"/invalid_http.html",_,_,_,_) -> @@ -2077,7 +2088,7 @@ run_clients(NumClients, ServerPort, SeqNumServer) -> wait4clients([], _Timeout) -> ok; wait4clients(Clients, Timeout) when Timeout > 0 -> - Time = inets_time_compat:monotonic_time(), + Time = erlang:monotonic_time(), receive {'DOWN', _MRef, process, Pid, normal} -> @@ -2177,7 +2188,7 @@ parse_connection_type(Request) -> end. set_random_seed() -> - Unique = inets_time_compat:unique_integer(), + Unique = erlang:unique_integer(), A = erlang:phash2([make_ref(), self(), Unique]), random:seed(A, A, A). diff --git a/lib/inets/test/httpc_cookie_SUITE.erl b/lib/inets/test/httpc_cookie_SUITE.erl index 0eca3edae2..8140967bca 100644 --- a/lib/inets/test/httpc_cookie_SUITE.erl +++ b/lib/inets/test/httpc_cookie_SUITE.erl @@ -23,14 +23,8 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). -%% Test server specific exports --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, init_per_testcase/2, end_per_testcase/2]). - -%% Test cases must be exported. --export([session_cookies_only/1, netscape_cookies/1, - cookie_cancel/1, cookie_expires/1, persistent_cookie/1, - domain_cookie/1, secure_cookie/1, update_cookie/1, - update_cookie_session/1, cookie_attributes/1]). +%% Note: This directive should only be used in test suites. +-compile(export_all). -define(URL, "http://myhost.cookie.test.org"). -define(URL_DOMAIN, "http://myhost2.cookie.test.org"). @@ -38,86 +32,10 @@ %% Test server callback functions -%%-------------------------------------------------------------------- -%% Function: init_per_testcase(TestCase, Config) -> Config -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% -%% Description: Initiation before each test case -%% -%% Note: This function is free to add any key/value pairs to the Config -%% variable, but should NOT alter/remove any existing entries. -%% Description: Initiation before each test case -%%-------------------------------------------------------------------- -init_per_testcase(session_cookies_only = Case, Config0) -> - tsp("init_per_testcase(~p) -> entry with" - "~n Config0: ~p", [Case, Config0]), - Config = init_workdir(Case, Config0), - application:start(inets), - httpc:set_options([{cookies, verify}]), - watch_dog(Config); - -init_per_testcase(Case, Config0) -> - tsp("init_per_testcase(~p) -> entry with" - "~n Config0: ~p", [Case, Config0]), - Config = init_workdir(Case, Config0), - CaseDir = ?config(case_top_dir, Config), - application:load(inets), - application:set_env(inets, services, [{httpc, {default, CaseDir}}]), - application:start(inets), - httpc:set_options([{cookies, verify}]), - watch_dog(Config). - -watch_dog(Config) -> - Dog = test_server:timetrap(inets_test_lib:minutes(10)), - NewConfig = lists:keydelete(watchdog, 1, Config), - [{watchdog, Dog} | NewConfig]. - -init_workdir(Case, Config) -> - PrivDir = ?config(priv_dir, Config), - SuiteTopDir = filename:join(PrivDir, ?MODULE), - case file:make_dir(SuiteTopDir) of - ok -> - ok; - {error, eexist} -> - ok; - Error -> - tsf({failed_creating_subsuite_top_dir, Error}) - end, - - CaseTopDir = filename:join(SuiteTopDir, Case), - ?line ok = file:make_dir(CaseTopDir), - [{suite_top_dir, SuiteTopDir}, - {case_top_dir, CaseTopDir} | Config]. - - -%%-------------------------------------------------------------------- -%% Function: end_per_testcase(TestCase, Config) -> _ -%% Case - atom() -%% Name of the test case that is about to be run. -%% Config - [tuple()] -%% A list of key/value pairs, holding the test case configuration. -%% Description: Cleanup after each test case -%%-------------------------------------------------------------------- -end_per_testcase(Case, Config) -> - tsp("end_per_testcase(~p) -> entry with" - "~n Config: ~p", [Case, Config]), - application:stop(inets), - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - ok. - -%%-------------------------------------------------------------------- -%% Function: all(Clause) -> TestCases -%% Clause - atom() - suite | doc -%% TestCases - [Case] -%% Case - atom() -%% Name of a test case. -%% Description: Returns a list of all test cases in this test suite -%%-------------------------------------------------------------------- -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds,15}} + ]. all() -> [ @@ -148,17 +66,55 @@ init_per_group(_GroupName, Config) -> end_per_group(_GroupName, Config) -> Config. +init_per_testcase(session_cookies_only = Case, Config0) -> + Config = init_workdir(Case, Config0), + application:start(inets), + httpc:set_options([{cookies, verify}]), + Config; +init_per_testcase(cookie_expires = Case, Config0) -> + Config = init_workdir(Case, Config0), + CaseDir = proplists:get_value(case_top_dir, Config), + application:start(inets), + application:set_env(inets, services, [{httpc, {default, CaseDir}}]), + application:start(inets), + httpc:set_options([{cookies, verify}]), + Config; +init_per_testcase(Case, Config0) -> + Config = init_workdir(Case, Config0), + CaseDir = proplists:get_value(case_top_dir, Config), + application:load(inets), + application:set_env(inets, services, [{httpc, {default, CaseDir}}]), + application:start(inets), + httpc:set_options([{cookies, verify}]), + Config. + +init_workdir(Case, Config) -> + PrivDir = proplists:get_value(priv_dir, Config), + SuiteTopDir = filename:join(PrivDir, ?MODULE), + case file:make_dir(SuiteTopDir) of + ok -> + ok; + {error, eexist} -> + ok; + Error -> + ct:fail({failed_creating_subsuite_top_dir, Error}) + end, + + CaseTopDir = filename:join(SuiteTopDir, Case), + ok = file:make_dir(CaseTopDir), + [{suite_top_dir, SuiteTopDir}, + {case_top_dir, CaseTopDir} | Config]. + +end_per_testcase(_, _) -> + application:stop(inets). + %% Test cases starts here. %%-------------------------------------------------------------------- -session_cookies_only(doc) -> - ["Test that all cookies are handled as session cookies if there" - "does not exist a directory to save presitent cookies in."]; -session_cookies_only(suite) -> - []; +session_cookies_only() -> + [{doc, "Test that all cookies are handled as session cookies if there" + "does not exist a directory to save presitent cookies in."}]. session_cookies_only(Config) when is_list(Config) -> - tsp("session_cookies_only -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" ";max-age=60000"}], httpc:store_cookies(SetCookieHeaders, ?URL), @@ -166,36 +122,22 @@ session_cookies_only(Config) when is_list(Config) -> httpc:cookie_header(?URL), application:stop(inets), application:start(inets), - {"cookie", ""} = httpc:cookie_header(?URL), - - tsp("session_cookies_only -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. + {"cookie", ""} = httpc:cookie_header(?URL). -netscape_cookies(doc) -> - ["Test that the old (original) format of cookies are accepted."]; -netscape_cookies(suite) -> - []; +netscape_cookies() -> + [{doc, "Test that the old (original) format of cookies are accepted."}]. netscape_cookies(Config) when is_list(Config) -> - tsp("netscape_cookies -> Cookies 1: ~p", [httpc:which_cookies()]), - Expires = future_netscape_date(), SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; " "expires=" ++ Expires}], httpc:store_cookies(SetCookieHeaders, ?URL), {"cookie", "$Version=0; test_cookie=true; $Path=/"} = - httpc:cookie_header(?URL), + httpc:cookie_header(?URL). - tsp("netscape_cookies -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. - -cookie_cancel(doc) -> - ["A cookie can be canceld by sending the same cookie with max-age=0 " - "this test cheks that cookie is canceled."]; -cookie_cancel(suite) -> - []; +cookie_cancel() -> + [{doc, "A cookie can be canceld by sending the same cookie with max-age=0 " + "this test cheks that cookie is canceled."}]. cookie_cancel(Config) when is_list(Config) -> - tsp("cookie_cancel -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" "max-age=60000"}], httpc:store_cookies(SetCookieHeaders, ?URL), @@ -204,155 +146,60 @@ cookie_cancel(Config) when is_list(Config) -> NewSetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;max-age=0"}], httpc:store_cookies(NewSetCookieHeaders, ?URL), - {"cookie", ""} = httpc:cookie_header(?URL), + {"cookie", ""} = httpc:cookie_header(?URL). - tsp("cookie_cancel -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. - -cookie_expires(doc) -> - ["Test that a cookie is not used when it has expired"]; -cookie_expires(suite) -> - []; +cookie_expires() -> + [{doc, "Test that a cookie is not used when it has expired"}]. cookie_expires(Config) when is_list(Config) -> - tsp("cookie_expires -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" "max-age=5"}], httpc:store_cookies(SetCookieHeaders, ?URL), {"cookie", "$Version=0; test_cookie=true; $Path=/"} = httpc:cookie_header(?URL), - test_server:sleep(10000), - {"cookie", ""} = httpc:cookie_header(?URL), + timer:sleep(10000), + {"cookie", ""} = httpc:cookie_header(?URL). - tsp("cookie_expires -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. - -persistent_cookie(doc) -> - ["Test domian cookie attribute"]; -persistent_cookie(suite) -> - []; +persistent_cookie() -> + [{doc, "Test domian cookie attribute"}]. persistent_cookie(Config) when is_list(Config)-> - tsp("persistent_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" "max-age=60000"}], httpc:store_cookies(SetCookieHeaders, ?URL), {"cookie", "$Version=0; test_cookie=true; $Path=/"} = httpc:cookie_header(?URL), - CaseDir = ?config(case_top_dir, Config), + CaseDir = proplists:get_value(case_top_dir, Config), application:stop(inets), application:load(inets), application:set_env(inets, services, [{httpc, {default, CaseDir}}]), application:start(inets), httpc:set_options([{cookies, enabled}]), - {"cookie","$Version=0; test_cookie=true; $Path=/"} = httpc:cookie_header(?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} = httpc:cookie_header(?URL). - tsp("persistent_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. - - -domain_cookie(doc) -> - ["Test the domian cookie attribute"]; -domain_cookie(suite) -> - []; +domain_cookie() -> + [{doc, "Test the domian cookie attribute"}]. domain_cookie(Config) when is_list(Config) -> - tsp("domain_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" "domain=.cookie.test.org"}], httpc:store_cookies(SetCookieHeaders, ?URL), {"cookie","$Version=0; test_cookie=true; $Path=/; " "$Domain=.cookie.test.org"} = - httpc:cookie_header(?URL_DOMAIN), + httpc:cookie_header(?URL_DOMAIN). - tsp("domain_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), - ok. - - -secure_cookie(doc) -> - ["Test the secure cookie attribute"]; -secure_cookie(suite) -> - []; +secure_cookie() -> + [{doc, "Test the secure cookie attribute"}]. secure_cookie(Config) when is_list(Config) -> - tsp("secure_cookie -> entry with" - "~n Config: ~p", [Config]), - - %% httpc:reset_cookies(), - - tsp("secure_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), - SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; secure"}], - tsp("secure_cookie -> store cookies (1)"), ok = httpc:store_cookies(SetCookieHeaders, ?URL), - - tsp("secure_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), - - tsp("secure_cookie -> check cookie (secure)"), check_cookie("$Version=0; test_cookie=true; $Path=/", ?URL_SECURE), - - tsp("secure_cookie -> check cookie (plain)"), check_cookie("", ?URL), - - tsp("secure_cookie -> store cookies (2)"), SetCookieHeaders1 = [{"set-cookie", "test1_cookie=true; path=/; secure"}], ok = httpc:store_cookies(SetCookieHeaders1, ?URL), - - tsp("secure_cookie -> Cookies 3: ~p", [httpc:which_cookies()]), - - tsp("secure_cookie -> cookie header (3)"), check_cookie("$Version=0; test_cookie=true; $Path=/; " "test1_cookie=true; $Path=/", - ?URL_SECURE), -%% {"cookie","$Version=0; test_cookie=true; $Path=/; " -%% "test1_cookie=true; $Path=/"} = httpc:cookie_header(?URL_SECURE), - - tsp("secure_cookie -> Cookies 4: ~p", [httpc:which_cookies()]), - - tsp("secure_cookie -> done"), - ok. + ?URL_SECURE). -expect_cookie_header(No, ExpectedCookie) -> - case httpc:cookie_header(?URL) of - {"cookie", ExpectedCookie} -> - ok; - {"cookie", BadCookie} -> - io:format("Bad Cookie ~w: " - "~n Expected: ~s" - "~n Received: ~s" - "~n", [No, ExpectedCookie, BadCookie]), - exit({bad_cookie_header, No, ExpectedCookie, BadCookie}) - end. - -print_cookies(Pre) -> - io:format("~s: ", [Pre]), - print_cookies2(httpc:which_cookies()). - -print_cookies2([]) -> - ok; -print_cookies2([{cookies, Cookies}|Rest]) -> - print_cookies3("Cookies", Cookies), - print_cookies2(Rest); -print_cookies2([{session_cookies, Cookies}|Rest]) -> - print_cookies3("Session Cookies", Cookies), - print_cookies2(Rest); -print_cookies2([_|Rest]) -> - print_cookies2(Rest). - -print_cookies3(Header, []) -> - io:format(" ~s: []", [Header]); -print_cookies3(Header, Cookies) -> - io:format(" ~s: ", [Header]), - Prefix = " ", - PrintCookie = - fun(Cookie) -> - io:format("~s", [httpc_cookie:image_of(Prefix, Cookie)]) - end, - lists:foreach(PrintCookie, Cookies). - -update_cookie(doc)-> - ["Test that a (plain) cookie can be updated."]; -update_cookie(suite) -> - []; +update_cookie()-> + [{doc, "Test that a (plain) cookie can be updated."}]. update_cookie(Config) when is_list(Config) -> print_cookies("Cookies before store"), @@ -377,10 +224,8 @@ update_cookie(Config) when is_list(Config) -> "test_cookie=false; $Path=/", expect_cookie_header(2, ExpectCookie2). -update_cookie_session(doc)-> - ["Test that a session cookie can be updated."]; -update_cookie_session(suite) -> - []; +update_cookie_session()-> + [{doc, "Test that a session cookie can be updated."}]. update_cookie_session(Config) when is_list(Config)-> print_cookies("Cookies before store"), @@ -400,23 +245,57 @@ update_cookie_session(Config) when is_list(Config)-> expect_cookie_header(2, ExpectedCookie2). -cookie_attributes(doc) -> - ["Test attribute not covered by the other test cases"]; -cookie_attributes(suite) -> - []; +cookie_attributes() -> + [{doc, "Test attribute not covered by the other test cases"}]. cookie_attributes(Config) when is_list(Config) -> SetCookieHeaders = [{"set-cookie", "test_cookie=true;version=1;" "comment=foobar; "%% Comment "foo=bar;" %% Nonsense should be ignored "max-age=60000"}], httpc:store_cookies(SetCookieHeaders, ?URL), - {"cookie","$Version=1; test_cookie=true"} = httpc:cookie_header(?URL), - ok. + {"cookie","$Version=1; test_cookie=true"} = httpc:cookie_header(?URL). %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- +print_cookies(Pre) -> + io:format("~s: ", [Pre]), + print_cookies2(httpc:which_cookies()). + +print_cookies2([]) -> + ok; +print_cookies2([{cookies, Cookies}|Rest]) -> + print_cookies3("Cookies", Cookies), + print_cookies2(Rest); +print_cookies2([{session_cookies, Cookies}|Rest]) -> + print_cookies3("Session Cookies", Cookies), + print_cookies2(Rest); +print_cookies2([_|Rest]) -> + print_cookies2(Rest). + +print_cookies3(Header, []) -> + io:format(" ~s: []", [Header]); +print_cookies3(Header, Cookies) -> + io:format(" ~s: ", [Header]), + Prefix = " ", + PrintCookie = + fun(Cookie) -> + io:format("~s", [httpc_cookie:image_of(Prefix, Cookie)]) + end, + lists:foreach(PrintCookie, Cookies). + +expect_cookie_header(No, ExpectedCookie) -> + case httpc:cookie_header(?URL) of + {"cookie", ExpectedCookie} -> + ok; + {"cookie", BadCookie} -> + io:format("Bad Cookie ~w: " + "~n Expected: ~s" + "~n Received: ~s" + "~n", [No, ExpectedCookie, BadCookie]), + exit({bad_cookie_header, No, ExpectedCookie, BadCookie}) + end. check_cookie(Expect, URL) -> case httpc:cookie_header(URL) of @@ -426,12 +305,12 @@ check_cookie(Expect, URL) -> case lists:prefix(Expect, Unexpected) of true -> Extra = Unexpected -- Expect, - tsf({extra_cookie_info, Extra}); + ct:fail({extra_cookie_info, Extra}); false -> - tsf({unknown_cookie, Expect, Unexpected}) + ct:fail({unknown_cookie, Expect, Unexpected}) end; Bad -> - tsf({bad_cookies, Bad}) + ct:fail({bad_cookies, Bad}) end. @@ -509,11 +388,3 @@ month_str(11) ->"Nov"; month_str(12) ->"Dec". -tsp(F) -> - tsp(F, []). -tsp(F, A) -> - test_server:format("~p ~p:" ++ F ++ "~n", [self(), ?MODULE | A]). - -tsf(Reason) -> - test_server:fail(Reason). - diff --git a/lib/inets/test/httpc_proxy_SUITE.erl b/lib/inets/test/httpc_proxy_SUITE.erl index 2f6f0bc26f..198b245399 100644 --- a/lib/inets/test/httpc_proxy_SUITE.erl +++ b/lib/inets/test/httpc_proxy_SUITE.erl @@ -141,7 +141,7 @@ end_per_testcase(_Case, Config) -> %% internal functions apps(_Case, Config) -> - case ?config(protocol, Config) of + case proplists:get_value(protocol, Config) of https -> [ssl]; _ -> @@ -438,7 +438,7 @@ header_value(Name, [{HeaderName,HeaderValue}|Headers]) -> https_connect_error(doc) -> ["Error from CONNECT tunnel should be returned"]; https_connect_error(Config) when is_list(Config) -> - {HttpServer,HttpPort} = ?config(http, Config), + {HttpServer,HttpPort} = proplists:get_value(http, Config), Method = get, %% using HTTPS scheme with HTTP port to trigger connection error URL = "https://" ++ HttpServer ++ ":" ++ @@ -477,7 +477,7 @@ app_start(App, Config) -> inets -> application:stop(App), ok = application:start(App), - case ?config(proxy, Config) of + case proplists:get_value(proxy, Config) of undefined -> ok; {_,ProxySpec} -> ok = httpc:set_options([{proxy,ProxySpec}]) @@ -495,7 +495,7 @@ app_stop(App) -> application:stop(App). make_cert_files(Alg, Prefix, Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), CaInfo = {CaCert,_} = erl_make_certs:make_cert([{key,Alg}]), {Cert,CertKey} = erl_make_certs:make_cert([{key,Alg},{issuer,CaInfo}]), CaCertFile = filename:join(PrivDir, Prefix++"cacerts.pem"), @@ -513,8 +513,8 @@ der_to_pem(File, Entries) -> url(AbsPath, Config) -> - Protocol = ?config(protocol, Config), - {ServerName,ServerPort} = ?config(Protocol, Config), + Protocol = proplists:get_value(protocol, Config), + {ServerName,ServerPort} = proplists:get_value(Protocol, Config), atom_to_list(Protocol) ++ "://" ++ ServerName ++ ":" ++ integer_to_list(ServerPort) ++ AbsPath. @@ -548,8 +548,8 @@ init_local_proxy_string(String, Config) -> |Config]. rcmd_local_proxy(Args, Config) -> - DataDir = ?config(data_dir, Config), - PrivDir = ?config(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Script = filename:join(DataDir, ?LOCAL_PROXY_SCRIPT), rcmd(Script, Args, [{cd,PrivDir}]). diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl index 93520c1cb4..f5167116ce 100644 --- a/lib/inets/test/httpd_SUITE.erl +++ b/lib/inets/test/httpd_SUITE.erl @@ -46,7 +46,9 @@ %% Common Test interface functions ----------------------------------- %%-------------------------------------------------------------------- suite() -> - [{ct_hooks,[ts_install_cth]}]. + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds, 120}} + ]. all() -> [ @@ -149,8 +151,8 @@ load() -> ]. init_per_suite(Config) -> - PrivDir = ?config(priv_dir, Config), - DataDir = ?config(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), inets_test_lib:stop_apps([inets]), ServerRoot = filename:join(PrivDir, "server_root"), inets_test_lib:del_dirs(ServerRoot), @@ -218,22 +220,22 @@ init_per_group(http_0_9, Config) -> [{http_version, "HTTP/0.9"} | Config] end; init_per_group(http_htaccess = Group, Config) -> - Path = ?config(doc_root, Config), + Path = proplists:get_value(doc_root, Config), catch remove_htaccess(Path), - create_htaccess_data(Path, ?config(address, Config)), + create_htaccess_data(Path, proplists:get_value(address, Config)), ok = start_apps(Group), init_httpd(Group, [{type, ip_comm} | Config]); init_per_group(https_htaccess = Group, Config) -> - Path = ?config(doc_root, Config), + Path = proplists:get_value(doc_root, Config), catch remove_htaccess(Path), - create_htaccess_data(Path, ?config(address, Config)), + create_htaccess_data(Path, proplists:get_value(address, Config)), init_ssl(Group, Config); init_per_group(auth_api, Config) -> [{auth_prefix, ""} | Config]; init_per_group(auth_api_dets, Config) -> [{auth_prefix, "dets_"} | Config]; init_per_group(auth_api_mnesia, Config) -> - start_mnesia(?config(node, Config)), + start_mnesia(proplists:get_value(node, Config)), [{auth_prefix, "mnesia_"} | Config]; init_per_group(_, Config) -> Config. @@ -271,7 +273,8 @@ end_per_group(_, _) -> %%-------------------------------------------------------------------- init_per_testcase(Case, Config) when Case == host; Case == trace -> - Prop = ?config(tc_group_properties, Config), + ct:timetrap({seconds, 20}), + Prop = proplists:get_value(tc_group_properties, Config), Name = proplists:get_value(name, Prop), Cb = case Name of http_1_0 -> @@ -282,11 +285,13 @@ init_per_testcase(Case, Config) when Case == host; Case == trace -> [{version_cb, Cb} | proplists:delete(version_cb, Config)]; init_per_testcase(range, Config) -> - DocRoot = ?config(doc_root, Config), + ct:timetrap({seconds, 20}), + DocRoot = proplists:get_value(doc_root, Config), create_range_data(DocRoot), Config; init_per_testcase(_, Config) -> + ct:timetrap({seconds, 20}), Config. end_per_testcase(_Case, _Config) -> @@ -300,10 +305,10 @@ head() -> [{doc, "HTTP HEAD request for static page"}]. head(Config) when is_list(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), ?config(node, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), proplists:get_value(node, Config), http_request("HEAD /index.html ", Version, Host), [{statuscode, head_status(Version)}, {version, Version}]). @@ -312,13 +317,13 @@ get() -> [{doc, "HTTP GET request for static page"}]. get(Config) when is_list(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Type = ?config(type, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), http_request("GET /index.html ", Version, Host), [{statuscode, 200}, {header, "Content-Type", "text/html"}, @@ -339,8 +344,8 @@ basic_auth() -> [{doc, "Test Basic authentication with WWW-Authenticate header"}]. basic_auth(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), basic_auth_requiered(Config), %% Authentication OK! ["one:OnePassword" user first in user list] ok = auth_status(auth_request("/open/dummy.html", "one", "onePassword", Version, Host), Config, @@ -380,15 +385,15 @@ auth_api() -> [{doc, "Test mod_auth API"}]. auth_api(Config) when is_list(Config) -> - Prefix = ?config(auth_prefix, Config), + Prefix = proplists:get_value(auth_prefix, Config), do_auth_api(Prefix, Config). do_auth_api(AuthPrefix, Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Node = ?config(node, Config), - ServerRoot = ?config(server_root, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Node = proplists:get_value(node, Config), + ServerRoot = proplists:get_value(server_root, Config), ok = http_status("GET / ", Config, [{statuscode, 200}]), ok = auth_status(auth_request("/", "one", "WrongPassword", Version, Host), Config, @@ -550,12 +555,12 @@ ipv6(Config) when is_list(Config) -> {ok, Hostname0} = inet:gethostname(), case lists:member(list_to_atom(Hostname0), ct:get_config(ipv6_hosts)) of true -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), URI = http_request("GET / ", Version, Host), - httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), [inet6], - ?config(code, Config), + httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), [inet6], + proplists:get_value(code, Config), URI, [{statuscode, 200}, {version, Version}]); false -> @@ -576,11 +581,11 @@ htaccess() -> [{doc, "Test mod_auth API"}]. htaccess(Config) when is_list(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Type = ?config(type, Config), - Port = ?config(port, Config), - Node = ?config(node, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + Port = proplists:get_value(port, Config), + Node = proplists:get_value(node, Config), %% Control that authentication required! %% Control that the pages that shall be %% authenticated really need authenticatin @@ -691,23 +696,23 @@ host() -> [{doc, "Test host header"}]. host(Config) when is_list(Config) -> - Cb = ?config(version_cb, Config), - Cb:host(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config)). + Cb = proplists:get_value(version_cb, Config), + Cb:host(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config)). %%------------------------------------------------------------------------- chunked() -> [{doc, "Check that the server accepts chunked requests."}]. chunked(Config) when is_list(Config) -> - httpd_1_1:chunked(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config)). + httpd_1_1:chunked(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config)). %%------------------------------------------------------------------------- expect() -> ["Check that the server handles request with the expect header " "field appropiate"]. expect(Config) when is_list(Config) -> - httpd_1_1:expect(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config)). + httpd_1_1:expect(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config)). %%------------------------------------------------------------------------- max_clients_1_1() -> [{doc, "Test max clients limit"}]. @@ -762,10 +767,10 @@ esi(Config) when is_list(Config) -> %%------------------------------------------------------------------------- mod_esi_chunk_timeout(Config) when is_list(Config) -> - ok = httpd_1_1:mod_esi_chunk_timeout(?config(type, Config), - ?config(port, Config), - ?config(host, Config), - ?config(node, Config)). + ok = httpd_1_1:mod_esi_chunk_timeout(proplists:get_value(type, Config), + proplists:get_value(port, Config), + proplists:get_value(host, Config), + proplists:get_value(node, Config)). %%------------------------------------------------------------------------- cgi() -> @@ -846,7 +851,7 @@ cgi(Config) when is_list(Config) -> cgi_chunked_encoding_test() -> [{doc, "Test chunked encoding together with mod_cgi "}]. cgi_chunked_encoding_test(Config) when is_list(Config) -> - Host = ?config(host, Config), + Host = proplists:get_value(host, Config), Script = case test_server:os_type() of {win32, _} -> @@ -858,9 +863,9 @@ cgi_chunked_encoding_test(Config) when is_list(Config) -> ["GET " ++ Script ++ " HTTP/1.1\r\nHost:"++ Host ++"\r\n\r\n", "GET /cgi-bin/erl/httpd_example/newformat HTTP/1.1\r\nHost:" ++ Host ++"\r\n\r\n"], - httpd_1_1:mod_cgi_chunked_encoding_test(?config(type, Config), ?config(port, Config), + httpd_1_1:mod_cgi_chunked_encoding_test(proplists:get_value(type, Config), proplists:get_value(port, Config), Host, - ?config(node, Config), + proplists:get_value(node, Config), Requests). %%------------------------------------------------------------------------- alias_1_1() -> @@ -920,52 +925,52 @@ range() -> [{doc, "Test Range header"}]. range(Config) when is_list(Config) -> - httpd_1_1:range(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config)). + httpd_1_1:range(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config)). %%------------------------------------------------------------------------- if_modified_since() -> [{doc, "Test If-Modified-Since header"}]. if_modified_since(Config) when is_list(Config) -> - httpd_1_1:if_test(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config), - ?config(doc_root, Config)). + httpd_1_1:if_test(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config), + proplists:get_value(doc_root, Config)). %%------------------------------------------------------------------------- trace() -> [{doc, "Test TRACE method"}]. trace(Config) when is_list(Config) -> - Cb = ?config(version_cb, Config), - Cb:trace(?config(type, Config), ?config(port, Config), - ?config(host, Config), ?config(node, Config)). + Cb = proplists:get_value(version_cb, Config), + Cb:trace(proplists:get_value(type, Config), proplists:get_value(port, Config), + proplists:get_value(host, Config), proplists:get_value(node, Config)). %%------------------------------------------------------------------------- light() -> ["Test light load"]. light(Config) when is_list(Config) -> - httpd_load:load_test(?config(type, Config), ?config(port, Config), ?config(host, Config), - ?config(node, Config), 10). + httpd_load:load_test(proplists:get_value(type, Config), proplists:get_value(port, Config), proplists:get_value(host, Config), + proplists:get_value(node, Config), 10). %%------------------------------------------------------------------------- medium() -> ["Test medium load"]. medium(Config) when is_list(Config) -> - httpd_load:load_test(?config(type, Config), ?config(port, Config), ?config(host, Config), - ?config(node, Config), 100). + httpd_load:load_test(proplists:get_value(type, Config), proplists:get_value(port, Config), proplists:get_value(host, Config), + proplists:get_value(node, Config), 100). %%------------------------------------------------------------------------- heavy() -> ["Test heavy load"]. heavy(Config) when is_list(Config) -> - httpd_load:load_test(?config(type, Config), ?config(port, Config), ?config(host, Config), - ?config(node, Config), + httpd_load:load_test(proplists:get_value(type, Config), proplists:get_value(port, Config), proplists:get_value(host, Config), + proplists:get_value(node, Config), 1000). %%------------------------------------------------------------------------- content_length() -> ["Tests that content-length is correct OTP-5775"]. content_length(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), ?config(node, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), proplists:get_value(node, Config), http_request("GET /cgi-bin/erl/httpd_example:get_bin ", Version, Host), [{statuscode, 200}, @@ -975,10 +980,10 @@ content_length(Config) -> bad_hex() -> ["Tests that a URI with a bad hexadecimal code is handled OTP-6003"]. bad_hex(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), ?config(node, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), proplists:get_value(node, Config), http_request("GET http://www.erlang.org/%skalle ", Version, Host), [{statuscode, 400}, @@ -987,10 +992,10 @@ bad_hex(Config) -> missing_CR() -> ["Tests missing CR in delimiter OTP-7304"]. missing_CR(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), ?config(node, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), proplists:get_value(node, Config), http_request_missing_CR("GET /index.html ", Version, Host), [{statuscode, 200}, {version, Version}]). @@ -1001,12 +1006,12 @@ customize() -> customize(Config) when is_list(Config) -> Version = "HTTP/1.1", - Host = ?config(host, Config), - Type = ?config(type, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), http_request("GET /index.html ", Version, Host), [{statuscode, 200}, {header, "Content-Type", "text/html"}, @@ -1019,12 +1024,12 @@ add_default() -> add_default(Config) when is_list(Config) -> Version = "HTTP/1.1", - Host = ?config(host, Config), - Type = ?config(type, Config), - ok = httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + ok = httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), http_request("GET /index.html ", Version, Host), [{statuscode, 200}, {header, "Content-Type", "text/html"}, @@ -1036,24 +1041,24 @@ add_default(Config) when is_list(Config) -> max_header() -> ["Denial Of Service (DOS) attack, prevented by max_header"]. max_header(Config) when is_list(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), case Version of "HTTP/0.9" -> {skip, not_implemented}; _ -> - dos_hostname(?config(type, Config), ?config(port, Config), Host, - ?config(node, Config), Version, ?MAX_HEADER_SIZE) + dos_hostname(proplists:get_value(type, Config), proplists:get_value(port, Config), Host, + proplists:get_value(node, Config), Version, ?MAX_HEADER_SIZE) end. %%------------------------------------------------------------------------- max_content_length() -> ["Denial Of Service (DOS) attack, prevented by max_content_length"]. max_content_length(Config) when is_list(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - garbage_content_length(?config(type, Config), ?config(port, Config), Host, - ?config(node, Config), Version). + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + garbage_content_length(proplists:get_value(type, Config), proplists:get_value(port, Config), Host, + proplists:get_value(node, Config), Version). %%------------------------------------------------------------------------- security_1_1(Config) when is_list(Config) -> @@ -1065,15 +1070,15 @@ security_1_0(Config) when is_list(Config) -> security() -> ["Test mod_security"]. security(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Node = ?config(node, Config), - ServerRoot = ?config(server_root, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Node = proplists:get_value(node, Config), + ServerRoot = proplists:get_value(server_root, Config), global:register_name(mod_security_test, self()), % Receive events - test_server:sleep(5000), + ct:sleep(5000), OpenDir = filename:join([ServerRoot, "htdocs", "open"]), @@ -1171,7 +1176,7 @@ security(Config) -> ["one"] = list_auth_users(Node, Port, OpenDir), %% Wait for successful auth to timeout. - test_server:sleep(?AUTH_TIMEOUT*1001), + ct:sleep(?AUTH_TIMEOUT*1001), [] = list_auth_users(Node, Port), @@ -1200,11 +1205,11 @@ disturbing_reconfiger_dies(Config) when is_list(Config) -> do_reconfiger_dies([{http_version, "HTTP/1.1"} | Config], disturbing). do_reconfiger_dies(Config, DisturbingType) -> - Server = ?config(server_pid, Config), - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Type = ?config(type, Config), + Server = proplists:get_value(server_pid, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Type = proplists:get_value(type, Config), HttpdConfig = httpd:info(Server), BlockRequest = http_request("GET /eval?httpd_example:delay(2000) ", Version, Host), @@ -1235,11 +1240,11 @@ disturbing_0_9(Config) when is_list(Config) -> disturbing([{http_version, "HTTP/0.9"} | Config]). disturbing(Config) when is_list(Config)-> - Server = ?config(server_pid, Config), - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Type = ?config(type, Config), + Server = proplists:get_value(server_pid, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Type = proplists:get_value(type, Config), HttpdConfig = httpd:info(Server), BlockRequest = http_request("GET /eval?httpd_example:delay(2000) ", Version, Host), {ok, Socket} = inets_test_lib:connect_bin(Type, Host, Port, transport_opts(Type, Config)), @@ -1267,11 +1272,11 @@ non_disturbing_0_9(Config) when is_list(Config) -> non_disturbing([{http_version, "HTTP/0.9"} | Config]). non_disturbing(Config) when is_list(Config)-> - Server = ?config(server_pid, Config), - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Type = ?config(type, Config), + Server = proplists:get_value(server_pid, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Type = proplists:get_value(type, Config), HttpdConfig = httpd:info(Server), BlockRequest = http_request("GET /eval?httpd_example:delay(2000) ", Version, Host), @@ -1296,15 +1301,15 @@ non_disturbing(Config) when is_list(Config)-> %% Internal functions ----------------------------------- %%-------------------------------------------------------------------- url(http, End, Config) -> - Port = ?config(port, Config), + Port = proplists:get_value(port, Config), {ok,Host} = inet:gethostname(), ?URL_START ++ Host ++ ":" ++ integer_to_list(Port) ++ End. do_max_clients(Config) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Port = ?config(port, Config), - Type = ?config(type, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + Type = proplists:get_value(type, Config), Request = http_request("GET /index.html ", Version, Host), BlockRequest = http_request("GET /eval?httpd_example:delay(2000) ", Version, Host), @@ -1314,7 +1319,7 @@ do_max_clients(Config) -> ok = httpd_test_lib:verify_request(Type, Host, Port, transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), Request, [{statuscode, 503}, {version, Version}]), @@ -1327,7 +1332,7 @@ do_max_clients(Config) -> ok = httpd_test_lib:verify_request(Type, Host, Port, transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), Request, [{statuscode, 200}, {version, Version}]). @@ -1406,7 +1411,7 @@ server_start(_, HttpdConfig) -> {Pid, proplists:get_value(port, Info)}. init_ssl(Group, Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), CaKey = {_Trusted,_} = erl_make_certs:make_cert([{key, dsa}, {subject, @@ -1457,54 +1462,54 @@ server_config(https_custom, Config) -> server_config(https_limit, Config) -> [{max_clients, 1}] ++ server_config(https, Config); server_config(http_basic_auth, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_conf(ServerRoot) ++ server_config(http, Config); server_config(https_basic_auth, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_conf(ServerRoot) ++ server_config(https, Config); server_config(http_auth_api, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, plain) ++ server_config(http, Config); server_config(https_auth_api, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, plain) ++ server_config(https, Config); server_config(http_auth_api_dets, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, dets) ++ server_config(http, Config); server_config(https_auth_api_dets, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, dets) ++ server_config(https, Config); server_config(http_auth_api_mnesia, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, mnesia) ++ server_config(http, Config); server_config(https_auth_api_mnesia, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), auth_api_conf(ServerRoot, mnesia) ++ server_config(https, Config); server_config(http_htaccess, Config) -> auth_access_conf() ++ server_config(http, Config); server_config(https_htaccess, Config) -> auth_access_conf() ++ server_config(https, Config); server_config(http_security, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), tl(auth_conf(ServerRoot)) ++ security_conf(ServerRoot) ++ server_config(http, Config); server_config(https_security, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), tl(auth_conf(ServerRoot)) ++ security_conf(ServerRoot) ++ server_config(https, Config); server_config(http_mime_types, Config0) -> Config1 = basic_conf() ++ server_config(http, Config0), - ServerRoot = ?config(server_root, Config0), + ServerRoot = proplists:get_value(server_root, Config0), MimeTypesFile = filename:join([ServerRoot,"config", "mime.types"]), [{mime_types, MimeTypesFile} | proplists:delete(mime_types, Config1)]; server_config(http, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), [{port, 0}, {socket_type, {ip_comm, [{nodelay, true}]}}, {server_name,"httpd_test"}, {server_root, ServerRoot}, - {document_root, ?config(doc_root, Config)}, + {document_root, proplists:get_value(doc_root, Config)}, {bind_address, any}, - {ipfamily, ?config(ipfamily, Config)}, + {ipfamily, proplists:get_value(ipfamily, Config)}, {max_header_size, 256}, {max_header_action, close}, {directory_index, ["index.html", "welcome.html"]}, @@ -1519,7 +1524,7 @@ server_config(http, Config) -> ]; server_config(https, Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), [{socket_type, {essl, [{nodelay, true}, {cacertfile, @@ -1693,35 +1698,35 @@ mod_security_conf(SecFile, Dir) -> http_status(Request, Config, Expected) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Type = ?config(type, Config), - httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), http_request(Request, Version, Host), Expected ++ [{version, Version}]). http_status(Request, HeadersAndBody, Config, Expected) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Type = ?config(type, Config), - httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), http_request(Request, Version, Host, HeadersAndBody), Expected ++ [{version, Version}]). auth_status(AuthRequest, Config, Expected) -> - Version = ?config(http_version, Config), - Host = ?config(host, Config), - Type = ?config(type, Config), - httpd_test_lib:verify_request(?config(type, Config), Host, - ?config(port, Config), + Version = proplists:get_value(http_version, Config), + Host = proplists:get_value(host, Config), + Type = proplists:get_value(type, Config), + httpd_test_lib:verify_request(proplists:get_value(type, Config), Host, + proplists:get_value(port, Config), transport_opts(Type, Config), - ?config(node, Config), + proplists:get_value(node, Config), AuthRequest, Expected ++ [{version, Version}]). @@ -1773,11 +1778,11 @@ cleanup_mnesia() -> ok. transport_opts(ssl, Config) -> - PrivDir = ?config(priv_dir, Config), - [?config(ipfamily, Config), + PrivDir = proplists:get_value(priv_dir, Config), + [proplists:get_value(ipfamily, Config), {cacertfile, filename:join(PrivDir, "public_key_cacert.pem")}]; transport_opts(_, Config) -> - [?config(ipfamily, Config)]. + [proplists:get_value(ipfamily, Config)]. %%% mod_range @@ -2076,4 +2081,4 @@ peer(Config) -> "true"; _ -> "false" - end.
\ No newline at end of file + end. diff --git a/lib/inets/test/httpd_basic_SUITE.erl b/lib/inets/test/httpd_basic_SUITE.erl index 352ff3b1ae..f413248092 100644 --- a/lib/inets/test/httpd_basic_SUITE.erl +++ b/lib/inets/test/httpd_basic_SUITE.erl @@ -30,7 +30,8 @@ -define(URL_START, "http://localhost:"). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> [{ct_hooks,[ts_install_cth]}, + {timetrap, {seconds, 30}}]. all() -> [uri_too_long_414, @@ -66,8 +67,8 @@ end_per_group(_GroupName, Config) -> init_per_suite(Config) -> inets_test_lib:stop_apps([inets]), inets_test_lib:start_apps([inets]), - PrivDir = ?config(priv_dir, Config), - DataDir = ?config(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), Dummy = "<HTML> @@ -152,7 +153,7 @@ end_per_testcase(_Case, Config) -> uri_too_long_414() -> [{doc, "Test that too long uri's get 414 HTTP code"}]. uri_too_long_414(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{max_uri_size, 10} | HttpdConf]), Info = httpd:info(Pid), @@ -173,7 +174,7 @@ uri_too_long_414(Config) when is_list(Config) -> header_too_long_413() -> [{doc,"Test that too long headers's get 413 HTTP code"}]. header_too_long_413(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{max_header_size, 10} | HttpdConf]), Info = httpd:info(Pid), @@ -192,7 +193,7 @@ header_too_long_413(Config) when is_list(Config) -> entity_too_long() -> [{doc, "Test that too long versions and method strings are rejected"}]. entity_too_long(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, HttpdConf), Info = httpd:info(Pid), Port = proplists:get_value(port, Info), @@ -259,7 +260,7 @@ erl_script_nocache_opt(doc) -> erl_script_nocache_opt(suite) -> []; erl_script_nocache_opt(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{port, 0}, {erl_script_nocache, true} | HttpdConf]), Info = httpd:info(Pid), Port = proplists:get_value(port, Info), @@ -282,7 +283,7 @@ erl_script_nocache_opt(Config) when is_list(Config) -> escaped_url_in_error_body() -> [{doc, "Test Url-encoding see OTP-8940"}]. escaped_url_in_error_body(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{port, 0} | HttpdConf]), Info = httpd:info(Pid), Port = proplists:get_value(port, Info), @@ -324,7 +325,7 @@ keep_alive_timeout(doc) -> keep_alive_timeout(suite) -> []; keep_alive_timeout(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{port, 0}, {keep_alive, true}, {keep_alive_timeout, 2} | HttpdConf]), Info = httpd:info(Pid), Port = proplists:get_value(port, Info), @@ -348,9 +349,9 @@ script_timeout(Config) when is_list(Config) -> ok. verify_script_timeout(Config, ScriptTimeout, StatusCode) -> - HttpdConf = ?config(httpd_conf, Config), - CgiScript = ?config(cgi_sleep, Config), - CgiDir = ?config(cgi_dir, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), + CgiScript = proplists:get_value(cgi_sleep, Config), + CgiDir = proplists:get_value(cgi_dir, Config), {ok, Pid} = inets:start(httpd, [{port, 0}, {script_alias, {"/cgi-bin/", CgiDir ++ "/"}}, @@ -371,7 +372,7 @@ verify_script_timeout(Config, ScriptTimeout, StatusCode) -> slowdose() -> [{doc, "Testing minimum bytes per second option"}]. slowdose(Config) when is_list(Config) -> - HttpdConf = ?config(httpd_conf, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), {ok, Pid} = inets:start(httpd, [{port, 0}, {minimum_bytes_per_second, 200}|HttpdConf]), Info = httpd:info(Pid), Port = proplists:get_value(port, Info), @@ -386,9 +387,9 @@ slowdose(Config) when is_list(Config) -> %%------------------------------------------------------------------------- verify_script_nocache(Config, CgiNoCache, EsiNoCache, CgiOption, EsiOption) -> - HttpdConf = ?config(httpd_conf, Config), - CgiScript = ?config(cgi_printenv, Config), - CgiDir = ?config(cgi_dir, Config), + HttpdConf = proplists:get_value(httpd_conf, Config), + CgiScript = proplists:get_value(cgi_printenv, Config), + CgiDir = proplists:get_value(cgi_dir, Config), {ok, Pid} = inets:start(httpd, [{port, 0}, {script_alias, {"/cgi-bin/", CgiDir ++ "/"}}, diff --git a/lib/inets/test/httpd_block.erl b/lib/inets/test/httpd_block.erl index 44f6f644ad..45547e6d4e 100644 --- a/lib/inets/test/httpd_block.erl +++ b/lib/inets/test/httpd_block.erl @@ -133,7 +133,7 @@ block_disturbing_active_timeout_released(Type, Port, Host, Node) -> block_non_disturbing_active_timeout_not_released(Type, Port, Host, Node) -> process_flag(trap_exit, true), Poller = long_poll(Type, Host, Port, Node, 200, 60000), - test_server:sleep(5000), + ct:sleep(5000), ok = block_nd_server(Node, Host, Port, 40000), await_normal_process_exit(Poller, "poller", 60000), blocked = get_admin_state(Node, Host, Port), diff --git a/lib/inets/test/httpd_load.erl b/lib/inets/test/httpd_load.erl index 37ebc4fc90..7f4d16139f 100644 --- a/lib/inets/test/httpd_load.erl +++ b/lib/inets/test/httpd_load.erl @@ -63,7 +63,7 @@ load_test(Fun, URIs, Type, Host, Port, Node, 0, List) -> {'EXIT', Pid, Reason} -> Str = lists:flatten(io_lib:format("client ~p exited: ~p", [Pid,Reason])), - test_server:fail(Str); + ct:fail(Str); _ -> load_test(Fun, URIs, Type, Host, Port, Node, 0, List) end; @@ -86,12 +86,11 @@ load_test_client(Fun, [URI|URIs], Type, Host, Port, Node, Boss, Timeout) -> {'EXIT', {suite_failed, connection_closed, _, _}} -> %% Some platforms seems to handle heavy load badly. %% So, back off and see if this helps - %%?LOG("load_test_client->requestfailed:connection_closed"[]), 2 * Timeout; _ -> Timeout end, - test_server:sleep(Timeout1), + ct:sleep(Timeout1), load_test_client(Fun, URIs, Type, Host, Port, Node, Boss, Timeout1). load_test_client_done(Boss) -> diff --git a/lib/inets/test/httpd_mod.erl b/lib/inets/test/httpd_mod.erl index 7a1250cb29..d9118aa1a4 100644 --- a/lib/inets/test/httpd_mod.erl +++ b/lib/inets/test/httpd_mod.erl @@ -86,240 +86,116 @@ actions(Type, Port, Host, Node) -> security(ServerRoot, Type, Port, Host, Node) -> global:register_name(mod_security_test, self()), % Receive events - - tsp("security -> " - "sleep"), - test_server:sleep(5000), + + ct:sleep(5000), OpenDir = filename:join([ServerRoot, "htdocs", "open"]), %% Test blocking / unblocking of users. %% /open, require user one Aladdin - tsp("security -> " - "blocking and unblocking of users - " - "remove all existing users"), + remove_users(Node, ServerRoot, Host, Port, "open"), - tsp("security -> " - "blocking and unblocking of users - " - "auth request for nonex user 'one' - expect 401"), auth_request(Type, Host, Port, Node, "/open/", "one", "onePassword", [{statuscode, 401}]), - tsp("security -> " - "blocking and unblocking of users - " - "await fail security event"), receive_security_event({event, auth_fail, Port, OpenDir, [{user, "one"}, {password, "onePassword"}]}, Node, Port), - tsp("security -> " - "blocking and unblocking of users - " - "auth request for nonex user 'two' - expect 401"), auth_request(Type,Host,Port,Node,"/open/", "two", "twoPassword", [{statuscode, 401}]), - tsp("security -> " - "blocking and unblocking of users - " - "await fail security event"), receive_security_event({event, auth_fail, Port, OpenDir, [{user, "two"}, {password, "twoPassword"}]}, Node, Port), - - tsp("security -> " - "blocking and unblocking of users - " - "auth request for nonex user 'Alladin' - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "Aladdin", "AladdinPassword", [{statuscode, 401}]), - tsp("security -> " - "blocking and unblocking of users - " - "await fail security event"), receive_security_event({event, auth_fail, Port, OpenDir, [{user, "Aladdin"}, {password, "AladdinPassword"}]}, Node, Port), - - tsp("security -> " - "blocking and unblocking of users - " - "add user 'one'"), add_user(Node, ServerRoot, Port, "open", "one", "onePassword", []), - tsp("security -> " - "blocking and unblocking of users - " - "add user 'two'"), add_user(Node, ServerRoot, Port, "open", "two", "twoPassword", []), - tsp("security -> " - "blocking and unblocking of users - " - "auth request 1 for user 'one' with wrong password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", [{statuscode, 401}]), - - tsp("security -> " - "blocking and unblocking of users - " - "await fail security event"), receive_security_event({event, auth_fail, Port, OpenDir, [{user, "one"}, {password, "WrongPassword"}]}, Node, Port), - - tsp("security -> " - "blocking and unblocking of users - " - "auth request 2 for user 'one' with wrong password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", [{statuscode, 401}]), - tsp("security -> " - "blocking and unblocking of users - " - "await fail security event"), receive_security_event({event, auth_fail, Port, OpenDir, [{user, "one"}, {password, "WrongPassword"}]}, Node, Port), - - tsp("security -> " - "blocking and unblocking of users - " - "await block security event (two failed attempts)"), - receive_security_event({event, user_block, Port, OpenDir, + receive_security_event({event, user_block, Port, OpenDir, [{user, "one"}]}, Node, Port), - tsp("security -> " - "blocking and unblocking of users - " - "unregister - no more security events"), global:unregister_name(mod_security_test), % No more events. - tsp("security -> " - "blocking and unblocking of users - " - "auth request for user 'one' with wrong password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", [{statuscode, 401}]), - tsp("security -> " - "blocking and unblocking of users - " - "auth request for user 'one' with correct password - expect 403"), auth_request(Type, Host, Port, Node,"/open/", "one", "onePassword", [{statuscode, 403}]), %% User "one" should be blocked now.. - tsp("security -> " - "blocking and unblocking of users - " - "list blocked users - 'one' should be the only one"), case list_blocked_users(Node, Port) of [{"one",_, Port, OpenDir,_}] -> ok; Blocked -> - tsp(" *** unexpected blocked users ***" - "~n Blocked: ~p", [Blocked]), exit({unexpected_blocked, Blocked}) end, - tsp("security -> " - "blocking and unblocking of users - " - "list users blocked for dir '~p' - " - "user 'one' should be the only one", [OpenDir]), [{"one",_, Port, OpenDir,_}] = list_blocked_users(Node, Port, OpenDir), - tsp("security -> " - "blocking and unblocking of users - " - "unblock user 'one' for dir '~p'", [OpenDir]), true = unblock_user(Node, "one", Port, OpenDir), %% User "one" should not be blocked any more. - tsp("security -> " - "blocking and unblocking of users - " - "ensure user 'one' is no longer blocked"), [] = list_blocked_users(Node, Port), - - tsp("security -> " - "blocking and unblocking of users - " - "auth request for user 'one' with correct password - expect 200"), auth_request(Type, Host, Port, Node,"/open/", "one", "onePassword", [{statuscode, 200}]), %% Test list_auth_users & auth_timeout - - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users - expect user 'one'"), ["one"] = list_auth_users(Node, Port), - tsp("security -> " - "list-auth-users and auth-timeout - " - "auth request for user 'two' with wrong password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "two", "onePassword", [{statuscode, 401}]), - - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users - expect user 'one'"), ["one"] = list_auth_users(Node, Port), - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users for dir '~p' - expect user 'one'", [OpenDir]), ["one"] = list_auth_users(Node, Port, OpenDir), - tsp("security -> " - "list-auth-users and auth-timeout - " - "auth request for user 'two' with correct password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "two", "twoPassword", [{statuscode, 401}]), - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users - expect user 'one'"), ["one"] = list_auth_users(Node, Port), - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users for dir '~p' - expect user 'one'", [OpenDir]), ["one"] = list_auth_users(Node, Port, OpenDir), %% Wait for successful auth to timeout. - tsp("security -> " - "list-auth-users and auth-timeout - " - "wait for successful auth to timeout"), - test_server:sleep(?AUTH_TIMEOUT*1001), - - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users - expect none"), + ct:sleep(?AUTH_TIMEOUT*1001), + [] = list_auth_users(Node, Port), - tsp("security -> " - "list-auth-users and auth-timeout - " - "list auth users for dir '~p'~n - expect none", [OpenDir]), + [] = list_auth_users(Node, Port, OpenDir), %% "two" is blocked. - tsp("security -> " - "list-auth-users and auth-timeout - " - "unblock user 'two' for dir '~p'", [OpenDir]), true = unblock_user(Node, "two", Port, OpenDir), - - %% Test explicit blocking. Block user 'two'. - tsp("security -> " - "explicit blocking - list blocked users - should be none"), [] = list_blocked_users(Node,Port,OpenDir), - tsp("security -> " - "explicit blocking - " - "block user 'two' for dir '~p'", [OpenDir]), true = block_user(Node, "two", Port, OpenDir, 10), - - tsp("security -> " - "explicit blocking - " - "auth request for user 'two' with correct password - expect 401"), auth_request(Type, Host, Port, Node,"/open/", "two", "twoPassword", - [{statuscode, 401}]), - tsp("security -> " - "done"). - + [{statuscode, 401}]). %%------------------------------------------------------------------------- auth(Type, Port, Host, Node) -> @@ -743,7 +619,6 @@ cgi(Type, Port, Host, Node) -> end, %% The length (> 100) is intentional -%% tsp("cgi -> request 01 with length > 100"), ok = httpd_test_lib: verify_request(Type, Host, Port, Node, "POST /cgi-bin/" ++ Script3 ++ @@ -771,55 +646,51 @@ cgi(Type, Port, Host, Node) -> {version, "HTTP/1.0"}, {header, "content-type", "text/plain"}]), -%% tsp("cgi -> request 02"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /cgi-bin/"++ Script ++ " HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 03"), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /cgi-bin/not_there " "HTTP/1.0\r\n\r\n", [{statuscode, 404},{statuscode, 500}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 04"), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /cgi-bin/"++ Script ++ "?Nisse:kkk?sss/lll HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 04"), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "POST /cgi-bin/"++ Script ++ " HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 05"), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /htbin/"++ Script ++ " HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 06"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /htbin/not_there " "HTTP/1.0\r\n\r\n", [{statuscode, 404},{statuscode, 500}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 07"), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /htbin/"++ Script ++ "?Nisse:kkk?sss/lll HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 08"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "POST /htbin/"++ Script ++ " HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 09"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "POST /htbin/"++ Script ++ " HTTP/1.0\r\n\r\n", @@ -827,31 +698,25 @@ cgi(Type, Port, Host, Node) -> {version, "HTTP/1.0"}]), %% Execute an existing, but bad CGI script.. -%% tsp("cgi -> request 10 - bad script"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "POST /htbin/"++ Script2 ++ " HTTP/1.0\r\n\r\n", [{statuscode, 404}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> request 11 - bad script"), ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "POST /cgi-bin/"++ Script2 ++ " HTTP/1.0\r\n\r\n", [{statuscode, 404}, {version, "HTTP/1.0"}]), -%% tsp("cgi -> done"), - %% Check "ScriptNoCache" directive (default: false) ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /cgi-bin/" ++ Script ++ " HTTP/1.0\r\n\r\n", [{statuscode, 200}, {no_header, "cache-control"}, - {version, "HTTP/1.0"}]), - ok. - + {version, "HTTP/1.0"}]). %%-------------------------------------------------------------------- esi(Type, Port, Host, Node) -> @@ -1018,18 +883,15 @@ list_users(Node, Root, _Host, Port, Dir) -> receive_security_event(Event, Node, Port) -> - tsp("receive_security_event -> await ~w event", [element(2, Event)]), receive Event -> - tsp("receive_security_event -> " - "received expected ~w event", [element(2, Event)]), ok; {'EXIT', _, _} -> receive_security_event(Event, Node, Port) after 5000 -> %% Flush the message queue, to see if we got something... Msgs = inets_test_lib:flush(), - tsf({expected_event_not_received, Msgs}) + ct:fail({expected_event_not_received, Msgs}) end. @@ -1045,10 +907,10 @@ receive_security_event(Event, Node, Port) -> %% {'EXIT', _, _} -> %% receive_security_event(Event, Node, Port); %% Other -> -%% test_server:fail({unexpected_event, +%% ct:fail({unexpected_event, %% {expected, Event}, {received, Other}}) %% after 5000 -> -%% test_server:fail(no_event_recived) +%% ct:fail(no_event_recived) %% end. @@ -1130,17 +992,4 @@ check_lists_members1(L1,L2) -> {error,{lists_not_equal,L1,L2}}. -%% p(F) -> -%% p(F, []). - -%% p(F, A) -> -%% io:format(user, "~w:" ++ F ++ "~n", [?MODULE|A]). - -tsp(F) -> - inets_test_lib:tsp(F). -tsp(F, A) -> - inets_test_lib:tsp(F, A). - -tsf(Reason) -> - test_server:fail(Reason). diff --git a/lib/inets/test/httpd_time_test.erl b/lib/inets/test/httpd_time_test.erl index fddc0003cd..e858ddf4f6 100644 --- a/lib/inets/test/httpd_time_test.erl +++ b/lib/inets/test/httpd_time_test.erl @@ -117,7 +117,7 @@ main(N, SocketType, Host, Port, Time) loop(Pollers, Timeout) -> d("loop -> entry when" "~n Timeout: ~p", [Timeout]), - Start = inets_time_compat:monotonic_time(), + Start = erlang:monotonic_time(), receive {'EXIT', Pid, {poller_stat_failure, SocketType, Host, Port, Time, Reason}} -> diff --git a/lib/inets/test/inets_SUITE.erl b/lib/inets/test/inets_SUITE.erl index 928d9dc391..5eaf3a28a0 100644 --- a/lib/inets/test/inets_SUITE.erl +++ b/lib/inets/test/inets_SUITE.erl @@ -28,10 +28,13 @@ -define(NUM_DEFAULT_SERVICES, 1). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds,5}} + ]. all() -> - [{group, app_test}, {group, appup_test}, + [{group, app_test}, {group, services_test}, httpd_reload]. groups() -> @@ -42,8 +45,7 @@ groups() -> start_ftpc, start_tftpd ]}, - {app_test, [], [{inets_app_test, all}]}, - {appup_test, [], [{inets_appup_test, all}]}]. + {app_test, [], [app, appup]}]. init_per_group(_GroupName, Config) -> Config. @@ -84,6 +86,10 @@ end_per_suite(_Config) -> %% Note: This function is free to add any key/value pairs to the Config %% variable, but should NOT alter/remove any existing entries. %%-------------------------------------------------------------------- +init_per_testcase(httpd_reload, Config) -> + inets:stop(), + ct:timetrap({seconds, 40}), + Config; init_per_testcase(_Case, Config) -> inets:stop(), Config. @@ -102,6 +108,15 @@ end_per_testcase(_, Config) -> %%------------------------------------------------------------------------- %% Test cases starts here. %%------------------------------------------------------------------------- +app() -> + [{doc, "Test that the inets app file is ok"}]. +app(Config) when is_list(Config) -> + ok = ?t:app_test(inets). +%%-------------------------------------------------------------------- +appup() -> + [{doc, "Test that the inets appup file is ok"}]. +appup(Config) when is_list(Config) -> + ok = ?t:appup_test(inets). start_inets() -> [{doc, "Test inets API functions"}]. @@ -134,7 +149,7 @@ start_httpc() -> [{doc, "Start/stop of httpc service"}]. start_httpc(Config) when is_list(Config) -> process_flag(trap_exit, true), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ok = inets:start(), {ok, Pid0} = inets:start(httpc, [{profile, foo}]), @@ -145,7 +160,7 @@ start_httpc(Config) when is_list(Config) -> inets:stop(httpc, Pid0), - test_server:sleep(100), + ct:sleep(100), Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], false = lists:member(Pid0, Pids1), @@ -188,7 +203,7 @@ start_httpd() -> [{doc, "Start/stop of httpd service"}]. start_httpd(Config) when is_list(Config) -> process_flag(trap_exit, true), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), HttpdConf = [{server_name, "httpd_test"}, {server_root, PrivDir}, {document_root, PrivDir}, {bind_address, any}], @@ -199,7 +214,7 @@ start_httpd(Config) when is_list(Config) -> [_|_] = inets:services_info(), inets:stop(httpd, Pid0), - test_server:sleep(500), + ct:sleep(500), Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], false = lists:member(Pid0, Pids1), {ok, Pid1} = @@ -212,7 +227,7 @@ start_httpd(Config) when is_list(Config) -> {'EXIT', Pid1, shutdown} -> ok after 100 -> - test_server:fail(stand_alone_not_shutdown) + ct:fail(stand_alone_not_shutdown) end, ok = inets:stop(), File0 = filename:join(PrivDir, "httpd.conf"), @@ -279,44 +294,38 @@ start_httpd(Config) when is_list(Config) -> start_ftpc(doc) -> [{doc, "Start/stop of ftpc service"}]; -start_ftpc(Config) when is_list(Config) -> +start_ftpc(Config0) when is_list(Config0) -> process_flag(trap_exit, true), ok = inets:start(), - try - begin - {_Tag, FtpdHost} = ftp_suite_lib:dirty_select_ftpd_host(Config), - case inets:start(ftpc, [{host, FtpdHost}]) of - {ok, Pid0} -> - Pids0 = [ServicePid || {_, ServicePid} <- - inets:services()], - true = lists:member(Pid0, Pids0), - [_|_] = inets:services_info(), - inets:stop(ftpc, Pid0), - test_server:sleep(100), - Pids1 = [ServicePid || {_, ServicePid} <- - inets:services()], - false = lists:member(Pid0, Pids1), - {ok, Pid1} = - inets:start(ftpc, [{host, FtpdHost}], stand_alone), - Pids2 = [ServicePid || {_, ServicePid} <- - inets:services()], - false = lists:member(Pid1, Pids2), - ok = inets:stop(stand_alone, Pid1), - receive - {'EXIT', Pid1, shutdown} -> - ok - after 100 -> - ct:fail(stand_alone_not_shutdown) - end, - ok = inets:stop(), - ok; - _ -> - {skip, "Unable to reach selected FTP server " ++ FtpdHost} - end - end - catch - throw:{error, not_found} -> - {skip, "No available FTP servers"} + case ftp_SUITE:init_per_suite(Config0) of + {skip, _} = Skip -> + Skip; + Config -> + FtpdHost = proplists:get_value(ftpd_host,Config), + {ok, Pid0} = inets:start(ftpc, [{host, FtpdHost}]), + Pids0 = [ServicePid || {_, ServicePid} <- + inets:services()], + true = lists:member(Pid0, Pids0), + [_|_] = inets:services_info(), + inets:stop(ftpc, Pid0), + ct:sleep(100), + Pids1 = [ServicePid || {_, ServicePid} <- + inets:services()], + false = lists:member(Pid0, Pids1), + {ok, Pid1} = + inets:start(ftpc, [{host, FtpdHost}], stand_alone), + Pids2 = [ServicePid || {_, ServicePid} <- + inets:services()], + false = lists:member(Pid1, Pids2), + ok = inets:stop(stand_alone, Pid1), + receive + {'EXIT', Pid1, shutdown} -> + ok + after 100 -> + ct:fail(stand_alone_not_shutdown) + end, + ok = inets:stop(), + catch ftp_SUITE:end_per_SUITE(Config) end. %%------------------------------------------------------------------------- @@ -331,7 +340,7 @@ start_tftpd(Config) when is_list(Config) -> true = lists:member(Pid0, Pids0), [_|_] = inets:services_info(), inets:stop(tftpd, Pid0), - test_server:sleep(100), + ct:sleep(100), Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], false = lists:member(Pid0, Pids1), {ok, Pid1} = @@ -343,7 +352,7 @@ start_tftpd(Config) when is_list(Config) -> {'EXIT', Pid1, shutdown} -> ok after 100 -> - test_server:fail(stand_alone_not_shutdown) + ct:fail(stand_alone_not_shutdown) end, ok = inets:stop(), application:load(inets), @@ -360,34 +369,34 @@ httpd_reload() -> [{doc, "Reload httpd configuration without restarting service"}]. httpd_reload(Config) when is_list(Config) -> process_flag(trap_exit, true), - PrivDir = ?config(priv_dir, Config), - DataDir = ?config(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), HttpdConf = [{server_name, "httpd_test"}, {server_root, PrivDir}, {document_root, PrivDir}, {bind_address, "localhost"}], ok = inets:start(), - test_server:sleep(5000), + ct:sleep(5000), {ok, Pid0} = inets:start(httpd, [{port, 0}, {ipfamily, inet} | HttpdConf]), - test_server:sleep(5000), + ct:sleep(5000), [{port, Port0}] = httpd:info(Pid0, [port]), - test_server:sleep(5000), + ct:sleep(5000), [{document_root, PrivDir}] = httpd:info(Pid0, [document_root]), - test_server:sleep(5000), + ct:sleep(5000), ok = httpd:reload_config([{port, Port0}, {ipfamily, inet}, {server_name, "httpd_test"}, {server_root, PrivDir}, {document_root, DataDir}, {bind_address, "localhost"}], non_disturbing), - test_server:sleep(5000), + ct:sleep(5000), [{document_root, DataDir}] = httpd:info(Pid0, [document_root]), - test_server:sleep(5000), + ct:sleep(5000), ok = httpd:reload_config([{port, Port0}, {ipfamily, inet}, {server_name, "httpd_test"}, diff --git a/lib/inets/test/inets_app_test.erl b/lib/inets/test/inets_app_test.erl deleted file mode 100644 index c6d0715e1f..0000000000 --- a/lib/inets/test/inets_app_test.erl +++ /dev/null @@ -1,245 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-2015. 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% -%% -%% -%%---------------------------------------------------------------------- -%% Purpose: Verify the application specifics of the inets application -%%---------------------------------------------------------------------- --module(inets_app_test). - --compile(export_all). - --include("inets_test_lib.hrl"). - - -% t() -> megaco_test_lib:t(?MODULE). -% t(Case) -> megaco_test_lib:t({?MODULE, Case}). - - -%% Test server callbacks -init_per_testcase(_, Config) -> - Config. - -end_per_testcase(_Case, Config) -> - Config. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -all() -> - [fields, modules, exportall, app_depend]. - -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -init_per_suite(suite) -> []; -init_per_suite(doc) -> []; -init_per_suite(Config) when is_list(Config) -> - case is_app(inets) of - {ok, AppFile} -> - io:format("AppFile: ~n~p~n", [AppFile]), - inets:print_version_info(), - [{app_file, AppFile}|Config]; - {error, Reason} -> - fail(Reason) - end. - -is_app(App) -> - LibDir = code:lib_dir(App), - File = filename:join([LibDir, "ebin", atom_to_list(App) ++ ".app"]), - case file:consult(File) of - {ok, [{application, App, AppFile}]} -> - {ok, AppFile}; - Error -> - {error, {invalid_format, Error}} - end. - - -end_per_suite(suite) -> []; -end_per_suite(doc) -> []; -end_per_suite(Config) when is_list(Config) -> - Config. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -fields(suite) -> - []; -fields(doc) -> - []; -fields(Config) when is_list(Config) -> - AppFile = key1search(app_file, Config), - Fields = [vsn, description, modules, registered, applications], - case check_fields(Fields, AppFile, []) of - [] -> - ok; - Missing -> - fail({missing_fields, Missing}) - end. - -check_fields([], _AppFile, Missing) -> - Missing; -check_fields([Field|Fields], AppFile, Missing) -> - check_fields(Fields, AppFile, check_field(Field, AppFile, Missing)). - -check_field(Name, AppFile, Missing) -> - io:format("checking field: ~p~n", [Name]), - case lists:keymember(Name, 1, AppFile) of - true -> - Missing; - false -> - [Name|Missing] - end. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -modules(suite) -> - []; -modules(doc) -> - []; -modules(Config) when is_list(Config) -> - AppFile = key1search(app_file, Config), - Mods = key1search(modules, AppFile), - EbinList = get_ebin_mods(inets), - case missing_modules(Mods, EbinList, []) of - [] -> - ok; - Missing -> - throw({error, {missing_modules, Missing}}) - end, - case extra_modules(Mods, EbinList, []) of - [] -> - ok; - Extra -> - throw({error, {extra_modules, Extra}}) - end, - {ok, Mods}. - -get_ebin_mods(App) -> - LibDir = code:lib_dir(App), - EbinDir = filename:join([LibDir,"ebin"]), - {ok, Files0} = file:list_dir(EbinDir), - Files1 = [lists:reverse(File) || File <- Files0], - [list_to_atom(lists:reverse(Name)) || [$m,$a,$e,$b,$.|Name] <- Files1]. - - -missing_modules([], _Ebins, Missing) -> - Missing; -missing_modules([Mod|Mods], Ebins, Missing) -> - case lists:member(Mod, Ebins) of - true -> - missing_modules(Mods, Ebins, Missing); - false -> - io:format("missing module: ~p~n", [Mod]), - missing_modules(Mods, Ebins, [Mod|Missing]) - end. - - -extra_modules(_Mods, [], Extra) -> - Extra; -extra_modules(Mods, [Mod|Ebins], Extra) -> - case lists:member(Mod, Mods) of - true -> - extra_modules(Mods, Ebins, Extra); - false -> - io:format("supefluous module: ~p~n", [Mod]), - extra_modules(Mods, Ebins, [Mod|Extra]) - end. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -exportall(suite) -> - []; -exportall(doc) -> - []; -exportall(Config) when is_list(Config) -> - AppFile = key1search(app_file, Config), - Mods = key1search(modules, AppFile), - check_export_all(Mods). - - -check_export_all([]) -> - ok; -check_export_all([Mod|Mods]) -> - case (catch apply(Mod, module_info, [compile])) of - {'EXIT', {undef, _}} -> - check_export_all(Mods); - O -> - case lists:keysearch(options, 1, O) of - false -> - check_export_all(Mods); - {value, {options, List}} -> - case lists:member(export_all, List) of - true -> - throw({error, {export_all, Mod}}); - false -> - check_export_all(Mods) - end - end - end. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -app_depend(suite) -> - []; -app_depend(doc) -> - []; -app_depend(Config) when is_list(Config) -> - AppFile = key1search(app_file, Config), - Apps = key1search(applications, AppFile), - check_apps(Apps). - - -check_apps([]) -> - ok; -check_apps([App|Apps]) -> - case is_app(App) of - {ok, _} -> - check_apps(Apps); - Error -> - throw({error, {missing_app, {App, Error}}}) - end. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -fail(Reason) -> - exit({suite_failed, Reason}). - -key1search(Key, L) -> - case lists:keysearch(Key, 1, L) of - undefined -> - fail({not_found, Key, L}); - {value, {Key, Value}} -> - Value - end. diff --git a/lib/inets/test/inets_appup_test.erl b/lib/inets/test/inets_appup_test.erl deleted file mode 100644 index b76cd59141..0000000000 --- a/lib/inets/test/inets_appup_test.erl +++ /dev/null @@ -1,71 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-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% -%% -%% -%%---------------------------------------------------------------------- -%% Purpose: Verify the application specifics of the Inets application -%%---------------------------------------------------------------------- --module(inets_appup_test). - --compile(export_all). --include_lib("common_test/include/ct.hrl"). - - -%% Test server callbacks -init_per_testcase(_Case, Config) -> - Config. - -end_per_testcase(_Case, Config) -> - Config. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -all() -> - [appup]. - -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -init_per_suite(suite) -> []; -init_per_suite(doc) -> []; -init_per_suite(Config) when is_list(Config) -> - Config. - - -end_per_suite(suite) -> []; -end_per_suite(doc) -> []; -end_per_suite(Config) when is_list(Config) -> - Config. - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -appup() -> - [{doc, "Perform a simple check of the inets appup file"}]. -appup(Config) when is_list(Config) -> - ok = ?t:appup_test(inets). diff --git a/lib/inets/test/inets_socketwrap_SUITE.erl b/lib/inets/test/inets_socketwrap_SUITE.erl index cfbda3ccf5..18df995215 100644 --- a/lib/inets/test/inets_socketwrap_SUITE.erl +++ b/lib/inets/test/inets_socketwrap_SUITE.erl @@ -61,8 +61,8 @@ end_per_testcase(_, Config) -> start_httpd_fd() -> [{doc, "Start/stop of httpd service with socket wrapper"}]. start_httpd_fd(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), - DataDir = ?config(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), HttpdConf = [{port, 80}, {ipfamily, inet}, {server_name, "httpd_fd_test"}, {server_root, PrivDir}, {document_root, PrivDir}, {bind_address, any}], @@ -94,7 +94,7 @@ start_httpd_fd(Config) when is_list(Config) -> start_tftpd_fd() -> [{doc, "Start/stop of tfpd service with socket wrapper"}]. start_tftpd_fd(Config) when is_list(Config) -> - DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), case setup_node_info(node()) of {skip, _} = Skip -> Skip; diff --git a/lib/inets/test/inets_sup_SUITE.erl b/lib/inets/test/inets_sup_SUITE.erl index 9836cd76e0..5b8b1463c8 100644 --- a/lib/inets/test/inets_sup_SUITE.erl +++ b/lib/inets/test/inets_sup_SUITE.erl @@ -26,7 +26,10 @@ %% Note: This directive should only be used in test suites. -compile(export_all). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds, 10}} + ]. all() -> [default_tree, ftpc_worker, tftpd_worker, @@ -50,9 +53,7 @@ end_per_suite(_) -> ok. init_per_testcase(httpd_subtree, Config) -> - Dog = test_server:timetrap(?t:minutes(1)), - NewConfig = lists:keydelete(watchdog, 1, Config), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Dir = filename:join(PrivDir, "root"), ok = file:make_dir(Dir), @@ -67,7 +68,7 @@ init_per_testcase(httpd_subtree, Config) -> inets:stop(), inets:start(), inets:start(httpd, SimpleConfig), - [{watchdog, Dog} | NewConfig] + Config catch _:Reason -> inets:stop(), @@ -75,9 +76,7 @@ init_per_testcase(httpd_subtree, Config) -> end; init_per_testcase(httpd_subtree_profile, Config) -> - Dog = test_server:timetrap(?t:minutes(1)), - NewConfig = lists:keydelete(watchdog, 1, Config), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Dir = filename:join(PrivDir, "root"), ok = file:make_dir(Dir), @@ -93,7 +92,7 @@ init_per_testcase(httpd_subtree_profile, Config) -> inets:stop(), inets:start(), {ok, _} = inets:start(httpd, SimpleConfig), - [{watchdog, Dog} | NewConfig] + Config catch _:Reason -> inets:stop(), @@ -102,24 +101,18 @@ init_per_testcase(httpd_subtree_profile, Config) -> init_per_testcase(_Case, Config) -> - Dog = test_server:timetrap(?t:minutes(5)), - NewConfig = lists:keydelete(watchdog, 1, Config), inets:stop(), ok = inets:start(), - [{watchdog, Dog} | NewConfig]. + Config. end_per_testcase(Case, Config) when Case == httpd_subtree; Case == httpd_subtree_profile -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Dir = filename:join(PrivDir, "root"), inets_test_lib:del_dirs(Dir), ok; -end_per_testcase(_, Config) -> - Dog = ?config(watchdog, Config), - test_server:timetrap_cancel(Dog), +end_per_testcase(_, _) -> inets:stop(), ok. @@ -164,29 +157,25 @@ default_tree(Config) when is_list(Config) -> ftpc_worker() -> [{doc, "Makes sure the ftp worker processes are added and removed " "appropriatly to/from the supervison tree."}]. -ftpc_worker(Config) when is_list(Config) -> +ftpc_worker(Config0) when is_list(Config0) -> [] = supervisor:which_children(ftp_sup), - try - begin - {_Tag, FtpdHost} = ftp_suite_lib:dirty_select_ftpd_host(Config), - case inets:start(ftpc, [{host, FtpdHost}]) of - {ok, Pid} -> - case supervisor:which_children(ftp_sup) of - [{_,_, worker, [ftp]}] -> - inets:stop(ftpc, Pid), - test_server:sleep(5000), - [] = supervisor:which_children(ftp_sup), - ok; - Children -> - exit({unexpected_children, Children}) - end; - _ -> - {skip, "Unable to reach test FTP server"} + case ftp_SUITE:init_per_suite(Config0) of + {skip, _} = Skip -> + Skip; + Config -> + FtpdHost = proplists:get_value(ftpd_host,Config), + {ok, Pid} = inets:start(ftpc, [{host, FtpdHost}]), + case supervisor:which_children(ftp_sup) of + [{_,_, worker, [ftp]}] -> + inets:stop(ftpc, Pid), + ct:sleep(5000), + [] = supervisor:which_children(ftp_sup), + catch ftp_SUITE:end_per_SUITE(Config), + ok; + Children -> + catch ftp_SUITE:end_per_SUITE(Config), + exit({unexpected_children, Children}) end - end - catch - throw:{error, not_found} -> - {skip, "No available FTP servers"} end. tftpd_worker() -> @@ -200,7 +189,7 @@ tftpd_worker(Config) when is_list(Config) -> [{_,Pid0, worker, _}] = supervisor:which_children(tftp_sup), inets:stop(tftpd, Pid0), - test_server:sleep(5000), + ct:sleep(5000), [] = supervisor:which_children(tftp_sup), ok. diff --git a/lib/inets/test/inets_test_lib.hrl b/lib/inets/test/inets_test_lib.hrl index a36ab0b1cf..d436395290 100644 --- a/lib/inets/test/inets_test_lib.hrl +++ b/lib/inets/test/inets_test_lib.hrl @@ -21,96 +21,8 @@ %%---------------------------------------------------------------------- %% Purpose: Define common macros for testing %%---------------------------------------------------------------------- - -%% - Print macros - - --ifdef(inets_debug). --define(DEBUG(F,A), inets_test_lib:debug(F, A, ?MODULE, ?LINE)). --else. --define(DEBUG(F,A),ok). --endif. - --ifdef(inets_log). --define(LOG(F,A), inets_test_lib:log(F, A, ?MODULE, ?LINE)). --else. --define(LOG(F,A),ok). --endif. - --define(INFO(F,A), inets_test_lib:info(F, A, ?MODULE, ?LINE)). --define(PRINT(F,A), inets_test_lib:print(F, A, ?MODULE, ?LINE)). - - -%% - Macros stolen from the test server - - --ifndef(line). --define(line,put(test_server_loc,{?MODULE,?LINE}),). --endif. - - -%% - OS Command and stuff - --define(OSCMD(Cmd), inets_test_lib:oscmd(Cmd)). - --define(PRINT_SYSTEM_INFO(P), inets_test_lib:print_system_info(P)). - --define(RUN_ON_OS(OS, FUN), inets_test_lib:run_on_os(OS, FUN)). --define(RUN_ON_WINDOWS(FUN), inets_test_lib:run_on_windows(FUN)). - - -%% - Test case macros - - --define(EXPANDABLE(I, C, F), inets_test_lib:expandable(I, C, F)). --define(OS_BASED_SKIP(Skippable), - inets_test_lib:os_based_skip(Skippable)). - --define(NON_PC_TC_MAYBE_SKIP(Config, Condition), - inets_test_lib:non_pc_tc_maybe_skip(Config, Condition, ?MODULE, ?LINE)). - - - %% - Misc macros - -define(ENSURE_STARTED(A), inets_test_lib:ensure_started(A)). --define(UPDATE(K,V,C), inets_test_lib:update_config(K,V,C)). --define(CONFIG(K,C), inets_test_lib:get_config(K,C)). --define(HOSTNAME(), inets_test_lib:hostname()). --define(SZ(X), inets_test_lib:sz(X)). - - -%% - Test case macros - - --define(SKIP(Reason), inets_test_lib:skip(Reason, ?MODULE, ?LINE)). --define(FAIL(Reason), inets_test_lib:fail(Reason, ?MODULE, ?LINE)). - - -%% - Socket macros - - --define(CONNECT(M,H,P), inets_test_lib:connect(M,H,P)). --define(SEND(M,S,D), inets_test_lib:send(M,S,D)). --define(CSEND(M,S,D,C,T), inets_test_lib:csend(M,S,D,C,T)). --define(CLOSE(M,S), inets_test_lib:close(M,S)). - - -%% - Time macros - - --define(HOURS(N), inets_test_lib:hours(N)). --define(MINS(N), inets_test_lib:minutes(N)). --define(SECS(N), inets_test_lib:seconds(N)). - --define(WD_START(T), inets_test_lib:watchdog_start(T)). --define(WD_STOP(P), inets_test_lib:watchdog_stop(P)). - --define(SLEEP(MSEC), inets_test_lib:sleep(MSEC)). --define(M(), inets_test_lib:millis()). --define(MDIFF(A,B), inets_test_lib:millis_diff(A,B)). - - -%% - Process utility macros - - --define(FLUSH(), inets_test_lib:flush_mqueue()). --define(ETRAP_GET(), inets_test_lib:trap_exit()). --define(ETRAP_SET(O), inets_test_lib:trap_exit(O)). - - diff --git a/lib/inets/test/old_httpd_SUITE.erl b/lib/inets/test/old_httpd_SUITE.erl index 9902c1459e..172db53844 100644 --- a/lib/inets/test/old_httpd_SUITE.erl +++ b/lib/inets/test/old_httpd_SUITE.erl @@ -286,9 +286,7 @@ init_per_suite(Config) -> "~n Config: ~p" "~n", [Config]), - ?PRINT_SYSTEM_INFO([]), - - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), SuiteTopDir = filename:join(PrivDir, ?MODULE), case file:make_dir(SuiteTopDir) of ok -> @@ -314,7 +312,7 @@ init_per_suite(Config) -> %%-------------------------------------------------------------------- end_per_suite(_Config) -> - %% SuiteTopDir = ?config(suite_top_dir, Config), + %% SuiteTopDir = proplists:get_value(suite_top_dir, Config), %% inets_test_lib:del_dirs(SuiteTopDir), ok. @@ -346,8 +344,8 @@ init_per_testcase2(Case, Config) -> SslNormal = integer_to_list(?SSL_PORT) ++ ".conf", SslHtaccess = integer_to_list(?SSL_PORT) ++ "htaccess.conf", - DataDir = ?config(data_dir, Config), - SuiteTopDir = ?config(suite_top_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + SuiteTopDir = proplists:get_value(suite_top_dir, Config), %% tsp("init_per_testcase2 -> " %% "~n SuiteDir: ~p" @@ -499,7 +497,7 @@ init_per_testcase3(Case, Config) -> Dog = test_server:timetrap(inets_test_lib:minutes(10)), NewConfig = lists:keydelete(watchdog, 1, Config), - TcTopDir = ?config(tc_top_dir, Config), + TcTopDir = proplists:get_value(tc_top_dir, Config), CaseRest = case atom_to_list(Case) of @@ -581,16 +579,16 @@ init_per_testcase3(Case, Config) -> {skip, _} = Skip -> Skip; "mod_auth_" ++ _ -> - start_mnesia(?config(node, Config)), + start_mnesia(proplists:get_value(node, Config)), [{watchdog, Dog} | NewConfig]; "mod_htaccess" -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), Path = filename:join([ServerRoot, "htdocs"]), catch remove_htaccess(Path), - create_htaccess_data(Path, ?config(address, Config)), + create_htaccess_data(Path, proplists:get_value(address, Config)), [{watchdog, Dog} | NewConfig]; "range" -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), Path = filename:join([ServerRoot, "htdocs"]), create_range_data(Path), [{watchdog, Dog} | NewConfig]; @@ -613,7 +611,7 @@ init_per_testcase3(Case, Config) -> %% Description: Cleanup after each test case %%-------------------------------------------------------------------- end_per_testcase(Case, Config) -> - Dog = ?config(watchdog, Config), + Dog = proplists:get_value(watchdog, Config), test_server:timetrap_cancel(Dog), end_per_testcase2(Case, lists:keydelete(watchdog, 1, Config)), ok. @@ -641,7 +639,7 @@ ip_mod_alias(suite) -> []; ip_mod_alias(Config) when is_list(Config) -> httpd_mod:alias(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -651,7 +649,7 @@ ip_mod_actions(suite) -> []; ip_mod_actions(Config) when is_list(Config) -> httpd_mod:actions(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -660,9 +658,9 @@ ip_mod_security(doc) -> ip_mod_security(suite) -> []; ip_mod_security(Config) when is_list(Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), httpd_mod:security(ServerRoot, ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -672,7 +670,7 @@ ip_mod_auth(suite) -> []; ip_mod_auth(Config) when is_list(Config) -> httpd_mod:auth(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -681,9 +679,9 @@ ip_mod_auth_api(doc) -> ip_mod_auth_api(suite) -> []; ip_mod_auth_api(Config) when is_list(Config) -> - ServerRoot = ?config(server_root, Config), - Host = ?config(host, Config), - Node = ?config(node, Config), + ServerRoot = proplists:get_value(server_root, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_mod:auth_api(ServerRoot, "", ip_comm, ?IP_PORT, Host, Node), httpd_mod:auth_api(ServerRoot, "dets_", ip_comm, ?IP_PORT, Host, Node), httpd_mod:auth_api(ServerRoot, "mnesia_", ip_comm, ?IP_PORT, Host, Node), @@ -695,7 +693,7 @@ ip_mod_auth_mnesia_api(suite) -> []; ip_mod_auth_mnesia_api(Config) when is_list(Config) -> httpd_mod:auth_mnesia_api(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_mod_htaccess(doc) -> @@ -704,7 +702,7 @@ ip_mod_htaccess(suite) -> []; ip_mod_htaccess(Config) when is_list(Config) -> httpd_mod:htaccess(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_mod_cgi(doc) -> @@ -713,7 +711,7 @@ ip_mod_cgi(suite) -> []; ip_mod_cgi(Config) when is_list(Config) -> httpd_mod:cgi(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_mod_esi(doc) -> @@ -722,7 +720,7 @@ ip_mod_esi(suite) -> []; ip_mod_esi(Config) when is_list(Config) -> httpd_mod:esi(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -732,7 +730,7 @@ ip_mod_get(suite) -> []; ip_mod_get(Config) when is_list(Config) -> httpd_mod:get(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -742,7 +740,7 @@ ip_mod_head(suite) -> []; ip_mod_head(Config) when is_list(Config) -> httpd_mod:head(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_mod_all(doc) -> @@ -751,7 +749,7 @@ ip_mod_all(suite) -> []; ip_mod_all(Config) when is_list(Config) -> httpd_mod:all(ip_comm, ?IP_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_load_light(doc) -> @@ -759,8 +757,8 @@ ip_load_light(doc) -> ip_load_light(suite) -> []; ip_load_light(Config) when is_list(Config) -> - httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config), + httpd_load:load_test(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ip_comm, light)), ok. %%------------------------------------------------------------------------- @@ -769,8 +767,8 @@ ip_load_medium(doc) -> ip_load_medium(suite) -> []; ip_load_medium(Config) when is_list(Config) -> - httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config), + httpd_load:load_test(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ip_comm, medium)), ok. %%------------------------------------------------------------------------- @@ -779,8 +777,8 @@ ip_load_heavy(doc) -> ip_load_heavy(suite) -> []; ip_load_heavy(Config) when is_list(Config) -> - httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config), + httpd_load:load_test(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ip_comm, heavy)), ok. @@ -791,8 +789,8 @@ ip_dos_hostname(doc) -> ip_dos_hostname(suite) -> []; ip_dos_hostname(Config) when is_list(Config) -> - dos_hostname(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config), ?MAX_HEADER_SIZE), + dos_hostname(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config), ?MAX_HEADER_SIZE), ok. @@ -802,13 +800,7 @@ ip_time_test(doc) -> ip_time_test(suite) -> []; ip_time_test(Config) when is_list(Config) -> - %% <CONDITIONAL-SKIP> - Skippable = [win32], - Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - - httpd_time_test:t(ip_comm, ?config(host, Config), ?IP_PORT), + httpd_time_test:t(ip_comm, proplists:get_value(host, Config), ?IP_PORT), ok. %%------------------------------------------------------------------------- @@ -818,8 +810,8 @@ ip_block_503(doc) -> ip_block_503(suite) -> []; ip_block_503(Config) when is_list(Config) -> - httpd_block:block_503(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_block:block_503(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_block_disturbing_idle(doc) -> @@ -829,8 +821,8 @@ ip_block_disturbing_idle(suite) -> []; ip_block_disturbing_idle(Config) when is_list(Config) -> httpd_block:block_disturbing_idle(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_block_non_disturbing_idle(doc) -> @@ -840,8 +832,8 @@ ip_block_non_disturbing_idle(suite) -> []; ip_block_non_disturbing_idle(Config) when is_list(Config) -> httpd_block:block_non_disturbing_idle(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_block_disturbing_active(doc) -> @@ -851,8 +843,8 @@ ip_block_disturbing_active(suite) -> []; ip_block_disturbing_active(Config) when is_list(Config) -> httpd_block:block_disturbing_active(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_block_non_disturbing_active(doc) -> @@ -862,8 +854,8 @@ ip_block_non_disturbing_active(suite) -> []; ip_block_non_disturbing_active(Config) when is_list(Config) -> httpd_block:block_non_disturbing_idle(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -877,9 +869,9 @@ ip_block_disturbing_active_timeout_not_released(Config) when is_list(Config) -> httpd_block:block_disturbing_active_timeout_not_released(ip_comm, ?IP_PORT, - ?config(host, + proplists:get_value(host, Config), - ?config(node, + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -893,9 +885,9 @@ ip_block_disturbing_active_timeout_released(Config) when is_list(Config) -> httpd_block:block_disturbing_active_timeout_released(ip_comm, ?IP_PORT, - ?config(host, + proplists:get_value(host, Config), - ?config(node, + proplists:get_value(node, Config)), ok. @@ -910,9 +902,9 @@ ip_block_non_disturbing_active_timeout_not_released(Config) httpd_block: block_non_disturbing_active_timeout_not_released(ip_comm, ?IP_PORT, - ?config(host, + proplists:get_value(host, Config), - ?config(node, + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -927,9 +919,9 @@ ip_block_non_disturbing_active_timeout_released(Config) httpd_block: block_non_disturbing_active_timeout_released(ip_comm, ?IP_PORT, - ?config(host, + proplists:get_value(host, Config), - ?config(node, + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -939,8 +931,8 @@ ip_block_disturbing_blocker_dies(suite) -> []; ip_block_disturbing_blocker_dies(Config) when is_list(Config) -> httpd_block:disturbing_blocker_dies(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_block_non_disturbing_blocker_dies(doc) -> @@ -949,8 +941,8 @@ ip_block_non_disturbing_blocker_dies(suite) -> []; ip_block_non_disturbing_blocker_dies(Config) when is_list(Config) -> httpd_block:non_disturbing_blocker_dies(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_restart_no_block(doc) -> @@ -958,8 +950,8 @@ ip_restart_no_block(doc) -> ip_restart_no_block(suite) -> []; ip_restart_no_block(Config) when is_list(Config) -> - httpd_block:restart_no_block(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_block:restart_no_block(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_restart_disturbing_block(doc) -> @@ -967,33 +959,9 @@ ip_restart_disturbing_block(doc) -> ip_restart_disturbing_block(suite) -> []; ip_restart_disturbing_block(Config) when is_list(Config) -> - %% <CONDITIONAL-SKIP> - Condition = - fun() -> - case os:type() of - {unix, linux} -> - HW = string:strip(os:cmd("uname -m"), right, $\n), - case HW of - "ppc" -> - case inet:gethostname() of - {ok, "peach"} -> - true; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end - end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_block:restart_disturbing_block(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -1002,33 +970,9 @@ ip_restart_non_disturbing_block(doc) -> ip_restart_non_disturbing_block(suite) -> []; ip_restart_non_disturbing_block(Config) when is_list(Config) -> - %% <CONDITIONAL-SKIP> - Condition = - fun() -> - case os:type() of - {unix, linux} -> - HW = string:strip(os:cmd("uname -m"), right, $\n), - case HW of - "ppc" -> - case inet:gethostname() of - {ok, "peach"} -> - true; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end - end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_block:restart_non_disturbing_block(ip_comm, ?IP_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -1043,7 +987,7 @@ essl_mod_alias(Config) when is_list(Config) -> ssl_mod_alias(Tag, Config) -> httpd_mod:alias(Tag, ?SSL_PORT, - ?config(host, Config), ?config(node, Config)), + proplists:get_value(host, Config), proplists:get_value(node, Config)), ok. @@ -1060,8 +1004,8 @@ essl_mod_actions(Config) when is_list(Config) -> ssl_mod_actions(Tag, Config) -> httpd_mod:actions(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1075,12 +1019,12 @@ essl_mod_security(Config) when is_list(Config) -> ssl_mod_security(essl, Config). ssl_mod_security(Tag, Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), httpd_mod:security(ServerRoot, Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1096,8 +1040,8 @@ essl_mod_auth(Config) when is_list(Config) -> ssl_mod_auth(Tag, Config) -> httpd_mod:auth(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1112,9 +1056,9 @@ essl_mod_auth_api(Config) when is_list(Config) -> ssl_mod_auth_api(essl, Config). ssl_mod_auth_api(Tag, Config) -> - ServerRoot = ?config(server_root, Config), - Host = ?config(host, Config), - Node = ?config(node, Config), + ServerRoot = proplists:get_value(server_root, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_mod:auth_api(ServerRoot, "", Tag, ?SSL_PORT, Host, Node), httpd_mod:auth_api(ServerRoot, "dets_", Tag, ?SSL_PORT, Host, Node), httpd_mod:auth_api(ServerRoot, "mnesia_", Tag, ?SSL_PORT, Host, Node), @@ -1134,8 +1078,8 @@ essl_mod_auth_mnesia_api(Config) when is_list(Config) -> ssl_mod_auth_mnesia_api(Tag, Config) -> httpd_mod:auth_mnesia_api(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1151,8 +1095,8 @@ essl_mod_htaccess(Config) when is_list(Config) -> ssl_mod_htaccess(Tag, Config) -> httpd_mod:htaccess(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1168,8 +1112,8 @@ essl_mod_cgi(Config) when is_list(Config) -> ssl_mod_cgi(Tag, Config) -> httpd_mod:cgi(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1185,8 +1129,8 @@ essl_mod_esi(Config) when is_list(Config) -> ssl_mod_esi(Tag, Config) -> httpd_mod:esi(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1202,8 +1146,8 @@ essl_mod_get(Config) when is_list(Config) -> ssl_mod_get(Tag, Config) -> httpd_mod:get(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1219,8 +1163,8 @@ essl_mod_head(Config) when is_list(Config) -> ssl_mod_head(Tag, Config) -> httpd_mod:head(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1236,8 +1180,8 @@ essl_mod_all(Config) when is_list(Config) -> ssl_mod_all(Tag, Config) -> httpd_mod:all(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1253,8 +1197,8 @@ essl_load_light(Config) when is_list(Config) -> ssl_load_light(Tag, Config) -> httpd_load:load_test(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config), + proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ssl, light)), ok. @@ -1269,16 +1213,10 @@ essl_load_medium(Config) when is_list(Config) -> ssl_load_medium(essl, Config). ssl_load_medium(Tag, Config) -> - %% <CONDITIONAL-SKIP> - Skippable = [win32], - Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_load:load_test(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config), + proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ssl, medium)), ok. @@ -1293,16 +1231,10 @@ essl_load_heavy(Config) when is_list(Config) -> ssl_load_heavy(essl, Config). ssl_load_heavy(Tag, Config) -> - %% <CONDITIONAL-SKIP> - Skippable = [win32], - Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_load:load_test(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config), + proplists:get_value(host, Config), + proplists:get_value(node, Config), get_nof_clients(ssl, heavy)), ok. @@ -1320,8 +1252,8 @@ essl_dos_hostname(Config) when is_list(Config) -> ssl_dos_hostname(Tag, Config) -> dos_hostname(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config), + proplists:get_value(host, Config), + proplists:get_value(node, Config), ?MAX_HEADER_SIZE), ok. @@ -1337,23 +1269,8 @@ essl_time_test(Config) when is_list(Config) -> ssl_time_test(essl, Config). ssl_time_test(Tag, Config) when is_list(Config) -> - %% <CONDITIONAL-SKIP> - FreeBSDVersionVerify = - fun() -> - case os:version() of - {7, 1, _} -> % We only have one such machine, so... - true; - _ -> - false - end - end, - Skippable = [win32, {unix, [{freebsd, FreeBSDVersionVerify}]}], - Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_time_test:t(Tag, - ?config(host, Config), + proplists:get_value(host, Config), ?SSL_PORT), ok. @@ -1372,8 +1289,8 @@ essl_block_503(Config) when is_list(Config) -> ssl_block_503(Tag, Config) -> httpd_block:block_503(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1391,8 +1308,8 @@ essl_block_disturbing_idle(Config) when is_list(Config) -> ssl_block_disturbing_idle(Tag, Config) -> httpd_block:block_disturbing_idle(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1410,8 +1327,8 @@ essl_block_non_disturbing_idle(Config) when is_list(Config) -> ssl_block_non_disturbing_idle(Tag, Config) -> httpd_block:block_non_disturbing_idle(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1429,8 +1346,8 @@ essl_block_disturbing_active(Config) when is_list(Config) -> ssl_block_disturbing_active(Tag, Config) -> httpd_block:block_disturbing_active(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1448,8 +1365,8 @@ essl_block_non_disturbing_active(Config) when is_list(Config) -> ssl_block_non_disturbing_active(Tag, Config) -> httpd_block:block_non_disturbing_idle(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1468,8 +1385,8 @@ essl_block_disturbing_active_timeout_not_released(Config) ssl_block_disturbing_active_timeout_not_released(Tag, Config) -> Port = ?SSL_PORT, - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_block:block_disturbing_active_timeout_not_released(Tag, Port, Host, Node), ok. @@ -1490,8 +1407,8 @@ essl_block_disturbing_active_timeout_released(Config) ssl_block_disturbing_active_timeout_released(Tag, Config) -> Port = ?SSL_PORT, - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_block:block_disturbing_active_timeout_released(Tag, Port, Host, @@ -1513,8 +1430,8 @@ essl_block_non_disturbing_active_timeout_not_released(Config) ssl_block_non_disturbing_active_timeout_not_released(Tag, Config) -> Port = ?SSL_PORT, - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_block:block_non_disturbing_active_timeout_not_released(Tag, Port, Host, @@ -1539,8 +1456,8 @@ essl_block_non_disturbing_active_timeout_released(Config) ssl_block_non_disturbing_active_timeout_released(Tag, Config) when is_list(Config) -> Port = ?SSL_PORT, - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), httpd_block:block_non_disturbing_active_timeout_released(Tag, Port, Host, @@ -1562,8 +1479,8 @@ essl_block_disturbing_blocker_dies(Config) when is_list(Config) -> ssl_block_disturbing_blocker_dies(Tag, Config) -> httpd_block:disturbing_blocker_dies(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1579,8 +1496,8 @@ essl_block_non_disturbing_blocker_dies(Config) when is_list(Config) -> ssl_block_non_disturbing_blocker_dies(Tag, Config) -> httpd_block:non_disturbing_blocker_dies(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1597,8 +1514,8 @@ essl_restart_no_block(Config) when is_list(Config) -> ssl_restart_no_block(Tag, Config) -> httpd_block:restart_no_block(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1613,43 +1530,9 @@ essl_restart_disturbing_block(Config) when is_list(Config) -> ssl_restart_disturbing_block(essl, Config). ssl_restart_disturbing_block(Tag, Config) -> - %% <CONDITIONAL-SKIP> - Condition = - fun() -> - case os:type() of - {unix, linux} -> - case ?OSCMD("uname -m") of - "ppc" -> - case file:read_file_info("/etc/fedora-release") of - {ok, _} -> - case ?OSCMD("awk '{print $2}' /etc/fedora-release") of - "release" -> - %% Fedora 7 and later - case ?OSCMD("awk '{print $3}' /etc/fedora-release") of - "7" -> - true; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end - end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_block:restart_disturbing_block(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1664,34 +1547,10 @@ essl_restart_non_disturbing_block(Config) when is_list(Config) -> ssl_restart_non_disturbing_block(essl, Config). ssl_restart_non_disturbing_block(Tag, Config) -> - %% <CONDITIONAL-SKIP> - Condition = - fun() -> - case os:type() of - {unix, linux} -> - HW = string:strip(os:cmd("uname -m"), right, $\n), - case HW of - "ppc" -> - case inet:gethostname() of - {ok, "peach"} -> - true; - _ -> - false - end; - _ -> - false - end; - _ -> - false - end - end, - ?NON_PC_TC_MAYBE_SKIP(Config, Condition), - %% </CONDITIONAL-SKIP> - httpd_block:restart_non_disturbing_block(Tag, ?SSL_PORT, - ?config(host, Config), - ?config(node, Config)), + proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. @@ -1701,8 +1560,8 @@ ip_host(doc) -> ip_host(suite)-> []; ip_host(Config) when is_list(Config) -> - httpd_1_1:host(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:host(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_chunked(doc) -> @@ -1710,8 +1569,8 @@ ip_chunked(doc) -> ip_chunked(suite) -> []; ip_chunked(Config) when is_list(Config) -> - httpd_1_1:chunked(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:chunked(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_expect(doc) -> @@ -1720,8 +1579,8 @@ ip_expect(doc) -> ip_expect(suite)-> []; ip_expect(Config) when is_list(Config) -> - httpd_1_1:expect(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:expect(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_range(doc) -> @@ -1729,8 +1588,8 @@ ip_range(doc) -> ip_range(suite)-> []; ip_range(Config) when is_list(Config) -> - httpd_1_1:range(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:range(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_if_test(doc) -> @@ -1738,10 +1597,10 @@ ip_if_test(doc) -> ip_if_test(suite) -> []; ip_if_test(Config) when is_list(Config) -> - ServerRoot = ?config(server_root, Config), + ServerRoot = proplists:get_value(server_root, Config), DocRoot = filename:join([ServerRoot, "htdocs"]), - httpd_1_1:if_test(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config), DocRoot), + httpd_1_1:if_test(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config), DocRoot), ok. %%------------------------------------------------------------------------- ip_http_trace(doc) -> @@ -1749,8 +1608,8 @@ ip_http_trace(doc) -> ip_http_trace(suite) -> []; ip_http_trace(Config) when is_list(Config) -> - httpd_1_1:http_trace(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:http_trace(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- ip_http1_1_head(doc) -> @@ -1758,8 +1617,8 @@ ip_http1_1_head(doc) -> ip_http1_1_head(suite)-> []; ip_http1_1_head(Config) when is_list(Config) -> - httpd_1_1:head(ip_comm, ?IP_PORT, ?config(host, Config), - ?config(node, Config)), + httpd_1_1:head(ip_comm, ?IP_PORT, proplists:get_value(host, Config), + proplists:get_value(node, Config)), ok. %%------------------------------------------------------------------------- @@ -1768,8 +1627,8 @@ ip_get_0_9(doc) -> ip_get_0_9(suite)-> []; ip_get_0_9(Config) when is_list(Config) -> - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, "GET / \r\n\r\n", [{statuscode, 200}, @@ -1791,8 +1650,8 @@ ip_head_1_0(doc) -> ip_head_1_0(suite)-> []; ip_head_1_0(Config) when is_list(Config) -> - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, "HEAD / HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), @@ -1804,8 +1663,8 @@ ip_get_1_0(doc) -> ip_get_1_0(suite)-> []; ip_get_1_0(Config) when is_list(Config) -> - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, "GET / HTTP/1.0\r\n\r\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), @@ -1817,8 +1676,8 @@ ip_post_1_0(doc) -> ip_post_1_0(suite)-> []; ip_post_1_0(Config) when is_list(Config) -> - Host = ?config(host, Config), - Node = ?config(node, Config), + Host = proplists:get_value(host, Config), + Node = proplists:get_value(node, Config), %% Test the post message formatin 1.0! Real post are testes elsewhere ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, "POST / HTTP/1.0\r\n\r\n " @@ -1832,7 +1691,7 @@ ip_mod_cgi_chunked_encoding_test(doc) -> ip_mod_cgi_chunked_encoding_test(suite)-> []; ip_mod_cgi_chunked_encoding_test(Config) when is_list(Config) -> - Host = ?config(host, Config), + Host = proplists:get_value(host, Config), Script = case test_server:os_type() of {win32, _} -> @@ -1846,7 +1705,7 @@ ip_mod_cgi_chunked_encoding_test(Config) when is_list(Config) -> ++ Host ++"\r\n\r\n"], httpd_1_1:mod_cgi_chunked_encoding_test(ip_comm, ?IP_PORT, Host, - ?config(node, Config), + proplists:get_value(node, Config), Requests), ok. @@ -1875,7 +1734,7 @@ ipv6_hostname(SocketType, Port, Config) when is_list(Config) -> "~n SocketType: ~p" "~n Port: ~p" "~n Config: ~p", [SocketType, Port, Config]), - Host = ?config(host, Config), + Host = proplists:get_value(host, Config), URI = "GET HTTP://" ++ Host ++ ":" ++ integer_to_list(Port) ++ "/ HTTP/1.1\r\n\r\n", tsp("ipv6_hostname -> Host: ~p", [Host]), @@ -1910,7 +1769,7 @@ ipv6_address(SocketType, Port, Config) when is_list(Config) -> "~n SocketType: ~p" "~n Port: ~p" "~n Config: ~p", [SocketType, Port, Config]), - Host = ?config(host, Config), + Host = proplists:get_value(host, Config), tsp("ipv6_address -> Host: ~p", [Host]), URI = "GET HTTP://" ++ Host ++ ":" ++ integer_to_list(Port) ++ "/ HTTP/1.1\r\n\r\n", @@ -1927,8 +1786,8 @@ ticket_5775(doc) -> ticket_5775(suite) -> []; ticket_5775(Config) -> - ok=httpd_test_lib:verify_request(ip_comm, ?config(host, Config), - ?IP_PORT, ?config(node, Config), + ok=httpd_test_lib:verify_request(ip_comm, proplists:get_value(host, Config), + ?IP_PORT, proplists:get_value(node, Config), "GET /cgi-bin/erl/httpd_example:get_bin " "HTTP/1.0\r\n\r\n", [{statuscode, 200}, @@ -1939,9 +1798,9 @@ ticket_5865(doc) -> ticket_5865(suite) -> []; ticket_5865(Config) -> - ?SKIP(as_of_r15_behaviour_of_calendar_has_changed), - Host = ?config(host,Config), - ServerRoot = ?config(server_root, Config), + ct:skip(as_of_r15_behaviour_of_calendar_has_changed), + Host = proplists:get_value(host,Config), + ServerRoot = proplists:get_value(server_root, Config), DocRoot = filename:join([ServerRoot, "htdocs"]), File = filename:join([DocRoot,"last_modified.html"]), @@ -1957,7 +1816,7 @@ ticket_5865(Config) -> case file:write_file_info(File,FI#file_info{mtime=Bad_mtime}) of ok -> ok = httpd_test_lib:verify_request(ip_comm, Host, - ?IP_PORT, ?config(node, Config), + ?IP_PORT, proplists:get_value(node, Config), "GET /last_modified.html" " HTTP/1.1\r\nHost:" ++Host++"\r\n\r\n", @@ -1977,8 +1836,8 @@ ticket_5913(doc) -> ["Tests that a header without last-modified is handled"]; ticket_5913(suite) -> []; ticket_5913(Config) -> - ok = httpd_test_lib:verify_request(ip_comm, ?config(host, Config), - ?IP_PORT, ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, proplists:get_value(host, Config), + ?IP_PORT, proplists:get_value(node, Config), "GET /cgi-bin/erl/httpd_example:get_bin " "HTTP/1.0\r\n\r\n", [{statuscode, 200}, @@ -1989,8 +1848,8 @@ ticket_6003(doc) -> ["Tests that a URI with a bad hexadecimal code is handled"]; ticket_6003(suite) -> []; ticket_6003(Config) -> - ok = httpd_test_lib:verify_request(ip_comm, ?config(host, Config), - ?IP_PORT, ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, proplists:get_value(host, Config), + ?IP_PORT, proplists:get_value(node, Config), "GET http://www.erlang.org/%skalle " "HTTP/1.0\r\n\r\n", [{statuscode, 400}, @@ -2002,8 +1861,8 @@ ticket_7304(doc) -> ticket_7304(suite) -> []; ticket_7304(Config) -> - ok = httpd_test_lib:verify_request(ip_comm, ?config(host, Config), - ?IP_PORT, ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, proplists:get_value(host, Config), + ?IP_PORT, proplists:get_value(node, Config), "GET / HTTP/1.0\r\n\n", [{statuscode, 200}, {version, "HTTP/1.0"}]), @@ -2030,11 +1889,11 @@ dos_hostname(Type, Port, Host, Node, Max) -> %%-------------------------------------------------------------------- %% Other help functions create_config(Config, Access, FileName) -> - ServerRoot = ?config(server_root, Config), - TcTopDir = ?config(tc_top_dir, Config), - Port = ?config(port, Config), - Type = ?config(sock_type, Config), - Host = ?config(host, Config), + ServerRoot = proplists:get_value(server_root, Config), + TcTopDir = proplists:get_value(tc_top_dir, Config), + Port = proplists:get_value(port, Config), + Type = proplists:get_value(sock_type, Config), + Host = proplists:get_value(host, Config), Mods = io_lib:format("~p", [httpd_mod]), Funcs = io_lib:format("~p", [ssl_password_cb]), MaxHdrSz = io_lib:format("~p", [256]), @@ -2424,13 +2283,13 @@ create_range_data(Path) -> "12345678901234567890"])). create_ipv6_config(Config, FileName, Ipv6Address) -> - ServerRoot = ?config(server_root, Config), - TcTopDir = ?config(tc_top_dir, Config), - Port = ?config(port, Config), - SockType = ?config(sock_type, Config), + ServerRoot = proplists:get_value(server_root, Config), + TcTopDir = proplists:get_value(tc_top_dir, Config), + Port = proplists:get_value(port, Config), + SockType = proplists:get_value(sock_type, Config), Mods = io_lib:format("~p", [httpd_mod]), Funcs = io_lib:format("~p", [ssl_password_cb]), - Host = ?config(ipv6_host, Config), + Host = proplists:get_value(ipv6_host, Config), MaxHdrSz = io_lib:format("~p", [256]), MaxHdrAct = io_lib:format("~p", [close]), diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk index d52dbad555..543e0d44fd 100644 --- a/lib/inets/vsn.mk +++ b/lib/inets/vsn.mk @@ -19,6 +19,6 @@ # %CopyrightEnd% APPLICATION = inets -INETS_VSN = 6.2.3 +INETS_VSN = 6.3 PRE_VSN = APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)" |