diff options
Diffstat (limited to 'lib/stdlib/test')
37 files changed, 2159 insertions, 406 deletions
diff --git a/lib/stdlib/test/ExpandTestCaps.erl b/lib/stdlib/test/ExpandTestCaps.erl new file mode 100644 index 0000000000..96c4115354 --- /dev/null +++ b/lib/stdlib/test/ExpandTestCaps.erl @@ -0,0 +1,32 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module('ExpandTestCaps'). + +-export([a_fun_name/1, + a_less_fun_name/1, + b_comes_after_a/1]). + +a_fun_name(X) -> + X. + +a_less_fun_name(X) -> + X. + +b_comes_after_a(X) -> + X. diff --git a/lib/stdlib/test/ExpandTestCaps1.erl b/lib/stdlib/test/ExpandTestCaps1.erl new file mode 100644 index 0000000000..09ee9f81c4 --- /dev/null +++ b/lib/stdlib/test/ExpandTestCaps1.erl @@ -0,0 +1,44 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module('ExpandTestCaps1'). + +-export([a_fun_name/1, + a_less_fun_name/1, + b_comes_after_a/1, + 'Quoted_fun_name'/0, + 'Quoted_fun_too'/0, + '#weird-fun-name'/0]). + +a_fun_name(X) -> + X. + +a_less_fun_name(X) -> + X. + +b_comes_after_a(X) -> + X. + +'Quoted_fun_name'() -> + whoopee. + +'Quoted_fun_too'() -> + too. + +'#weird-fun-name'() -> + weird. diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile index 7a87eef5f3..9beac93eb8 100644 --- a/lib/stdlib/test/Makefile +++ b/lib/stdlib/test/Makefile @@ -18,6 +18,7 @@ MODULES= \ digraph_utils_SUITE \ dummy1_h \ dummy_h \ + edlin_expand_SUITE \ epp_SUITE \ erl_eval_helper \ erl_eval_SUITE \ @@ -29,6 +30,10 @@ MODULES= \ escript_SUITE \ ets_SUITE \ ets_tough_SUITE \ + expand_test \ + expand_test1 \ + ExpandTestCaps \ + ExpandTestCaps1 \ filelib_SUITE \ file_sorter_SUITE \ filename_SUITE \ @@ -105,7 +110,7 @@ COVERFILE=stdlib.cover make_emakefile: $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) \ - >> $(EMAKEFILE) + > $(EMAKEFILE) tests debug opt: make_emakefile erl $(ERL_MAKE_FLAGS) -make diff --git a/lib/stdlib/test/array_SUITE.erl b/lib/stdlib/test/array_SUITE.erl index 7cfdcf6dfd..e7cfc65be1 100644 --- a/lib/stdlib/test/array_SUITE.erl +++ b/lib/stdlib/test/array_SUITE.erl @@ -384,11 +384,17 @@ set_get_test_() -> ?_assert(array:get(0, set(0, 42, set(0, 17, new()))) =:= 42), - ?_assert(array:get(0, reset(0, new())) =:= undefined), - ?_assert(array:get(0, reset(0, set(0, 17, new()))) =:= undefined), - ?_assert(array:get(0, reset(0, new({default,42}))) =:= 42), - ?_assert(array:get(0, reset(0, set(0, 17, new({default,42})))) - =:= 42) + ?_assertError(badarg, array:get(0, reset(11, new([{size,10}])))), + ?_assertError(badarg, array:get(0, reset(-1, new([{size,10}])))), + ?_assert(array:get(0, reset(0, new())) =:= undefined), + ?_assert(array:get(0, reset(0, set(0, 17, new()))) =:= undefined), + ?_assert(array:get(0, reset(9, set(9, 17, new()))) =:= undefined), + ?_assert(array:get(0, reset(11, set(11, 17, new()))) =:= undefined), + ?_assert(array:get(0, reset(11, set(12, 17, new()))) =:= undefined), + ?_assert(array:get(0, reset(1, set(12, 17, new()))) =:= undefined), + ?_assert(array:get(0, reset(11, new())) =:= undefined), + ?_assert(array:get(0, reset(0, set(0, 17, new({default,42})))) =:= 42), + ?_assert(array:get(0, reset(0, new({default,42}))) =:= 42) ]. to_list_test_() -> diff --git a/lib/stdlib/test/c_SUITE.erl b/lib/stdlib/test/c_SUITE.erl index 5608d73d19..2edbc7ab4c 100644 --- a/lib/stdlib/test/c_SUITE.erl +++ b/lib/stdlib/test/c_SUITE.erl @@ -18,15 +18,16 @@ %% -module(c_SUITE). -export([all/1]). --export([c_1/1, c_2/1, c_3/1, c_4/1, memory/1]). +-export([c_1/1, c_2/1, c_3/1, c_4/1, nc_1/1, nc_2/1, nc_3/1, nc_4/1, + memory/1]). -include("test_server.hrl"). --import(c, [c/2]). +-import(c, [c/2, nc/2]). all(doc) -> ["Test cases for the 'c' module."]; all(suite) -> - [c_1, c_2, c_3, c_4, memory]. + [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, memory]. %%% Write output to a directory other than current directory: @@ -34,7 +35,7 @@ c_1(doc) -> ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; c_1(suite) -> []; -c_1(Config) when list(Config) -> +c_1(Config) when is_list(Config) -> ?line R = filename:join(?config(data_dir, Config), "m.erl"), ?line W = ?config(priv_dir, Config), ?line Result = c(R,[{outdir,W}]), @@ -44,7 +45,7 @@ c_2(doc) -> ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; c_2(suite) -> []; -c_2(Config) when list(Config) -> +c_2(Config) when is_list(Config) -> ?line R = filename:join(?config(data_dir, Config), "m"), ?line W = ?config(priv_dir, Config), ?line Result = c(R,[{outdir,W}]), @@ -59,7 +60,7 @@ c_3(doc) -> "directory). [ticket OTP-1209]."]; c_3(suite) -> []; -c_3(Config) when list(Config) -> +c_3(Config) when is_list(Config) -> ?line R = filename:join(?config(data_dir, Config), "m.erl"), ?line W = ?config(priv_dir, Config), ?line file:set_cwd(W), @@ -71,18 +72,68 @@ c_4(doc) -> "directory). [ticket OTP-1209]."]; c_4(suite) -> []; -c_4(Config) when list(Config) -> +c_4(Config) when is_list(Config) -> ?line R = filename:join(?config(data_dir, Config), "m"), ?line W = ?config(priv_dir, Config), ?line file:set_cwd(W), ?line Result = c(R,[{outdir,W}]), ?line {ok, m} = Result. +%%% Write output to a directory other than current directory: + +nc_1(doc) -> + ["Checks that c:nc works also with option 'outdir'."]; +nc_1(suite) -> + []; +nc_1(Config) when is_list(Config) -> + ?line R = filename:join(?config(data_dir, Config), "m.erl"), + ?line W = ?config(priv_dir, Config), + ?line Result = nc(R,[{outdir,W}]), + ?line {ok, m} = Result. + +nc_2(doc) -> + ["Checks that c:nc works also with option 'outdir'."]; +nc_2(suite) -> + []; +nc_2(Config) when is_list(Config) -> + ?line R = filename:join(?config(data_dir, Config), "m"), + ?line W = ?config(priv_dir, Config), + ?line Result = nc(R,[{outdir,W}]), + ?line {ok, m} = Result. + + +%%% Put results in current directory (or rather, change current dir +%%% to the output dir): + +nc_3(doc) -> + ["Checks that c:nc works also with option 'outdir' (same as current" + "directory)."]; +nc_3(suite) -> + []; +nc_3(Config) when is_list(Config) -> + ?line R = filename:join(?config(data_dir, Config), "m.erl"), + ?line W = ?config(priv_dir, Config), + ?line file:set_cwd(W), + ?line Result = nc(R,[{outdir,W}]), + ?line {ok, m} = Result. + +nc_4(doc) -> + ["Checks that c:nc works also with option 'outdir' (same as current" + "directory)."]; +nc_4(suite) -> + []; +nc_4(Config) when is_list(Config) -> + ?line R = filename:join(?config(data_dir, Config), "m"), + ?line W = ?config(priv_dir, Config), + ?line file:set_cwd(W), + ?line Result = nc(R,[{outdir,W}]), + ?line {ok, m} = Result. + memory(doc) -> ["Checks that c:memory/[0,1] returns consistent results."]; memory(suite) -> []; -memory(Config) when list(Config) -> +memory(Config) when is_list(Config) -> try ?line ML = c:memory(), ?line T = mget(total, ML), @@ -112,5 +163,5 @@ mget(K, L) -> ?line test_v(V). % Help function for c_SUITE:memory/1 -test_v(V) when integer(V) -> +test_v(V) when is_integer(V) -> ?line V. diff --git a/lib/stdlib/test/calendar_SUITE.erl b/lib/stdlib/test/calendar_SUITE.erl index ea81bb99a9..10fb72c1b1 100644 --- a/lib/stdlib/test/calendar_SUITE.erl +++ b/lib/stdlib/test/calendar_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(calendar_SUITE). @@ -48,7 +48,7 @@ gregorian_days(doc) -> "At the same time valid_date is tested."; gregorian_days(suite) -> []; -gregorian_days(Config) when list(Config) -> +gregorian_days(Config) when is_list(Config) -> ?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}), ?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}), ?line check_gregorian_days(Days, MaxDays). @@ -60,7 +60,7 @@ gregorian_seconds(doc) -> "every 2 days + 1 second."; gregorian_seconds(suite) -> []; -gregorian_seconds(Config) when list(Config) -> +gregorian_seconds(Config) when is_list(Config) -> ?line Secs = calendar:datetime_to_gregorian_seconds({{?START_YEAR, 1, 1}, {0, 0, 0}}), ?line MaxSecs = calendar:datetime_to_gregorian_seconds({{?END_YEAR, 1, 1}, @@ -72,7 +72,7 @@ day_of_the_week(doc) -> "year ?START_YEAR up to ?END_YEAR."; day_of_the_week(suite) -> []; -day_of_the_week(Config) when list(Config) -> +day_of_the_week(Config) when is_list(Config) -> ?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}), ?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}), ?line DayNumber = calendar:day_of_the_week({?START_YEAR, 1, 1}), @@ -82,7 +82,7 @@ day_of_the_week_calibrate(doc) -> "Tests that day_of_the_week for 1997-11-11 is Tuesday (2)"; day_of_the_week_calibrate(suite) -> []; -day_of_the_week_calibrate(Config) when list(Config) -> +day_of_the_week_calibrate(Config) when is_list(Config) -> ?line 2 = calendar:day_of_the_week({1997, 11, 11}). leap_years(doc) -> @@ -90,7 +90,7 @@ leap_years(doc) -> "year ?START_YEAR up to ?END_YEAR."; leap_years(suite) -> []; -leap_years(Config) when list(Config) -> +leap_years(Config) when is_list(Config) -> ?line check_leap_years(?START_YEAR, ?END_YEAR). last_day_of_the_month(doc) -> @@ -98,14 +98,14 @@ last_day_of_the_month(doc) -> "year ?START_YEAR up to ?END_YEAR."; last_day_of_the_month(suite) -> []; -last_day_of_the_month(Config) when list(Config) -> +last_day_of_the_month(Config) when is_list(Config) -> ?line check_last_day_of_the_month({?START_YEAR, 1}, {?END_YEAR, 1}). local_time_to_universal_time_dst(doc) -> "Tests local_time_to_universal_time_dst for MET"; local_time_to_universal_time_dst(suite) -> []; -local_time_to_universal_time_dst(Config) when list(Config) -> +local_time_to_universal_time_dst(Config) when is_list(Config) -> case os:type() of {unix,_} -> case os:cmd("date '+%Z'") of @@ -117,7 +117,7 @@ local_time_to_universal_time_dst(Config) when list(Config) -> _ -> local_time_to_universal_time_dst_x(Config) end. -local_time_to_universal_time_dst_x(Config) when list(Config) -> +local_time_to_universal_time_dst_x(Config) when is_list(Config) -> %% Assumes MET (UTC+1 / UTC+2(dst) ?line LtW = {{2003,01,15},{14,00,00}}, % Winter ?line UtW = {{2003,01,15},{13,00,00}}, % diff --git a/lib/stdlib/test/edlin_expand_SUITE.erl b/lib/stdlib/test/edlin_expand_SUITE.erl new file mode 100644 index 0000000000..613bfd000e --- /dev/null +++ b/lib/stdlib/test/edlin_expand_SUITE.erl @@ -0,0 +1,156 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(edlin_expand_SUITE). +-export([all/1]). + +-export([normal/1, quoted_fun/1, quoted_module/1, quoted_both/1]). + +-export([init_per_testcase/2, fin_per_testcase/2]). + +-include("test_server.hrl"). + +% Default timetrap timeout (set in init_per_testcase). +-define(default_timeout, ?t:minutes(1)). + +init_per_testcase(_Case, Config) -> + ?line Dog = ?t:timetrap(?default_timeout), + [{watchdog, Dog} | Config]. +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +all(doc) -> + ["Test cases for edlin_expand."]; +all(suite) -> + [normal, quoted_fun, quoted_module, quoted_both]. + +normal(doc) -> + [""]; +normal(suite) -> + []; +normal(Config) when is_list(Config) -> + ?line {module,expand_test} = c:l(expand_test), + % These tests might fail if another module with the prefix "expand_" happens + % to also be loaded. + ?line {yes, "test:", []} = edlin_expand:expand(lists:reverse("expand_")), + ?line {no, [], []} = edlin_expand:expand(lists:reverse("expandXX_")), + ?line {no,[], + [{"a_fun_name",1}, + {"a_less_fun_name",1}, + {"b_comes_after_a",1}, + {"module_info",0}, + {"module_info",1}]} = edlin_expand:expand(lists:reverse("expand_test:")), + ?line {yes,[],[{"a_fun_name",1}, + {"a_less_fun_name",1}]} = edlin_expand:expand( + lists:reverse("expand_test:a_")), + ok. + +quoted_fun(doc) -> + ["Normal module name, some function names using quoted atoms"]; +quoted_fun(suite) -> + []; +quoted_fun(Config) when is_list(Config) -> + ?line {module,expand_test} = c:l(expand_test), + ?line {module,expand_test1} = c:l(expand_test1), + %% should be no colon after test this time + ?line {yes, "test", []} = edlin_expand:expand(lists:reverse("expand_")), + ?line {no, [], []} = edlin_expand:expand(lists:reverse("expandXX_")), + ?line {no,[],[{"'#weird-fun-name'",0}, + {"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}, + {"a_fun_name",1}, + {"a_less_fun_name",1}, + {"b_comes_after_a",1}, + {"module_info",0}, + {"module_info",1}]} = edlin_expand:expand( + lists:reverse("expand_test1:")), + ?line {yes,"_",[]} = edlin_expand:expand( + lists:reverse("expand_test1:a")), + ?line {yes,[],[{"a_fun_name",1}, + {"a_less_fun_name",1}]} = edlin_expand:expand( + lists:reverse("expand_test1:a_")), + ?line {yes,[], + [{"'#weird-fun-name'",0}, + {"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}]} = edlin_expand:expand( + lists:reverse("expand_test1:'")), + ?line {yes,"uoted_fun_",[]} = edlin_expand:expand( + lists:reverse("expand_test1:'Q")), + ?line {yes,[], + [{"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}]} = edlin_expand:expand( + lists:reverse("expand_test1:'Quoted_fun_")), + ?line {yes,"weird-fun-name'(",[]} = edlin_expand:expand( + lists:reverse("expand_test1:'#")), + ok. + +quoted_module(doc) -> + [""]; +quoted_module(suite) -> + []; +quoted_module(Config) when is_list(Config) -> + ?line {module,'ExpandTestCaps'} = c:l('ExpandTestCaps'), + ?line {yes, "Caps':", []} = edlin_expand:expand(lists:reverse("'ExpandTest")), + ?line {no,[], + [{"a_fun_name",1}, + {"a_less_fun_name",1}, + {"b_comes_after_a",1}, + {"module_info",0}, + {"module_info",1}]} = edlin_expand:expand(lists:reverse("'ExpandTestCaps':")), + ?line {yes,[],[{"a_fun_name",1}, + {"a_less_fun_name",1}]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps':a_")), + ok. + +quoted_both(suite) -> + []; +quoted_both(Config) when is_list(Config) -> + ?line {module,'ExpandTestCaps'} = c:l('ExpandTestCaps'), + ?line {module,'ExpandTestCaps1'} = c:l('ExpandTestCaps1'), + %% should be no colon (or quote) after test this time + ?line {yes, "Caps", []} = edlin_expand:expand(lists:reverse("'ExpandTest")), + ?line {no,[],[{"'#weird-fun-name'",0}, + {"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}, + {"a_fun_name",1}, + {"a_less_fun_name",1}, + {"b_comes_after_a",1}, + {"module_info",0}, + {"module_info",1}]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':")), + ?line {yes,"_",[]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':a")), + ?line {yes,[],[{"a_fun_name",1}, + {"a_less_fun_name",1}]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':a_")), + ?line {yes,[], + [{"'#weird-fun-name'",0}, + {"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':'")), + ?line {yes,"uoted_fun_",[]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':'Q")), + ?line {yes,[], + [{"'Quoted_fun_name'",0}, + {"'Quoted_fun_too'",0}]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':'Quoted_fun_")), + ?line {yes,"weird-fun-name'(",[]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':'#")), + ok. diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl index 67e20fd2e1..9a3ae0baf5 100644 --- a/lib/stdlib/test/epp_SUITE.erl +++ b/lib/stdlib/test/epp_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1998-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -module(epp_SUITE). @@ -23,7 +23,7 @@ upcase_mac/1, upcase_mac_1/1, upcase_mac_2/1, variable/1, variable_1/1, otp_4870/1, otp_4871/1, otp_5362/1, pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1, - otp_8130/1]). + otp_8130/1, overload_mac/1, otp_8388/1]). -export([epp_parse_erl_form/2]). @@ -61,8 +61,9 @@ fin_per_testcase(_, Config) -> all(doc) -> ["Test cases for epp."]; all(suite) -> - [rec_1, upcase_mac, predef_mac, variable, otp_4870, otp_4871, otp_5362, - pmod, not_circular, skip_header, otp_6277, otp_7702, otp_8130]. + [rec_1, upcase_mac, predef_mac, variable, otp_4870, otp_4871, otp_5362, + pmod, not_circular, skip_header, otp_6277, otp_7702, otp_8130, + overload_mac, otp_8388]. rec_1(doc) -> ["Recursive macros hang or crash epp (OTP-1398)."]; @@ -466,7 +467,7 @@ otp_6277(Config) when is_list(Config) -> -define(ASSERT, ?MODULE). ?ASSERT().">>, - [{error,{{4,16},epp,{undefined,'MODULE'}}}]}], + [{error,{{4,16},epp,{undefined,'MODULE', none}}}]}], ?line [] = check(Config, Ts), ok. @@ -673,7 +674,7 @@ otp_8130(Config) when is_list(Config) -> {otp_8130_c7, <<"\nt() -> ?A.\n">>, - {errors,[{{2,9},epp,{undefined,'A'}}],[]}}, + {errors,[{{2,9},epp,{undefined,'A', none}}],[]}}, {otp_8130_c8, <<"\n-include_lib(\"$apa/foo.hrl\").\n">>, @@ -683,7 +684,7 @@ otp_8130(Config) when is_list(Config) -> {otp_8130_c9, <<"-define(S, ?S).\n" "t() -> ?S.\n">>, - {errors,[{{2,9},epp,{circular,'S'}}],[]}}, + {errors,[{{2,9},epp,{circular,'S', none}}],[]}}, {otp_8130_c10, <<"\n-file.">>, @@ -718,22 +719,22 @@ otp_8130(Config) when is_list(Config) -> {otp_8130_c17, <<"\n-define(A(B), B).\n" "-define(A, 1).\n">>, - {errors,[{{3,9},epp,{redefine,'A'}}],[]}}, + []}, {otp_8130_c18, <<"\n-define(A, 1).\n" "-define(A(B), B).\n">>, - {errors,[{{3,9},epp,{redefine,'A'}}],[]}}, + []}, {otp_8130_c19, <<"\n-define(a(B), B).\n" "-define(a, 1).\n">>, - {errors,[{{3,9},epp,{redefine,a}}],[]}}, + []}, {otp_8130_c20, <<"\n-define(a, 1).\n" "-define(a(B), B).\n">>, - {errors,[{{3,9},epp,{redefine,a}}],[]}}, + []}, {otp_8130_c21, <<"\n-define(A(B, B), B).\n">>, @@ -745,7 +746,7 @@ otp_8130(Config) when is_list(Config) -> {otp_8130_c23, <<"\n-file(?b, 3).\n">>, - {errors,[{{2,8},epp,{undefined,b}}],[]}}, + {errors,[{{2,8},epp,{undefined,b, none}}],[]}}, {otp_8130_c24, <<"\n-include(\"no such file.erl\").\n">>, @@ -821,7 +822,8 @@ macs(Epp) -> macro(Epp, N) -> case lists:keyfind({atom,N}, 1, epp:macro_defs(Epp)) of false -> false; - {{atom,N},{_,V}} -> V + {{atom,N},{_,V}} -> V; + {{atom,N},Defs} -> lists:append([V || {_,{_,V}} <- Defs]) end. ifdef(Config) -> @@ -1030,6 +1032,113 @@ ifdef(Config) -> ], ?line [] = run(Config, Ts). + + +overload_mac(doc) -> + ["Advanced test on overloading macros."]; +overload_mac(suite) -> + []; +overload_mac(Config) when is_list(Config) -> + Cs = [ + %% '-undef' removes all definitions of a macro + {overload_mac_c1, + <<"-define(A, a).\n" + "-define(A(X), X).\n" + "-undef(A).\n" + "t1() -> ?A.\n", + "t2() -> ?A(1).">>, + {errors,[{{4,9},epp,{undefined,'A', none}}, + {{5,9},epp,{undefined,'A', 1}}],[]}}, + + %% cannot overload predefined macros + {overload_mac_c2, + <<"-define(MODULE(X), X).">>, + {errors,[{{1,9},epp,{redefine_predef,'MODULE'}}],[]}}, + + %% cannot overload macros with same arity + {overload_mac_c3, + <<"-define(A(X), X).\n" + "-define(A(Y), Y).">>, + {errors,[{{2,9},epp,{redefine,'A'}}],[]}}, + + {overload_mac_c4, + <<"-define(A, a).\n" + "-define(A(X,Y), {X,Y}).\n" + "a(X) -> X.\n" + "t() -> ?A(1).">>, + {errors,[{{4,9},epp,{mismatch,'A'}}],[]}} + ], + ?line [] = compile(Config, Cs), + + Ts = [ + {overload_mac_r1, + <<"-define(A, 1).\n" + "-define(A(X), X).\n" + "-define(A(X, Y), {X, Y}).\n" + "t() -> {?A, ?A(2), ?A(3, 4)}.">>, + {1, 2, {3, 4}}}, + + {overload_mac_r2, + <<"-define(A, 1).\n" + "-define(A(X), X).\n" + "t() -> ?A(?A).">>, + 1}, + + {overload_mac_r3, + <<"-define(A, ?B).\n" + "-define(B, a).\n" + "-define(B(X), {b,X}).\n" + "a(X) -> X.\n" + "t() -> ?A(1).">>, + 1} + ], + ?line [] = run(Config, Ts). + + +otp_8388(doc) -> + ["OTP-8388. More tests on overloaded macros."]; +otp_8388(suite) -> + []; +otp_8388(Config) when is_list(Config) -> + Dir = ?config(priv_dir, Config), + ?line File = filename:join(Dir, "otp_8388.erl"), + ?line ok = file:write_file(File, <<"-module(otp_8388)." + "-define(LINE, a).">>), + fun() -> + PreDefMacros = [{'LINE', a}], + ?line {error,{redefine_predef,'LINE'}} = + epp:open(File, [], PreDefMacros) + end(), + + fun() -> + PreDefMacros = ['LINE'], + ?line {error,{redefine_predef,'LINE'}} = + epp:open(File, [], PreDefMacros) + end(), + + Ts = [ + {macro_1, + <<"-define(m(A), A).\n" + "t() -> ?m(,).\n">>, + {errors,[{{2,11},epp,{arg_error,m}}],[]}}, + {macro_2, + <<"-define(m(A), A).\n" + "t() -> ?m(a,).\n">>, + {errors,[{{2,12},epp,{arg_error,m}}],[]}}, + {macro_3, + <<"-define(LINE, a).\n">>, + {errors,[{{1,9},epp,{redefine_predef,'LINE'}}],[]}}, + {macro_4, + <<"-define(A(B, C, D), {B,C,D}).\n" + "t() -> ?A(a,,3).\n">>, + {errors,[{{2,8},epp,{mismatch,'A'}}],[]}}, + {macro_5, + <<"-define(Q, {?F0(), ?F1(,,4)}).\n">>, + {errors,[{{1,24},epp,{arg_error,'F1'}}],[]}} + ], + ?line [] = compile(Config, Ts), + ok. + check(Config, Tests) -> eval_tests(Config, fun check_test/2, Tests). diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index bfbd7b3dc1..8581b496aa 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(erl_lint_SUITE). @@ -2597,7 +2597,7 @@ otp_8051(Config) when is_list(Config) -> <<"-opaque foo() :: bar(). ">>, [], - {error,[{1,erl_lint,{type_ref,{bar,0}}}], + {error,[{1,erl_lint,{undefined_type,{bar,0}}}], [{1,erl_lint,{unused_type,{foo,0}}}]}}], ?line [] = run(Config, Ts), ok. diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl index 6016bc9bdc..13c87ca005 100644 --- a/lib/stdlib/test/ets_SUITE.erl +++ b/lib/stdlib/test/ets_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(ets_SUITE). @@ -4530,10 +4530,16 @@ meta_wb(Config) when is_list(Config) -> meta_wb_do(Opts) -> %% Do random new/delete/rename of colliding named tables - Names = [pioneer | colliding_names(pioneer)], + Names0 = [pioneer | colliding_names(pioneer)], + + %% Remove any names that happen to exist as tables already + Names = lists:filter(fun(Name) -> ets:info(Name) == undefined end, + Names0), Len = length(Names), OpFuns = {fun meta_wb_new/4, fun meta_wb_delete/4, fun meta_wb_rename/4}, + ?line true = (Len >= 3), + io:format("Colliding names = ~p\n",[Names]), F = fun(0,_,_) -> ok; (N,Tabs,Me) -> Name1 = lists:nth(random:uniform(Len),Names), diff --git a/lib/stdlib/test/ets_tough_SUITE.erl b/lib/stdlib/test/ets_tough_SUITE.erl index e3d44d00b9..4c8d941f13 100644 --- a/lib/stdlib/test/ets_tough_SUITE.erl +++ b/lib/stdlib/test/ets_tough_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(ets_tough_SUITE). @@ -40,7 +40,7 @@ fin_per_testcase(_Func, Config) -> ets:delete(?GLOBAL_PARAMS). -ex1(Config) when list(Config) -> +ex1(Config) when is_list(Config) -> ?line ets:new(?GLOBAL_PARAMS,[named_table,public]), ?line ets:insert(?GLOBAL_PARAMS,{a,set}), ?line ets:insert(?GLOBAL_PARAMS,{b,set}), @@ -269,7 +269,7 @@ show_entries(Fd) -> start(DbName) -> case gen_server:start_link(ets_tough_SUITE,{DbName,no_dump_dir},[]) of - {ok,Pid} when pid(Pid) -> + {ok,Pid} when is_pid(Pid) -> {ok, Pid}; Other -> Other @@ -283,7 +283,7 @@ start(DbName) -> start(DbName,DumpDir) -> case gen_server:start_link(ets_tough_SUITE, {DbName,{dump_dir,DumpDir}},[]) of - {ok,Pid} when pid(Pid) -> + {ok,Pid} when is_pid(Pid) -> {ok, Pid}; Other -> Other @@ -1075,7 +1075,7 @@ phys_read_len(Fd) -> phys_read_entry(Fd,Len) -> case io:get_chars(Fd,'',Len) of - L when list(L), length(L) == Len -> + L when is_list(L), length(L) == Len -> {ok,binary_to_term(list_to_binary(L))}; Other -> {error,{read_term,Other}} diff --git a/lib/stdlib/test/expand_test.erl b/lib/stdlib/test/expand_test.erl new file mode 100644 index 0000000000..63e4bc3aa0 --- /dev/null +++ b/lib/stdlib/test/expand_test.erl @@ -0,0 +1,32 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(expand_test). + +-export([a_fun_name/1, + a_less_fun_name/1, + b_comes_after_a/1]). + +a_fun_name(X) -> + X. + +a_less_fun_name(X) -> + X. + +b_comes_after_a(X) -> + X. diff --git a/lib/stdlib/test/expand_test1.erl b/lib/stdlib/test/expand_test1.erl new file mode 100644 index 0000000000..11b6fec0f3 --- /dev/null +++ b/lib/stdlib/test/expand_test1.erl @@ -0,0 +1,44 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(expand_test1). + +-export([a_fun_name/1, + a_less_fun_name/1, + b_comes_after_a/1, + 'Quoted_fun_name'/0, + 'Quoted_fun_too'/0, + '#weird-fun-name'/0]). + +a_fun_name(X) -> + X. + +a_less_fun_name(X) -> + X. + +b_comes_after_a(X) -> + X. + +'Quoted_fun_name'() -> + whoopee. + +'Quoted_fun_too'() -> + too. + +'#weird-fun-name'() -> + weird. diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl index c9c6054f7b..d54741051f 100644 --- a/lib/stdlib/test/filelib_SUITE.erl +++ b/lib/stdlib/test/filelib_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -21,7 +21,7 @@ -export([all/1,init_per_testcase/2,fin_per_testcase/2, wildcard_one/1,wildcard_two/1,wildcard_errors/1, - fold_files/1,otp_5960/1]). + fold_files/1,otp_5960/1,ensure_dir_eexist/1]). -import(lists, [foreach/2]). @@ -38,7 +38,8 @@ fin_per_testcase(_Case, Config) -> ok. all(suite) -> - [wildcard_one,wildcard_two,wildcard_errors,fold_files,otp_5960]. + [wildcard_one,wildcard_two,wildcard_errors,fold_files,otp_5960, + ensure_dir_eexist]. wildcard_one(Config) when is_list(Config) -> ?line {ok,OldCwd} = file:get_cwd(), @@ -223,7 +224,9 @@ otp_5960(Config) when is_list(Config) -> ?line Name1 = filename:join(Dir, name1), ?line Name2 = filename:join(Dir, name2), ?line ok = filelib:ensure_dir(Name1), % parent is created + ?line ok = filelib:ensure_dir(Name1), % repeating it should be OK ?line ok = filelib:ensure_dir(Name2), % parent already exists + ?line ok = filelib:ensure_dir(Name2), % repeating it should be OK ?line Name3 = filename:join(Name1, name3), ?line {ok, FileInfo} = file:read_file_info(Dir), case os:type() of @@ -239,3 +242,16 @@ otp_5960(Config) when is_list(Config) -> ?line ok = file:write_file_info(Dir, #file_info{mode=Mode}), ok end. + +ensure_dir_eexist(Config) when is_list(Config) -> + ?line PrivDir = ?config(priv_dir, Config), + ?line Dir = filename:join(PrivDir, ensure_dir_eexist), + ?line Name = filename:join(Dir, "same_name_as_file_and_dir"), + ?line ok = filelib:ensure_dir(Name), + ?line ok = file:write_file(Name, <<"some string\n">>), + + %% There already is a file with the name of the directory + %% we want to create. + ?line NeedFile = filename:join(Name, "file"), + ?line {error, eexist} = filelib:ensure_dir(NeedFile), + ok. diff --git a/lib/stdlib/test/fixtable_SUITE.erl b/lib/stdlib/test/fixtable_SUITE.erl index 9f21308ad4..1940ee147e 100644 --- a/lib/stdlib/test/fixtable_SUITE.erl +++ b/lib/stdlib/test/fixtable_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%---------------------------------------------------------------------- @@ -83,7 +83,7 @@ fixbag(doc) -> "incorrect lookups"]; fixbag(suite) -> []; -fixbag(Config) when list(Config) -> +fixbag(Config) when is_list(Config) -> ?line T = ets:new(x,[bag]), ?line ets:insert(T,{a,1}), ?line ets:insert(T,{a,2}), @@ -101,7 +101,7 @@ insert_same_key(doc) -> ["Check correct behaviour if a key is deleted and reinserted during fixation."]; insert_same_key(suite) -> []; -insert_same_key(Config) when list(Config) -> +insert_same_key(Config) when is_list(Config) -> ?line {ok,Dets1} = dets:open_file(?DETS_TMP1, [{file, dets_filename(?DETS_TMP1,Config)}]), ?line Ets1 = ets:new(ets,[]), @@ -180,7 +180,7 @@ owner_dies(doc) -> ["Check correct behaviour if the table owner dies."]; owner_dies(suite) -> []; -owner_dies(Config) when list(Config) -> +owner_dies(Config) when is_list(Config) -> ?line P1 = start_commander(), ?line Ets1 = command(P1,{ets,new,[ets,[]]}), ?line command(P1,{ets,safe_fixtable,[Ets1,true]}), @@ -236,7 +236,7 @@ other_process_closes(doc) -> other_process_closes(suite) -> []; -other_process_closes(Config) when list(Config) -> +other_process_closes(Config) when is_list(Config) -> ?line {ok,Dets} = dets:open_file(?DETS_TMP1, [{file, dets_filename(tmp1,Config)}]), ?line P2 = start_commander(), @@ -265,7 +265,7 @@ other_process_deletes(doc) -> "deletes an ets table"]; other_process_deletes(suite) -> []; -other_process_deletes(Config) when list(Config) -> +other_process_deletes(Config) when is_list(Config) -> ?line Ets = ets:new(ets,[public]), ?line P = start_commander(), ?line ets:safe_fixtable(Ets,true), @@ -282,7 +282,7 @@ multiple_fixes(doc) -> ["Check that multiple safe_fixtable keeps the reference counter."]; multiple_fixes(suite) -> []; -multiple_fixes(Config) when list(Config) -> +multiple_fixes(Config) when is_list(Config) -> ?line {ok,Dets} = dets:open_file(?DETS_TMP1, [{file, dets_filename(?DETS_TMP1,Config)}]), ?line Ets = ets:new(ets,[]), @@ -317,7 +317,7 @@ multiple_processes(doc) -> "counted OK"]; multiple_processes(suite) -> []; -multiple_processes(Config) when list(Config) -> +multiple_processes(Config) when is_list(Config) -> ?line {ok,Dets} = dets:open_file(?DETS_TMP1,[{file, dets_filename(?DETS_TMP1, Config)}]), @@ -370,7 +370,7 @@ multiple_processes(Tab, Mod) -> %%% Helpers -dets_filename(Base, Config) when atom(Base) -> +dets_filename(Base, Config) when is_atom(Base) -> dets_filename(atom_to_list(Base) ++ ".dat", Config); dets_filename(Basename, Config) -> PrivDir = ?config(priv_dir,Config), diff --git a/lib/stdlib/test/format_SUITE.erl b/lib/stdlib/test/format_SUITE.erl index 2c415894f4..1c9e953003 100644 --- a/lib/stdlib/test/format_SUITE.erl +++ b/lib/stdlib/test/format_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1998-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(format_SUITE). @@ -45,7 +45,7 @@ hang_1(doc) -> ["Bad args can hang (OTP-2400)"]; hang_1(suite) -> []; -hang_1(Config) when list(Config) -> +hang_1(Config) when is_list(Config) -> ?line _ = (catch io:format(a, "", [])), ?line _ = (catch io:format({}, "", [])), ok. diff --git a/lib/stdlib/test/gen_event_SUITE.erl b/lib/stdlib/test/gen_event_SUITE.erl index dc5ddebf53..8cbffaca56 100644 --- a/lib/stdlib/test/gen_event_SUITE.erl +++ b/lib/stdlib/test/gen_event_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(gen_event_SUITE). @@ -33,7 +33,7 @@ all(suite) -> {req, [stdlib], [start, test_all, hibernate]}. start(doc) -> []; start(suite) -> []; -start(Config) when list(Config) -> +start(Config) when is_list(Config) -> OldFl = process_flag(trap_exit, true), ?line {ok, Pid0} = gen_event:start(), %anonymous @@ -175,7 +175,7 @@ test_all(suite) -> [add_handler, add_sup_handler, delete_handler, add_handler(doc) -> []; add_handler(suite) -> []; -add_handler(Config) when list(Config) -> +add_handler(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line {error, my_error} = gen_event:add_handler(my_dummy_handler, dummy_h, make_error), @@ -196,7 +196,7 @@ add_handler(Config) when list(Config) -> add_sup_handler(doc) -> []; add_sup_handler(suite) -> []; -add_sup_handler(Config) when list(Config) -> +add_sup_handler(Config) when is_list(Config) -> ?line {ok,Pid} = gen_event:start({local, my_dummy_handler}), ?line {error, my_error} = gen_event:add_sup_handler(my_dummy_handler, dummy_h, make_error), @@ -238,7 +238,7 @@ add_sup_handler(Config) when list(Config) -> delete_handler(doc) -> []; delete_handler(suite) -> []; -delete_handler(Config) when list(Config) -> +delete_handler(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), ?line {error, module_not_found} = @@ -270,7 +270,7 @@ delete_handler(Config) when list(Config) -> swap_handler(doc) -> []; swap_handler(suite) -> []; -swap_handler(Config) when list(Config) -> +swap_handler(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), ?line {error, non_existing} = @@ -299,7 +299,7 @@ swap_handler(Config) when list(Config) -> swap_sup_handler(doc) -> []; swap_sup_handler(suite) -> []; -swap_sup_handler(Config) when list(Config) -> +swap_sup_handler(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_sup_handler(my_dummy_handler, dummy_h, [self()]), ?line {error, non_existing} = @@ -341,7 +341,7 @@ swap_sup_handler(Config) when list(Config) -> notify(doc) -> []; notify(suite) -> []; -notify(Config) when list(Config) -> +notify(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), Event = {event, self()}, @@ -457,7 +457,7 @@ notify(Config) when list(Config) -> sync_notify(doc) -> []; sync_notify(suite) -> []; -sync_notify(Config) when list(Config) -> +sync_notify(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), Event = {event, self()}, @@ -576,7 +576,7 @@ sync_notify(Config) when list(Config) -> call(doc) -> []; call(suite) -> []; -call(Config) when list(Config) -> +call(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), ?line ok = gen_event:add_handler(my_dummy_handler, {dummy_h, 1}, [self()]), @@ -718,7 +718,7 @@ flush() -> info(doc) -> []; info(suite) -> []; -info(Config) when list(Config) -> +info(Config) when is_list(Config) -> ?line {ok,_} = gen_event:start({local, my_dummy_handler}), ?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]), Info = {info, self()}, diff --git a/lib/stdlib/test/gen_fsm_SUITE.erl b/lib/stdlib/test/gen_fsm_SUITE.erl index 62f8b2f9dd..23c1d9a193 100644 --- a/lib/stdlib/test/gen_fsm_SUITE.erl +++ b/lib/stdlib/test/gen_fsm_SUITE.erl @@ -30,7 +30,7 @@ -export([shutdown/1]). --export([sys/1, sys1/1]). +-export([sys/1, sys1/1, call_format_status/1]). -export([hibernate/1,hiber_idle/3,hiber_wakeup/3,hiber_idle/2,hiber_wakeup/2]). @@ -42,7 +42,7 @@ % The gen_fsm behaviour -export([init/1, handle_event/3, handle_sync_event/4, terminate/3, - handle_info/3]). + handle_info/3, format_status/2]). -export([idle/2, idle/3, timeout/2, wfor_conf/2, wfor_conf/3, @@ -305,7 +305,7 @@ shutdown(Config) when is_list(Config) -> ok. -sys(suite) -> [sys1]. +sys(suite) -> [sys1, call_format_status]. sys1(Config) when is_list(Config) -> ?line {ok, Pid} = @@ -317,6 +317,13 @@ sys1(Config) when is_list(Config) -> ?line sys:resume(Pid), ?line stop_it(Pid). +call_format_status(Config) when is_list(Config) -> + ?line {ok, Pid} = gen_fsm:start(gen_fsm_SUITE, [], []), + ?line Status = sys:get_status(Pid), + ?line {status, Pid, _Mod, [_PDict, running, _Parent, _, Data]} = Status, + ?line [format_status_called | _] = lists:reverse(Data), + ?line stop_it(Pid). + %% Hibernation hibernate(suite) -> []; @@ -836,3 +843,6 @@ handle_sync_event(stop_shutdown_reason, _From, _State, Data) -> {stop, {shutdown,reason}, {shutdown,reason}, Data}; handle_sync_event({get, _Pid}, _From, State, Data) -> {reply, {state, State, Data}, State, Data}. + +format_status(_Opt, [_Pdict, _StateData]) -> + [format_status_called]. diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl index 86a5a65ba3..6efdce78a1 100644 --- a/lib/stdlib/test/gen_server_SUITE.erl +++ b/lib/stdlib/test/gen_server_SUITE.erl @@ -30,7 +30,7 @@ call_remote_n1/1, call_remote_n2/1, call_remote_n3/1, spec_init/1, spec_init_local_registered_parent/1, spec_init_global_registered_parent/1, - otp_5854/1, hibernate/1, otp_7669/1 + otp_5854/1, hibernate/1, otp_7669/1, call_format_status/1 ]). % spawn export @@ -42,7 +42,7 @@ % The gen_server behaviour -export([init/1, handle_call/3, handle_cast/2, - handle_info/2, terminate/2]). + handle_info/2, terminate/2, format_status/2]). all(suite) -> [start, crash, call, cast, cast_fast, info, @@ -51,7 +51,7 @@ all(suite) -> call_remote_n2, call_remote_n3, spec_init, spec_init_local_registered_parent, spec_init_global_registered_parent, - otp_5854,hibernate,otp_7669]. + otp_5854, hibernate, otp_7669, call_format_status]. -define(default_timeout, ?t:minutes(1)). @@ -851,7 +851,7 @@ otp_5854(Config) when is_list(Config) -> ok. %% If initialization fails (with ignore or {stop,Reason}), -%% make sure that the process is not registered when gen_sever:start() +%% make sure that the process is not registered when gen_server:start() %% returns. otp_7669(Config) when is_list(Config) -> @@ -887,6 +887,24 @@ do_otp_7669_stop() -> ?MODULE, stop, []), ?line undefined = global:whereis_name(?MODULE). +%% Verify that sys:get_status correctly calls our format_status/2 fun +%% +call_format_status(suite) -> + []; +call_format_status(doc) -> + ["Test that sys:get_status/1,2 calls format_status/2"]; +call_format_status(Config) when is_list(Config) -> + ?line {ok, Pid} = gen_server:start_link({local, call_format_status}, + gen_server_SUITE, [], []), + ?line Status1 = sys:get_status(call_format_status), + ?line {status, Pid, _Mod, [_PDict, running, _Parent, _, Data1]} = Status1, + ?line [format_status_called | _] = lists:reverse(Data1), + ?line Status2 = sys:get_status(call_format_status, 5000), + ?line {status, Pid, _Mod, [_PDict, running, _Parent, _, Data2]} = Status2, + ?line [format_status_called | _] = lists:reverse(Data2), + ok. + + %%-------------------------------------------------------------- %% Help functions to spec_init_* start_link(Init, Options) -> @@ -1046,4 +1064,5 @@ terminate({From, stopped_info}, _State) -> terminate(_Reason, _State) -> ok. - +format_status(_Opt, [_PDict, _State]) -> + [format_status_called]. diff --git a/lib/stdlib/test/io_proto_SUITE.erl b/lib/stdlib/test/io_proto_SUITE.erl index 46407193d7..93159fbd5b 100644 --- a/lib/stdlib/test/io_proto_SUITE.erl +++ b/lib/stdlib/test/io_proto_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(io_proto_SUITE). @@ -23,7 +23,7 @@ -export([init_per_testcase/2, fin_per_testcase/2]). -export([setopts_getopts/1,unicode_options/1,unicode_options_gen/1, binary_options/1, bc_with_r12/1, - bc_with_r12_gl/1, read_modes_gl/1,bc_with_r12_ogl/1, read_modes_ogl/1, broken_unicode/1,eof_on_pipe/1]). + bc_with_r12_gl/1, read_modes_gl/1,bc_with_r12_ogl/1, read_modes_ogl/1, broken_unicode/1,eof_on_pipe/1,unicode_prompt/1]). -export([io_server_proxy/1,start_io_server_proxy/0, proxy_getall/1, proxy_setnext/2, proxy_quit/1]). @@ -31,6 +31,8 @@ -export([toerl_server/3,hold_the_line/3,answering_machine1/3, answering_machine2/3]). +-export([uprompt/1]). + %-define(without_test_server, true). -ifdef(without_test_server). @@ -43,14 +45,17 @@ -define(privdir(Conf), ?config(priv_dir, Conf)). -endif. -%-define(debug, true). +-define(debug, true). -ifdef(debug). -define(format(S, A), io:format(S, A)). -define(dbg(Data),io:format(standard_error, "DBG: ~p\r\n",[Data])). +-define(RM_RF(Dir),begin io:format(standard_error, "Not Removed: ~p\r\n",[Dir]), + ok end). -else. -define(format(S, A), ok). -define(dbg(Data),noop). +-define(RM_RF(Dir),rm_rf(Dir)). -endif. @@ -79,7 +84,7 @@ all(doc) -> all(suite) -> [setopts_getopts, unicode_options, unicode_options_gen, binary_options, bc_with_r12, bc_with_r12_gl,bc_with_r12_ogl, read_modes_gl, read_modes_ogl, - broken_unicode,eof_on_pipe]. + broken_unicode,eof_on_pipe,unicode_prompt]. -record(state, { @@ -88,6 +93,48 @@ all(suite) -> mode = list }). +uprompt(_L) -> + [1050,1072,1082,1074,1086,32,1077,32,85,110,105,99,111,100,101,32,63]. + +unicode_prompt(suite) -> + []; +unicode_prompt(doc) -> + ["Test that an Unicode prompt does not crash the shell"]; +unicode_prompt(Config) when is_list(Config) -> + ?line PA = filename:dirname(code:which(?MODULE)), + ?line rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, + {getline, "default"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "\"hej\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline, "ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "<<\"hej\\n\">>"} + ],[],[],"-pa "++ PA), + %% And one with oldshell + ?line rtnode([{putline,""}, + {putline, "2."}, + {getline_re, ".*2."}, + {getline, "2"}, + {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, + {getline_re, ".*default"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*\"hej\\\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline_re, ".*ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*<<\"hej\\\\n\">>"} + ],[],[],"-oldshell -pa "++PA), + ok. + + setopts_getopts(suite) -> []; setopts_getopts(doc) -> @@ -197,6 +244,15 @@ setopts_getopts(Config) when is_list(Config) -> {getline_re, ".*<<\"hej\\\\n\">>"} ],[],[],"-oldshell"), ok. + + +get_lc_ctype() -> + case {os:type(),os:version()} of + {{unix,sunos},{5,N,_}} when N =< 8 -> + "iso_8859_1"; + _ -> + "ISO-8859-1" + end. unicode_options(suite) -> []; @@ -369,7 +425,7 @@ unicode_options(Config) when is_list(Config) -> {getline, binary_to_list(unicode:characters_to_binary( [1024],unicode,utf8))} - ],[],"LC_CTYPE=\"ISO-8859-1\"; export LC_CTYPE; "), + ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "), ?line rtnode([{putline,""}, {putline, "2."}, {getline_re, ".*2."}, @@ -384,7 +440,7 @@ unicode_options(Config) when is_list(Config) -> {getline_re, ".*"++binary_to_list(unicode:characters_to_binary( [1024],unicode,utf8))} - ],[],"LC_CTYPE=\"ISO-8859-1\"; export LC_CTYPE; ", + ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; ", " -oldshell "), ok. @@ -974,7 +1030,7 @@ answering_machine1(OthNode,OthReg,Me) -> {putline, TestDataUtf}, {getline_re, ".*Okej"} - ],Me,"LC_CTYPE=\"ISO-8859-1\"; export LC_CTYPE; "), + ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "), O = list_to_atom(OthReg), O ! {self(),done}, ok. @@ -1045,7 +1101,7 @@ answering_machine2(OthNode,OthReg,Me) -> {putline, TestDataUtf}, {getline_re, ".*Okej"} - ],Me,"LC_CTYPE=\"ISO-8859-1\"; export LC_CTYPE; "," -oldshell "), + ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "," -oldshell "), O = list_to_atom(OthReg), O ! {self(),done}, ok. @@ -1087,7 +1143,9 @@ read_modes_gl_1(_Config,Machine) -> [MyNodeList, "io_proto_suite", N2List]), ?line GL = receive X when is_pid(X) -> X end, + ?dbg({group_leader,X}), %% get_line + ?line receive after 500 -> ok end, % Dont clash with the new shell... ?line "Hej\n" = io:get_line(GL,"Prompt\n"), ?line io:setopts(GL,[binary]), ?line io:format(GL,"Okej~n",[]), @@ -1287,7 +1345,7 @@ rtnode(Commands,Nodename,ErlPrefix,Extra) -> ?line ok end, ?line wait_for_runerl_server(SPid), - ?line ok = rm_rf(Tempdir), + ?line ok = ?RM_RF(Tempdir), ?line ok = Res end end. @@ -1308,7 +1366,7 @@ timeout(normal) -> %% stop_noshell_node(Node) -> %% test_server:stop_node(Node). - +-ifndef(debug). rm_rf(Dir) -> try {ok,List} = file:list_dir(Dir), @@ -1324,7 +1382,7 @@ rm_rf(Dir) -> catch _:Exception -> {error, {Exception,Dir}} end. - +-endif. get_and_put(_CPid,[],_) -> ok; @@ -1527,6 +1585,8 @@ start_runerl_node(RunErl,Erl,Tempdir,Nodename,Extra) -> " "++Extra end, spawn(fun() -> + ?dbg(RunErl++" "++Tempdir++"/ "++Tempdir++" \""++ + Erl++XArg++XXArg++"\""), os:cmd(RunErl++" "++Tempdir++"/ "++Tempdir++" \""++ Erl++XArg++XXArg++"\"") end). diff --git a/lib/stdlib/test/ms_transform_SUITE.erl b/lib/stdlib/test/ms_transform_SUITE.erl index cf0926b7fa..79a0a9af89 100644 --- a/lib/stdlib/test/ms_transform_SUITE.erl +++ b/lib/stdlib/test/ms_transform_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(ms_transform_SUITE). @@ -56,7 +56,7 @@ andalso_orelse(suite) -> []; andalso_orelse(doc) -> ["Tests that andalso and orelse are allowed in guards."]; -andalso_orelse(Config) when list(Config) -> +andalso_orelse(Config) when is_list(Config) -> ?line setup(Config), ?line [{{'$1','$2'}, [{'and',{is_integer,'$1'},{'>',{'+','$1',5},'$2'}}], @@ -93,7 +93,7 @@ bitsyntax(suite) -> []; bitsyntax(doc) -> ["Tests that bitsyntax works and does not work where appropriate"]; -bitsyntax(Config) when list(Config) -> +bitsyntax(Config) when is_list(Config) -> ?line setup(Config), ?line [{'_',[], [<<0,27,0,27>>]}] = @@ -131,7 +131,7 @@ record_defaults(suite) -> []; record_defaults(doc) -> ["Tests that record defaults works"]; -record_defaults(Config) when list(Config) -> +record_defaults(Config) when is_list(Config) -> ?line setup(Config), ?line [{{<<27>>,{a,5,'$1',hej,hej}}, [], @@ -146,7 +146,7 @@ basic_ets(suite) -> []; basic_ets(doc) -> ["Tests basic ets:fun2ms"]; -basic_ets(Config) when list(Config) -> +basic_ets(Config) when is_list(Config) -> ?line setup(Config), ?line [{{a,b},[],[true]}] = compile_and_run( <<"ets:fun2ms(fun({a,b}) -> true end)">>), @@ -167,7 +167,7 @@ basic_dbg(suite) -> []; basic_dbg(doc) -> ["Tests basic ets:fun2ms"]; -basic_dbg(Config) when list(Config) -> +basic_dbg(Config) when is_list(Config) -> ?line setup(Config), ?line [{[a,b],[],[{message,banan},{return_trace}]}] = compile_and_run(<<"dbg:fun2ms(fun([a,b]) -> message(banan), ", @@ -186,7 +186,7 @@ from_shell(suite) -> []; from_shell(doc) -> ["Test calling of ets/dbg:fun2ms from the shell"]; -from_shell(Config) when list(Config) -> +from_shell(Config) when is_list(Config) -> ?line setup(Config), ?line Fun = do_eval("fun({a,b}) -> true end"), ?line [{{a,b},[],[true]}] = apply(ets,fun2ms,[Fun]), @@ -203,7 +203,7 @@ records(suite) -> []; records(doc) -> ["Tests expansion of records in fun2ms"]; -records(Config) when list(Config) -> +records(Config) when is_list(Config) -> ?line setup(Config), ?line RD = <<"-record(t, {" "t1 = []," @@ -253,7 +253,7 @@ record_index(suite) -> []; record_index(doc) -> ["Tests expansion of records in fun2ms, part 2"]; -record_index(Config) when list(Config) -> +record_index(Config) when is_list(Config) -> ?line setup(Config), ?line RD = <<"-record(a,{a,b}).">>, ?line [{{2},[],[true]}] = compile_and_run(RD, @@ -268,7 +268,7 @@ top_match(suite) -> []; top_match(doc) -> ["Tests matching on top level in head to give alias for object()"]; -top_match(Config) when list(Config) -> +top_match(Config) when is_list(Config) -> ?line setup(Config), ?line RD = <<"-record(a,{a,b}).">>, ?line [{{a,3,'_'},[],['$_']}] = @@ -295,7 +295,7 @@ multipass(suite) -> []; multipass(doc) -> ["Tests that multi-defined fields in records give errors."]; -multipass(Config) when list(Config) -> +multipass(Config) when is_list(Config) -> ?line setup(Config), ?line RD = <<"-record(a,{a,b}).">>, ?line expect_failure(RD,<<"ets:fun2ms(fun(A) -> #a{a=2,a=3} end)">>), @@ -319,7 +319,7 @@ old_guards(suite) -> []; old_guards(doc) -> ["Tests that old type tests in guards are translated"]; -old_guards(Config) when list(Config) -> +old_guards(Config) when is_list(Config) -> ?line setup(Config), Tests = [ {atom,is_atom}, @@ -382,7 +382,7 @@ autoimported(suite) -> autoimported(doc) -> ["Tests use of autoimported bif's used like erlang:'+'(A,B) in guards" " and body."]; -autoimported(Config) when list(Config) -> +autoimported(Config) when is_list(Config) -> ?line setup(Config), Allowed = [ {abs,1}, @@ -582,7 +582,7 @@ float_1_function(suite) -> []; float_1_function(doc) -> ["OTP-5297. The function float/1."]; -float_1_function(Config) when list(Config) -> +float_1_function(Config) when is_list(Config) -> ?line setup(Config), RunMS = fun(L, MS) -> ets:match_spec_run(L, ets:match_spec_compile(MS)) diff --git a/lib/stdlib/test/queue_SUITE.erl b/lib/stdlib/test/queue_SUITE.erl index ec3080baa0..2cd6b52311 100644 --- a/lib/stdlib/test/queue_SUITE.erl +++ b/lib/stdlib/test/queue_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(queue_SUITE). @@ -45,7 +45,7 @@ do(doc) -> [""]; do(suite) -> []; -do(Config) when list(Config) -> +do(Config) when is_list(Config) -> ?line L = [{in, 1}, {in, 2}, {out, {value, 1}}, @@ -66,7 +66,7 @@ to_list(doc) -> ["OTP-2701"]; to_list(suite) -> []; -to_list(Config) when list(Config) -> +to_list(Config) when is_list(Config) -> ?line E = queue:new(), ?line Q = do_queue(E, [{in, 1}, {in, 2}, @@ -104,7 +104,7 @@ io_test(doc) -> "Test input and output"; io_test(suite) -> []; -io_test(Config) when list(Config) -> +io_test(Config) when is_list(Config) -> E = queue:new(), do_io_test(E), ok. @@ -284,7 +284,7 @@ op_test(doc) -> "Test operations on whole queues"; op_test(suite) -> []; -op_test(Config) when list(Config) -> +op_test(Config) when is_list(Config) -> do_op_test(fun id/1), ok. @@ -382,7 +382,7 @@ error(doc) -> "Test queue errors"; error(suite) -> []; -error(Config) when list(Config) -> +error(Config) when is_list(Config) -> do_error(fun id/1, illegal_queue), do_error(fun id/1, {[],illegal_queue}), do_error(fun id/1, {illegal_queue,[17]}), @@ -449,7 +449,7 @@ oops(doc) -> "Test queue errors"; oops(suite) -> []; -oops(Config) when list(Config) -> +oops(Config) when is_list(Config) -> ?line N = 3142, ?line Optab = optab(), ?line Seed0 = random:seed0(), diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl index 98eb66d1fb..02683f9f1a 100644 --- a/lib/stdlib/test/re_SUITE.erl +++ b/lib/stdlib/test/re_SUITE.erl @@ -1,29 +1,29 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(re_SUITE). --export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1]). +-export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_input_types/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1,pcre_cve_2008_2371/1]). -include("test_server.hrl"). -include_lib("kernel/include/file.hrl"). -all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_return,split_autogen,split_options,split_specials,error_handling]. +all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_input_types,replace_return,split_autogen,split_options,split_specials,error_handling,pcre_cve_2008_2371]. pcre(doc) -> ["Run all applicable tests from the PCRE testsuites."]; @@ -268,7 +268,17 @@ global_capture(Config) when is_list(Config) -> ?line {match,[[{3,5},{5,3}],[{11,4},{12,3}]]} = re:run("ABC�bcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,index},unicode]), ?t:timetrap_cancel(Dog), ok. - + +replace_input_types(doc) -> + ["Tests replace with different input types"]; +replace_input_types(Config) when is_list(Config) -> + Dog = ?t:timetrap(?t:minutes(3)), + ?line <<"abcd">> = re:replace("abcd","Z","X",[{return,binary},unicode]), + ?line <<"abcd">> = re:replace("abcd","\x{400}","X",[{return,binary},unicode]), + ?line <<"a",208,128,"cd">> = re:replace(<<"abcd">>,"b","\x{400}",[{return,binary},unicode]), + ?t:timetrap_cancel(Dog), + ok. + replace_return(doc) -> ["Tests return options of replace together with global searching"]; replace_return(Config) when is_list(Config) -> @@ -289,6 +299,10 @@ replace_return(Config) when is_list(Config) -> ?line <<"iXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\9X",[{return,binary}]), ?line <<"jXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\10X",[{return,binary}]), ?line <<"Xk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\11X",[{return,binary}]), + ?line "a\x{400}bcX" = re:replace("a\x{400}bcd","d","X",[global,{return,list},unicode]), + ?line <<"a",208,128,"bcX">> = re:replace("a\x{400}bcd","d","X",[global,{return,binary},unicode]), + ?line "a\x{400}bcd" = re:replace("a\x{400}bcd","Z","X",[global,{return,list},unicode]), + ?line <<"a",208,128,"bcd">> = re:replace("a\x{400}bcd","Z","X",[global,{return,binary},unicode]), ?t:timetrap_cancel(Dog), ok. @@ -524,3 +538,9 @@ error_handling(Config) when is_list(Config) -> ?t:timetrap_cancel(Dog), ok. +pcre_cve_2008_2371(doc) -> + "Fix as in http://vcs.pcre.org/viewvc?revision=360&view=revision"; +pcre_cve_2008_2371(Config) when is_list(Config) -> + %% Make sure it doesn't crash the emulator. + re:compile(<<"(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]">>, [unicode]), + ok. diff --git a/lib/stdlib/test/re_SUITE_data/mod_testoutput8 b/lib/stdlib/test/re_SUITE_data/mod_testoutput8 new file mode 100644 index 0000000000..b7e7b02d6c --- /dev/null +++ b/lib/stdlib/test/re_SUITE_data/mod_testoutput8 @@ -0,0 +1,877 @@ +/-- Do not use the \x{} construct except with patterns that have the --/ +/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/ +No match +/-- that option is set. However, the latest Perls recognize them always. --/ +No match + +\x{100}ab/8 + \x{100}ab + 0: \x{100}ab + +/a\x{100}*b/8 + ab + 0: ab + a\x{100}b + 0: a\x{100}b + a\x{100}\x{100}b + 0: a\x{100}\x{100}b + +/a\x{100}+b/8 + a\x{100}b + 0: a\x{100}b + a\x{100}\x{100}b + 0: a\x{100}\x{100}b + *** Failers +No match + ab +No match + +/\bX/8 + Xoanon + 0: X + +Xoanon + 0: X + \x{300}Xoanon + 0: X + *** Failers +No match + YXoanon +No match + +/\BX/8 + YXoanon + 0: X + *** Failers +No match + Xoanon +No match + +Xoanon +No match + \x{300}Xoanon +No match + +/X\b/8 + X+oanon + 0: X + ZX\x{300}oanon + 0: X + FAX + 0: X + *** Failers +No match + Xoanon +No match + +/X\B/8 + Xoanon + 0: X + *** Failers +No match + X+oanon +No match + ZX\x{300}oanon +No match + FAX +No match + +/[^a]/8 + abcd + 0: b + a\x{100} + 0: \x{100} + +/^[abc\x{123}\x{400}-\x{402}]{2,3}\d/8 + ab99 + 0: ab9 + \x{123}\x{123}45 + 0: \x{123}\x{123}4 + \x{400}\x{401}\x{402}6 + 0: \x{400}\x{401}\x{402}6 + *** Failers +No match + d99 +No match + \x{123}\x{122}4 +No match + \x{400}\x{403}6 +No match + \x{400}\x{401}\x{402}\x{402}6 +No match + +/abc/8 + �] +Error -10 + � +Error -10 + ��� +Error -10 + ���\? +No match + +/a.b/8 + acb + 0: acb + a\x7fb + 0: a\x{7f}b + a\x{100}b + 0: a\x{100}b + *** Failers +No match + a\nb +No match + +/^[a\x{c0}]/8 + *** Failers +No match + \x{100} +No match + +/(?<=aXb)cd/8 + aXbcd + 0: cd + +/(?<=a\x{100}b)cd/8 + a\x{100}bcd + 0: cd + +/(?<=a\x{100000}b)cd/8 + a\x{100000}bcd + 0: cd + +/(?:\x{100}){3}b/8 + \x{100}\x{100}\x{100}b + 0: \x{100}\x{100}\x{100}b + *** Failers +No match + \x{100}\x{100}b +No match + +/\x{ab}/8 + \x{ab} + 0: \x{ab} + \xc2\xab + 0: \x{ab} + *** Failers +No match + \x00{ab} +No match + +/^[^a]{2}/8 + \x{100}bc + 0: \x{100}b + +/^[^a]{2,}/8 + \x{100}bcAa + 0: \x{100}bcA + +/^[^a]{2,}?/8 + \x{100}bca + 0: \x{100}b + +/^[^a]{2}/8i + \x{100}bc + 0: \x{100}b + +/^[^a]{2,}/8i + \x{100}bcAa + 0: \x{100}bc + +/^[^a]{2,}?/8iU + \x{100}bca + 0: \x{100}bc + +/\x{100}{0,0}/8 + abcd + 0: + +/\x{100}?/8 + abcd + 0: + \x{100}\x{100} + 0: \x{100} + +/\x{100}{0,3}/8 + \x{100}\x{100} + 0: \x{100}\x{100} + \x{100}\x{100}\x{100}\x{100} + 0: \x{100}\x{100}\x{100} + +/\x{100}*/8 + abce + 0: + \x{100}\x{100}\x{100}\x{100} + 0: \x{100}\x{100}\x{100}\x{100} + +/\x{100}{1,1}/8 + abcd\x{100}\x{100}\x{100}\x{100} + 0: \x{100} + +/\x{100}{1,3}/8 + abcd\x{100}\x{100}\x{100}\x{100} + 0: \x{100}\x{100}\x{100} + +/\x{100}+/8 + abcd\x{100}\x{100}\x{100}\x{100} + 0: \x{100}\x{100}\x{100}\x{100} + +/\x{100}{3}/8 + abcd\x{100}\x{100}\x{100}XX + 0: \x{100}\x{100}\x{100} + +/\x{100}{3,5}/8 + abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX + 0: \x{100}\x{100}\x{100}\x{100}\x{100} + +/\x{100}{3,}/8 + abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX + 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100} + +/(?<=a\x{100}{2}b)X/8 + Xyyya\x{100}\x{100}bXzzz + 0: X + +/\D*/8 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + +/\D*/8 + \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100} + 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100} + +/\D/8 + 1X2 + 0: X + 1\x{100}2 + 0: \x{100} + +/>\S/8 + > >X Y + 0: >X + > >\x{100} Y + 0: >\x{100} + +/\d/8 + \x{100}3 + 0: 3 + +/\s/8 + \x{100} X + 0: + +/\D+/8 + 12abcd34 + 0: abcd + *** Failers + 0: *** Failers + 1234 +No match + +/\d+/8 + 12abcd34 + 0: 12 + *** Failers +No match + +/\d{2,3}/8 + 12abcd34 + 0: 12 + 1234abcd + 0: 123 + *** Failers +No match + 1.4 +No match + +/\S+/8 + 12abcd34 + 0: 12abcd34 + *** Failers + 0: *** + \ \ +No match + +/>\s+</8 + 12> <34 + 0: > < + *** Failers +No match + +/>\s{2,3}</8 + ab> <cd + 0: > < + ab> <ce + 0: > < + *** Failers +No match + ab> <cd +No match + +/>\s{2,3}?</8 + ab> <cd + 0: > < + ab> <ce + 0: > < + *** Failers +No match + ab> <cd +No match + +/\w+/8 + 12 34 + 0: 12 + *** Failers + 0: Failers + +++=*! +No match + +/\w{2,3}/8 + ab cd + 0: ab + abcd ce + 0: abc + *** Failers + 0: Fai + a.b.c +No match + +/\W+/8 + 12====34 + 0: ==== + *** Failers + 0: *** + abcd +No match + +/\W{2,3}/8 + ab====cd + 0: === + ab==cd + 0: == + *** Failers + 0: *** + a.b.c +No match + +/\W{2,3}?/8U + ab====cd + 0: === + ab==cd + 0: == + *** Failers + 0: *** + a.b.c +No match + +/[\x{100}]/8 + \x{100} + 0: \x{100} + Z\x{100} + 0: \x{100} + \x{100}Z + 0: \x{100} + *** Failers +No match + +/[Z\x{100}]/8 + Z\x{100} + 0: Z + \x{100} + 0: \x{100} + \x{100}Z + 0: \x{100} + *** Failers +No match + +/[\x{100}\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + *** Failers +No match + +/[\x{100}-\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{111}cd + 0: \x{111} + *** Failers +No match + +/[z-\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{111}cd + 0: \x{111} + abzcd + 0: z + ab|cd + 0: | + *** Failers +No match + +/[Q\x{100}\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + Q? + 0: Q + *** Failers +No match + +/[Q\x{100}-\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{111}cd + 0: \x{111} + Q? + 0: Q + *** Failers +No match + +/[Qz-\x{200}]/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{111}cd + 0: \x{111} + abzcd + 0: z + ab|cd + 0: | + Q? + 0: Q + *** Failers +No match + +/[\x{100}\x{200}]{1,3}/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{200}\x{100}\x{200}\x{100}cd + 0: \x{200}\x{100}\x{200} + *** Failers +No match + +/[\x{100}\x{200}]{1,3}?/8U + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{200}\x{100}\x{200}\x{100}cd + 0: \x{200}\x{100}\x{200} + *** Failers +No match + +/[Q\x{100}\x{200}]{1,3}/8 + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{200}\x{100}\x{200}\x{100}cd + 0: \x{200}\x{100}\x{200} + *** Failers +No match + +/[Q\x{100}\x{200}]{1,3}?/8U + ab\x{100}cd + 0: \x{100} + ab\x{200}cd + 0: \x{200} + ab\x{200}\x{100}\x{200}\x{100}cd + 0: \x{200}\x{100}\x{200} + *** Failers +No match + +/(?<=[\x{100}\x{200}])X/8 + abc\x{200}X + 0: X + abc\x{100}X + 0: X + *** Failers +No match + X +No match + +/(?<=[Q\x{100}\x{200}])X/8 + abc\x{200}X + 0: X + abc\x{100}X + 0: X + abQX + 0: X + *** Failers +No match + X +No match + +/(?<=[\x{100}\x{200}]{3})X/8 + abc\x{100}\x{200}\x{100}X + 0: X + *** Failers +No match + abc\x{200}X +No match + X +No match + +/[^\x{100}\x{200}]X/8 + AX + 0: AX + \x{150}X + 0: \x{150}X + \x{500}X + 0: \x{500}X + *** Failers +No match + \x{100}X +No match + \x{200}X +No match + +/[^Q\x{100}\x{200}]X/8 + AX + 0: AX + \x{150}X + 0: \x{150}X + \x{500}X + 0: \x{500}X + *** Failers +No match + \x{100}X +No match + \x{200}X +No match + QX +No match + +/[^\x{100}-\x{200}]X/8 + AX + 0: AX + \x{500}X + 0: \x{500}X + *** Failers +No match + \x{100}X +No match + \x{150}X +No match + \x{200}X +No match + +/[z-\x{100}]/8i + z + 0: z + Z + 0: Z + \x{100} + 0: \x{100} + *** Failers +No match + \x{102} +No match + y +No match + +/[\xFF]/ + >\xff< + 0: \xff + +/[\xff]/8 + >\x{ff}< + 0: \x{ff} + +/[^\xFF]/ + XYZ + 0: X + +/[^\xff]/8 + XYZ + 0: X + \x{123} + 0: \x{123} + +/^[ac]*b/8 + xb +No match + +/^[ac\x{100}]*b/8 + xb +No match + +/^[^x]*b/8i + xb +No match + +/^[^x]*b/8 + xb +No match + +/^\d*b/8 + xb +No match + +/^\x{85}$/8i + \x{85} + 0: \x{85} + +/^abc./mgx8<any> + abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK + 0: abc1 + 0: abc2 + 0: abc3 + 0: abc4 + 0: abc5 + 0: abc6 + 0: abc7 + 0: abc8 + 0: abc9 + +/abc.$/mgx8<any> + abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9 + 0: abc1 + 0: abc2 + 0: abc3 + 0: abc4 + 0: abc5 + 0: abc6 + 0: abc7 + 0: abc8 + 0: abc9 + +/^a\Rb/8<bsr_unicode> + a\nb + 0: a\x{0a}b + a\rb + 0: a\x{0d}b + a\r\nb + 0: a\x{0d}\x{0a}b + a\x0bb + 0: a\x{0b}b + a\x0cb + 0: a\x{0c}b + a\x{85}b + 0: a\x{85}b + a\x{2028}b + 0: a\x{2028}b + a\x{2029}b + 0: a\x{2029}b + ** Failers +No match + a\n\rb +No match + +/^a\R*b/8<bsr_unicode> + ab + 0: ab + a\nb + 0: a\x{0a}b + a\rb + 0: a\x{0d}b + a\r\nb + 0: a\x{0d}\x{0a}b + a\x0bb + 0: a\x{0b}b + a\x0c\x{2028}\x{2029}b + 0: a\x{0c}\x{2028}\x{2029}b + a\x{85}b + 0: a\x{85}b + a\n\rb + 0: a\x{0a}\x{0d}b + a\n\r\x{85}\x0cb + 0: a\x{0a}\x{0d}\x{85}\x{0c}b + +/^a\R+b/8<bsr_unicode> + a\nb + 0: a\x{0a}b + a\rb + 0: a\x{0d}b + a\r\nb + 0: a\x{0d}\x{0a}b + a\x0bb + 0: a\x{0b}b + a\x0c\x{2028}\x{2029}b + 0: a\x{0c}\x{2028}\x{2029}b + a\x{85}b + 0: a\x{85}b + a\n\rb + 0: a\x{0a}\x{0d}b + a\n\r\x{85}\x0cb + 0: a\x{0a}\x{0d}\x{85}\x{0c}b + ** Failers +No match + ab +No match + +/^a\R{1,3}b/8<bsr_unicode> + a\nb + 0: a\x{0a}b + a\n\rb + 0: a\x{0a}\x{0d}b + a\n\r\x{85}b + 0: a\x{0a}\x{0d}\x{85}b + a\r\n\r\nb + 0: a\x{0d}\x{0a}\x{0d}\x{0a}b + a\r\n\r\n\r\nb + 0: a\x{0d}\x{0a}\x{0d}\x{0a}\x{0d}\x{0a}b + a\n\r\n\rb + 0: a\x{0a}\x{0d}\x{0a}\x{0d}b + a\n\n\r\nb + 0: a\x{0a}\x{0a}\x{0d}\x{0a}b + ** Failers +No match + a\n\n\n\rb +No match + a\r +No match + +/\h+\V?\v{3,4}/8 + \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a + 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d} + +/\V?\v{3,4}/8 + \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a + 0: X\x{0a}\x{0b}\x{0c}\x{0d} + +/\h+\V?\v{3,4}/8 + >\x09\x20\x{a0}X\x0a\x0a\x0a< + 0: \x{09} \x{a0}X\x{0a}\x{0a}\x{0a} + +/\V?\v{3,4}/8 + >\x09\x20\x{a0}X\x0a\x0a\x0a< + 0: X\x{0a}\x{0a}\x{0a} + +/\H\h\V\v/8 + X X\x0a + 0: X X\x{0a} + X\x09X\x0b + 0: X\x{09}X\x{0b} + ** Failers +No match + \x{a0} X\x0a +No match + +/\H*\h+\V?\v{3,4}/8 + \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a + 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d} + \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a + 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d} + \x09\x20\x{a0}\x0a\x0b\x0c + 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c} + ** Failers +No match + \x09\x20\x{a0}\x0a\x0b +No match + +/\H\h\V\v/8 + \x{3001}\x{3000}\x{2030}\x{2028} + 0: \x{3001}\x{3000}\x{2030}\x{2028} + X\x{180e}X\x{85} + 0: X\x{180e}X\x{85} + ** Failers +No match + \x{2009} X\x0a +No match + +/\H*\h+\V?\v{3,4}/8 + \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a + 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d} + \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a + 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028} + \x09\x20\x{202f}\x0a\x0b\x0c + 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c} + ** Failers +No match + \x09\x{200a}\x{a0}\x{2028}\x0b +No match + +/a\Rb/I8<bsr_anycrlf> +Capturing subpattern count = 0 +Options: bsr_anycrlf utf8 +First char = 'a' +Need char = 'b' + a\rb + 0: a\x{0d}b + a\nb + 0: a\x{0a}b + a\r\nb + 0: a\x{0d}\x{0a}b + ** Failers +No match + a\x{85}b +No match + a\x0bb +No match + +/a\Rb/I8<bsr_unicode> +Capturing subpattern count = 0 +Options: bsr_unicode utf8 +First char = 'a' +Need char = 'b' + a\rb + 0: a\x{0d}b + a\nb + 0: a\x{0a}b + a\r\nb + 0: a\x{0d}\x{0a}b + a\x{85}b + 0: a\x{85}b + a\x0bb + 0: a\x{0b}b + ** Failers +No match + a\x{85}b\<bsr_anycrlf> +No match + a\x0bb\<bsr_anycrlf> +No match + +/a\R?b/I8<bsr_anycrlf> +Capturing subpattern count = 0 +Options: bsr_anycrlf utf8 +First char = 'a' +Need char = 'b' + a\rb + 0: a\x{0d}b + a\nb + 0: a\x{0a}b + a\r\nb + 0: a\x{0d}\x{0a}b + ** Failers +No match + a\x{85}b +No match + a\x0bb +No match + +/a\R?b/I8<bsr_unicode> +Capturing subpattern count = 0 +Options: bsr_unicode utf8 +First char = 'a' +Need char = 'b' + a\rb + 0: a\x{0d}b + a\nb + 0: a\x{0a}b + a\r\nb + 0: a\x{0d}\x{0a}b + a\x{85}b + 0: a\x{85}b + a\x0bb + 0: a\x{0b}b + ** Failers +No match + a\x{85}b\<bsr_anycrlf> +No match + a\x0bb\<bsr_anycrlf> +No match + +/ End of testinput 8 / diff --git a/lib/stdlib/test/re_testoutput1_replacement_test.erl b/lib/stdlib/test/re_testoutput1_replacement_test.erl index b20db3f9c3..69cb140e0d 100644 --- a/lib/stdlib/test/re_testoutput1_replacement_test.erl +++ b/lib/stdlib/test/re_testoutput1_replacement_test.erl @@ -1,23 +1,24 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(re_testoutput1_replacement_test). -compile(export_all). +-compile(no_native). -include("test_server.hrl"). %% This file is generated by running run_pcre_tests:gen_repl_test("re_SUITE_data/testoutput1") run() -> diff --git a/lib/stdlib/test/re_testoutput1_split_test.erl b/lib/stdlib/test/re_testoutput1_split_test.erl index 7e2d3f79ec..e86a04b008 100644 --- a/lib/stdlib/test/re_testoutput1_split_test.erl +++ b/lib/stdlib/test/re_testoutput1_split_test.erl @@ -1,23 +1,24 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(re_testoutput1_split_test). -compile(export_all). +-compile(no_native). -include("test_server.hrl"). %% This file is generated by running run_pcre_tests:gen_split_test("re_SUITE_data/testoutput1") join([]) -> []; diff --git a/lib/stdlib/test/run_pcre_tests.erl b/lib/stdlib/test/run_pcre_tests.erl index 0ef3986918..78b4803fc8 100644 --- a/lib/stdlib/test/run_pcre_tests.erl +++ b/lib/stdlib/test/run_pcre_tests.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(run_pcre_tests). @@ -25,7 +25,7 @@ test(RootDir) -> erts_debug:set_internal_state(available_internal_state,true), io:format("oldlimit: ~p~n",[ erts_debug:set_internal_state(re_loop_limit,10)]), Testfiles0 = ["testoutput1", "testoutput2", "testoutput3", "testoutput4", - "testoutput5", "testoutput6", "testoutput10"], + "testoutput5", "testoutput6","mod_testoutput8","testoutput10"], Testfiles = [ filename:join([RootDir,FN]) || FN <- Testfiles0 ], Res = [ begin io:format("~s~n",[X]), t(X) end || X <- Testfiles ], io:format("limit was: ~p~n",[ erts_debug:set_internal_state(re_loop_limit,default)]), @@ -42,12 +42,14 @@ t(OneFile,Num) -> put(error_limit,Num), put(skipped,0), Res = - [test(Structured,true,index), - test(Structured,false,index), - test(Structured,true,binary), - test(Structured,false,binary), - test(Structured,true,list), - test(Structured,false,list)], + [test(Structured,true,index,false), + test(Structured,false,index,false), + test(Structured,true,index,true), + test(Structured,false,index,true), + test(Structured,true,binary,false), + test(Structured,false,binary,false), + test(Structured,true,list,false), + test(Structured,false,list,false)], {lists:sum(Res),length(Structured)*6,get(skipped)}. @@ -63,11 +65,21 @@ pick_exec_options([Opt|T]) -> pick_exec_options([]) -> {[],[]}. -test([],_,_) -> +test([],_,_,_) -> 0; -test([{RE,Line,Options0,Tests}|T],PreCompile,XMode) -> +test([{RE0,Line,Options0,Tests}|T],PreCompile,XMode,REAsList) -> %io:format("."), %case RE of <<>> -> io:format("Empty re:~w~n",[Line]); _ -> ok end, + Unicode = lists:member(unicode,Options0), + RE = case REAsList of + true -> + if + Unicode -> unicode:characters_to_list(RE0); + true -> binary_to_list(RE0) + end; + false -> + RE0 + end, {Options,ExecOptions} = pick_exec_options(Options0), {Cres, Xopt} = case PreCompile of true -> @@ -80,7 +92,7 @@ test([{RE,Line,Options0,Tests}|T],PreCompile,XMode) -> %erlang:display({testrun,RE,P,Tests,ExecOptions,Xopt,XMode}), case (catch testrun(RE,P,Tests,ExecOptions,Xopt,XMode)) of N when is_integer(N) -> - N + test(T,PreCompile,XMode); + N + test(T,PreCompile,XMode,REAsList); limit -> io:format("Error limit reached.~n"), 1; @@ -91,12 +103,12 @@ test([{RE,Line,Options0,Tests}|T],PreCompile,XMode) -> _ -> put(skipped,1) end, - test(T,PreCompile,XMode) + test(T,PreCompile,XMode,REAsList) end; {error,Err} -> io:format("Compile error(~w): ~w~n",[Line,Err]), case get(error_limit) of - infinite -> 1 + test(T,PreCompile,XMode); + infinite -> 1 + test(T,PreCompile,XMode,REAsList); X -> case X-1 of Y when Y =< 0 -> @@ -104,7 +116,7 @@ test([{RE,Line,Options0,Tests}|T],PreCompile,XMode) -> 1; Y -> put(error_limit,Y), - 1 + test(T,PreCompile,XMode) + 1 + test(T,PreCompile,XMode,REAsList) end end end. @@ -549,6 +561,8 @@ tr_option($N) -> [no_auto_capture]; tr_option($8) -> [unicode]; +tr_option($U) -> + [ungreedy]; tr_option($g) -> [{exec_option,g}]; tr_option(_) -> @@ -973,6 +987,7 @@ gen_split_test(OneFile) -> {ok,F}= file:open(ErlFileName,[write]), io:format(F,"-module(~s).~n",[ErlModule]), io:format(F,"-compile(export_all).~n",[]), + io:format(F,"-compile(no_native).~n",[]), io:format(F,"-include(\"test_server.hrl\").~n",[]), %io:format(F,"-define(line,erlang:display(?LINE),).~n",[]), io:format(F,"%% This file is generated by running ~w:gen_split_test(~p)~n", @@ -1054,6 +1069,7 @@ gen_repl_test(OneFile) -> {ok,F}= file:open(ErlFileName,[write]), io:format(F,"-module(~s).~n",[ErlModule]), io:format(F,"-compile(export_all).~n",[]), + io:format(F,"-compile(no_native).~n",[]), io:format(F,"-include(\"test_server.hrl\").~n",[]), io:format(F,"%% This file is generated by running ~w:gen_repl_test(~p)~n", [?MODULE,OneFile]), diff --git a/lib/stdlib/test/select_SUITE.erl b/lib/stdlib/test/select_SUITE.erl index 54664fbb00..6900f1a8f5 100644 --- a/lib/stdlib/test/select_SUITE.erl +++ b/lib/stdlib/test/select_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2000-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -79,14 +79,14 @@ select_test(suite) -> []; select_test(doc) -> ["Tests select in numerous ways"]; -select_test(Config) when list(Config) -> +select_test(Config) when is_list(Config) -> do_test(Config). return_values(suite) -> []; return_values(doc) -> ["Tests return values in specific situations for select/3 and select/1"]; -return_values(Config) when list(Config) -> +return_values(Config) when is_list(Config) -> do_return_values(). -endif. @@ -279,7 +279,7 @@ cmp_ms_to_fun({Mod,Tab}, MS, Fun1, Fun2, ChunkSize) -> MSRes = lists:sort(chunked_select(Mod,Tab,MS,ChunkSize)), FunRes0 = table_foldl(Fun1,[],{Mod,Tab}), FunRes = case Fun2 of - F when function(F) -> + F when is_function(F) -> FunRes1 = table_foldl(F,[],{Mod,Tab}), lists:merge(FunRes0,FunRes1); [] -> diff --git a/lib/stdlib/test/shell_SUITE.erl b/lib/stdlib/test/shell_SUITE.erl index 5827d5f332..588342d46a 100644 --- a/lib/stdlib/test/shell_SUITE.erl +++ b/lib/stdlib/test/shell_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(shell_SUITE). @@ -28,13 +28,14 @@ progex/1, progex_bit_syntax/1, progex_records/1, progex_lc/1, progex_funs/1, tickets/1, otp_5990/1, otp_6166/1, otp_6554/1, otp_6785/1, - otp_7184/1, otp_7232/1]). + otp_7184/1, otp_7232/1, otp_8393/1]). -export([restricted/1, start_restricted_from_shell/1, start_restricted_on_command_line/1,restricted_local/1]). %% Internal export. --export([otp_5435_2/0]). +-export([otp_5435_2/0, prompt1/1, prompt2/1, prompt3/1, prompt4/1, + prompt5/1]). %% %% Define to run outside of test server @@ -2256,7 +2257,7 @@ progex_funs(Config) when is_list(Config) -> ok. tickets(suite) -> - [otp_5990, otp_6166, otp_6554, otp_6785, otp_7184, otp_7232]. + [otp_5990, otp_6166, otp_6554, otp_6785, otp_7184, otp_7232, otp_8393]. otp_5990(doc) -> "OTP-5990. {erlang,is_record}."; @@ -2598,6 +2599,93 @@ otp_7232(Config) when is_list(Config) -> " end}])" = evaluate(Info, []), ok. +otp_8393(doc) -> + "OTP-8393. Prompt string."; +otp_8393(suite) -> []; +otp_8393(Config) when is_list(Config) -> + ?line _ = shell:prompt_func(default), + ?line "Bad prompt function: '> '" = + prompt_err(<<"shell:prompt_func('> ').">>), + + ?line _ = shell:prompt_func(default), + ?line "exception error: bad argument in an arithmetic expression"++_ = + prompt_err(<<"shell:prompt_func({shell_SUITE,prompt4}).">>), + + ?line _ = shell:prompt_func(default), + ?line "default.\n" = + t(<<"shell:prompt_func({shell_SUITE,prompt2}).">>), + + ?line _ = shell:prompt_func(default), + ?line "default\nl.\n" = + t(<<"shell:prompt_func({shell_SUITE,prompt3}). l.">>), + + %% + %% Although this tests that you can set a unicode prompt function + %% it does not really test that it does work with the io-servers. + %% That is instead tested in the io_proto_SUITE, which has + %% the right infrastructure in place for such tests. /PaN + %% + ?line _ = shell:prompt_func(default), + ?line "default\nl.\n" = + t(<<"shell:prompt_func({shell_SUITE,prompt5}). l.">>), + + %% Restricted shell. + Contents = <<"-module(test_restricted_shell). + -export([local_allowed/3, non_local_allowed/3]). + local_allowed(_,_,State) -> + {false,State}. + + non_local_allowed({shell,stop_restricted},[],State) -> + {true,State}; + non_local_allowed({shell,prompt_func},[_L],State) -> + {true,State}; + non_local_allowed({shell_SUITE,prompt1},[_L],State) -> + {true,State}; + non_local_allowed(_,_,State) -> + {false,State}. + ">>, + ?line Test = filename:join(?config(priv_dir, Config), + "test_restricted_shell.erl"), + ?line ok = compile_file(Config, Test, Contents, []), + ?line _ = shell:prompt_func(default), + ?line "exception exit: restricted shell starts now" = + comm_err(<<"begin shell:start_restricted(" + "test_restricted_shell) end.">>), + ?line "default.\n"++_ = + t(<<"shell:prompt_func({shell_SUITE,prompt1}).">>), + ?line "exception exit: restricted shell does not allow apple(" ++ _ = + comm_err(<<"apple(1).">>), + ?line "{shell_SUITE,prompt1}.\n" = + t(<<"shell:prompt_func(default).">>), + ?line "exception exit: restricted shell stopped"= + comm_err(<<"begin shell:stop_restricted() end.">>), + ?line undefined = + application:get_env(stdlib, restricted_shell), + + ?line NR = shell:results(20), + ?line "default\n20.\n" = + t(<<"shell:prompt_func({shell_SUITE,prompt3}). results(0).">>), + + ?line _ = shell:prompt_func(default), + ?line 0 = shell:results(NR), + ok. + +prompt1(_L) -> + "prompt> ". + +prompt2(_L) -> + {'EXIT', []}. + +prompt3(L) -> + N = proplists:get_value(history, L), + integer_to_list(N). + +prompt4(_L) -> + erlang:apply({erlang,'/'}, [1,0]). + +prompt5(_L) -> + [1050,1072,1082,1074,1086,32,1077,32,85,110,105,99,111,100,101,32,63]. + -ifdef(not_used). exit_term(B) -> "** exception exit:" ++ Reply = t(B), @@ -2627,7 +2715,16 @@ comm_err(B) -> Reply = t(B), S0 = string:left(Reply, string:chr(Reply, $\n)-1), S1 = string:strip(S0, left, $*), - S2 = string:strip(S1, both, $ ), + S2 = string:strip(S1, both, $ ), + S = string:strip(S2, both, $"), + string:strip(S, right, $.). + +prompt_err(B) -> + Reply = t(B), + S00 = string:sub_string(Reply, string:chr(Reply, $\n)+1), + S0 = string:left(S00, string:chr(S00, $\n)-1), + S1 = string:strip(S0, left, $*), + S2 = string:strip(S1, both, $ ), S = string:strip(S2, both, $"), string:strip(S, right, $.). diff --git a/lib/stdlib/test/slave_SUITE.erl b/lib/stdlib/test/slave_SUITE.erl index 3b737af64d..5c1282fe9b 100644 --- a/lib/stdlib/test/slave_SUITE.erl +++ b/lib/stdlib/test/slave_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(slave_SUITE). @@ -31,7 +31,7 @@ all(suite) -> [t_start_link, start_link_nodedown, t_start, errors]. t_start_link(suite) -> []; -t_start_link(Config) when list(Config) -> +t_start_link(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(20)), %% Define useful variables. @@ -81,7 +81,7 @@ t_start_link(Config) when list(Config) -> %% Test that slave:start_link() works when the master exits. start_link_nodedown(suite) -> []; -start_link_nodedown(Config) when list(Config) -> +start_link_nodedown(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(20)), %% Define useful variables. @@ -109,7 +109,7 @@ start_a_slave(ReplyTo, Host, Name) -> %% Test slave:start(). t_start(suite) -> []; -t_start(Config) when list(Config) -> +t_start(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(20)), %% Define useful variables. @@ -160,7 +160,7 @@ t_start(Config) when list(Config) -> %% in slave is 32 seconds). errors(suite) -> []; -errors(Config) when list(Config) -> +errors(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(50)), ?line process_flag(trap_exit, true), diff --git a/lib/stdlib/test/sofs_SUITE.erl b/lib/stdlib/test/sofs_SUITE.erl index 0849e0f59c..d60cfc6895 100644 --- a/lib/stdlib/test/sofs_SUITE.erl +++ b/lib/stdlib/test/sofs_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(sofs_SUITE). @@ -115,7 +115,7 @@ sofs(suite) -> from_term_1(suite) -> []; from_term_1(doc) -> [""]; -from_term_1(Conf) when list(Conf) -> +from_term_1(Conf) when is_list(Conf) -> %% would go wrong: projection(1,from_term([{2,b},{1,a,b}])), ?line {'EXIT', {badarg, _}} = (catch from_term([], {atom,'_',atom})), @@ -203,7 +203,7 @@ from_term_1(Conf) when list(Conf) -> set_1(suite) -> []; set_1(doc) -> [""]; -set_1(Conf) when list(Conf) -> +set_1(Conf) when is_list(Conf) -> %% set/1 ?line {'EXIT', {badarg, _}} = (catch set(a)), ?line {'EXIT', {badarg, _}} = (catch set({a})), @@ -235,7 +235,7 @@ set_1(Conf) when list(Conf) -> from_sets_1(suite) -> []; from_sets_1(doc) -> [""]; -from_sets_1(Conf) when list(Conf) -> +from_sets_1(Conf) when is_list(Conf) -> ?line E = empty_set(), %% unordered @@ -272,7 +272,7 @@ from_sets_1(Conf) when list(Conf) -> relation_1(suite) -> []; relation_1(doc) -> [""]; -relation_1(Conf) when list(Conf) -> +relation_1(Conf) when is_list(Conf) -> %% relation/1 ?line eval(relation([]), from_term([], [{atom,atom}])), ?line eval(from_term([{a}]), relation([{a}])), @@ -305,7 +305,7 @@ relation_1(Conf) when list(Conf) -> a_function_1(suite) -> []; a_function_1(doc) -> [""]; -a_function_1(Conf) when list(Conf) -> +a_function_1(Conf) when is_list(Conf) -> %% a_function/1 ?line eval(a_function([]), from_term([], [{atom,atom}])), ?line eval(a_function([{a,b},{a,b},{b,c}]), from_term([{a,b},{b,c}])), @@ -352,7 +352,7 @@ a_function_1(Conf) when list(Conf) -> family_1(suite) -> []; family_1(doc) -> [""]; -family_1(Conf) when list(Conf) -> +family_1(Conf) when is_list(Conf) -> %% family/1 ?line eval(family([]), from_term([],[{atom,[atom]}])), ?line {'EXIT', {badarg, _}} = (catch family(a)), @@ -413,7 +413,7 @@ family_1(Conf) when list(Conf) -> projection(suite) -> []; projection(doc) -> [""]; -projection(Conf) when list(Conf) -> +projection(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), @@ -535,7 +535,7 @@ projection(Conf) when list(Conf) -> substitution(suite) -> []; substitution(doc) -> [""]; -substitution(Conf) when list(Conf) -> +substitution(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), @@ -633,7 +633,7 @@ substitution(Conf) when list(Conf) -> restriction(suite) -> []; restriction(doc) -> [""]; -restriction(Conf) when list(Conf) -> +restriction(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), @@ -752,7 +752,7 @@ restriction(Conf) when list(Conf) -> drestriction(suite) -> []; drestriction(doc) -> [""]; -drestriction(Conf) when list(Conf) -> +drestriction(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), @@ -869,7 +869,7 @@ drestriction(Conf) when list(Conf) -> strict_relation_1(suite) -> []; strict_relation_1(doc) -> [""]; -strict_relation_1(Conf) when list(Conf) -> +strict_relation_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), ?line eval(strict_relation(E), E), @@ -890,7 +890,7 @@ strict_relation_1(Conf) when list(Conf) -> extension(suite) -> []; extension(doc) -> [""]; -extension(Conf) when list(Conf) -> +extension(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), ?line EF = family([]), @@ -933,7 +933,7 @@ lextension(R, S, C) -> weak_relation_1(suite) -> []; weak_relation_1(doc) -> [""]; -weak_relation_1(Conf) when list(Conf) -> +weak_relation_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), ?line eval(weak_relation(E), E), @@ -966,7 +966,7 @@ weak_relation_1(Conf) when list(Conf) -> to_sets_1(suite) -> []; to_sets_1(doc) -> [""]; -to_sets_1(Conf) when list(Conf) -> +to_sets_1(Conf) when is_list(Conf) -> ?line {'EXIT', {badarg, _}} = (catch to_sets(from_term(a))), ?line {'EXIT', {function_clause, _}} = (catch to_sets(a)), %% unordered @@ -988,8 +988,8 @@ to_sets_1(Conf) when list(Conf) -> specification(suite) -> []; specification(doc) -> [""]; -specification(Conf) when list(Conf) -> - Fun = {external, fun(I) when integer(I) -> true; (_) -> false end}, +specification(Conf) when is_list(Conf) -> + Fun = {external, fun(I) when is_integer(I) -> true; (_) -> false end}, ?line [1,2,3] = to_external(specification(Fun, set([a,1,b,2,c,3]))), Fun2 = fun(S) -> is_subset(S, set([1,3,5,7,9])) end, @@ -1014,7 +1014,7 @@ specification(Conf) when list(Conf) -> union_1(suite) -> []; union_1(doc) -> [""]; -union_1(Conf) when list(Conf) -> +union_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), ?line {'EXIT', {badarg, _}} = (catch union(ER)), @@ -1044,7 +1044,7 @@ union_1(Conf) when list(Conf) -> intersection_1(suite) -> []; intersection_1(doc) -> [""]; -intersection_1(Conf) when list(Conf) -> +intersection_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {badarg, _}} = (catch intersection(from_term([a,b]))), ?line {'EXIT', {badarg, _}} = (catch intersection(E)), @@ -1068,7 +1068,7 @@ intersection_1(Conf) when list(Conf) -> difference(suite) -> []; difference(doc) -> [""]; -difference(Conf) when list(Conf) -> +difference(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {type_mismatch, _}} = (catch difference(relation([{a,b}]), relation([{a,b,c}]))), @@ -1089,7 +1089,7 @@ difference(Conf) when list(Conf) -> symdiff(suite) -> []; symdiff(doc) -> [""]; -symdiff(Conf) when list(Conf) -> +symdiff(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {type_mismatch, _}} = (catch symdiff(relation([{a,b}]), relation([{a,b,c}]))), @@ -1114,7 +1114,7 @@ symdiff(Conf) when list(Conf) -> symmetric_partition(suite) -> []; symmetric_partition(doc) -> [""]; -symmetric_partition(Conf) when list(Conf) -> +symmetric_partition(Conf) when is_list(Conf) -> ?line E = set([]), ?line S1 = set([1,2,3,4]), ?line S2 = set([3,4,5,6]), @@ -1148,7 +1148,7 @@ symmetric_partition(Conf) when list(Conf) -> is_sofs_set_1(suite) -> []; is_sofs_set_1(doc) -> [""]; -is_sofs_set_1(Conf) when list(Conf) -> +is_sofs_set_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line true = is_sofs_set(E), ?line true = is_sofs_set(from_term([a])), @@ -1159,7 +1159,7 @@ is_sofs_set_1(Conf) when list(Conf) -> is_set_1(suite) -> []; is_set_1(doc) -> [""]; -is_set_1(Conf) when list(Conf) -> +is_set_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line true = is_set(E), ?line true = is_set(from_term([a])), @@ -1177,7 +1177,7 @@ is_set_1(Conf) when list(Conf) -> is_equal(suite) -> []; is_equal(doc) -> [""]; -is_equal(Conf) when list(Conf) -> +is_equal(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line true = is_equal(E, E), ?line false = is_equal(from_term([a]), E), @@ -1212,7 +1212,7 @@ is_equal(Conf) when list(Conf) -> is_subset(suite) -> []; is_subset(doc) -> [""]; -is_subset(Conf) when list(Conf) -> +is_subset(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line true = is_subset(E, E), ?line true = is_subset(set([a,c,e]), set([a,b,c,d,e])), @@ -1230,7 +1230,7 @@ is_subset(Conf) when list(Conf) -> is_a_function_1(suite) -> []; is_a_function_1(doc) -> [""]; -is_a_function_1(Conf) when list(Conf) -> +is_a_function_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([], 2), ?line {'EXIT', {badarg, _}} = (catch is_a_function(set([a,b]))), @@ -1254,7 +1254,7 @@ is_a_function_1(Conf) when list(Conf) -> is_disjoint(suite) -> []; is_disjoint(doc) -> [""]; -is_disjoint(Conf) when list(Conf) -> +is_disjoint(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {type_mismatch, _}} = (catch is_disjoint(relation([{a,1}]), set([a,b]))), @@ -1268,7 +1268,7 @@ is_disjoint(Conf) when list(Conf) -> join(suite) -> []; join(doc) -> [""]; -join(Conf) when list(Conf) -> +join(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {badarg, _}} = (catch join(relation([{a,1}]), 3, E, 5)), @@ -1306,7 +1306,7 @@ join(Conf) when list(Conf) -> canonical(suite) -> []; canonical(doc) -> [""]; -canonical(Conf) when list(Conf) -> +canonical(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line {'EXIT', {badarg, _}} = (catch canonical_relation(set([a,b]))), @@ -1318,7 +1318,7 @@ canonical(Conf) when list(Conf) -> relation_to_family_1(suite) -> []; relation_to_family_1(doc) -> [""]; -relation_to_family_1(Conf) when list(Conf) -> +relation_to_family_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line eval(relation_to_family(E), E), @@ -1333,7 +1333,7 @@ relation_to_family_1(Conf) when list(Conf) -> domain_1(suite) -> []; domain_1(doc) -> [""]; -domain_1(Conf) when list(Conf) -> +domain_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line {'EXIT', {badarg, _}} = (catch domain(relation([],3))), @@ -1355,7 +1355,7 @@ domain_1(Conf) when list(Conf) -> range_1(suite) -> []; range_1(doc) -> [""]; -range_1(Conf) when list(Conf) -> +range_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line {'EXIT', {badarg, _}} = (catch range(relation([],3))), @@ -1367,7 +1367,7 @@ range_1(Conf) when list(Conf) -> inverse_1(suite) -> []; inverse_1(doc) -> [""]; -inverse_1(Conf) when list(Conf) -> +inverse_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line {'EXIT', {badarg, _}} = (catch inverse(relation([],3))), @@ -1391,7 +1391,7 @@ inverse_1(Conf) when list(Conf) -> converse_1(suite) -> []; converse_1(doc) -> [""]; -converse_1(Conf) when list(Conf) -> +converse_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line {'EXIT', {badarg, _}} = (catch converse(relation([],3))), @@ -1407,7 +1407,7 @@ converse_1(Conf) when list(Conf) -> no_elements_1(suite) -> []; no_elements_1(doc) -> [""]; -no_elements_1(Conf) when list(Conf) -> +no_elements_1(Conf) when is_list(Conf) -> ?line 0 = no_elements(empty_set()), ?line 0 = no_elements(set([])), ?line 1 = no_elements(from_term([a])), @@ -1419,7 +1419,7 @@ no_elements_1(Conf) when list(Conf) -> image(suite) -> []; image(doc) -> [""]; -image(Conf) when list(Conf) -> +image(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line eval(image(E, E), E), @@ -1441,7 +1441,7 @@ image(Conf) when list(Conf) -> inverse_image(suite) -> []; inverse_image(doc) -> [""]; -inverse_image(Conf) when list(Conf) -> +inverse_image(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line eval(inverse_image(E, E), E), @@ -1468,7 +1468,7 @@ inverse_image(Conf) when list(Conf) -> composite_1(suite) -> []; composite_1(doc) -> [""]; -composite_1(Conf) when list(Conf) -> +composite_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = a_function([]), ?line eval(composite(E, E), E), @@ -1520,7 +1520,7 @@ composite_1(Conf) when list(Conf) -> relative_product_1(suite) -> []; relative_product_1(doc) -> [""]; -relative_product_1(Conf) when list(Conf) -> +relative_product_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line eval(relative_product1(E, E), E), @@ -1548,7 +1548,7 @@ relative_product_1(Conf) when list(Conf) -> relative_product_2(suite) -> []; relative_product_2(doc) -> [""]; -relative_product_2(Conf) when list(Conf) -> +relative_product_2(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), @@ -1597,7 +1597,7 @@ relative_product_2(Conf) when list(Conf) -> product_1(suite) -> []; product_1(doc) -> [""]; -product_1(Conf) when list(Conf) -> +product_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line eval(product(E, E), E), ?line eval(product(relation([]), E), E), @@ -1625,7 +1625,7 @@ product_1(Conf) when list(Conf) -> partition_1(suite) -> []; partition_1(doc) -> [""]; -partition_1(Conf) when list(Conf) -> +partition_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line Id = fun(A) -> A end, @@ -1671,7 +1671,7 @@ partition_1(Conf) when list(Conf) -> partition_3(suite) -> []; partition_3(doc) -> [""]; -partition_3(Conf) when list(Conf) -> +partition_3(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), @@ -1818,7 +1818,7 @@ lpartition(F, S1, S2) -> multiple_relative_product(suite) -> []; multiple_relative_product(doc) -> [""]; -multiple_relative_product(Conf) when list(Conf) -> +multiple_relative_product(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line T = relation([{a,1},{a,11},{b,2},{c,3},{c,33},{d,4}]), @@ -1842,7 +1842,7 @@ multiple_relative_product(Conf) when list(Conf) -> digraph(suite) -> []; digraph(doc) -> [""]; -digraph(Conf) when list(Conf) -> +digraph(Conf) when is_list(Conf) -> ?line T0 = ets:all(), ?line E = empty_set(), ?line R = relation([{a,b},{b,c},{c,d},{d,a}]), @@ -1901,7 +1901,7 @@ digraph(Conf) when list(Conf) -> constant_function(suite) -> []; constant_function(doc) -> [""]; -constant_function(Conf) when list(Conf) -> +constant_function(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line C = from_term(3), ?line eval(constant_function(E, C), E), @@ -1913,7 +1913,7 @@ constant_function(Conf) when list(Conf) -> misc(suite) -> []; misc(doc) -> [""]; -misc(Conf) when list(Conf) -> +misc(Conf) when is_list(Conf) -> % find "relational" part of relation: ?line S = relation([{a,b},{b,c},{b,d},{c,d}]), Id = fun(A) -> A end, @@ -1943,7 +1943,7 @@ sofs_family(suite) -> family_specification(suite) -> []; family_specification(doc) -> [""]; -family_specification(Conf) when list(Conf) -> +family_specification(Conf) when is_list(Conf) -> E = empty_set(), %% internal ?line eval(family_specification({sofs, is_set}, E), E), @@ -1963,7 +1963,7 @@ family_specification(Conf) when list(Conf) -> (catch family_specification(Fun3, F3)), %% external - IsList = {external, fun(L) when list(L) -> true; (_) -> false end}, + IsList = {external, fun(L) when is_list(L) -> true; (_) -> false end}, ?line eval(family_specification(IsList, E), E), ?line eval(family_specification(IsList, F1), F1), MF = {external, fun(L) -> lists:member(3, L) end}, @@ -1975,7 +1975,7 @@ family_specification(Conf) when list(Conf) -> family_domain_1(suite) -> []; family_domain_1(doc) -> [""]; -family_domain_1(Conf) when list(Conf) -> +family_domain_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]), ?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]), @@ -2001,7 +2001,7 @@ family_domain_1(Conf) when list(Conf) -> family_range_1(suite) -> []; family_range_1(doc) -> [""]; -family_range_1(Conf) when list(Conf) -> +family_range_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]), ?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]), @@ -2023,7 +2023,7 @@ family_range_1(Conf) when list(Conf) -> family_to_relation_1(suite) -> []; family_to_relation_1(doc) -> [""]; -family_to_relation_1(Conf) when list(Conf) -> +family_to_relation_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line ER = relation([]), ?line EF = family([]), @@ -2037,7 +2037,7 @@ family_to_relation_1(Conf) when list(Conf) -> union_of_family_1(suite) -> []; union_of_family_1(doc) -> [""]; -union_of_family_1(Conf) when list(Conf) -> +union_of_family_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]), ?line eval(union_of_family(E), E), @@ -2052,7 +2052,7 @@ union_of_family_1(Conf) when list(Conf) -> intersection_of_family_1(suite) -> []; intersection_of_family_1(doc) -> [""]; -intersection_of_family_1(Conf) when list(Conf) -> +intersection_of_family_1(Conf) when is_list(Conf) -> ?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]), ?line eval(intersection_of_family(EF), set([])), ?line FR = from_term([{a,[1,2,3]},{b,[2,3]},{c,[3,4,5]}]), @@ -2066,7 +2066,7 @@ intersection_of_family_1(Conf) when list(Conf) -> family_projection(suite) -> []; family_projection(doc) -> [""]; -family_projection(Conf) when list(Conf) -> +family_projection(Conf) when is_list(Conf) -> SSType = [{atom,[[atom]]}], SRType = [{atom,[{atom,atom}]}], ?line E = empty_set(), @@ -2127,7 +2127,7 @@ family_projection(Conf) when list(Conf) -> family_difference(suite) -> []; family_difference(doc) -> [""]; -family_difference(Conf) when list(Conf) -> +family_difference(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line F9 = from_term([{b,[b,c]}]), @@ -2164,7 +2164,7 @@ family_difference(Conf) when list(Conf) -> family_intersection_1(suite) -> []; family_intersection_1(doc) -> [""]; -family_intersection_1(Conf) when list(Conf) -> +family_intersection_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line ES = from_term([], [{atom,[[atom]]}]), @@ -2184,7 +2184,7 @@ family_intersection_1(Conf) when list(Conf) -> family_intersection_2(suite) -> []; family_intersection_2(doc) -> [""]; -family_intersection_2(Conf) when list(Conf) -> +family_intersection_2(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line F1 = from_term([{a,[1,2]},{b,[4,5]},{c,[7,8]},{d,[10,11]}]), @@ -2215,7 +2215,7 @@ family_intersection_2(Conf) when list(Conf) -> family_union_1(suite) -> []; family_union_1(doc) -> [""]; -family_union_1(Conf) when list(Conf) -> +family_union_1(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line ES = from_term([], [{atom,[[atom]]}]), @@ -2230,7 +2230,7 @@ family_union_1(Conf) when list(Conf) -> family_union_2(suite) -> []; family_union_2(doc) -> [""]; -family_union_2(Conf) when list(Conf) -> +family_union_2(Conf) when is_list(Conf) -> ?line E = empty_set(), ?line EF = family([]), ?line F1 = from_term([{a,[1,2]},{b,[4,5]},{c,[7,8]},{d,[10,11]}]), @@ -2259,7 +2259,7 @@ family_union_2(Conf) when list(Conf) -> partition_family(suite) -> []; partition_family(doc) -> [""]; -partition_family(Conf) when list(Conf) -> +partition_family(Conf) when is_list(Conf) -> ?line E = empty_set(), %% set of ordered sets diff --git a/lib/stdlib/test/supervisor_SUITE.erl b/lib/stdlib/test/supervisor_SUITE.erl index b5d9ca44bf..039ea298c4 100644 --- a/lib/stdlib/test/supervisor_SUITE.erl +++ b/lib/stdlib/test/supervisor_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Description: Tests supervisor.erl @@ -50,7 +50,7 @@ simple_one_for_one_extra/1]). %% Misc tests --export([child_unlink/1, tree/1]). +-export([child_unlink/1, tree/1, count_children_memory/1]). %------------------------------------------------------------------------- @@ -60,7 +60,8 @@ all(suite) -> child_adm_simple, extra_return, child_specs, restart_one_for_one, restart_one_for_all, restart_simple_one_for_one, restart_rest_for_one, - normal_termination, abnormal_termination, child_unlink, tree]}. + normal_termination, abnormal_termination, child_unlink, tree, + count_children_memory]}. start(InitResult) -> @@ -72,6 +73,15 @@ init(fail) -> init(InitResult) -> InitResult. +%% Respect proplist return of supervisor:count_children +get_child_counts(Supervisor) -> + Counts = supervisor:count_children(Supervisor), + [proplists:get_value(specs, Counts), + proplists:get_value(active, Counts), + proplists:get_value(supervisors, Counts), + proplists:get_value(workers, Counts)]. + + %------------------------------------------------------------------------- % % Test cases starts here. @@ -89,7 +99,7 @@ sup_start_normal(doc) -> ["Tests that the supervisor process starts correctly and that it " "can be terminated gracefully."]; sup_start_normal(suite) -> []; -sup_start_normal(Config) when list(Config) -> +sup_start_normal(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), ?line exit(Pid, shutdown), @@ -107,7 +117,7 @@ sup_start_normal(Config) when list(Config) -> sup_start_ignore_init(doc) -> ["Tests what happens if init-callback returns ignore"]; sup_start_ignore_init(suite) -> []; -sup_start_ignore_init(Config) when list(Config) -> +sup_start_ignore_init(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line ignore = start(ignore), @@ -127,7 +137,7 @@ sup_start_ignore_init(Config) when list(Config) -> sup_start_ignore_child(doc) -> ["Tests what happens if init-callback returns ignore"]; sup_start_ignore_child(suite) -> []; -sup_start_ignore_child(Config) when list(Config) -> +sup_start_ignore_child(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, [ignore]}, @@ -140,13 +150,15 @@ sup_start_ignore_child(Config) when list(Config) -> ?line [{child2, CPid2, worker, []},{child1, undefined, worker, []}] = supervisor:which_children(sup_test), + ?line [2,1,0,2] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- sup_start_error_return(doc) -> ["Tests what happens if init-callback returns a invalid value"]; sup_start_error_return(suite) -> []; -sup_start_error_return(Config) when list(Config) -> +sup_start_error_return(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {error, Term} = start(invalid), @@ -165,7 +177,7 @@ sup_start_error_return(Config) when list(Config) -> sup_start_fail(doc) -> ["Tests what happens if init-callback fails"]; sup_start_fail(suite) -> []; -sup_start_fail(Config) when list(Config) -> +sup_start_fail(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {error, Term} = start(fail), @@ -192,7 +204,7 @@ sup_stop_infinity(doc) -> "for children of type supervisor"]; sup_stop_infinity(suite) -> []; -sup_stop_infinity(Config) when list(Config) -> +sup_stop_infinity(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, @@ -230,7 +242,7 @@ sup_stop_timeout(doc) -> ["See sup_stop/1 when Shutdown = 1000"]; sup_stop_timeout(suite) -> []; -sup_stop_timeout(Config) when list(Config) -> +sup_stop_timeout(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, @@ -278,7 +290,7 @@ sup_stop_brutal_kill(doc) -> ["See sup_stop/1 when Shutdown = brutal_kill"]; sup_stop_brutal_kill(suite) -> []; -sup_stop_brutal_kill(Config) when list(Config) -> +sup_stop_brutal_kill(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, @@ -327,7 +339,7 @@ extra_return(doc) -> "and restart_child/2"]; extra_return(suite) -> []; -extra_return(Config) when list(Config) -> +extra_return(Config) when is_list(Config) -> process_flag(trap_exit, true), Child = {child1, {supervisor_1, start_child, [extra_return]}, permanent, 1000, @@ -341,6 +353,8 @@ extra_return(Config) when list(Config) -> ?line {error, running} = supervisor:delete_child(sup_test, child1), ?line {error, running} = supervisor:restart_child(sup_test, child1), ?line [{child1, CPid, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), + ?line ok = supervisor:terminate_child(sup_test, child1), receive {'EXIT', CPid, shutdown} -> ok; @@ -350,29 +364,39 @@ extra_return(Config) when list(Config) -> ?line test_server:fail(no_child_termination) end, ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test), + ?line [1,0,0,1] = get_child_counts(sup_test), + ?line {ok, CPid2,extra_return} = supervisor:restart_child(sup_test, child1), ?line [{child1, CPid2, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), + ?line ok = supervisor:terminate_child(sup_test, child1), ?line ok = supervisor:terminate_child(sup_test, child1), ?line ok = supervisor:delete_child(sup_test, child1), ?line {error, not_found} = supervisor:restart_child(sup_test, child1), ?line [] = supervisor:which_children(sup_test), + ?line [0,0,0,0] = get_child_counts(sup_test), + ?line {ok, CPid3, extra_return} = supervisor:start_child(sup_test, Child), ?line [{child1, CPid3, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- child_adm(doc)-> ["Test API functions start_child/2, terminate_child/2, delete_child/2 " - "restart_child/2, which_children/1. Only correct childspecs are used, " - "handling of incorrect childspecs is tested in child_specs/1"]; + "restart_child/2, which_children/1, count_children/1. Only correct " + "childspecs are used, handling of incorrect childspecs is tested in " + "child_specs/1"]; child_adm(suite) -> []; -child_adm(Config) when list(Config) -> +child_adm(Config) when is_list(Config) -> process_flag(trap_exit, true), Child = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, ?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, [Child]}}), ?line [{child1, CPid, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), link(CPid), %% Start of an already runnig process @@ -392,6 +416,7 @@ child_adm(Config) when list(Config) -> ?line test_server:fail(no_child_termination) end, ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test), + ?line [1,0,0,1] = get_child_counts(sup_test), %% Like deleting something that does not exist, it will succeed! ?line ok = supervisor:terminate_child(sup_test, child1), @@ -402,6 +427,7 @@ child_adm(Config) when list(Config) -> %% Restart ?line {ok, CPid2} = supervisor:restart_child(sup_test, child1), ?line [{child1, CPid2, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), ?line {error, running} = supervisor:restart_child(sup_test, child1), ?line {error, not_found} = supervisor:restart_child(sup_test, child2), @@ -414,15 +440,19 @@ child_adm(Config) when list(Config) -> ?line ok = supervisor:delete_child(sup_test, child1), ?line {error, not_found} = supervisor:restart_child(sup_test, child1), ?line [] = supervisor:which_children(sup_test), + ?line [0,0,0,0] = get_child_counts(sup_test), %% Start ?line {'EXIT',{noproc,{gen_server,call, _}}} = (catch supervisor:start_child(foo, Child)), ?line {ok, CPid3} = supervisor:start_child(sup_test, Child), ?line [{child1, CPid3, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), ?line {'EXIT',{noproc,{gen_server,call,[foo,which_children,infinity]}}} = (catch supervisor:which_children(foo)), + ?line {'EXIT',{noproc,{gen_server,call,[foo,count_children,infinity]}}} + = (catch supervisor:count_children(foo)), ok. %------------------------------------------------------------------------- child_adm_simple(doc) -> @@ -430,12 +460,13 @@ child_adm_simple(doc) -> "restart_child/2 are not valid for a simple_one_for_one supervisor " "check that the correct error message is returned."]; child_adm_simple(suite) -> []; -child_adm_simple(Config) when list(Config) -> +child_adm_simple(Config) when is_list(Config) -> Child = {child, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, ?line {ok, _Pid} = start({ok, {{simple_one_for_one, 2, 3600}, [Child]}}), %% In simple_one_for_one all children are added dynamically ?line [] = supervisor:which_children(sup_test), + ?line [1,0,0,0] = get_child_counts(sup_test), %% Start ?line {'EXIT',{noproc,{gen_server,call, _}}} = @@ -443,12 +474,14 @@ child_adm_simple(Config) when list(Config) -> ?line {ok, CPid1} = supervisor:start_child(sup_test, []), ?line [{undefined, CPid1, worker, []}] = supervisor:which_children(sup_test), + ?line [1,1,0,1] = get_child_counts(sup_test), ?line {ok, CPid2} = supervisor:start_child(sup_test, []), ?line Children = supervisor:which_children(sup_test), ?line 2 = length(Children), ?line true = lists:member({undefined, CPid2, worker, []}, Children), ?line true = lists:member({undefined, CPid1, worker, []}, Children), + ?line [1,2,0,2] = get_child_counts(sup_test), %% Termination ?line {error, simple_one_for_one} = @@ -467,7 +500,7 @@ child_adm_simple(Config) when list(Config) -> child_specs(doc) -> ["Tests child specs, invalid formats should be rejected."]; child_specs(suite) -> []; -child_specs(Config) when list(Config) -> +child_specs(Config) when is_list(Config) -> process_flag(trap_exit, true), ?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, []}}), ?line {error, _} = supervisor:start_child(sup_test, hej), @@ -526,7 +559,7 @@ normal_termination(suite) -> permanent_normal(doc) -> ["A permanent child should always be restarted"]; permanent_normal(suite) -> []; -permanent_normal(Config) when list(Config) -> +permanent_normal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -541,14 +574,16 @@ permanent_normal(Config) when list(Config) -> ok; false -> ?line test_server:fail({permanent_child_not_restarted, Child1}) - end. + end, + ?line [1,1,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- transient_normal(doc) -> ["A transient child should not be restarted if it exits with " "reason normal"]; transient_normal(suite) -> []; -transient_normal(Config) when list(Config) -> +transient_normal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, transient, 1000, worker, []}, @@ -558,13 +593,15 @@ transient_normal(Config) when list(Config) -> CPid1 ! stop, test_server:sleep(100), - ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test). + ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test), + ?line [1,0,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- temporary_normal(doc) -> ["A temporary process should never be restarted"]; temporary_normal(suite) -> []; -temporary_normal(Config) when list(Config) -> +temporary_normal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, temporary, 1000, worker, []}, @@ -574,8 +611,10 @@ temporary_normal(Config) when list(Config) -> CPid1 ! stop, test_server:sleep(100), - ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test). + ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test), + ?line [1,0,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- abnormal_termination(doc) -> ["Testes the supervisors behaviour if a child dies with reason abnormal"]; @@ -586,7 +625,7 @@ abnormal_termination(suite) -> permanent_abnormal(doc) -> ["A permanent child should always be restarted"]; permanent_abnormal(suite) -> []; -permanent_abnormal(Config) when list(Config) -> +permanent_abnormal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -601,14 +640,16 @@ permanent_abnormal(Config) when list(Config) -> ok; false -> ?line test_server:fail({permanent_child_not_restarted, Child1}) - end. + end, + ?line [1,1,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- transient_abnormal(doc) -> ["A transient child should be restarted if it exits with " "reason abnormal"]; transient_abnormal(suite) -> []; -transient_abnormal(Config) when list(Config) -> +transient_abnormal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, transient, 1000, worker, []}, @@ -624,14 +665,15 @@ transient_abnormal(Config) when list(Config) -> ok; false -> ?line test_server:fail({transient_child_not_restarted, Child1}) - end. - + end, + ?line [1,1,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- temporary_abnormal(doc) -> ["A temporary process should never be restarted"]; temporary_abnormal(suite) -> []; -temporary_abnormal(Config) when list(Config) -> +temporary_abnormal(Config) when is_list(Config) -> ?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), Child1 = {child1, {supervisor_1, start_child, []}, temporary, 1000, worker, []}, @@ -641,8 +683,10 @@ temporary_abnormal(Config) when list(Config) -> CPid1 ! die, test_server:sleep(100), - ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test). + ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test), + ?line [1,0,0,1] = get_child_counts(sup_test), + ok. %------------------------------------------------------------------------- restart_one_for_one(doc) -> ["Test that the one_for_one strategy works."]; @@ -653,7 +697,7 @@ restart_one_for_one(suite) -> [one_for_one, one_for_one_escalation]. one_for_one(doc) -> ["Test the one_for_one base case."]; one_for_one(suite) -> []; -one_for_one(Config) when list(Config) -> +one_for_one(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -679,6 +723,7 @@ one_for_one(Config) when list(Config) -> end; true -> ?line test_server:fail({bad_child_list, Children}) end, + ?line [2,2,0,2] = get_child_counts(sup_test), %% Test restart frequency property CPid2 ! die, @@ -697,7 +742,7 @@ one_for_one(Config) when list(Config) -> one_for_one_escalation(doc) -> ["Test restart escalation on a one_for_one supervisor."]; one_for_one_escalation(suite) -> []; -one_for_one_escalation(Config) when list(Config) -> +one_for_one_escalation(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, [error]}, permanent, 1000, @@ -737,7 +782,7 @@ restart_one_for_all(suite) -> one_for_all(doc) -> ["Test the one_for_all base case."]; one_for_all(suite) -> []; -one_for_all(Config) when list(Config) -> +one_for_all(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -772,6 +817,8 @@ one_for_all(Config) when list(Config) -> true -> ?line test_server:fail(bad_child); false -> ok end, + ?line [2,2,0,2] = get_child_counts(sup_test), + %%% Test restart frequency property [{_, Pid3, _, _}|_] = supervisor:which_children(sup_test), Pid3 ! die, @@ -788,7 +835,7 @@ one_for_all(Config) when list(Config) -> one_for_all_escalation(doc) -> ["Test restart escalation on a one_for_all supervisor."]; one_for_all_escalation(suite) -> []; -one_for_all_escalation(Config) when list(Config) -> +one_for_all_escalation(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -830,7 +877,7 @@ restart_simple_one_for_one(suite) -> simple_one_for_one(doc) -> ["Test the simple_one_for_one base case."]; simple_one_for_one(suite) -> []; -simple_one_for_one(Config) when list(Config) -> +simple_one_for_one(Config) when is_list(Config) -> process_flag(trap_exit, true), Child = {child, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -854,6 +901,8 @@ simple_one_for_one(Config) when list(Config) -> end; true -> ?line test_server:fail({bad_child_list, Children}) end, + ?line [1,2,0,2] = get_child_counts(sup_test), + %% Test restart frequency property CPid2 ! die, receive @@ -872,7 +921,7 @@ simple_one_for_one_extra(doc) -> ["Tests automatic restart of children " "who's start function return extra info."]; simple_one_for_one_extra(suite) -> []; -simple_one_for_one_extra(Config) when list(Config) -> +simple_one_for_one_extra(Config) when is_list(Config) -> process_flag(trap_exit, true), Child = {child, {supervisor_1, start_child, [extra_info]}, permanent, 1000, worker, []}, @@ -896,6 +945,8 @@ simple_one_for_one_extra(Config) when list(Config) -> end; true -> ?line test_server:fail({bad_child_list, Children}) end, + ?line [1,2,0,2] = get_child_counts(sup_test), + CPid2 ! die, receive {'EXIT', CPid2, _} -> ok @@ -912,7 +963,7 @@ simple_one_for_one_extra(Config) when list(Config) -> simple_one_for_one_escalation(doc) -> ["Test restart escalation on a simple_one_for_one supervisor."]; simple_one_for_one_escalation(suite) -> []; -simple_one_for_one_escalation(Config) when list(Config) -> +simple_one_for_one_escalation(Config) when is_list(Config) -> process_flag(trap_exit, true), Child = {child, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -947,7 +998,7 @@ restart_rest_for_one(suite) -> [rest_for_one, rest_for_one_escalation]. rest_for_one(doc) -> ["Test the rest_for_one base case."]; rest_for_one(suite) -> []; -rest_for_one(Config) when list(Config) -> +rest_for_one(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -962,6 +1013,8 @@ rest_for_one(Config) when list(Config) -> link(CPid2), ?line {ok, CPid3} = supervisor:start_child(sup_test, Child3), link(CPid3), + ?line [3,3,0,3] = get_child_counts(sup_test), + CPid2 ! die, receive {'EXIT', CPid2, died} -> ok; @@ -987,6 +1040,8 @@ rest_for_one(Config) when list(Config) -> if length(Children) == 3 -> ok; true -> ?line test_server:fail({bad_child_list, Children}) end, + ?line [3,3,0,3] = get_child_counts(sup_test), + %% Test that no old children is still alive SCh = lists:map(fun({_,P,_,_}) -> P end, Children), case lists:member(CPid1, SCh) of @@ -1018,7 +1073,7 @@ rest_for_one(Config) when list(Config) -> rest_for_one_escalation(doc) -> ["Test restart escalation on a rest_for_one supervisor."]; rest_for_one_escalation(suite) -> []; -rest_for_one_escalation(Config) when list(Config) -> +rest_for_one_escalation(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000, worker, []}, @@ -1052,7 +1107,7 @@ rest_for_one_escalation(Config) when list(Config) -> child_unlink(doc)-> ["Test that the supervisor does not hang forever if " "the child unliks and then is terminated by the supervisor."]; child_unlink(suite) -> []; -child_unlink(Config) when list(Config) -> +child_unlink(Config) when is_list(Config) -> ?line {ok, SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}), @@ -1081,7 +1136,7 @@ tree(doc) -> ["Test a basic supervison tree."]; tree(suite) -> []; -tree(Config) when list(Config) -> +tree(Config) when is_list(Config) -> process_flag(trap_exit, true), Child1 = {child1, {supervisor_1, start_child, []}, @@ -1114,15 +1169,19 @@ tree(Config) when list(Config) -> %% Child supervisors ?line {ok, Sup1} = supervisor:start_child(Pid, ChildSup1), ?line {ok, Sup2} = supervisor:start_child(Pid, ChildSup2), + ?line [2,2,2,0] = get_child_counts(Pid), %% Workers - ?line [{_, CPid2, _, _},{_, CPid1, _, _}] = supervisor:which_children(Sup1), + ?line [2,2,0,2] = get_child_counts(Sup1), + ?line [0,0,0,0] = get_child_counts(Sup2), %% Dynamic children ?line {ok, CPid3} = supervisor:start_child(Sup2, Child3), ?line {ok, CPid4} = supervisor:start_child(Sup2, Child4), + ?line [2,2,0,2] = get_child_counts(Sup1), + ?line [2,2,0,2] = get_child_counts(Sup2), link(Sup1), link(Sup2), @@ -1144,9 +1203,11 @@ tree(Config) when list(Config) -> ?line [{_, CPid2, _, _},{_, CPid1, _, _}] = supervisor:which_children(Sup1), + ?line [2,2,0,2] = get_child_counts(Sup1), ?line [{_, NewCPid4, _, _},{_, CPid3, _, _}] = supervisor:which_children(Sup2), + ?line [2,2,0,2] = get_child_counts(Sup2), link(NewCPid4), @@ -1195,9 +1256,99 @@ tree(Config) when list(Config) -> ?line [{supchild2, NewSup2, _, _},{supchild1, NewSup1, _, _}] = supervisor:which_children(Pid), + ?line [2,2,2,0] = get_child_counts(Pid), ?line [{child2, _, _, _},{child1, _, _, _}] = supervisor:which_children(NewSup1), + ?line [2,2,0,2] = get_child_counts(NewSup1), + ?line [] = supervisor:which_children(NewSup2), + ?line [0,0,0,0] = get_child_counts(NewSup2), ok. +%------------------------------------------------------------------------- +count_children_allocator_test(MemoryState) -> + Allocators = [temp_alloc, eheap_alloc, binary_alloc, ets_alloc, + driver_alloc, sl_alloc, ll_alloc, fix_alloc, std_alloc, + sys_alloc], + MemoryStateList = element(4, MemoryState), + AllocTypes = [lists:keyfind(Alloc, 1, MemoryStateList) + || Alloc <- Allocators], + AllocStates = [lists:keyfind(e, 1, AllocValue) + || {_Type, AllocValue} <- AllocTypes], + lists:all(fun(State) -> State == {e, true} end, AllocStates). + +count_children_memory(doc) -> + ["Test that which_children eats memory, but count_children does not."]; +count_children_memory(suite) -> + MemoryState = erlang:system_info(allocator), + case count_children_allocator_test(MemoryState) of + true -> []; + false -> + {skip, "+Meamin used during test; erlang:memory/1 not available"} + end; +count_children_memory(Config) when is_list(Config) -> + process_flag(trap_exit, true), + Child = {child, {supervisor_1, start_child, []}, temporary, 1000, + worker, []}, + ?line {ok, _Pid} = start({ok, {{simple_one_for_one, 2, 3600}, [Child]}}), + [supervisor:start_child(sup_test, []) || _Ignore <- lists:seq(1,1000)], + + garbage_collect(), + _Size1 = erlang:memory(processes_used), + Children = supervisor:which_children(sup_test), + _Size2 = erlang:memory(processes_used), + ChildCount = get_child_counts(sup_test), + Size3 = erlang:memory(processes_used), + + [supervisor:start_child(sup_test, []) || _Ignore2 <- lists:seq(1,1000)], + + garbage_collect(), + Children2 = supervisor:which_children(sup_test), + Size4 = erlang:memory(processes_used), + ChildCount2 = get_child_counts(sup_test), + Size5 = erlang:memory(processes_used), + + garbage_collect(), + Children3 = supervisor:which_children(sup_test), + Size6 = erlang:memory(processes_used), + ChildCount3 = get_child_counts(sup_test), + Size7 = erlang:memory(processes_used), + + ?line 1000 = length(Children), + ?line [1,1000,0,1000] = ChildCount, + ?line 2000 = length(Children2), + ?line [1,2000,0,2000] = ChildCount2, + ?line Children3 = Children2, + ?line ChildCount3 = ChildCount2, + + %% count_children consumes memory using an accumulator function, + %% but the space can be reclaimed incrementally, whereas + %% which_children generates a return list. + case (Size5 =< Size4) of + true -> ok; + false -> + ?line test_server:fail({count_children, used_more_memory}) + end, + case Size7 =< Size6 of + true -> ok; + false -> + ?line test_server:fail({count_children, used_more_memory}) + end, + + case Size4 > Size3 of + true -> ok; + false -> + ?line test_server:fail({which_children, used_no_memory}) + end, + case Size6 > Size5 of + true -> ok; + false -> + ?line test_server:fail({which_children, used_no_memory}) + end, + + [exit(Pid, kill) || {undefined, Pid, worker, _Modules} <- Children3], + test_server:sleep(100), + ?line [1,0,0,0] = get_child_counts(sup_test), + + ok. diff --git a/lib/stdlib/test/tar_SUITE.erl b/lib/stdlib/test/tar_SUITE.erl index af687ed2e1..7646f4c249 100644 --- a/lib/stdlib/test/tar_SUITE.erl +++ b/lib/stdlib/test/tar_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(tar_SUITE). @@ -183,7 +183,7 @@ atomic(doc) -> "and uncompressed archives." "Also test the 'cooked' option."]; atomic(suite) -> []; -atomic(Config) when list(Config) -> +atomic(Config) when is_list(Config) -> ?line ok = file:set_cwd(?config(priv_dir, Config)), ?line DataFiles = data_files(), ?line Names = [Name || {Name,_,_} <- DataFiles], @@ -369,7 +369,7 @@ try_bad(Name0, Reason, Config) -> case catch erl_tar:format_error(Reason) of {'EXIT', CrashReason} -> test_server:fail({format_error, crashed, CrashReason}); - String when list(String) -> + String when is_list(String) -> io:format("format_error(~p) -> ~s", [Reason, String]); Other -> test_server:fail({format_error, returned, Other}) @@ -413,7 +413,7 @@ try_error(M, F, A, Error) -> case catch erl_tar:format_error(Error) of {'EXIT', FReason} -> test_server:fail({format_error, crashed, FReason}); - String when list(String) -> + String when is_list(String) -> io:format("format_error(~p) -> ~s", [Error, String]); Other -> test_server:fail({format_error, returned, Other}) @@ -431,7 +431,7 @@ remove_prefix(_, Result) -> extract_from_binary(doc) -> "Test extracting a tar archive from a binary."; -extract_from_binary(Config) when list(Config) -> +extract_from_binary(Config) when is_list(Config) -> ?line DataDir = ?config(data_dir, Config), ?line PrivDir = ?config(priv_dir, Config), ?line Long = filename:join(DataDir, "no_fancy_stuff.tar"), diff --git a/lib/stdlib/test/timer_SUITE.erl b/lib/stdlib/test/timer_SUITE.erl index 86d8612b56..5f38c91c64 100644 --- a/lib/stdlib/test/timer_SUITE.erl +++ b/lib/stdlib/test/timer_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(timer_SUITE). @@ -271,7 +271,7 @@ collect(N, {E,A,B}, I) -> print_report -> print_report({E,A,B,I}), collect(N,{E,A,B}, I); - {Pid, get_report} when pid(Pid) -> + {Pid, get_report} when is_pid(Pid) -> Pid ! {report, {E, A, B, I}}, collect(N,{E,A,B}, I); reset -> diff --git a/lib/stdlib/test/unicode_SUITE.erl b/lib/stdlib/test/unicode_SUITE.erl index 706445005c..141ac64606 100644 --- a/lib/stdlib/test/unicode_SUITE.erl +++ b/lib/stdlib/test/unicode_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(unicode_SUITE). @@ -276,7 +276,7 @@ ex_latin1(Config) when is_list(Config) -> unicode:characters_to_list(make_unaligned(MissingLastByte),unicode), ?line DoubleSize16 = byte_size(DoubleUtf16), - ?line DoubleUtf16_2 = erlang:concat_binary([DoubleUtf16,<<16#FFFFF/utf16-big>>]), + ?line DoubleUtf16_2 = list_to_binary([DoubleUtf16,<<16#FFFFF/utf16-big>>]), ?line DoubleSize16_2 = byte_size(DoubleUtf16_2), ?line AllBut1_16 = DoubleSize16 - 1, ?line AllBut2_16_2 = DoubleSize16_2 - 2, @@ -884,15 +884,15 @@ utf8_to_list_bsyntax(<<C/utf8,R/binary>>) -> list_to_utf8_bsyntax(List,unicode) -> FList = flatx(List), - erlang:concat_binary([ if - is_binary(E) -> - E; - true -> - <<E/utf8>> - end || E <- FList ]); + list_to_binary([ if + is_binary(E) -> + E; + true -> + <<E/utf8>> + end || E <- FList ]); list_to_utf8_bsyntax(List,latin1) -> FList = flatb(List), - erlang:concat_binary([ <<E/utf8>> || E <- FList ]). + list_to_binary([ <<E/utf8>> || E <- FList ]). @@ -954,15 +954,15 @@ utf16_big_to_list_bsyntax(<<C/utf16-big,R/binary>>) -> list_to_utf16_big_bsyntax(List,{utf16,big}) -> FList = flatx(List), - erlang:concat_binary([ if - is_binary(E) -> - E; - true -> - <<E/utf16-big>> - end || E <- FList ]); + list_to_binary([ if + is_binary(E) -> + E; + true -> + <<E/utf16-big>> + end || E <- FList ]); list_to_utf16_big_bsyntax(List,latin1) -> FList = flatb(List), - erlang:concat_binary([ <<E/utf16-big>> || E <- FList ]). + list_to_binary([ <<E/utf16-big>> || E <- FList ]). utf16_little_to_list_bsyntax(<<>>) -> @@ -972,15 +972,15 @@ utf16_little_to_list_bsyntax(<<C/utf16-little,R/binary>>) -> list_to_utf16_little_bsyntax(List,{utf16,little}) -> FList = flatx(List), - erlang:concat_binary([ if - is_binary(E) -> - E; - true -> - <<E/utf16-little>> - end || E <- FList ]); + list_to_binary([ if + is_binary(E) -> + E; + true -> + <<E/utf16-little>> + end || E <- FList ]); list_to_utf16_little_bsyntax(List,latin1) -> FList = flatb(List), - erlang:concat_binary([ <<E/utf16-little>> || E <- FList ]). + list_to_binary([ <<E/utf16-little>> || E <- FList ]). @@ -991,15 +991,15 @@ utf32_big_to_list_bsyntax(<<C/utf32-big,R/binary>>) -> list_to_utf32_big_bsyntax(List,{utf32,big}) -> FList = flatx(List), - erlang:concat_binary([ if - is_binary(E) -> - E; - true -> - <<E/utf32-big>> - end || E <- FList ]); + list_to_binary([ if + is_binary(E) -> + E; + true -> + <<E/utf32-big>> + end || E <- FList ]); list_to_utf32_big_bsyntax(List,latin1) -> FList = flatb(List), - erlang:concat_binary([ <<E/utf32-big>> || E <- FList ]). + list_to_binary([ <<E/utf32-big>> || E <- FList ]). utf32_little_to_list_bsyntax(<<>>) -> @@ -1009,15 +1009,15 @@ utf32_little_to_list_bsyntax(<<C/utf32-little,R/binary>>) -> list_to_utf32_little_bsyntax(List,{utf32,little}) -> FList = flatx(List), - erlang:concat_binary([ if - is_binary(E) -> - E; - true -> - <<E/utf32-little>> - end || E <- FList ]); + list_to_binary([ if + is_binary(E) -> + E; + true -> + <<E/utf32-little>> + end || E <- FList ]); list_to_utf32_little_bsyntax(List,latin1) -> FList = flatb(List), - erlang:concat_binary([ <<E/utf32-little>> || E <- FList ]). + list_to_binary([ <<E/utf32-little>> || E <- FList ]). diff --git a/lib/stdlib/test/win32reg_SUITE.erl b/lib/stdlib/test/win32reg_SUITE.erl index 3ad58eba03..c8cc82f61e 100644 --- a/lib/stdlib/test/win32reg_SUITE.erl +++ b/lib/stdlib/test/win32reg_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(win32reg_SUITE). @@ -37,7 +37,7 @@ fini(Config) when is_list(Config) -> Config. long(doc) -> "Test long keys and entries (OTP-3446)."; -long(Config) when list(Config) -> +long(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(10)), ?line LongKey = "software\\" ++ @@ -61,7 +61,7 @@ long(Config) when list(Config) -> ?line test_server:timetrap_cancel(Dog), ok. -evil_write(Config) when list(Config) -> +evil_write(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(10)), ?line Key = "Software\\Ericsson\\Erlang", diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl index 55cbd277ef..12ca655000 100644 --- a/lib/stdlib/test/zip_SUITE.erl +++ b/lib/stdlib/test/zip_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(zip_SUITE). @@ -181,7 +181,7 @@ atomic(doc) -> ["Test the 'atomic' operations: zip/unzip/list_dir, on archives." "Also test the 'cooked' option."]; atomic(suite) -> []; -atomic(Config) when list(Config) -> +atomic(Config) when is_list(Config) -> ok = file:set_cwd(?config(priv_dir, Config)), DataFiles = data_files(), Names = [Name || {Name,_,_} <- DataFiles], @@ -209,7 +209,7 @@ openzip_api(doc) -> ["Test the openzip_open/2, openzip_get/1, openzip_get/2, openzip_close/1 " "and openzip_list_dir/1 functions."]; openzip_api(suite) -> []; -openzip_api(Config) when list(Config) -> +openzip_api(Config) when is_list(Config) -> ok = file:set_cwd(?config(priv_dir, Config)), DataFiles = data_files(), Names = [Name || {Name, _, _} <- DataFiles], @@ -248,7 +248,7 @@ zip_api(doc) -> ["Test the zip_open/2, zip_get/1, zip_get/2, zip_close/1 " "and zip_list_dir/1 functions."]; zip_api(suite) -> []; -zip_api(Config) when list(Config) -> +zip_api(Config) when is_list(Config) -> ok = file:set_cwd(?config(priv_dir, Config)), DataFiles = data_files(), Names = [Name || {Name, _, _} <- DataFiles], @@ -550,7 +550,7 @@ aliases(Config) when is_list(Config) -> unzip_from_binary(doc) -> ["Test extracting a zip archive from a binary."]; -unzip_from_binary(Config) when list(Config) -> +unzip_from_binary(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), ExtractDir = filename:join(PrivDir, "extract_from_binary"), @@ -626,7 +626,7 @@ delete_all_in(Dir) -> compress_control(doc) -> ["Test control of which files that should be compressed"]; compress_control(suite) -> []; -compress_control(Config) when list(Config) -> +compress_control(Config) when is_list(Config) -> ok = file:set_cwd(?config(priv_dir, Config)), Dir = "compress_control", Files = [ |