aboutsummaryrefslogtreecommitdiffstats
path: root/erts/test
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-08-30 20:55:08 +0200
committerSverker Eriksson <[email protected]>2017-08-30 20:55:08 +0200
commit7c67bbddb53c364086f66260701bc54a61c9659c (patch)
tree92ab0d4b91d5e2f6e7a3f9d61ea25089e8a71fe0 /erts/test
parent97dc5e7f396129222419811c173edc7fa767b0f8 (diff)
parent3b7a6ffddc819bf305353a593904cea9e932e7dc (diff)
downloadotp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.gz
otp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.bz2
otp-7c67bbddb53c364086f66260701bc54a61c9659c.zip
Merge tag 'OTP-19.0' into sverker/19/binary_to_atom-utf8-crash/ERL-474/OTP-14590
Diffstat (limited to 'erts/test')
-rw-r--r--erts/test/Makefile28
-rw-r--r--erts/test/erl_print_SUITE.erl528
-rw-r--r--erts/test/erl_print_SUITE_data/Makefile.src25
-rw-r--r--erts/test/erl_print_SUITE_data/character_test.h23
-rw-r--r--erts/test/erl_print_SUITE_data/erl_print_tests.c44
-rw-r--r--erts/test/erl_print_SUITE_data/integer_64_test.h23
-rw-r--r--erts/test/erl_print_SUITE_data/integer_test.h23
-rw-r--r--erts/test/erl_print_SUITE_data/snprintf_test.h23
-rw-r--r--erts/test/erl_print_SUITE_data/string_test.h23
-rw-r--r--erts/test/erlc_SUITE.erl397
-rw-r--r--erts/test/erlc_SUITE_data/include/erl_test.hrl23
-rw-r--r--erts/test/erlc_SUITE_data/src/erl_test_bad.erl23
-rw-r--r--erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl23
-rw-r--r--erts/test/erlc_SUITE_data/src/erl_test_ok.erl23
-rw-r--r--erts/test/erlc_SUITE_data/src/start_ok.script2
-rw-r--r--erts/test/erlc_SUITE_data/src/yecc_test_bad.yrl23
-rw-r--r--erts/test/erlc_SUITE_data/src/yecc_test_ok.yrl23
-rw-r--r--erts/test/erlexec_SUITE.erl272
-rw-r--r--erts/test/erlexec_SUITE_data/Makefile.src23
-rw-r--r--erts/test/erlexec_SUITE_data/erlexec_tests.c21
-rw-r--r--erts/test/ethread_SUITE.erl300
-rw-r--r--erts/test/ethread_SUITE_data/Makefile.src27
-rw-r--r--erts/test/ethread_SUITE_data/ethread_tests.c29
-rw-r--r--erts/test/ignore_cores.erl35
-rw-r--r--erts/test/install_SUITE.erl371
-rw-r--r--erts/test/nt_SUITE.erl726
-rw-r--r--erts/test/nt_SUITE_data/Makefile.src23
-rw-r--r--erts/test/nt_SUITE_data/nt_info.c23
-rw-r--r--erts/test/otp_SUITE.erl625
-rw-r--r--erts/test/run_erl_SUITE.erl194
-rw-r--r--erts/test/run_erl_SUITE_data/defuncter.pl23
-rw-r--r--erts/test/run_erl_SUITE_data/run_erl_test.pl23
-rw-r--r--erts/test/system_smoke.spec3
-rw-r--r--erts/test/upgrade_SUITE.erl452
-rw-r--r--erts/test/upgrade_SUITE_data/start.src37
-rw-r--r--erts/test/utils/gccifier.c23
-rwxr-xr-xerts/test/utils/gccifier.sh21
-rw-r--r--erts/test/z_SUITE.erl99
38 files changed, 2577 insertions, 2050 deletions
diff --git a/erts/test/Makefile b/erts/test/Makefile
index 6b409e2f1b..1fe230adaf 100644
--- a/erts/test/Makefile
+++ b/erts/test/Makefile
@@ -1,18 +1,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 1997-2012. All Rights Reserved.
+# Copyright Ericsson AB 1997-2016. 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/.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
-# 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.
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
@@ -36,7 +37,8 @@ MODULES= \
erl_print_SUITE \
run_erl_SUITE \
erlexec_SUITE \
- z_SUITE
+ z_SUITE \
+ upgrade_SUITE
ERL_FILES= $(MODULES:%=%.erl)
@@ -52,7 +54,7 @@ RELSYSDIR = $(RELEASE_PATH)/system_test
# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
-ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/test_server/include
+ERL_COMPILE_FLAGS +=
# ----------------------------------------------------
# Targets
@@ -79,7 +81,7 @@ release_spec:
release_tests_spec: opt
$(INSTALL_DIR) "$(RELSYSDIR)"
- $(INSTALL_DATA) system.spec system.dynspec \
+ $(INSTALL_DATA) system.spec system.dynspec system_smoke.spec \
$(ERL_FILES) $(TARGET_FILES) "$(RELSYSDIR)"
chmod -R u+w "$(RELSYSDIR)"
tar cf - *_SUITE_data utils | (cd "$(RELSYSDIR)"; tar xf -)
diff --git a/erts/test/erl_print_SUITE.erl b/erts/test/erl_print_SUITE.erl
index a49d8f069f..463d890688 100644
--- a/erts/test/erl_print_SUITE.erl
+++ b/erts/test/erl_print_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -27,153 +28,133 @@
-module(erl_print_SUITE).
-author('[email protected]').
+-export([all/0, suite/0, init_per_testcase/2, end_per_testcase/2]).
-%-define(line_trace, 1).
-
--define(DEFAULT_TIMEOUT, ?t:minutes(10)).
-
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
- init_per_testcase/2, end_per_testcase/2]).
+-export([erlang_display/1, integer/1, float/1,
+ string/1, character/1, snprintf/1, quote/1]).
--export([erlang_display/1, integer/1, float/1,
- string/1, character/1, snprintf/1, quote/1]).
+-include_lib("common_test/include/ct.hrl").
--include_lib("test_server/include/test_server.hrl").
-
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 10}}].
all() ->
- test_cases().
-
-groups() ->
- [].
+ [erlang_display, integer, float, string, character,
+ snprintf, quote].
-init_per_suite(Config) ->
- Config.
+init_per_testcase(Case, Config) ->
+ [{testcase, Case}|Config].
-end_per_suite(_Config) ->
+end_per_testcase(_Case, _Config) ->
ok.
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
-
%%
%%
%% Test cases
%%
%%
-test_cases() ->
- [erlang_display, integer, float, string, character,
- snprintf, quote].
-
-erlang_display(doc) -> [];
-erlang_display(suite) -> [];
erlang_display(Config) when is_list(Config) ->
- ?line put(erlang_display_test, ok),
+ put(erlang_display_test, ok),
OAIS = erts_debug:set_internal_state(available_internal_state, true),
%% atoms
- ?line chk_display(atom, "atom"),
- ?line chk_display(true, "true"),
- ?line chk_display(false, "false"),
- ?line chk_display('DOWN', "'DOWN'"),
- ?line chk_display('EXIT', "'EXIT'"),
- ?line chk_display('asdDofw $@{}][', "'asdDofw $@{}]['"),
+ chk_display(atom, "atom"),
+ chk_display(true, "true"),
+ chk_display(false, "false"),
+ chk_display('DOWN', "'DOWN'"),
+ chk_display('EXIT', "'EXIT'"),
+ chk_display('asdDofw $@{}][', "'asdDofw $@{}]['"),
%% integers
- ?line chk_display(0, "0"),
- ?line chk_display(1, "1"),
- ?line chk_display(4711, "4711"),
- ?line chk_display(((1 bsl 27) - 1), "134217727"),
- ?line chk_display((1 bsl 27), "134217728"),
- ?line chk_display((1 bsl 32), "4294967296"),
- ?line chk_display(11111111111, "11111111111"),
- ?line chk_display((1 bsl 59) - 1, "576460752303423487"),
- ?line chk_display(1 bsl 59, "576460752303423488"),
- ?line chk_display(111111111111111111111, "111111111111111111111"),
- ?line chk_display(123456789012345678901234567890,
- "123456789012345678901234567890"),
- ?line chk_display(1 bsl 10000, str_1_bsl_10000()),
- ?line chk_display(-1, "-1"),
- ?line chk_display(-4711, "-4711"),
- ?line chk_display(-(1 bsl 27), "-134217728"),
- ?line chk_display(-((1 bsl 27) + 1), "-134217729"),
- ?line chk_display(-(1 bsl 32), "-4294967296"),
- ?line chk_display(-11111111111, "-11111111111"),
- ?line chk_display(-(1 bsl 59), "-576460752303423488"),
- ?line chk_display(-((1 bsl 59) + 1), "-576460752303423489"),
- ?line chk_display(-111111111111111111111, "-111111111111111111111"),
- ?line chk_display(-123456789012345678901234567890,
- "-123456789012345678901234567890"),
- ?line chk_display(-(1 bsl 10000), [$- | str_1_bsl_10000()]),
-
- ?line MyCre = my_cre(),
+ chk_display(0, "0"),
+ chk_display(1, "1"),
+ chk_display(4711, "4711"),
+ chk_display(((1 bsl 27) - 1), "134217727"),
+ chk_display((1 bsl 27), "134217728"),
+ chk_display((1 bsl 32), "4294967296"),
+ chk_display(11111111111, "11111111111"),
+ chk_display((1 bsl 59) - 1, "576460752303423487"),
+ chk_display(1 bsl 59, "576460752303423488"),
+ chk_display(111111111111111111111, "111111111111111111111"),
+ chk_display(123456789012345678901234567890,
+ "123456789012345678901234567890"),
+ chk_display(1 bsl 10000, str_1_bsl_10000()),
+ chk_display(-1, "-1"),
+ chk_display(-4711, "-4711"),
+ chk_display(-(1 bsl 27), "-134217728"),
+ chk_display(-((1 bsl 27) + 1), "-134217729"),
+ chk_display(-(1 bsl 32), "-4294967296"),
+ chk_display(-11111111111, "-11111111111"),
+ chk_display(-(1 bsl 59), "-576460752303423488"),
+ chk_display(-((1 bsl 59) + 1), "-576460752303423489"),
+ chk_display(-111111111111111111111, "-111111111111111111111"),
+ chk_display(-123456789012345678901234567890,
+ "-123456789012345678901234567890"),
+ chk_display(-(1 bsl 10000), [$- | str_1_bsl_10000()]),
+
+ MyCre = my_cre(),
%% pids
- ?line chk_display(mk_pid_xstr({node(), MyCre}, 4711, 42)),
- ?line chk_display(mk_pid_xstr({node(), oth_cre(MyCre)}, 4711, 42)),
- ?line chk_display(mk_pid_xstr({node(), oth_cre(oth_cre(MyCre))}, 4711, 42)),
+ chk_display(mk_pid_xstr({node(), MyCre}, 4711, 42)),
+ chk_display(mk_pid_xstr({node(), oth_cre(MyCre)}, 4711, 42)),
+ chk_display(mk_pid_xstr({node(), oth_cre(oth_cre(MyCre))}, 4711, 42)),
- ?line chk_display(mk_pid_xstr({a@b, MyCre}, 4711, 42)),
- ?line chk_display(mk_pid_xstr({a@b, oth_cre(MyCre)}, 4711, 42)),
- ?line chk_display(mk_pid_xstr({a@b, oth_cre(oth_cre(MyCre))}, 4711, 42)),
+ chk_display(mk_pid_xstr({a@b, MyCre}, 4711, 42)),
+ chk_display(mk_pid_xstr({a@b, oth_cre(MyCre)}, 4711, 42)),
+ chk_display(mk_pid_xstr({a@b, oth_cre(oth_cre(MyCre))}, 4711, 42)),
%% ports
- ?line chk_display(mk_port_xstr({node(), MyCre}, 4711)),
- ?line chk_display(mk_port_xstr({node(), oth_cre(MyCre)}, 4711)),
- ?line chk_display(mk_port_xstr({node(), oth_cre(oth_cre(MyCre))}, 4711)),
+ chk_display(mk_port_xstr({node(), MyCre}, 4711)),
+ chk_display(mk_port_xstr({node(), oth_cre(MyCre)}, 4711)),
+ chk_display(mk_port_xstr({node(), oth_cre(oth_cre(MyCre))}, 4711)),
- ?line chk_display(mk_port_xstr({c@d, MyCre}, 4711)),
- ?line chk_display(mk_port_xstr({c@d, oth_cre(MyCre)}, 4711)),
- ?line chk_display(mk_port_xstr({c@d, oth_cre(oth_cre(MyCre))}, 4711)),
+ chk_display(mk_port_xstr({c@d, MyCre}, 4711)),
+ chk_display(mk_port_xstr({c@d, oth_cre(MyCre)}, 4711)),
+ chk_display(mk_port_xstr({c@d, oth_cre(oth_cre(MyCre))}, 4711)),
%% refs
- ?line chk_display(mk_ref_xstr({node(), MyCre}, [1,2,3])),
- ?line chk_display(mk_ref_xstr({node(), oth_cre(MyCre)}, [1,2,3])),
- ?line chk_display(mk_ref_xstr({node(), oth_cre(oth_cre(MyCre))}, [1,2,3])),
+ chk_display(mk_ref_xstr({node(), MyCre}, [1,2,3])),
+ chk_display(mk_ref_xstr({node(), oth_cre(MyCre)}, [1,2,3])),
+ chk_display(mk_ref_xstr({node(), oth_cre(oth_cre(MyCre))}, [1,2,3])),
- ?line chk_display(mk_ref_xstr({e@f, MyCre},[1,2,3] )),
- ?line chk_display(mk_ref_xstr({e@f, oth_cre(MyCre)}, [1,2,3])),
- ?line chk_display(mk_ref_xstr({e@f, oth_cre(oth_cre(MyCre))}, [1,2,3])),
+ chk_display(mk_ref_xstr({e@f, MyCre},[1,2,3] )),
+ chk_display(mk_ref_xstr({e@f, oth_cre(MyCre)}, [1,2,3])),
+ chk_display(mk_ref_xstr({e@f, oth_cre(oth_cre(MyCre))}, [1,2,3])),
%% Compund terms
- ?line {Pid, PidStr} = mk_pid_xstr({x@y, oth_cre(MyCre)}, 4712, 41),
- ?line {Port, PortStr} = mk_port_xstr({x@y, oth_cre(MyCre)}, 4712),
- ?line {Ref, RefStr} = mk_ref_xstr({e@f, oth_cre(MyCre)}, [11,12,13]),
-
- ?line chk_display({atom,-4711,Ref,{"hej",[Pid,222222222222222222222222,Port,4711]}},
- "{atom,-4711,"++RefStr++",{\"hej\",["++PidStr++",222222222222222222222222,"++PortStr++",4711]}}"),
- ?line chk_display({{{{{{{{{{{{{{{{{{{{{{{hi}}}}}}}}}}}}}}}}}}}}}}},
- "{{{{{{{{{{{{{{{{{{{{{{{hi}}}}}}}}}}}}}}}}}}}}}}}"),
- ?line chk_display([[[[[[[[[[[[[[[[[[[[[[[yo]]]]]]]]]]]]]]]]]]]]]]],
- "[[[[[[[[[[[[[[[[[[[[[[[yo]]]]]]]]]]]]]]]]]]]]]]]"),
- ?line chk_display({[{[{[{[{[{[{[{[{[{[{[{[ii]}]}]}]}]}]}]}]}]}]}]}]},
- "{[{[{[{[{[{[{[{[{[{[{[{[ii]}]}]}]}]}]}]}]}]}]}]}]}"),
- ?line chk_display([], "[]"), % Not really a compound term :)
- ?line chk_display([a|b], "[a|b]"),
- ?line chk_display([a,b,c|z], "[a,b,c|z]"),
- ?line chk_display([a,b,c], "[a,b,c]"),
- ?line chk_display([Pid,Port,Ref],
- "["++PidStr++","++PortStr++","++RefStr++"]"),
- ?line chk_display("abcdefghijklmnopqrstuvwxyz",
- "\"abcdefghijklmnopqrstuvwxyz\""),
- ?line chk_display("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\""),
- ?line chk_display("H E J", "\"H E J\""),
- ?line chk_display("asdDofw $@{}][", "\"asdDofw $@{}][\""),
-
+ {Pid, PidStr} = mk_pid_xstr({x@y, oth_cre(MyCre)}, 4712, 41),
+ {Port, PortStr} = mk_port_xstr({x@y, oth_cre(MyCre)}, 4712),
+ {Ref, RefStr} = mk_ref_xstr({e@f, oth_cre(MyCre)}, [11,12,13]),
+
+ chk_display({atom,-4711,Ref,{"hej",[Pid,222222222222222222222222,Port,4711]}},
+ "{atom,-4711,"++RefStr++",{\"hej\",["++PidStr++",222222222222222222222222,"++PortStr++",4711]}}"),
+ chk_display({{{{{{{{{{{{{{{{{{{{{{{hi}}}}}}}}}}}}}}}}}}}}}}},
+ "{{{{{{{{{{{{{{{{{{{{{{{hi}}}}}}}}}}}}}}}}}}}}}}}"),
+ chk_display([[[[[[[[[[[[[[[[[[[[[[[yo]]]]]]]]]]]]]]]]]]]]]]],
+ "[[[[[[[[[[[[[[[[[[[[[[[yo]]]]]]]]]]]]]]]]]]]]]]]"),
+ chk_display({[{[{[{[{[{[{[{[{[{[{[{[ii]}]}]}]}]}]}]}]}]}]}]}]},
+ "{[{[{[{[{[{[{[{[{[{[{[{[ii]}]}]}]}]}]}]}]}]}]}]}]}"),
+ chk_display([], "[]"), % Not really a compound term :)
+ chk_display([a|b], "[a|b]"),
+ chk_display([a,b,c|z], "[a,b,c|z]"),
+ chk_display([a,b,c], "[a,b,c]"),
+ chk_display([Pid,Port,Ref],
+ "["++PidStr++","++PortStr++","++RefStr++"]"),
+ chk_display("abcdefghijklmnopqrstuvwxyz",
+ "\"abcdefghijklmnopqrstuvwxyz\""),
+ chk_display("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\""),
+ chk_display("H E J", "\"H E J\""),
+ chk_display("asdDofw $@{}][", "\"asdDofw $@{}][\""),
+
%%
%% TODO: Check binaries, fun and floats...
%%
erts_debug:set_internal_state(available_internal_state, OAIS),
- ?line ok = get(erlang_display_test).
+ ok = get(erlang_display_test).
get_chnl_no(NodeName) when is_atom(NodeName) ->
erts_debug:get_internal_state({channel_number, NodeName}).
@@ -181,20 +162,20 @@ get_chnl_no(NodeName) when is_atom(NodeName) ->
chk_display(Term, Expect) when is_list(Expect) ->
Dstr = erts_debug:display(Term),
case Expect ++ io_lib:nl() of
- Dstr ->
- ?t:format("Test of \"~p\" succeeded.~n"
- " Expected and got: ~s~n",
- [Term, io_lib:write_string(Dstr)]);
- DoExpect ->
- ?t:format("***~n"
- "*** Test of \"~p\" failed!~n"
- "*** Expected: ~s~n"
- "*** Got: ~s~n"
- "***~n",
- [Term,
- io_lib:write_string(DoExpect),
- io_lib:write_string(Dstr)]),
- put(erlang_display_test, failed)
+ Dstr ->
+ io:format("Test of \"~p\" succeeded.~n"
+ " Expected and got: ~s~n",
+ [Term, io_lib:write_string(Dstr)]);
+ DoExpect ->
+ io:format("***~n"
+ "*** Test of \"~p\" failed!~n"
+ "*** Expected: ~s~n"
+ "*** Got: ~s~n"
+ "***~n",
+ [Term,
+ io_lib:write_string(DoExpect),
+ io_lib:write_string(Dstr)]),
+ put(erlang_display_test, failed)
end.
chk_display({Term, Expect}) ->
@@ -203,20 +184,20 @@ chk_display({Term, Expect}) ->
mk_pid_xstr({NodeName, Creation}, Number, Serial) ->
Pid = mk_pid({NodeName, Creation}, Number, Serial),
XStr = "<" ++ integer_to_list(get_chnl_no(NodeName))
- ++ "." ++ integer_to_list(Number)
- ++ "." ++ integer_to_list(Serial) ++ ">",
+ ++ "." ++ integer_to_list(Number)
+ ++ "." ++ integer_to_list(Serial) ++ ">",
{Pid, XStr}.
mk_port_xstr({NodeName, Creation}, Number) ->
Port = mk_port({NodeName, Creation}, Number),
XStr = "#Port<" ++ integer_to_list(get_chnl_no(NodeName))
- ++ "." ++ integer_to_list(Number) ++ ">",
+ ++ "." ++ integer_to_list(Number) ++ ">",
{Port, XStr}.
mk_ref_xstr({NodeName, Creation}, Numbers) ->
Ref = mk_ref({NodeName, Creation}, Numbers),
XStr = "#Ref<" ++ integer_to_list(get_chnl_no(NodeName))
- ++ ref_numbers_xstr(Numbers) ++ ">",
+ ++ ref_numbers_xstr(Numbers) ++ ">",
{Ref, XStr}.
ref_numbers_xstr([]) ->
@@ -239,18 +220,7 @@ ref_numbers_xstr([N | Ns]) ->
%%
%%
-default_testcase_impl(doc) -> [];
-default_testcase_impl(suite) -> [];
-default_testcase_impl(Config) when is_list(Config) -> ?line run_case(Config).
-
-init_per_testcase(Case, Config) ->
- Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
- [{testcase, Case}, {watchdog, Dog} |Config].
-
-end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
- ok.
+default_testcase_impl(Config) when is_list(Config) -> run_case(Config).
-define(TESTPROG, "erl_print_tests").
-define(FAILED_MARKER, $E,$P,$-,$T,$E,$S,$T,$-,$F,$A,$I,$L,$U,$R,$E).
@@ -259,62 +229,62 @@ end_per_testcase(_Case, Config) ->
-define(PID_MARKER, $E,$P,$-,$T,$E,$S,$T,$-,$P,$I,$D).
port_prog_killer(EProc, OSProc) when is_pid(EProc), is_list(OSProc) ->
- ?line process_flag(trap_exit, true),
- ?line Ref = erlang:monitor(process, EProc),
- ?line receive
- {'DOWN', Ref, _, _, Reason} when is_tuple(Reason),
- element(1, Reason)
- == timetrap_timeout ->
- ?line Cmd = "kill -9 " ++ OSProc,
- ?line ?t:format("Test case timed out. "
- "Trying to kill port program.~n"
- " Executing: ~p~n", [Cmd]),
- ?line case os:cmd(Cmd) of
- [] ->
- ok;
- OsCmdRes ->
- ?line ?t:format(" ~s", [OsCmdRes])
- end;
- {'DOWN', Ref, _, _, _} ->
- %% OSProc is assumed to have terminated by itself
- ?line ok
- end.
+ process_flag(trap_exit, true),
+ Ref = erlang:monitor(process, EProc),
+ receive
+ {'DOWN', Ref, _, _, Reason} when is_tuple(Reason),
+ element(1, Reason)
+ == timetrap_timeout ->
+ Cmd = "kill -9 " ++ OSProc,
+ io:format("Test case timed out. "
+ "Trying to kill port program.~n"
+ " Executing: ~p~n", [Cmd]),
+ case os:cmd(Cmd) of
+ [] ->
+ ok;
+ OsCmdRes ->
+ io:format(" ~s", [OsCmdRes])
+ end;
+ {'DOWN', Ref, _, _, _} ->
+ %% OSProc is assumed to have terminated by itself
+ ok
+ end.
get_line(_Port, eol, Data) ->
- ?line Data;
+ Data;
get_line(Port, noeol, Data) ->
- ?line receive
- {Port, {data, {Flag, NextData}}} ->
- ?line get_line(Port, Flag, Data ++ NextData);
- {Port, eof} ->
- ?line ?t:fail(port_prog_unexpectedly_closed)
- end.
+ receive
+ {Port, {data, {Flag, NextData}}} ->
+ get_line(Port, Flag, Data ++ NextData);
+ {Port, eof} ->
+ ct:fail(port_prog_unexpectedly_closed)
+ end.
read_case_data(Port, TestCase) ->
- ?line receive
- {Port, {data, {eol, [?SUCCESS_MARKER]}}} ->
- ?line ok;
- {Port, {data, {Flag, [?SUCCESS_MARKER | CommentStart]}}} ->
- ?line {comment, get_line(Port, Flag, CommentStart)};
- {Port, {data, {Flag, [?SKIPPED_MARKER | CommentStart]}}} ->
- ?line {skipped, get_line(Port, Flag, CommentStart)};
- {Port, {data, {Flag, [?FAILED_MARKER | ReasonStart]}}} ->
- ?line ?t:fail(get_line(Port, Flag, ReasonStart));
- {Port, {data, {eol, [?PID_MARKER | PidStr]}}} ->
- ?line ?t:format("Port program pid: ~s~n", [PidStr]),
- ?line CaseProc = self(),
- ?line _ = list_to_integer(PidStr), % Sanity check
- spawn_opt(fun () ->
- port_prog_killer(CaseProc, PidStr)
- end,
- [{priority, max}, link]),
- read_case_data(Port, TestCase);
- {Port, {data, {Flag, LineStart}}} ->
- ?line ?t:format("~s~n", [get_line(Port, Flag, LineStart)]),
- read_case_data(Port, TestCase);
- {Port, eof} ->
- ?line ?t:fail(port_prog_unexpectedly_closed)
- end.
+ receive
+ {Port, {data, {eol, [?SUCCESS_MARKER]}}} ->
+ ok;
+ {Port, {data, {Flag, [?SUCCESS_MARKER | CommentStart]}}} ->
+ {comment, get_line(Port, Flag, CommentStart)};
+ {Port, {data, {Flag, [?SKIPPED_MARKER | CommentStart]}}} ->
+ {skipped, get_line(Port, Flag, CommentStart)};
+ {Port, {data, {Flag, [?FAILED_MARKER | ReasonStart]}}} ->
+ ct:fail(get_line(Port, Flag, ReasonStart));
+ {Port, {data, {eol, [?PID_MARKER | PidStr]}}} ->
+ io:format("Port program pid: ~s~n", [PidStr]),
+ CaseProc = self(),
+ _ = list_to_integer(PidStr), % Sanity check
+ spawn_opt(fun () ->
+ port_prog_killer(CaseProc, PidStr)
+ end,
+ [{priority, max}, link]),
+ read_case_data(Port, TestCase);
+ {Port, {data, {Flag, LineStart}}} ->
+ io:format("~s~n", [get_line(Port, Flag, LineStart)]),
+ read_case_data(Port, TestCase);
+ {Port, eof} ->
+ ct:fail(port_prog_unexpectedly_closed)
+ end.
run_case(Config) ->
run_case(Config, "").
@@ -323,27 +293,27 @@ run_case(Config, TestArgs) ->
run_case(Config, TestArgs, fun (_Port) -> ok end).
run_case(Config, TestArgs, Fun) ->
- Test = atom_to_list(?config(testcase, Config)),
- TestProg = filename:join([?config(data_dir, Config),
- ?TESTPROG
- ++ "."
- ++ atom_to_list(erlang:system_info(threads))]),
+ Test = atom_to_list(proplists:get_value(testcase, Config)),
+ TestProg = filename:join([proplists:get_value(data_dir, Config),
+ ?TESTPROG
+ ++ "."
+ ++ atom_to_list(erlang:system_info(threads))]),
Cmd = TestProg ++ " " ++ Test ++ " " ++ TestArgs,
case catch open_port({spawn, Cmd}, [stream,
- use_stdio,
- stderr_to_stdout,
- eof,
- {line, 1024}]) of
- Port when is_port(Port) ->
- ?line Fun(Port),
- ?line CaseResult = read_case_data(Port, Test),
- ?line receive
- {Port, eof} ->
- ?line ok
- end,
- ?line CaseResult;
- Error ->
- ?line ?t:fail({open_port_failed, Error})
+ use_stdio,
+ stderr_to_stdout,
+ eof,
+ {line, 1024}]) of
+ Port when is_port(Port) ->
+ Fun(Port),
+ CaseResult = read_case_data(Port, Test),
+ receive
+ {Port, eof} ->
+ ok
+ end,
+ CaseResult;
+ Error ->
+ ct:fail({open_port_failed, Error})
end.
@@ -381,80 +351,80 @@ mk_pid({NodeName, Creation}, Number, Serial) when is_atom(NodeName) ->
mk_pid({atom_to_list(NodeName), Creation}, Number, Serial);
mk_pid({NodeName, Creation}, Number, Serial) ->
case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
- ?PID_EXT,
- ?ATOM_EXT,
- uint16_be(length(NodeName)),
- NodeName,
- uint32_be(Number),
- uint32_be(Serial),
- uint8(Creation)])) of
- Pid when is_pid(Pid) ->
- Pid;
- {'EXIT', {badarg, _}} ->
- exit({badarg, mk_pid, [{NodeName, Creation}, Number, Serial]});
- Other ->
- exit({unexpected_binary_to_term_result, Other})
+ ?PID_EXT,
+ ?ATOM_EXT,
+ uint16_be(length(NodeName)),
+ NodeName,
+ uint32_be(Number),
+ uint32_be(Serial),
+ uint8(Creation)])) of
+ Pid when is_pid(Pid) ->
+ Pid;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_pid, [{NodeName, Creation}, Number, Serial]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
end.
mk_port({NodeName, Creation}, Number) when is_atom(NodeName) ->
mk_port({atom_to_list(NodeName), Creation}, Number);
mk_port({NodeName, Creation}, Number) ->
case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
- ?PORT_EXT,
- ?ATOM_EXT,
- uint16_be(length(NodeName)),
- NodeName,
- uint32_be(Number),
- uint8(Creation)])) of
- Port when is_port(Port) ->
- Port;
- {'EXIT', {badarg, _}} ->
- exit({badarg, mk_port, [{NodeName, Creation}, Number]});
- Other ->
- exit({unexpected_binary_to_term_result, Other})
+ ?PORT_EXT,
+ ?ATOM_EXT,
+ uint16_be(length(NodeName)),
+ NodeName,
+ uint32_be(Number),
+ uint8(Creation)])) of
+ Port when is_port(Port) ->
+ Port;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_port, [{NodeName, Creation}, Number]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
end.
mk_ref({NodeName, Creation}, Numbers) when is_atom(NodeName),
- is_integer(Creation),
- is_list(Numbers) ->
+ is_integer(Creation),
+ is_list(Numbers) ->
mk_ref({atom_to_list(NodeName), Creation}, Numbers);
mk_ref({NodeName, Creation}, [Number]) when is_list(NodeName),
- is_integer(Creation),
- is_integer(Number) ->
+ is_integer(Creation),
+ is_integer(Number) ->
case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
- ?REFERENCE_EXT,
- ?ATOM_EXT,
- uint16_be(length(NodeName)),
- NodeName,
- uint32_be(Number),
- uint8(Creation)])) of
- Ref when is_reference(Ref) ->
- Ref;
- {'EXIT', {badarg, _}} ->
- exit({badarg, mk_ref, [{NodeName, Creation}, [Number]]});
- Other ->
- exit({unexpected_binary_to_term_result, Other})
+ ?REFERENCE_EXT,
+ ?ATOM_EXT,
+ uint16_be(length(NodeName)),
+ NodeName,
+ uint32_be(Number),
+ uint8(Creation)])) of
+ Ref when is_reference(Ref) ->
+ Ref;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_ref, [{NodeName, Creation}, [Number]]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
end;
mk_ref({NodeName, Creation}, Numbers) when is_list(NodeName),
- is_integer(Creation),
- is_list(Numbers) ->
+ is_integer(Creation),
+ is_list(Numbers) ->
case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
- ?NEW_REFERENCE_EXT,
- uint16_be(length(Numbers)),
- ?ATOM_EXT,
- uint16_be(length(NodeName)),
- NodeName,
- uint8(Creation),
- lists:map(fun (N) ->
- uint32_be(N)
- end,
- Numbers)])) of
- Ref when is_reference(Ref) ->
- Ref;
- {'EXIT', {badarg, _}} ->
- exit({badarg, mk_ref, [{NodeName, Creation}, Numbers]});
- Other ->
- exit({unexpected_binary_to_term_result, Other})
+ ?NEW_REFERENCE_EXT,
+ uint16_be(length(Numbers)),
+ ?ATOM_EXT,
+ uint16_be(length(NodeName)),
+ NodeName,
+ uint8(Creation),
+ lists:map(fun (N) ->
+ uint32_be(N)
+ end,
+ Numbers)])) of
+ Ref when is_reference(Ref) ->
+ Ref;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_ref, [{NodeName, Creation}, Numbers]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
end.
my_cre() -> erlang:system_info(creation).
diff --git a/erts/test/erl_print_SUITE_data/Makefile.src b/erts/test/erl_print_SUITE_data/Makefile.src
index 3d58669c18..69ff434c56 100644
--- a/erts/test/erl_print_SUITE_data/Makefile.src
+++ b/erts/test/erl_print_SUITE_data/Makefile.src
@@ -1,23 +1,24 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2005-2012. All Rights Reserved.
+# Copyright Ericsson AB 2005-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
-include @erts_lib_include_internal_generated@@[email protected]
+include @erts_lib_make_ethread@
CC = @CC@
CFLAGST = @ERTS_CFLAGS@
diff --git a/erts/test/erl_print_SUITE_data/character_test.h b/erts/test/erl_print_SUITE_data/character_test.h
index 9c66618a71..82310ee8e7 100644
--- a/erts/test/erl_print_SUITE_data/character_test.h
+++ b/erts/test/erl_print_SUITE_data/character_test.h
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/erl_print_SUITE_data/erl_print_tests.c b/erts/test/erl_print_SUITE_data/erl_print_tests.c
index acb213cd3a..2fb7d1ff25 100644
--- a/erts/test/erl_print_SUITE_data/erl_print_tests.c
+++ b/erts/test/erl_print_SUITE_data/erl_print_tests.c
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2012. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
@@ -502,16 +503,17 @@ main(int argc, char *argv[])
" * %%CopyrightBegin%%\n"
" * Copyright Ericsson AB 1996-2009. All Rights Reserved.\n"
" * \n"
- " * The contents of this file are subject to the Erlang Public License,\n"
- " * Version 1.1, (the \"License\"); you may not use this file except in\n"
- " * compliance with the License. You should have received a copy of the\n"
- " * Erlang Public License along with this software. If not, it can be\n"
- " * retrieved online at http://www.erlang.org/.\n"
- " * \n"
- " * Software distributed under the License is distributed on an \"AS IS\"\n"
- " * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See\n"
- " * the License for the specific language governing rights and limitations\n"
- " * under the License.\n"
+ " * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
+ " * you may not use this file except in compliance with the License.\n"
+ " * You may obtain a copy of the License at\n"
+ " * \n"
+ " * http://www.apache.org/licenses/LICENSE-2.0\n"
+ " * \n"
+ " * Unless required by applicable law or agreed to in writing, software\n"
+ " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
+ " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+ " * See the License for the specific language governing permissions and\n"
+ " * limitations under the License.\n"
" * %%CopyrightEnd%%\n"
" */\n"
"\n");
diff --git a/erts/test/erl_print_SUITE_data/integer_64_test.h b/erts/test/erl_print_SUITE_data/integer_64_test.h
index 0df09ded44..4bfc91334d 100644
--- a/erts/test/erl_print_SUITE_data/integer_64_test.h
+++ b/erts/test/erl_print_SUITE_data/integer_64_test.h
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/erl_print_SUITE_data/integer_test.h b/erts/test/erl_print_SUITE_data/integer_test.h
index 94c8d59897..b3744928b7 100644
--- a/erts/test/erl_print_SUITE_data/integer_test.h
+++ b/erts/test/erl_print_SUITE_data/integer_test.h
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/erl_print_SUITE_data/snprintf_test.h b/erts/test/erl_print_SUITE_data/snprintf_test.h
index 0849b60562..77692304a3 100644
--- a/erts/test/erl_print_SUITE_data/snprintf_test.h
+++ b/erts/test/erl_print_SUITE_data/snprintf_test.h
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/erl_print_SUITE_data/string_test.h b/erts/test/erl_print_SUITE_data/string_test.h
index 32249ab6e9..bfe4215d8a 100644
--- a/erts/test/erl_print_SUITE_data/string_test.h
+++ b/erts/test/erl_print_SUITE_data/string_test.h
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2005-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2005-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl
index ab774dbc4f..237558a129 100644
--- a/erts/test/erlc_SUITE.erl
+++ b/erts/test/erlc_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -21,17 +22,18 @@
%% Tests the erlc command by compiling various types of files.
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2, compile_erl/1,
- compile_yecc/1, compile_script/1,
- compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1]).
+ init_per_group/2,end_per_group/2, compile_erl/1,
+ compile_yecc/1, compile_script/1,
+ compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1,
+ make_dep_options/1]).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[compile_erl, compile_yecc, compile_script, compile_mib,
- good_citizen, deep_cwd, arg_overflow].
+ good_citizen, deep_cwd, arg_overflow, make_dep_options].
groups() ->
[].
@@ -55,113 +57,109 @@ end_per_group(_GroupName, Config) ->
%% Tests that compiling Erlang source code works.
compile_erl(Config) when is_list(Config) ->
- ?line {SrcDir, OutDir, Cmd} = get_cmd(Config),
- ?line FileName = filename:join(SrcDir, "erl_test_ok.erl"),
+ {SrcDir, OutDir, Cmd} = get_cmd(Config),
+ FileName = filename:join(SrcDir, "erl_test_ok.erl"),
%% By default, warnings are now turned on.
- ?line run(Config, Cmd, FileName, "",
- ["Warning: function foo/0 is unused\$",
- "_OK_"]),
+ run(Config, Cmd, FileName, "",
+ ["Warning: function foo/0 is unused\$", "_OK_"]),
%% Test that the compiled file is where it should be,
%% and that it is runnable.
- ?line {module, erl_test_ok} = code:load_abs(filename:join(OutDir,
- "erl_test_ok")),
- ?line 42 = erl_test_ok:shoe_size(#person{shoe_size=42}),
- ?line code:purge(erl_test_ok),
+ {module, erl_test_ok} = code:load_abs(filename:join(OutDir, "erl_test_ok")),
+ 42 = erl_test_ok:shoe_size(#person{shoe_size=42}),
+ code:purge(erl_test_ok),
%% Try disabling warnings.
- ?line run(Config, Cmd, FileName, "-W0", ["_OK_"]),
+ run(Config, Cmd, FileName, "-W0", ["_OK_"]),
%% Try treating warnings as errors.
- ?line run(Config, Cmd, FileName, "-Werror",
- ["compile: warnings being treated as errors\$",
- "function foo/0 is unused\$",
- "_ERROR_"]),
+ run(Config, Cmd, FileName, "-Werror",
+ ["compile: warnings being treated as errors\$",
+ "function foo/0 is unused\$", "_ERROR_"]),
%% Check a bad file.
- ?line BadFile = filename:join(SrcDir, "erl_test_bad.erl"),
- ?line run(Config, Cmd, BadFile, "", ["function non_existing/1 undefined\$",
- "_ERROR_"]),
+ BadFile = filename:join(SrcDir, "erl_test_bad.erl"),
+ run(Config, Cmd, BadFile, "", ["function non_existing/1 undefined\$",
+ "_ERROR_"]),
ok.
%% Test that compiling yecc source code works.
compile_yecc(Config) when is_list(Config) ->
- ?line {SrcDir, _, OutDir} = get_dirs(Config),
- ?line Cmd = erlc() ++ " -o" ++ OutDir ++ " ",
- ?line FileName = filename:join(SrcDir, "yecc_test_ok.yrl"),
- ?line run(Config, Cmd, FileName, "-W0", ["_OK_"]),
- ?line true = exists(filename:join(OutDir, "yecc_test_ok.erl")),
-
- ?line BadFile = filename:join(SrcDir, "yecc_test_bad.yrl"),
- ?line run(Config, Cmd, BadFile, "-W0",
- ["rootsymbol form is not a nonterminal\$",
- "undefined nonterminal: form\$",
- "Nonterminals is missing\$",
- "_ERROR_"]),
- ?line exists(filename:join(OutDir, "yecc_test_ok.erl")),
-
+ {SrcDir, _, OutDir} = get_dirs(Config),
+ Cmd = erlc() ++ " -o" ++ OutDir ++ " ",
+ FileName = filename:join(SrcDir, "yecc_test_ok.yrl"),
+ run(Config, Cmd, FileName, "-W0", ["_OK_"]),
+ true = exists(filename:join(OutDir, "yecc_test_ok.erl")),
+
+ BadFile = filename:join(SrcDir, "yecc_test_bad.yrl"),
+ run(Config, Cmd, BadFile, "-W0",
+ ["rootsymbol form is not a nonterminal\$",
+ "undefined nonterminal: form\$",
+ "Nonterminals is missing\$",
+ "_ERROR_"]),
+ exists(filename:join(OutDir, "yecc_test_ok.erl")),
ok.
%% Test that compiling start scripts works.
compile_script(Config) when is_list(Config) ->
- ?line {SrcDir, OutDir, Cmd} = get_cmd(Config),
- ?line FileName = filename:join(SrcDir, "start_ok.script"),
- ?line run(Config, Cmd, FileName, "", ["_OK_"]),
- ?line true = exists(filename:join(OutDir, "start_ok.boot")),
+ {SrcDir, OutDir, Cmd} = get_cmd(Config),
+ FileName = filename:join(SrcDir, "start_ok.script"),
+ run(Config, Cmd, FileName, "", ["_OK_"]),
+ true = exists(filename:join(OutDir, "start_ok.boot")),
- ?line BadFile = filename:join(SrcDir, "start_bad.script"),
- ?line run(Config, Cmd, BadFile, "", ["syntax error before:", "_ERROR_"]),
+ BadFile = filename:join(SrcDir, "start_bad.script"),
+ run(Config, Cmd, BadFile, "", ["syntax error before:", "_ERROR_"]),
ok.
%% Test that compiling SNMP mibs works.
compile_mib(Config) when is_list(Config) ->
- ?line {SrcDir, OutDir, Cmd} = get_cmd(Config),
- ?line FileName = filename:join(SrcDir, "GOOD-MIB.mib"),
- ?line run(Config, Cmd, FileName, "", ["_OK_"]),
- ?line Output = filename:join(OutDir, "GOOD-MIB.bin"),
- ?line true = exists(Output),
+ {SrcDir, OutDir, Cmd} = get_cmd(Config),
+ FileName = filename:join(SrcDir, "GOOD-MIB.mib"),
+ run(Config, Cmd, FileName, "", ["_OK_"]),
+ Output = filename:join(OutDir, "GOOD-MIB.bin"),
+ true = exists(Output),
%% Try -W option.
- ?line ok = file:delete(Output),
- ?line run(Config, Cmd, FileName, "-W",
- ["_OK_"]),
- ?line true = exists(Output),
+ ok = file:delete(Output),
+ run(Config, Cmd, FileName, "-W",
+ ["_OK_"]),
+ true = exists(Output),
%% Try -W option and more verbose.
- ?line ok = file:delete(Output),
- ?line case test_server:os_type() of
- {unix,_} ->
- ?line run(Config, Cmd, FileName, "-W +'{verbosity,info}'",
- ["\\[GOOD-MIB[.]mib\\]\\[INF\\]: No accessfunction for 'sysDescr' => using default",
- "_OK_"]),
- ?line true = exists(Output),
- ?line ok = file:delete(Output);
- _ -> ok %Don't bother -- too much work.
- end,
+ ok = file:delete(Output),
+ case test_server:os_type() of
+ {unix,_} ->
+ run(Config, Cmd, FileName, "-W +'{verbosity,info}'",
+ ["\\[GOOD-MIB[.]mib\\]\\[INF\\]: No accessfunction for 'sysDescr' => using default",
+ "_OK_"]),
+ true = exists(Output),
+ ok = file:delete(Output);
+ _ -> ok %Don't bother -- too much work.
+ end,
%% Try a bad file.
- ?line BadFile = filename:join(SrcDir, "BAD-MIB.mib"),
- ?line run(Config, Cmd, BadFile, "",
- ["BAD-MIB.mib: 1: syntax error before: mibs\$",
- "compilation_failed_ERROR_"]),
+ BadFile = filename:join(SrcDir, "BAD-MIB.mib"),
+ run(Config, Cmd, BadFile, "",
+ ["BAD-MIB.mib: 1: syntax error before: mibs\$",
+ "compilation_failed_ERROR_"]),
%% Make sure that no -I option works.
- ?line NewCmd = erlc() ++ " -o" ++ OutDir ++ " ",
- ?line run(Config, NewCmd, FileName, "", ["_OK_"]),
- ?line true = exists(Output),
+ NewCmd = erlc() ++ " -o" ++ OutDir ++ " ",
+ run(Config, NewCmd, FileName, "", ["_OK_"]),
+ true = exists(Output),
ok.
@@ -169,99 +167,175 @@ compile_mib(Config) when is_list(Config) ->
%% shell script with redirected input).
good_citizen(Config) when is_list(Config) ->
case os:type() of
- {unix, _} ->
- ?line PrivDir = ?config(priv_dir, Config),
- ?line Answer = filename:join(PrivDir, "answer"),
- ?line Script = filename:join(PrivDir, "test_script"),
- ?line Test = filename:join(PrivDir, "test.erl"),
- ?line S = ["#! /bin/sh\n", "erlc ", Test, "\n",
- "read reply\n", "echo $reply\n"],
- ?line ok = file:write_file(Script, S),
- ?line ok = file:write_file(Test, "-module(test).\n"),
- ?line Cmd = "echo y | sh " ++ Script ++ " > " ++ Answer,
- ?line os:cmd(Cmd),
- ?line {ok, Answer0} = file:read_file(Answer),
- ?line [$y|_] = binary_to_list(Answer0),
- ok;
- _ ->
- {skip, "Unix specific"}
+ {unix, _} ->
+ PrivDir = proplists:get_value(priv_dir, Config),
+ Answer = filename:join(PrivDir, "answer"),
+ Script = filename:join(PrivDir, "test_script"),
+ Test = filename:join(PrivDir, "test.erl"),
+ S = ["#! /bin/sh\n", "erlc ", Test, "\n",
+ "read reply\n", "echo $reply\n"],
+ ok = file:write_file(Script, S),
+ ok = file:write_file(Test, "-module(test).\n"),
+ Cmd = "echo y | sh " ++ Script ++ " > " ++ Answer,
+ os:cmd(Cmd),
+ {ok, Answer0} = file:read_file(Answer),
+ [$y|_] = binary_to_list(Answer0),
+ ok;
+ _ ->
+ {skip, "Unix specific"}
end.
%% Make sure that compiling an Erlang module deep down in
%% in a directory with more than 255 characters works.
deep_cwd(Config) when is_list(Config) ->
case os:type() of
- {unix, _} ->
- PrivDir = ?config(priv_dir, Config),
- deep_cwd_1(PrivDir);
- _ ->
- {skip, "Only a problem on Unix"}
+ {unix, _} ->
+ PrivDir = proplists:get_value(priv_dir, Config),
+ deep_cwd_1(PrivDir);
+ _ ->
+ {skip, "Only a problem on Unix"}
end.
deep_cwd_1(PrivDir) ->
- ?line DeepDir0 = filename:join(PrivDir, lists:duplicate(128, $a)),
- ?line DeepDir = filename:join(DeepDir0, lists:duplicate(128, $b)),
- ?line ok = file:make_dir(DeepDir0),
- ?line ok = file:make_dir(DeepDir),
- ?line ok = file:set_cwd(DeepDir),
- ?line ok = file:write_file("test.erl", "-module(test).\n\n"),
- ?line io:format("~s\n", [os:cmd("erlc test.erl")]),
- ?line true = filelib:is_file("test.beam"),
+ DeepDir0 = filename:join(PrivDir, lists:duplicate(128, $a)),
+ DeepDir = filename:join(DeepDir0, lists:duplicate(128, $b)),
+ ok = file:make_dir(DeepDir0),
+ ok = file:make_dir(DeepDir),
+ ok = file:set_cwd(DeepDir),
+ ok = file:write_file("test.erl", "-module(test).\n\n"),
+ io:format("~s\n", [os:cmd("erlc test.erl")]),
+ true = filelib:is_file("test.beam"),
ok.
%% Test that a large number of command line switches does not
%% overflow the argument buffer
arg_overflow(Config) when is_list(Config) ->
- ?line {SrcDir, _OutDir, Cmd} = get_cmd(Config),
- ?line FileName = filename:join(SrcDir, "erl_test_ok.erl"),
+ {SrcDir, _OutDir, Cmd} = get_cmd(Config),
+ FileName = filename:join(SrcDir, "erl_test_ok.erl"),
%% Each -D option will be expanded to three arguments when
%% invoking 'erl'.
- ?line NumDOptions = num_d_options(),
- ?line Args = lists:flatten([ ["-D", integer_to_list(N, 36), "=1 "] ||
- N <- lists:seq(1, NumDOptions) ]),
- ?line run(Config, Cmd, FileName, Args,
- ["Warning: function foo/0 is unused\$",
- "_OK_"]),
+ NumDOptions = num_d_options(),
+ Args = lists:flatten([ ["-D", integer_to_list(N, 36), "=1 "] ||
+ N <- lists:seq(1, NumDOptions) ]),
+ run(Config, Cmd, FileName, Args,
+ ["Warning: function foo/0 is unused\$",
+ "_OK_"]),
ok.
num_d_options() ->
case {os:type(),os:version()} of
- {{win32,_},_} ->
- %% The maximum size of a command line in the command
- %% shell on Windows is 8191 characters.
- %% Each -D option is expanded to "@dv NN 1", i.e.
- %% 8 characters. (Numbers up to 1295 can be expressed
- %% as two 36-base digits.)
- 1000;
- {{unix,linux},Version} when Version < {2,6,23} ->
- %% On some older 64-bit versions of Linux, the maximum number
- %% of arguments is 16383.
- %% See: http://www.in-ulm.de/~mascheck/various/argmax/
- 5440;
- {{unix,darwin},{Major,_,_}} when Major >= 11 ->
- %% "getconf ARG_MAX" still reports 262144 (as in previous
- %% version of MacOS X), but the useful space seem to have
- %% shrunk significantly (or possibly the number of arguments).
- %% 7673
- 7500;
- {_,_} ->
- 12000
+ {{win32,_},_} ->
+ %% The maximum size of a command line in the command
+ %% shell on Windows is 8191 characters.
+ %% Each -D option is expanded to "@dv NN 1", i.e.
+ %% 8 characters. (Numbers up to 1295 can be expressed
+ %% as two 36-base digits.)
+ 1000;
+ {{unix,linux},Version} when Version < {2,6,23} ->
+ %% On some older 64-bit versions of Linux, the maximum number
+ %% of arguments is 16383.
+ %% See: http://www.in-ulm.de/~mascheck/various/argmax/
+ 5440;
+ {{unix,darwin},{Major,_,_}} when Major >= 11 ->
+ %% "getconf ARG_MAX" still reports 262144 (as in previous
+ %% version of MacOS X), but the useful space seem to have
+ %% shrunk significantly (or possibly the number of arguments).
+ %% 7673
+ 7500;
+ {_,_} ->
+ 12000
end.
erlc() ->
case os:find_executable("erlc") of
- false ->
- test_server:fail("Can't find erlc");
- Erlc ->
- "\"" ++ Erlc ++ "\""
+ false ->
+ ct:fail("Can't find erlc");
+ Erlc ->
+ "\"" ++ Erlc ++ "\""
end.
-
+
+make_dep_options(Config) ->
+ {SrcDir,OutDir,Cmd} = get_cmd(Config),
+ FileName = filename:join(SrcDir, "erl_test_ok.erl"),
+
+
+ DepRE = ["/erl_test_ok[.]beam: \\\\$",
+ "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$",
+ "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$",
+ "_OK_"],
+
+ DepRETarget =
+ ["^target: \\\\$",
+ "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$",
+ "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$",
+ "_OK_"],
+
+ DepREMP =
+ ["/erl_test_ok[.]beam: \\\\$",
+ "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$",
+ "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$",
+ [],
+ "/system_test/erlc_SUITE_data/include/erl_test.hrl:$",
+ "_OK_"],
+
+ DepREMissing =
+ ["/erl_test_missing_header[.]beam: \\\\$",
+ "/system_test/erlc_SUITE_data/src/erl_test_missing_header[.]erl \\\\$",
+ "/system_test/erlc_SUITE_data/include/erl_test[.]hrl \\\\$",
+ "missing.hrl$",
+ "_OK_"],
+
+ %% Test plain -M
+ run(Config, Cmd, FileName, "-M", DepRE),
+
+ %% Test -MF File
+ DepFile = filename:join(OutDir, "my.deps"),
+ run(Config, Cmd, FileName, "-MF "++DepFile, ["_OK_"]),
+ {ok,MFBin} = file:read_file(DepFile),
+ verify_result(binary_to_list(MFBin)++["_OK_"], DepRE),
+
+ %% Test -MD
+ run(Config, Cmd, FileName, "-MD", ["_OK_"]),
+ MDFile = filename:join(OutDir, "erl_test_ok.Pbeam"),
+ {ok,MFBin} = file:read_file(MDFile),
+
+ %% Test -M -MT Target
+ run(Config, Cmd, FileName, "-M -MT target", DepRETarget),
+
+ %% Test -MF File -MT Target
+ TargetDepFile = filename:join(OutDir, "target.deps"),
+ run(Config, Cmd, FileName, "-MF "++TargetDepFile++" -MT target",
+ ["_OK_"]),
+ {ok,TargetBin} = file:read_file(TargetDepFile),
+ verify_result(binary_to_list(TargetBin)++["_OK_"], DepRETarget),
+
+ %% Test -MD -MT Target
+ run(Config, Cmd, FileName, "-MD -MT target", ["_OK_"]),
+ TargetMDFile = filename:join(OutDir, "erl_test_ok.Pbeam"),
+ {ok,TargetBin} = file:read_file(TargetMDFile),
+
+ %% Test -M -MQ Target. (Note: Passing a $ on the command line
+ %% portably for Unix and Windows is tricky, so we will just test
+ %% that MQ works at all.)
+ run(Config, Cmd, FileName, "-M -MQ target", DepRETarget),
+
+ %% Test -M -MP
+ run(Config, Cmd, FileName, "-M -MP", DepREMP),
+
+ %% Test -M -MG
+ MissingHeader = filename:join(SrcDir, "erl_test_missing_header.erl"),
+ run(Config, Cmd, MissingHeader, "-M -MG", DepREMissing),
+ ok.
+
%% Runs a command.
run(Config, Cmd0, Name, Options, Expect) ->
Cmd = Cmd0 ++ " " ++ Options ++ " " ++ Name,
- io:format("~s", [Cmd]),
+ io:format("~ts", [Cmd]),
Result = run_command(Config, Cmd),
+ verify_result(Result, Expect).
+
+verify_result(Result, Expect) ->
Messages = split(Result, [], []),
io:format("Result: ~p", [Messages]),
io:format("Expected: ~p", [Expect]),
@@ -279,34 +353,34 @@ split([], Current, Lines) ->
split([], [], [lists:reverse(Current)|Lines]).
match_messages([Msg|Rest1], [Regexp|Rest2]) ->
- case re:run(Msg, Regexp, [{capture,none}]) of
- match ->
- ok;
- nomatch ->
- io:format("Not matching: ~s\n", [Msg]),
- io:format("Regexp : ~s\n", [Regexp]),
- test_server:fail(message_mismatch)
+ case re:run(Msg, Regexp, [{capture,none}, unicode]) of
+ match ->
+ ok;
+ nomatch ->
+ io:format("Not matching: ~s\n", [Msg]),
+ io:format("Regexp : ~s\n", [Regexp]),
+ ct:fail(message_mismatch)
end,
match_messages(Rest1, Rest2);
match_messages([], [Expect|Rest]) ->
- test_server:fail({too_few_messages, [Expect|Rest]});
+ ct:fail({too_few_messages, [Expect|Rest]});
match_messages([Msg|Rest], []) ->
- test_server:fail({too_many_messages, [Msg|Rest]});
+ ct:fail({too_many_messages, [Msg|Rest]});
match_messages([], []) ->
ok.
get_cmd(Cfg) ->
- ?line {SrcDir, IncDir, OutDir} = get_dirs(Cfg),
- ?line Cmd = erlc() ++ " -I" ++ IncDir ++ " -o" ++ OutDir ++ " ",
+ {SrcDir, IncDir, OutDir} = get_dirs(Cfg),
+ Cmd = erlc() ++ " -I" ++ IncDir ++ " -o" ++ OutDir ++ " ",
{SrcDir, OutDir, Cmd}.
get_dirs(Cfg) ->
- ?line DataDir = ?config(data_dir, Cfg),
- ?line PrivDir = ?config(priv_dir, Cfg),
- ?line SrcDir = filename:join(DataDir, "src"),
- ?line IncDir = filename:join(DataDir, "include"),
+ DataDir = proplists:get_value(data_dir, Cfg),
+ PrivDir = proplists:get_value(priv_dir, Cfg),
+ SrcDir = filename:join(DataDir, "src"),
+ IncDir = filename:join(DataDir, "include"),
{SrcDir, IncDir, PrivDir}.
-
+
exists(Name) ->
filelib:is_file(Name).
@@ -318,16 +392,16 @@ exists(Name) ->
%% a non-zero exit status.
run_command(Config, Cmd) ->
- TmpDir = filename:join(?config(priv_dir, Config), "tmp"),
+ TmpDir = filename:join(proplists:get_value(priv_dir, Config), "tmp"),
file:make_dir(TmpDir),
{RunFile, Run, Script} = run_command(TmpDir, os:type(), Cmd),
- ok = file:write_file(filename:join(TmpDir, RunFile), Script),
+ ok = file:write_file(filename:join(TmpDir, RunFile), unicode:characters_to_binary(Script)),
os:cmd(Run).
run_command(Dir, {win32, _}, Cmd) ->
BatchFile = filename:join(Dir, "run.bat"),
Run = re:replace(filename:rootname(BatchFile), "/", "\\",
- [global,{return,list}]),
+ [global,{return,list}]),
{BatchFile,
Run,
["@echo off\r\n",
@@ -348,5 +422,4 @@ run_command(Dir, {unix, _}, Cmd) ->
" *) echo '_ERROR_';;\n",
"esac\n"]};
run_command(_Dir, Other, _Cmd) ->
- M = io_lib:format("Don't know how to test exit code for ~p", [Other]),
- test_server:fail(lists:flatten(M)).
+ ct:fail("Don't know how to test exit code for ~p", [Other]).
diff --git a/erts/test/erlc_SUITE_data/include/erl_test.hrl b/erts/test/erlc_SUITE_data/include/erl_test.hrl
index fd89cb2f60..70aecc4762 100644
--- a/erts/test/erlc_SUITE_data/include/erl_test.hrl
+++ b/erts/test/erlc_SUITE_data/include/erl_test.hrl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
diff --git a/erts/test/erlc_SUITE_data/src/erl_test_bad.erl b/erts/test/erlc_SUITE_data/src/erl_test_bad.erl
index fb62f835ca..cbfe81705f 100644
--- a/erts/test/erlc_SUITE_data/src/erl_test_bad.erl
+++ b/erts/test/erlc_SUITE_data/src/erl_test_bad.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
diff --git a/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl b/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl
new file mode 100644
index 0000000000..604bb16bd6
--- /dev/null
+++ b/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl
@@ -0,0 +1,23 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2013-2016. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(erl_test_missing_header).
+-include("erl_test.hrl").
+-include("missing.hrl").
diff --git a/erts/test/erlc_SUITE_data/src/erl_test_ok.erl b/erts/test/erlc_SUITE_data/src/erl_test_ok.erl
index 50fa063a94..f1a48cbf18 100644
--- a/erts/test/erlc_SUITE_data/src/erl_test_ok.erl
+++ b/erts/test/erlc_SUITE_data/src/erl_test_ok.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
diff --git a/erts/test/erlc_SUITE_data/src/start_ok.script b/erts/test/erlc_SUITE_data/src/start_ok.script
index 4cd89f0439..7ef97dc3f3 100644
--- a/erts/test/erlc_SUITE_data/src/start_ok.script
+++ b/erts/test/erlc_SUITE_data/src/start_ok.script
@@ -52,7 +52,6 @@
shell_default,
timer,
gen_fsm,
- pg,
unix,
dict,
pool,
@@ -156,7 +155,6 @@
{timer,1},
{gen_fsm,1},
{io_lib_pretty,1},
- {pg,1},
{slave,1},
{unix,1},
{dict,1},
diff --git a/erts/test/erlc_SUITE_data/src/yecc_test_bad.yrl b/erts/test/erlc_SUITE_data/src/yecc_test_bad.yrl
index 409718e24c..da488b7232 100644
--- a/erts/test/erlc_SUITE_data/src/yecc_test_bad.yrl
+++ b/erts/test/erlc_SUITE_data/src/yecc_test_bad.yrl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
diff --git a/erts/test/erlc_SUITE_data/src/yecc_test_ok.yrl b/erts/test/erlc_SUITE_data/src/yecc_test_ok.yrl
index a96085ac2d..feb067e34b 100644
--- a/erts/test/erlc_SUITE_data/src/yecc_test_ok.yrl
+++ b/erts/test/erlc_SUITE_data/src/yecc_test_ok.yrl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2016. 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.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
diff --git a/erts/test/erlexec_SUITE.erl b/erts/test/erlexec_SUITE.erl
index 0dfe6c2e5f..44d7f63387 100644
--- a/erts/test/erlexec_SUITE.erl
+++ b/erts/test/erlexec_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -26,71 +27,46 @@
%%%-------------------------------------------------------------------
-module(erlexec_SUITE).
+-export([all/0, suite/0, init_per_testcase/2, end_per_testcase/2]).
-%-define(line_trace, 1).
-
--define(DEFAULT_TIMEOUT, ?t:minutes(1)).
-
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
- init_per_testcase/2, end_per_testcase/2]).
+-export([args_file/1, evil_args_file/1, env/1, args_file_env/1,
+ otp_7461/1, otp_7461_remote/1, otp_8209/1,
+ zdbbl_dist_buf_busy_limit/1]).
--export([args_file/1, evil_args_file/1, env/1, args_file_env/1, otp_7461/1, otp_7461_remote/1, otp_8209/1, zdbbl_dist_buf_busy_limit/1]).
-
--include_lib("test_server/include/test_server.hrl").
-
+-include_lib("common_test/include/ct.hrl").
init_per_testcase(Case, Config) ->
- Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
SavedEnv = save_env(),
- [{testcase, Case}, {watchdog, Dog}, {erl_flags_env, SavedEnv} |Config].
+ [{testcase, Case},{erl_flags_env, SavedEnv}|Config].
end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- SavedEnv = ?config(erl_flags_env, Config),
+ SavedEnv = proplists:get_value(erl_flags_env, Config),
restore_env(SavedEnv),
cleanup_nodes(),
- ?t:timetrap_cancel(Dog),
ok.
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 1}}].
all() ->
[args_file, evil_args_file, env, args_file_env,
otp_7461, otp_8209, zdbbl_dist_buf_busy_limit].
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
-otp_8209(doc) ->
- ["Test that plain first argument does not "
- "destroy -home switch [OTP-8209]"];
-otp_8209(suite) ->
- [];
+%% Test that plain first argument does not
+%% destroy -home switch [OTP-8209]
otp_8209(Config) when is_list(Config) ->
- ?line {ok,[[PName]]} = init:get_argument(progname),
- ?line SNameS = "erlexec_test_01",
- ?line SName = list_to_atom(SNameS++"@"++
+ {ok,[[PName]]} = init:get_argument(progname),
+ SNameS = "erlexec_test_01",
+ SName = list_to_atom(SNameS++"@"++
hd(tl(string:tokens(atom_to_list(node()),"@")))),
- ?line Cmd = PName ++ " dummy_param -sname "++SNameS++" -setcookie "++
+ Cmd = PName ++ " dummy_param -sname "++SNameS++" -setcookie "++
atom_to_list(erlang:get_cookie()),
- ?line open_port({spawn,Cmd},[]),
- ?line pong = loop_ping(SName,40),
- ?line {ok,[[_]]} = rpc:call(SName,init,get_argument,[home]),
- ?line ["dummy_param"] = rpc:call(SName,init,get_plain_arguments,[]),
- ?line ok = cleanup_nodes(),
+ open_port({spawn,Cmd},[]),
+ pong = loop_ping(SName,40),
+ {ok,[[_]]} = rpc:call(SName,init,get_argument,[home]),
+ ["dummy_param"] = rpc:call(SName,init,get_plain_arguments,[]),
+ ok = cleanup_nodes(),
ok.
cleanup_nodes() ->
@@ -122,17 +98,14 @@ loop_ping(Node,N) ->
pong
end.
-args_file(doc) -> [];
-args_file(suite) -> [];
args_file(Config) when is_list(Config) ->
- ?line AFN1 = privfile("1", Config),
- ?line AFN2 = privfile("2", Config),
- ?line AFN3 = privfile("3", Config),
- ?line AFN4 = privfile("4", Config),
- ?line AFN5 = privfile("5", Config),
- ?line AFN6 = privfile("6", Config),
- ?line write_file(AFN1,
- "-MiscArg2~n"
+ AFN1 = privfile("1", Config),
+ AFN2 = privfile("2", Config),
+ AFN3 = privfile("3", Config),
+ AFN4 = privfile("4", Config),
+ AFN5 = privfile("5", Config),
+ AFN6 = privfile("6", Config),
+ write_file(AFN1, "-MiscArg2~n"
"# a comment +\\#1000~n"
"+\\#200 # another comment~n"
"~n"
@@ -144,7 +117,7 @@ args_file(Config) when is_list(Config) ->
"+\\#700~n"
"-extra +XtraArg6~n",
[AFN2]),
- ?line write_file(AFN2,
+ write_file(AFN2,
"-MiscArg3~n"
"+\\#300~n"
"-args_file ~s~n"
@@ -155,61 +128,59 @@ args_file(Config) when is_list(Config) ->
"-args_file ~s~n"
"-extra +XtraArg5~n",
[AFN3, AFN4, AFN5, AFN6]),
- ?line write_file(AFN3,
+ write_file(AFN3,
"# comment again~n"
" -MiscArg4 +\\#400 -extra +XtraArg1"),
- ?line write_file(AFN4,
+ write_file(AFN4,
" -MiscArg6 +\\#600 -extra +XtraArg2~n"
"+XtraArg3~n"
"+XtraArg4~n"
"# comment again~n"),
- ?line write_file(AFN5, ""),
- ?line write_file(AFN6, "-extra # +XtraArg10~n"),
- ?line CmdLine = "+#100 -MiscArg1 "
+ write_file(AFN5, ""),
+ write_file(AFN6, "-extra # +XtraArg10~n"),
+ CmdLine = "+#100 -MiscArg1 "
++ "-args_file " ++ AFN1
++ " +#800 -MiscArg8 -extra +XtraArg7 +XtraArg8",
- ?line {Emu, Misc, Extra} = emu_args(CmdLine),
- ?line verify_args(["-#100", "-#200", "-#300", "-#400",
+ {Emu, Misc, Extra} = emu_args(CmdLine),
+ verify_args(["-#100", "-#200", "-#300", "-#400",
"-#500", "-#600", "-#700", "-#800"], Emu),
- ?line verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
+ verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
"-MiscArg5", "-MiscArg6", "-MiscArg7", "-MiscArg8"],
Misc),
- ?line verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
+ verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
"+XtraArg5", "+XtraArg6", "+XtraArg7", "+XtraArg8"],
Extra),
- ?line verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
+ verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
"-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
"-MiscArg5", "-MiscArg6", "-MiscArg7", "-MiscArg8",
"+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
"+XtraArg5", "+XtraArg6", "+XtraArg7", "+XtraArg8"],
Emu),
- ?line verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
+ verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
"-#100", "-#200", "-#300", "-#400",
"-#500", "-#600", "-#700", "-#800",
"+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
"+XtraArg5", "+XtraArg6", "+XtraArg7", "+XtraArg8"],
Misc),
- ?line verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
+ verify_not_args(["-MiscArg10", "-#1000", "+XtraArg10",
"-#100", "-#200", "-#300", "-#400",
"-#500", "-#600", "-#700", "-#800",
"-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
"-MiscArg5", "-MiscArg6", "-MiscArg7", "-MiscArg8"],
Extra),
- ?line ok.
+ ok.
-evil_args_file(doc) -> [];
-evil_args_file(suite) -> [];
evil_args_file(Config) when is_list(Config) ->
- ?line Lim = 300,
- ?line FNums = lists:seq(1, Lim),
+ Lim = 300,
+ FNums = lists:seq(1, Lim),
lists:foreach(fun (End) when End == Lim ->
- ?line AFN = privfile(integer_to_list(End), Config),
- ?line write_file(AFN,
+ AFN = privfile(integer_to_list(End), Config),
+ write_file(AFN,
"-MiscArg~p ",
[End]);
(I) ->
- ?line AFNX = privfile(integer_to_list(I), Config),
- ?line AFNY = privfile(integer_to_list(I+1), Config),
+ AFNX = privfile(integer_to_list(I), Config),
+ AFNY = privfile(integer_to_list(I+1), Config),
{Frmt, Args} =
case I rem 2 of
0 ->
@@ -219,65 +190,59 @@ evil_args_file(Config) when is_list(Config) ->
{"-MiscArg~p -args_file ~s",
[I, AFNY]}
end,
- ?line write_file(AFNX, Frmt, Args)
+ write_file(AFNX, Frmt, Args)
end,
FNums),
- ?line {_Emu, Misc, _Extra} = emu_args("-args_file "
+ {_Emu, Misc, _Extra} = emu_args("-args_file "
++ privfile("1", Config)),
- ?line ANums = FNums
+ ANums = FNums
++ lists:reverse(lists:filter(fun (I) when I == Lim -> false;
(I) when I rem 2 == 0 -> true;
(_) -> false
end, FNums)),
- ?line verify_args(lists:map(fun (I) -> "-MiscArg"++integer_to_list(I) end,
+ verify_args(lists:map(fun (I) -> "-MiscArg"++integer_to_list(I) end,
ANums),
Misc),
- ?line ok.
+ ok.
-env(doc) -> [];
-env(suite) -> [];
env(Config) when is_list(Config) ->
- ?line os:putenv("ERL_AFLAGS", "-MiscArg1 +#100 -extra +XtraArg1 +XtraArg2"),
- ?line CmdLine = "+#200 -MiscArg2 -extra +XtraArg3 +XtraArg4",
- ?line os:putenv("ERL_FLAGS", "-MiscArg3 +#300 -extra +XtraArg5"),
- ?line os:putenv("ERL_ZFLAGS", "-MiscArg4 +#400 -extra +XtraArg6"),
- ?line {Emu, Misc, Extra} = emu_args(CmdLine),
- ?line verify_args(["-#100", "-#200", "-#300", "-#400"], Emu),
- ?line verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4"],
+ os:putenv("ERL_AFLAGS", "-MiscArg1 +#100 -extra +XtraArg1 +XtraArg2"),
+ CmdLine = "+#200 -MiscArg2 -extra +XtraArg3 +XtraArg4",
+ os:putenv("ERL_FLAGS", "-MiscArg3 +#300 -extra +XtraArg5"),
+ os:putenv("ERL_ZFLAGS", "-MiscArg4 +#400 -extra +XtraArg6"),
+ {Emu, Misc, Extra} = emu_args(CmdLine),
+ verify_args(["-#100", "-#200", "-#300", "-#400"], Emu),
+ verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4"],
Misc),
- ?line verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
+ verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
"+XtraArg5", "+XtraArg6"],
Extra),
- ?line ok.
+ ok.
-args_file_env(doc) -> [];
-args_file_env(suite) -> [];
args_file_env(Config) when is_list(Config) ->
- ?line AFN1 = privfile("1", Config),
- ?line AFN2 = privfile("2", Config),
- ?line write_file(AFN1, "-MiscArg2 +\\#200 -extra +XtraArg1"),
- ?line write_file(AFN2, "-MiscArg3 +\\#400 -extra +XtraArg3"),
- ?line os:putenv("ERL_AFLAGS",
+ AFN1 = privfile("1", Config),
+ AFN2 = privfile("2", Config),
+ write_file(AFN1, "-MiscArg2 +\\#200 -extra +XtraArg1"),
+ write_file(AFN2, "-MiscArg3 +\\#400 -extra +XtraArg3"),
+ os:putenv("ERL_AFLAGS",
"-MiscArg1 +#100 -args_file "++AFN1++ " -extra +XtraArg2"),
- ?line CmdLine = "+#300 -args_file "++AFN2++" -MiscArg4 -extra +XtraArg4",
- ?line os:putenv("ERL_FLAGS", "-MiscArg5 +#500 -extra +XtraArg5"),
- ?line os:putenv("ERL_ZFLAGS", "-MiscArg6 +#600 -extra +XtraArg6"),
- ?line {Emu, Misc, Extra} = emu_args(CmdLine),
- ?line verify_args(["-#100", "-#200", "-#300", "-#400",
+ CmdLine = "+#300 -args_file "++AFN2++" -MiscArg4 -extra +XtraArg4",
+ os:putenv("ERL_FLAGS", "-MiscArg5 +#500 -extra +XtraArg5"),
+ os:putenv("ERL_ZFLAGS", "-MiscArg6 +#600 -extra +XtraArg6"),
+ {Emu, Misc, Extra} = emu_args(CmdLine),
+ verify_args(["-#100", "-#200", "-#300", "-#400",
"-#500", "-#600"], Emu),
- ?line verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
+ verify_args(["-MiscArg1", "-MiscArg2", "-MiscArg3", "-MiscArg4",
"-MiscArg5", "-MiscArg6"],
Misc),
- ?line verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
+ verify_args(["+XtraArg1", "+XtraArg2", "+XtraArg3", "+XtraArg4",
"+XtraArg5", "+XtraArg6"],
Extra),
- ?line ok.
+ ok.
%% Make sure "erl -detached" survives when parent process group gets killed
-otp_7461(doc) -> [];
-otp_7461(suite) -> [];
otp_7461(Config) when is_list(Config) ->
case os:type() of
{unix,_} ->
@@ -301,9 +266,9 @@ otp_7461(Config) when is_list(Config) ->
otp_7461_do(Config) ->
io:format("alive=~p node=~p\n",[is_alive(), node()]),
- TestProg = filename:join([?config(data_dir, Config), "erlexec_tests"]),
+ TestProg = filename:join([proplists:get_value(data_dir, Config), "erlexec_tests"]),
{ok, [[ErlProg]]} = init:get_argument(progname),
- ?line Cmd = TestProg ++ " " ++ ErlProg ++
+ Cmd = TestProg ++ " " ++ ErlProg ++
" -detached -sname " ++ get_nodename(otp_7461) ++
" -setcookie " ++ atom_to_list(erlang:get_cookie()) ++
" -pa " ++ filename:dirname(code:which(?MODULE)) ++
@@ -313,29 +278,31 @@ otp_7461_do(Config) ->
%% open_port fork+exec
io:format("spawn port prog ~p\n",[Cmd]),
- ?line Port = open_port({spawn, Cmd}, [eof]),
+ Port = open_port({spawn, Cmd}, [eof]),
io:format("Wait for node to connect...\n",[]),
- ?line {nodeup, Slave} = receive Msg -> Msg
+ {nodeup, Slave} = receive Msg -> Msg
after 20*1000 -> timeout end,
io:format("Node alive: ~p\n", [Slave]),
- ?line pong = net_adm:ping(Slave),
+ pong = net_adm:ping(Slave),
io:format("Ping ok towards ~p\n", [Slave]),
- ?line Port ! { self(), {command, "K"}}, % Kill child process group
- ?line {Port, {data, "K"}} = receive Msg2 -> Msg2 end,
- ?line port_close(Port),
+ Port ! { self(), {command, "K"}}, % Kill child process group
+ {Port, {data, "K"}} = receive Msg2 -> Msg2 end,
+ port_close(Port),
%% Now the actual test. Detached node should still be alive.
- ?line pong = net_adm:ping(Slave),
+ pong = net_adm:ping(Slave),
io:format("Ping still ok towards ~p\n", [Slave]),
%% Halt node
- ?line rpc:cast(Slave, ?MODULE, otp_7461_remote, [[halt, self()]]),
+ rpc:cast(Slave, ?MODULE, otp_7461_remote, [[halt, self()]]),
- ?line {nodedown, Slave} = receive Msg3 -> Msg3
- after 20*1000 -> timeout end,
+ {nodedown, Slave} = receive
+ Msg3 -> Msg3
+ after 20*1000 -> timeout
+ end,
io:format("Node dead: ~p\n", [Slave]),
ok.
@@ -348,24 +315,21 @@ otp_7461_remote([halt, Pid]) ->
io:format("halt order from ~p to node ~p\n",[Pid,node()]),
halt().
-zdbbl_dist_buf_busy_limit(doc) ->
- ["Check +zdbbl flag"];
-zdbbl_dist_buf_busy_limit(suite) ->
- [];
+%% Check +zdbbl flag
zdbbl_dist_buf_busy_limit(Config) when is_list(Config) ->
LimKB = 1122233,
LimB = LimKB*1024,
- ?line {ok,[[PName]]} = init:get_argument(progname),
- ?line SNameS = "erlexec_test_02",
- ?line SName = list_to_atom(SNameS++"@"++
+ {ok,[[PName]]} = init:get_argument(progname),
+ SNameS = "erlexec_test_02",
+ SName = list_to_atom(SNameS++"@"++
hd(tl(string:tokens(atom_to_list(node()),"@")))),
- ?line Cmd = PName ++ " -sname "++SNameS++" -setcookie "++
+ Cmd = PName ++ " -sname "++SNameS++" -setcookie "++
atom_to_list(erlang:get_cookie()) ++
" +zdbbl " ++ integer_to_list(LimKB),
- ?line open_port({spawn,Cmd},[]),
- ?line pong = loop_ping(SName,40),
- ?line LimB = rpc:call(SName,erlang,system_info,[dist_buf_busy_limit]),
- ?line ok = cleanup_node(SNameS, 10),
+ open_port({spawn,Cmd},[]),
+ pong = loop_ping(SName,40),
+ LimB = rpc:call(SName,erlang,system_info,[dist_buf_busy_limit]),
+ ok = cleanup_node(SNameS, 10),
ok.
@@ -403,8 +367,8 @@ restore_env({erl_flags, AFlgs, Flgs, RFlgs, ZFlgs}) ->
ok.
privfile(Name, Config) ->
- filename:join([?config(priv_dir, Config),
- atom_to_list(?config(testcase, Config)) ++ "." ++ Name]).
+ filename:join([proplists:get_value(priv_dir, Config),
+ atom_to_list(proplists:get_value(testcase, Config)) ++ "." ++ Name]).
write_file(FileName, Frmt) ->
write_file(FileName, Frmt, []).
@@ -429,14 +393,13 @@ verify_not_args(Xs, Ys) ->
true -> exit({arg_present, X});
false -> ok
end
- end,
- Xs).
+ end, Xs).
emu_args(CmdLineArgs) ->
- io:format("CmdLineArgs = ~s~n", [CmdLineArgs]),
+ io:format("CmdLineArgs = ~ts~n", [CmdLineArgs]),
{ok,[[Erl]]} = init:get_argument(progname),
EmuCL = os:cmd(Erl ++ " -emu_args_exit " ++ CmdLineArgs),
- io:format("EmuCL = ~s", [EmuCL]),
+ io:format("EmuCL = ~ts", [EmuCL]),
split_emu_clt(string:tokens(EmuCL, [$ ,$\t,$\n,$\r])).
split_emu_clt(EmuCLT) ->
@@ -462,13 +425,10 @@ split_emu_clt([A|As], Emu, Misc, Extra, extra = Type) ->
get_nodename(T) ->
- {A, B, C} = now(),
atom_to_list(T)
++ "-"
++ atom_to_list(?MODULE)
++ "-"
- ++ integer_to_list(A)
- ++ "-"
- ++ integer_to_list(B)
+ ++ integer_to_list(erlang:system_time(seconds))
++ "-"
- ++ integer_to_list(C).
+ ++ integer_to_list(erlang:unique_integer([positive])).
diff --git a/erts/test/erlexec_SUITE_data/Makefile.src b/erts/test/erlexec_SUITE_data/Makefile.src
index 2a8decaa4b..641dff1e30 100644
--- a/erts/test/erlexec_SUITE_data/Makefile.src
+++ b/erts/test/erlexec_SUITE_data/Makefile.src
@@ -1,18 +1,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2008-2012. All Rights Reserved.
+# Copyright Ericsson AB 2008-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
diff --git a/erts/test/erlexec_SUITE_data/erlexec_tests.c b/erts/test/erlexec_SUITE_data/erlexec_tests.c
index 1d1ca881d9..bd28d2900c 100644
--- a/erts/test/erlexec_SUITE_data/erlexec_tests.c
+++ b/erts/test/erlexec_SUITE_data/erlexec_tests.c
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2008-2010. All Rights Reserved.
+ * Copyright Ericsson AB 2008-2016. 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/.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * 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.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/ethread_SUITE.erl b/erts/test/ethread_SUITE.erl
index 24075286a8..19f738c572 100644
--- a/erts/test/ethread_SUITE.erl
+++ b/erts/test/ethread_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -27,13 +28,7 @@
-module(ethread_SUITE).
-author('[email protected]').
-%-define(line_trace, 1).
-
--define(DEFAULT_TIMEOUT, ?t:minutes(10)).
-
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
- init_per_testcase/2, end_per_testcase/2]).
+-export([all/0, suite/0, init_per_testcase/2, end_per_testcase/2]).
-export([create_join_thread/1,
equal_tids/1,
@@ -50,9 +45,13 @@
atomic/1,
dw_atomic_massage/1]).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-tests() ->
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 10}}].
+
+all() ->
[create_join_thread,
equal_tids,
mutex,
@@ -68,110 +67,50 @@ tests() ->
atomic,
dw_atomic_massage].
-suite() -> [{ct_hooks,[ts_install_cth]}].
-
-all() ->
- tests().
-
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
+init_per_testcase(Case, Config) ->
+ case inet:gethostname() of
+ {ok,"fenris"} when Case == max_threads ->
+ %% Cannot use os:type+os:version as not all
+ %% solaris10 machines are buggy.
+ {skip, "This machine is buggy"};
+ _Else ->
+ Config
+ end.
-end_per_suite(_Config) ->
+end_per_testcase(_Case, _Config) ->
ok.
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
%%
%%
%% The test-cases
%%
%%
-create_join_thread(doc) ->
- ["Tests ethr_thr_create and ethr_thr_join."];
-create_join_thread(suite) ->
- [];
+%% Tests ethr_thr_create and ethr_thr_join.
create_join_thread(Config) ->
run_case(Config, "create_join_thread", "").
-equal_tids(doc) ->
- ["Tests ethr_equal_tids."];
-equal_tids(suite) ->
- [];
+%% Tests ethr_equal_tids.
equal_tids(Config) ->
run_case(Config, "equal_tids", "").
-mutex(doc) ->
- ["Tests mutexes."];
-mutex(suite) ->
- [];
+%% Tests mutexes.
mutex(Config) ->
run_case(Config, "mutex", "").
-try_lock_mutex(doc) ->
- ["Tests try lock on mutex."];
-try_lock_mutex(suite) ->
- [];
+%% Tests try lock on mutex.
try_lock_mutex(Config) ->
run_case(Config, "try_lock_mutex", "").
-%% Remove dead code?
-
-% wd_dispatch(P) ->
-% receive
-% bye ->
-% ?line true = port_command(P, "-1 "),
-% ?line bye;
-% L when is_list(L) ->
-% ?line true = port_command(P, L),
-% ?line wd_dispatch(P)
-% end.
-%
-% watchdog(Port) ->
-% ?line process_flag(priority, max),
-% ?line receive after 500 -> ok end,
-%
-% ?line random:seed(),
-% ?line true = port_command(Port, "0 "),
-% ?line lists:foreach(fun (T) ->
-% erlang:send_after(T,
-% self(),
-% integer_to_list(T)
-% ++ " ")
-% end,
-% lists:usort(lists:map(fun (_) ->
-% random:uniform(4500)+500
-% end,
-% lists:duplicate(50,0)))),
-% ?line erlang:send_after(5100, self(), bye),
-%
-% wd_dispatch(Port).
-
-cond_wait(doc) ->
- ["Tests ethr_cond_wait with ethr_cond_signal and ethr_cond_broadcast."];
-cond_wait(suite) ->
- [];
+%% Tests ethr_cond_wait with ethr_cond_signal and ethr_cond_broadcast.
cond_wait(Config) ->
run_case(Config, "cond_wait", "").
-broadcast(doc) ->
- ["Tests that a ethr_cond_broadcast really wakes up all waiting threads"];
-broadcast(suite) ->
- [];
+%% Tests that a ethr_cond_broadcast really wakes up all waiting threads
broadcast(Config) ->
run_case(Config, "broadcast", "").
-detached_thread(doc) ->
- ["Tests detached threads."];
-detached_thread(suite) ->
- [];
+%% Tests detached threads.
detached_thread(Config) ->
case {os:type(), os:version()} of
{{unix,darwin}, {9, _, _}} ->
@@ -183,10 +122,7 @@ detached_thread(Config) ->
run_case(Config, "detached_thread", "")
end.
-max_threads(doc) ->
- ["Tests maximum number of threads."];
-max_threads(suite) ->
- [];
+%% Tests maximum number of threads.
max_threads(Config) ->
case {os:type(), os:version()} of
{{unix,darwin}, {9, _, _}} ->
@@ -198,45 +134,27 @@ max_threads(Config) ->
run_case(Config, "max_threads", "")
end.
-tsd(doc) ->
- ["Tests thread specific data."];
-tsd(suite) ->
- [];
+%% Tests thread specific data.
tsd(Config) ->
run_case(Config, "tsd", "").
-spinlock(doc) ->
- ["Tests spinlocks."];
-spinlock(suite) ->
- [];
+%% Tests spinlocks.
spinlock(Config) ->
run_case(Config, "spinlock", "").
-rwspinlock(doc) ->
- ["Tests rwspinlocks."];
-rwspinlock(suite) ->
- [];
+%% Tests rwspinlocks.
rwspinlock(Config) ->
run_case(Config, "rwspinlock", "").
-rwmutex(doc) ->
- ["Tests rwmutexes."];
-rwmutex(suite) ->
- [];
+%% Tests rwmutexes.
rwmutex(Config) ->
run_case(Config, "rwmutex", "").
-atomic(doc) ->
- ["Tests atomics."];
-atomic(suite) ->
- [];
+%% Tests atomics.
atomic(Config) ->
run_case(Config, "atomic", "").
-dw_atomic_massage(doc) ->
- ["Massage double word atomics"];
-dw_atomic_massage(suite) ->
- [];
+%% Massage double word atomics
dw_atomic_massage(Config) ->
run_case(Config, "dw_atomic_massage", "").
@@ -246,22 +164,6 @@ dw_atomic_massage(Config) ->
%%
%%
-init_per_testcase(Case, Config) ->
- case inet:gethostname() of
- {ok,"fenris"} when Case == max_threads ->
- %% Cannot use os:type+os:version as not all
- %% solaris10 machines are buggy.
- {skip, "This machine is buggy"};
- _Else ->
- Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
- [{watchdog, Dog}|Config]
- end.
-
-end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
- ok.
-
-define(TESTPROG, "ethread_tests").
-define(FAILED_MARKER, $E,$T,$H,$R,$-,$T,$E,$S,$T,$-,$F,$A,$I,$L,$U,$R,$E).
-define(SKIPPED_MARKER, $E,$T,$H,$R,$-,$T,$E,$S,$T,$-,$S,$K,$I,$P).
@@ -269,68 +171,68 @@ end_per_testcase(_Case, Config) ->
-define(PID_MARKER, $E,$T,$H,$R,$-,$T,$E,$S,$T,$-,$P,$I,$D).
port_prog_killer(EProc, OSProc) when is_pid(EProc), is_list(OSProc) ->
- ?line process_flag(trap_exit, true),
- ?line Ref = erlang:monitor(process, EProc),
- ?line receive
- {'DOWN', Ref, _, _, Reason} when is_tuple(Reason),
- element(1, Reason)
- == timetrap_timeout ->
- ?line Cmd = "kill -9 " ++ OSProc,
- ?line ?t:format("Test case timed out. "
- "Trying to kill port program.~n"
- " Executing: ~p~n", [Cmd]),
- ?line case os:cmd(Cmd) of
- [] ->
- ok;
- OsCmdRes ->
- ?line ?t:format(" ~s", [OsCmdRes])
- end;
- {'DOWN', Ref, _, _, _} ->
- %% OSProc is assumed to have terminated by itself
- ?line ok
- end.
+ process_flag(trap_exit, true),
+ Ref = erlang:monitor(process, EProc),
+ receive
+ {'DOWN', Ref, _, _, Reason} when is_tuple(Reason),
+ element(1, Reason)
+ == timetrap_timeout ->
+ Cmd = "kill -9 " ++ OSProc,
+ io:format("Test case timed out. "
+ "Trying to kill port program.~n"
+ " Executing: ~p~n", [Cmd]),
+ case os:cmd(Cmd) of
+ [] ->
+ ok;
+ OsCmdRes ->
+ io:format(" ~s", [OsCmdRes])
+ end;
+ %% OSProc is assumed to have terminated by itself
+ {'DOWN', Ref, _, _, _} ->
+ ok
+ end.
get_line(_Port, eol, Data) ->
- ?line Data;
+ Data;
get_line(Port, noeol, Data) ->
- ?line receive
+ receive
{Port, {data, {Flag, NextData}}} ->
- ?line get_line(Port, Flag, Data ++ NextData);
+ get_line(Port, Flag, Data ++ NextData);
{Port, eof} ->
- ?line ?t:fail(port_prog_unexpectedly_closed)
+ ct:fail(port_prog_unexpectedly_closed)
end.
read_case_data(Port, TestCase) ->
- ?line receive
- {Port, {data, {eol, [?SUCCESS_MARKER]}}} ->
- ?line ok;
- {Port, {data, {Flag, [?SUCCESS_MARKER | CommentStart]}}} ->
- ?line {comment, get_line(Port, Flag, CommentStart)};
- {Port, {data, {Flag, [?SKIPPED_MARKER | CommentStart]}}} ->
- ?line {skipped, get_line(Port, Flag, CommentStart)};
- {Port, {data, {Flag, [?FAILED_MARKER | ReasonStart]}}} ->
- ?line ?t:fail(get_line(Port, Flag, ReasonStart));
- {Port, {data, {eol, [?PID_MARKER | PidStr]}}} ->
- ?line ?t:format("Port program pid: ~s~n", [PidStr]),
- ?line CaseProc = self(),
- ?line _ = list_to_integer(PidStr), % Sanity check
- spawn_opt(fun () ->
- port_prog_killer(CaseProc, PidStr)
- end,
- [{priority, max}, link]),
- read_case_data(Port, TestCase);
- {Port, {data, {Flag, LineStart}}} ->
- ?line ?t:format("~s~n", [get_line(Port, Flag, LineStart)]),
- read_case_data(Port, TestCase);
- {Port, eof} ->
- ?line ?t:fail(port_prog_unexpectedly_closed)
- end.
+ receive
+ {Port, {data, {eol, [?SUCCESS_MARKER]}}} ->
+ ok;
+ {Port, {data, {Flag, [?SUCCESS_MARKER | CommentStart]}}} ->
+ {comment, get_line(Port, Flag, CommentStart)};
+ {Port, {data, {Flag, [?SKIPPED_MARKER | CommentStart]}}} ->
+ {skipped, get_line(Port, Flag, CommentStart)};
+ {Port, {data, {Flag, [?FAILED_MARKER | ReasonStart]}}} ->
+ ct:fail(get_line(Port, Flag, ReasonStart));
+ {Port, {data, {eol, [?PID_MARKER | PidStr]}}} ->
+ io:format("Port program pid: ~s~n", [PidStr]),
+ CaseProc = self(),
+ _ = list_to_integer(PidStr), % Sanity check
+ spawn_opt(fun () ->
+ port_prog_killer(CaseProc, PidStr)
+ end,
+ [{priority, max}, link]),
+ read_case_data(Port, TestCase);
+ {Port, {data, {Flag, LineStart}}} ->
+ io:format("~s~n", [get_line(Port, Flag, LineStart)]),
+ read_case_data(Port, TestCase);
+ {Port, eof} ->
+ ct:fail(port_prog_unexpectedly_closed)
+ end.
run_case(Config, Test, TestArgs) ->
run_case(Config, Test, TestArgs, fun (_Port) -> ok end).
run_case(Config, Test, TestArgs, Fun) ->
- TestProg = filename:join([?config(data_dir, Config), ?TESTPROG]),
+ TestProg = filename:join([proplists:get_value(data_dir, Config), ?TESTPROG]),
Cmd = TestProg ++ " " ++ Test ++ " " ++ TestArgs,
case catch open_port({spawn, Cmd}, [stream,
use_stdio,
@@ -338,17 +240,13 @@ run_case(Config, Test, TestArgs, Fun) ->
eof,
{line, 1024}]) of
Port when is_port(Port) ->
- ?line Fun(Port),
- ?line CaseResult = read_case_data(Port, Test),
- ?line receive
- {Port, eof} ->
- ?line ok
- end,
- ?line CaseResult;
+ Fun(Port),
+ CaseResult = read_case_data(Port, Test),
+ receive
+ {Port, eof} ->
+ ok
+ end,
+ CaseResult;
Error ->
- ?line ?t:fail({open_port_failed, Error})
+ ct:fail({open_port_failed, Error})
end.
-
-
-
-
diff --git a/erts/test/ethread_SUITE_data/Makefile.src b/erts/test/ethread_SUITE_data/Makefile.src
index bad133c467..cf675b92a3 100644
--- a/erts/test/ethread_SUITE_data/Makefile.src
+++ b/erts/test/ethread_SUITE_data/Makefile.src
@@ -1,24 +1,25 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2004-2012. All Rights Reserved.
+# Copyright Ericsson AB 2004-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
-include @erts_lib_include_internal_generated@@[email protected]
-include @erts_lib_include_internal_generated@@DS@erts_internal.mk
+include @erts_lib_make_ethread@
+include @erts_lib_make_internal@
CC = @CC@
CFLAGS = @ERTS_CFLAGS@
diff --git a/erts/test/ethread_SUITE_data/ethread_tests.c b/erts/test/ethread_SUITE_data/ethread_tests.c
index ed96ecdbd2..fe7f92b012 100644
--- a/erts/test/ethread_SUITE_data/ethread_tests.c
+++ b/erts/test/ethread_SUITE_data/ethread_tests.c
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2004-2011. All Rights Reserved.
+ * Copyright Ericsson AB 2004-2016. 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/.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * 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.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
@@ -976,7 +977,7 @@ tsd_test(void)
ethr_tid tid[TT_THREADS];
int values[TT_THREADS];
- res = ethr_tsd_key_create(&tt_key);
+ res = ethr_tsd_key_create(&tt_key,"tsd_test");
ASSERT(res == 0);
for (i = 1; i < TT_THREADS; i++) {
@@ -1456,6 +1457,9 @@ do { \
ASSERT(ethr_ ## A ## _read ## B(&A) == 0x33333333); \
} while (0)
+ethr_atomic32_t atomic32;
+ethr_atomic_t atomic;
+ethr_dw_atomic_t dw_atomic;
static void
atomic_basic_test(void)
@@ -1464,8 +1468,6 @@ atomic_basic_test(void)
* Verify that each op does what it is expected
* to do for at least one input.
*/
- ethr_atomic32_t atomic32;
- ethr_atomic_t atomic;
print_line("AT_AINT32_MAX=%d",AT_AINT32_MAX);
print_line("AT_AINT32_MIN=%d",AT_AINT32_MIN);
@@ -1628,7 +1630,6 @@ atomic_basic_test(void)
/* Double word */
{
- ethr_dw_atomic_t dw_atomic;
ethr_dw_sint_t dw0, dw1;
dw0.sint[0] = 4711;
dw0.sint[1] = 4712;
diff --git a/erts/test/ignore_cores.erl b/erts/test/ignore_cores.erl
index 8b1ac0fe6c..25dce346b9 100644
--- a/erts/test/ignore_cores.erl
+++ b/erts/test/ignore_cores.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -27,7 +28,7 @@
-module(ignore_cores).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-export([init/1, fini/1, setup/3, setup/4, restore/1, dir/1]).
@@ -52,7 +53,7 @@ init(Config) ->
fini(Config) ->
#ignore_cores{org_cwd = OrgCWD,
org_path = OrgPath,
- org_pwd_env = OrgPWD} = ?config(ignore_cores, Config),
+ org_pwd_env = OrgPWD} = proplists:get_value(ignore_cores, Config),
ok = file:set_cwd(OrgCWD),
true = code:set_path(OrgPath),
case OrgPWD of
@@ -69,10 +70,10 @@ setup(Suite, Testcase, Config, SetCwd) when is_atom(Suite),
is_list(Config) ->
#ignore_cores{org_cwd = OrgCWD,
org_path = OrgPath,
- org_pwd_env = OrgPWD} = ?config(ignore_cores, Config),
+ org_pwd_env = OrgPWD} = proplists:get_value(ignore_cores, Config),
Path = lists:map(fun (".") -> OrgCWD; (Dir) -> Dir end, OrgPath),
true = code:set_path(Path),
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
IgnDir = filename:join([PrivDir,
atom_to_list(Suite)
++ "_"
@@ -93,7 +94,7 @@ setup(Suite, Testcase, Config, SetCwd) when is_atom(Suite),
end,
ok = file:write_file(filename:join([IgnDir, "ignore_core_files"]), <<>>),
%% cores are dumped in /cores on MacOS X
- CoresDir = case {?t:os_type(), filelib:is_dir("/cores")} of
+ CoresDir = case {os:type(), filelib:is_dir("/cores")} of
{{unix,darwin}, true} ->
filelib:fold_files("/cores",
"^core.*$",
@@ -118,7 +119,7 @@ restore(Config) ->
org_path = OrgPath,
org_pwd_env = OrgPWD,
ign_dir = IgnDir,
- cores_dir = CoresDir} = ?config(ignore_cores, Config),
+ cores_dir = CoresDir} = proplists:get_value(ignore_cores, Config),
try
case CoresDir of
false ->
@@ -154,5 +155,5 @@ restore(Config) ->
dir(Config) ->
- #ignore_cores{ign_dir = Dir} = ?config(ignore_cores, Config),
+ #ignore_cores{ign_dir = Dir} = proplists:get_value(ignore_cores, Config),
Dir.
diff --git a/erts/test/install_SUITE.erl b/erts/test/install_SUITE.erl
index f1d8dc2587..2c7e8972f6 100644
--- a/erts/test/install_SUITE.erl
+++ b/erts/test/install_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2010-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2010-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -27,11 +28,9 @@
%%%-------------------------------------------------------------------
-module(install_SUITE).
-%-define(line_trace, 1).
-
--export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2,
- init_per_suite/1, end_per_suite/1,
- init_per_testcase/2, end_per_testcase/2]).
+-export([all/0, suite/0,
+ init_per_suite/1, end_per_suite/1,
+ init_per_testcase/2, end_per_testcase/2]).
-export([bin_default/1,
bin_default_dirty/1,
@@ -48,10 +47,9 @@
bin_dirname_fail/1,
bin_no_use_dirname_fail/1]).
--define(DEFAULT_TIMEOUT, ?t:minutes(1)).
-define(JOIN(A,B,C), filename:join(A, B, C)).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-record(inst, {mkdirs = true,
symlinks = true,
@@ -76,49 +74,42 @@ dont_need_symlink_cases() ->
bin_unreasonable_path, 'bin white space',
bin_no_srcfile].
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 1}}].
all() ->
dont_need_symlink_cases() ++ need_symlink_cases().
-groups() ->
- [].
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
%%
%% The test cases
%%
bin_default(Config) when is_list(Config) ->
- ?line E = "/usr/local",
- ?line Bs = "/usr/local/bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
- ?line RP = "../lib/erlang/bin",
+ E = "/usr/local",
+ Bs = "/usr/local/bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/bin",
+ EBe = EBs,
+ RP = "../lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "absolute"} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
{true, _} ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -127,30 +118,30 @@ bin_default(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_default_dirty(Config) when is_list(Config) ->
- ?line E = "/usr/./local/lib/..",
- ?line Bs = "/usr/local//lib/../lib/erlang/../../bin",
- ?line Be = "/usr/local/lib/../lib/erlang/../../bin",
- ?line EBs = "/usr/local/lib/../lib/erlang/../erlang/bin/x/y/../..//",
- ?line EBe = "/usr/local/lib/../lib/erlang/../erlang/bin/x/y/../..",
- ?line RP = "../lib/erlang/bin",
+ E = "/usr/./local/lib/..",
+ Bs = "/usr/local//lib/../lib/erlang/../../bin",
+ Be = "/usr/local/lib/../lib/erlang/../../bin",
+ EBs = "/usr/local/lib/../lib/erlang/../erlang/bin/x/y/../..//",
+ EBe = "/usr/local/lib/../lib/erlang/../erlang/bin/x/y/../..",
+ RP = "../lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "absolute"} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,EP,EBe])}};
{true, _} ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -160,29 +151,29 @@ bin_default_dirty(Config) when is_list(Config) ->
bin_outside_eprfx(Config) when is_list(Config) ->
- ?line E = "/usr/local",
- ?line Bs = "/usr/bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
- ?line RP = "../local/lib/erlang/bin",
+ E = "/usr/local",
+ Bs = "/usr/bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/bin",
+ EBe = EBs,
+ RP = "../local/lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "relative"} ->
- ?line {ok,{relative,B,RP}};
+ {ok,{relative,B,RP}};
{true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}}
+ {ok,{absolute,B,join([TP,EP,EBe])}}
end,
expect(Expct, Res)
end,
@@ -192,29 +183,29 @@ bin_outside_eprfx(Config) when is_list(Config) ->
bin_outside_eprfx_dirty(Config) when is_list(Config) ->
- ?line E = "/usr/local/lib/..",
- ?line Bs = "/usr/local/lib/../../bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
- ?line RP = "../local/lib/erlang/bin",
+ E = "/usr/local/lib/..",
+ Bs = "/usr/local/lib/../../bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/bin",
+ EBe = EBs,
+ RP = "../local/lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "relative"} ->
- ?line {ok,{relative,B,RP}};
+ {ok,{relative,B,RP}};
{true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}}
+ {ok,{absolute,B,join([TP,EP,EBe])}}
end,
expect(Expct, Res)
end,
@@ -223,33 +214,33 @@ bin_outside_eprfx_dirty(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_unreasonable_path(Config) when is_list(Config) ->
- ?line E = "/usr/local/../../..",
- ?line Bs = "/usr/local/../../../bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/../../../bin_unreasonable_path/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
- ?line RP = "../bin_unreasonable_path/usr/local/lib/erlang/bin",
+ E = "/usr/local/../../..",
+ Bs = "/usr/local/../../../bin",
+ Be = Bs,
+ EBs = "/usr/local/../../../bin_unreasonable_path/usr/local/lib/erlang/bin",
+ EBe = EBs,
+ RP = "../bin_unreasonable_path/usr/local/lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {TP, SL, BSL} of
{_, false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{_, false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{"", true, "relative"} ->
{error, unreasonable_path};
{"", true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
{_, true, "absolute"} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
_ ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -258,7 +249,7 @@ bin_unreasonable_path(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_unreachable_absolute(Config) when is_list(Config) ->
- TDir = ?config(test_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
make_dirs(TDir, "/opt/local/lib/erlang/usr/bin"),
make_dirs(TDir, "/opt/local/lib/erlang/bin"),
Erl = join([TDir, "/opt/local/lib/erlang/bin/erl"]),
@@ -269,28 +260,28 @@ bin_unreachable_absolute(Config) when is_list(Config) ->
ok = file:write_file(Erlc, "erlc"),
ok = file:make_symlink("../../../opt/local/lib/erlang/usr",
join([TDir, "/usr/local/lib/erlang"])),
- ?line E = "/usr/local",
- ?line Bs = "/usr/local/bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/../bin",
- ?line EBe = EBs,
+ E = "/usr/local",
+ Bs = "/usr/local/bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/../bin",
+ EBe = EBs,
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "relative"} ->
{error, unreachable_absolute};
{true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}}
+ {ok,{absolute,B,join([TP,EP,EBe])}}
end,
expect(Expct, Res)
end,
@@ -299,7 +290,7 @@ bin_unreachable_absolute(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_unreachable_relative(Config) when is_list(Config) ->
- TDir = ?config(test_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
make_dirs(TDir, "/opt/local/lib/erlang/bin"),
make_dirs(TDir, "/opt/local/bin"),
make_dirs(TDir, "/usr/local/lib/erlang/bin"),
@@ -310,28 +301,28 @@ bin_unreachable_relative(Config) when is_list(Config) ->
ok = file:make_symlink("../../opt/local/bin",
join([TDir, "/usr/local/bin"])),
- ?line E = "/usr/local",
- ?line Bs = "/usr/local/bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
+ E = "/usr/local",
+ Bs = "/usr/local/bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/bin",
+ EBe = EBs,
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "relative"} ->
{error, unreachable_relative};
{true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}}
+ {ok,{absolute,B,join([TP,EP,EBe])}}
end,
expect(Expct, Res)
end,
@@ -340,7 +331,7 @@ bin_unreachable_relative(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_ok_symlink(Config) when is_list(Config) ->
- TDir = ?config(test_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
make_dirs(TDir, "/usr/local/bin"),
make_dirs(TDir, "/opt/local/lib/erlang/bin"),
Erl = join([TDir, "/opt/local/lib/erlang/bin/erl"]),
@@ -349,29 +340,29 @@ bin_ok_symlink(Config) when is_list(Config) ->
ok = file:write_file(Erlc, "erlc"),
ok = file:make_symlink("../../opt/local/lib",
join([TDir, "/usr/local/lib"])),
- ?line E = "/usr/local",
- ?line Bs = "/usr/local/bin",
- ?line Be = Bs,
- ?line EBs = "/usr/local/lib/erlang/bin",
- ?line EBe = EBs,
- ?line RP = "../lib/erlang/bin",
+ E = "/usr/local",
+ Bs = "/usr/local/bin",
+ Be = Bs,
+ EBs = "/usr/local/lib/erlang/bin",
+ EBe = EBs,
+ RP = "../lib/erlang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "absolute"} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
{true, _} ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -380,7 +371,7 @@ bin_ok_symlink(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_same_dir(Config) when is_list(Config) ->
- TDir = ?config(test_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
make_dirs(TDir, "/usr/local/bin"),
make_dirs(TDir, "/usr/local/lib"),
ok = file:make_symlink("..", join([TDir, "/usr/local/lib/erlang"])),
@@ -416,29 +407,29 @@ bin_not_abs(Config) when is_list(Config) ->
'bin white space'(Config) when is_list(Config) ->
- ?line E = "/u s r/local",
- ?line Bs = "/u s r/local/b i n",
- ?line Be = Bs,
- ?line EBs = "/u s r/local/lib/erl ang/bin",
- ?line EBe = EBs,
- ?line RP = "../lib/erl ang/bin",
+ E = "/u s r/local",
+ Bs = "/u s r/local/b i n",
+ Be = Bs,
+ EBs = "/u s r/local/lib/erl ang/bin",
+ EBe = EBs,
+ RP = "../lib/erl ang/bin",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "absolute"} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
{true, _} ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -447,29 +438,29 @@ bin_not_abs(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_dirname_fail(Config) when is_list(Config) ->
- ?line E = "/opt",
- ?line Bs = "/opt/lib/../bin",
- ?line Be = Bs,
- ?line EBs = "/opt/lib/erlang/otp/bin",
- ?line EBe = EBs,
- ?line CMDPRFX = "PATH=\""++?config(data_dir,Config)++":"++os:getenv("PATH")++"\"",
+ E = "/opt",
+ Bs = "/opt/lib/../bin",
+ Be = Bs,
+ EBs = "/opt/lib/erlang/otp/bin",
+ EBe = EBs,
+ CMDPRFX = "PATH=\""++proplists:get_value(data_dir,Config)++":"++os:getenv("PATH")++"\"",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "relative"} ->
- ?line {error, dirname_failed};
+ {error, dirname_failed};
{true, _} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}}
+ {ok,{absolute,B,join([TP,EP,EBe])}}
end,
expect(Expct, Res)
end,
@@ -479,30 +470,30 @@ bin_dirname_fail(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_no_use_dirname_fail(Config) when is_list(Config) ->
- ?line E = "/opt",
- ?line Bs = "/opt/bin",
- ?line Be = Bs,
- ?line EBs = "/opt/lib/erlang/otp/bin",
- ?line EBe = EBs,
- ?line RP = "../lib/erlang/otp/bin",
- ?line CMDPRFX = "PATH=\""++?config(data_dir,Config)++":"++os:getenv("PATH")++"\"",
+ E = "/opt",
+ Bs = "/opt/bin",
+ Be = Bs,
+ EBs = "/opt/lib/erlang/otp/bin",
+ EBe = EBs,
+ RP = "../lib/erlang/otp/bin",
+ CMDPRFX = "PATH=\""++proplists:get_value(data_dir,Config)++":"++os:getenv("PATH")++"\"",
ChkRes = fun (Res, #inst{test_prefix = TP,
destdir = D,
extra_prefix = EP,
bindir_symlinks = BSL,
symlinks = SL}) ->
- ?line B = join([TP, D, EP, Be]),
+ B = join([TP, D, EP, Be]),
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false, _} ->
- ?line {ok,{absolute,
+ {ok,{absolute,
B,join([TP,D,EP,EBe])}};
{true, "absolute"} ->
- ?line {ok,{absolute,B,join([TP,EP,EBe])}};
+ {ok,{absolute,B,join([TP,EP,EBe])}};
{true, _} ->
- ?line {ok,{relative,B,RP}}
+ {ok,{relative,B,RP}}
end,
expect(Expct, Res)
end,
@@ -512,7 +503,7 @@ bin_no_use_dirname_fail(Config) when is_list(Config) ->
erlang_bindir = EBs}, ChkRes).
bin_no_srcfile(Config) when is_list(Config) ->
- TDir = ?config(test_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
make_dirs(TDir, "/opt/local/bin"),
make_dirs(TDir, "/opt/local/lib/erlang/bin"),
Erl = join([TDir, "/opt/local/lib/erlang/bin/erl"]),
@@ -524,13 +515,13 @@ bin_no_srcfile(Config) when is_list(Config) ->
Expct = case {SL, BSL} of
{false, _} when BSL == "relative";
BSL == "absolute" ->
- ?line {error, no_ln_s};
+ {error, no_ln_s};
{false,_} ->
- ?line {error,{no_srcfile, Erlc}};
+ {error,{no_srcfile, Erlc}};
{true, "absolute"} ->
- ?line {error,{no_srcfile, Erlc}};
+ {error,{no_srcfile, Erlc}};
{true, _} ->
- ?line {error,{no_srcfile, RP_Erlc}}
+ {error,{no_srcfile, RP_Erlc}}
end,
expect(Expct, Res)
end,
@@ -548,34 +539,34 @@ bin_no_srcfile(Config) when is_list(Config) ->
%%
expect(X, X) ->
- ?t:format("result: ~p~n", [X]),
- ?t:format("-----------------------------------------------~n", []),
+ io:format("result: ~p~n", [X]),
+ io:format("-----------------------------------------------~n", []),
ok;
expect(X, Y) ->
- ?t:format("expected: ~p~n", [X]),
- ?t:format("got : ~p~n", [Y]),
- ?t:format("-----------------------------------------------~n", []),
- ?t:fail({X,Y}).
+ io:format("expected: ~p~n", [X]),
+ io:format("got : ~p~n", [Y]),
+ io:format("-----------------------------------------------~n", []),
+ ct:fail({X,Y}).
init_per_suite(Config) ->
- PD = ?config(priv_dir, Config),
- SymLinks = case ?t:os_type() of
- {win32, _} -> false;
- _ ->
- case file:make_symlink("nothing",
- filename:join(PD,
- "symlink_test")) of
- ok -> true;
- _ -> false
- end
- end,
+ PD = proplists:get_value(priv_dir, Config),
+ SymLinks = case os:type() of
+ {win32, _} -> false;
+ _ ->
+ case file:make_symlink("nothing",
+ filename:join(PD, "symlink_test")) of
+ ok -> true;
+ _ -> false
+ end
+ end,
[{symlinks, SymLinks} | Config].
end_per_suite(_Config) ->
ok.
init_per_testcase(Case, Config) ->
- init_per_testcase_aux(?config(symlinks,Config),?t:os_type(),Case,Config).
+ init_per_testcase_aux(proplists:get_value(symlinks,Config),
+ os:type(),Case,Config).
init_per_testcase_aux(_, {win32, _}, _Case, _Config) ->
{skip, "Not on windows"};
@@ -585,18 +576,13 @@ init_per_testcase_aux(false, OsType, Case, Config) ->
true -> {skip, "Cannot create symbolic links"}
end;
init_per_testcase_aux(true, _OsType, Case, Config) ->
- Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
- [{watchdog, Dog},
- {testcase, Case},
- {test_dir, make_dirs(?config(priv_dir, Config), atom_to_list(Case))}
+ [{testcase, Case},
+ {test_dir, make_dirs(proplists:get_value(priv_dir, Config), atom_to_list(Case))}
| Config].
-end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
+end_per_testcase(_Case, _Config) ->
ok.
-
make_dirs(Root, Suffix) ->
do_make_dirs(Root, string:tokens(Suffix, [$/])).
@@ -615,9 +601,9 @@ install_bin(Config, #inst{mkdirs = MkDirs,
exec_prefix = EXEC_PREFIX,
bindir = BINDIR,
erlang_bindir = ERLANG_BINDIR} = Inst, ChkRes) ->
- PDir = ?config(priv_dir, Config),
- TDir = ?config(test_dir, Config),
- TD = atom_to_list(?config(testcase, Config)),
+ PDir = proplists:get_value(priv_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
+ TD = atom_to_list(proplists:get_value(testcase, Config)),
case MkDirs of
false -> ok;
true ->
@@ -640,7 +626,7 @@ install_bin(Config, #inst{mkdirs = MkDirs,
bindir = join([TDir, BINDIR]),
erlang_bindir = join([TDir, ERLANG_BINDIR])},
ChkRes),
- case ?config(symlinks, Config) of
+ case proplists:get_value(symlinks, Config) of
true -> ok;
false -> {comment, "No symlink tests run, since symlinks not working"}
end.
@@ -663,7 +649,7 @@ install_bin2(Config, Inst, ChkRes) ->
install_bin3(Config, Inst#inst{symlinks = false,
ln_s = "cp -p",
bindir_symlinks = "absolute"}, ChkRes),
- case ?config(symlinks, Config) of
+ case proplists:get_value(symlinks, Config) of
true ->
install_bin3(Config, Inst#inst{symlinks = true,
ln_s = "ln -s"}, ChkRes),
@@ -689,9 +675,9 @@ install_bin3(Config,
erlang_bindir = ERLANG_BINDIR,
bindir_symlinks = BINDIR_SYMLINKS} = Inst,
ChkRes) ->
- Test = ?config(testcase, Config),
- DDir = ?config(data_dir, Config),
- TDir = ?config(test_dir, Config),
+ Test = proplists:get_value(testcase, Config),
+ DDir = proplists:get_value(data_dir, Config),
+ TDir = proplists:get_value(test_dir, Config),
InstallBin = filename:join(DDir, "install_bin"),
ResFile = filename:join(TDir, atom_to_list(Test) ++ "-result.txt"),
Cmd = CMD_PRFX ++ " "
@@ -704,7 +690,7 @@ install_bin3(Config,
++ "\" --exec-prefix \"" ++ EXEC_PREFIX
++ "\" --test-file \"" ++ ResFile ++ "\" erl erlc",
- ?t:format("CMD_PRFX = \"~s\"~n"
+ io:format("CMD_PRFX = \"~s\"~n"
"LN_S = \"~s\"~n"
"BINDIR_SYMLINKS = \"~s\"~n"
"exec_prefix = \"~s\"~n"
@@ -715,9 +701,9 @@ install_bin3(Config,
[CMD_PRFX, LN_S, BINDIR_SYMLINKS, EXEC_PREFIX, BINDIR,
ERLANG_BINDIR, EXTRA_PREFIX, DESTDIR]),
- ?t:format("$ ~s~n", [Cmd]),
+ io:format("$ ~s~n", [Cmd]),
CmdOutput = os:cmd(Cmd),
- ?t:format("~s~n", [CmdOutput]),
+ io:format("~s~n", [CmdOutput]),
ChkRes(case file:consult(ResFile) of
{ok, [Res]} -> Res;
Err -> exit({result, Err})
@@ -730,4 +716,3 @@ join([""|Ds]) ->
join(Ds);
join([D|Ds]) ->
"/" ++ string:strip(D, both, $/) ++ join(Ds).
-
diff --git a/erts/test/nt_SUITE.erl b/erts/test/nt_SUITE.erl
index e440b9e5d9..624e5484ba 100644
--- a/erts/test/nt_SUITE.erl
+++ b/erts/test/nt_SUITE.erl
@@ -1,97 +1,78 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
%%% Purpose: Test NT specific utilities
-module(nt_SUITE).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-include_lib("kernel/include/file.hrl").
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,init_per_testcase/2,
- end_per_testcase/2,nt/1,handle_eventlog/2,
- middleman/1,service_basic/1, service_env/1, user_env/1, synced/1,
- service_prio/1,
- logout/1, debug/1, restart/1, restart_always/1,stopaction/1,
- shutdown_io/0,do_shutdown_io/0]).
--define(TEST_TIMEOUT, ?t:seconds(180)).
+-export([all/0, suite/0,
+ init_per_testcase/2, end_per_testcase/2,
+ nt/1,handle_eventlog/2,
+ middleman/1,service_basic/1, service_env/1, user_env/1, synced/1,
+ service_prio/1,
+ logout/1, debug/1, restart/1, restart_always/1,stopaction/1,
+ shutdown_io/0,do_shutdown_io/0]).
-define(TEST_SERVICES, [1,2,3,4,5,6,7,8,9,10,11]).
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 3}}].
-all() ->
- case os:type() of
- {win32, nt} ->
+all() ->
+ case {os:type(), os:version()} of
+ {{win32, nt}, Vsn} when Vsn =< {6,1,999999} ->
[nt, service_basic, service_env, user_env, synced,
service_prio, logout, debug, restart, restart_always,
stopaction];
_ -> [nt]
end.
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
-
init_per_testcase(_Func, Config) ->
- Dog = test_server:timetrap(?TEST_TIMEOUT),
- [{watchdog, Dog} | Config].
+ Config.
-end_per_testcase(_Func, Config) ->
+end_per_testcase(_Func, _Config) ->
lists:foreach(fun(X) ->
- catch remove_service("test_service_" ++
- integer_to_list(X)) end,
- ?TEST_SERVICES),
- Dog = ?config(watchdog, Config),
- catch test_server:timetrap_cancel(Dog),
+ catch remove_service("test_service_" ++ integer_to_list(X))
+ end, ?TEST_SERVICES),
ok.
erlsrv() ->
- os:find_executable(erlsrv).
+ "\"" ++ os:find_executable(erlsrv) ++ "\"".
recv_prog_output(Port) ->
receive
- {Port, {data, {eol,Data}}} ->
- %%io:format("Got data: ~s~n", [Data]),
- [ Data | recv_prog_output(Port)];
- _X ->
- %%io:format("Got data: ~p~n", [_X]),
- Port ! {self(), close},
- receive
- _ ->
- []
- end
+ {Port, {data, {eol,Data}}} ->
+ %%io:format("Got data: ~s~n", [Data]),
+ [ Data | recv_prog_output(Port)];
+ _X ->
+ %%io:format("Got data: ~p~n", [_X]),
+ Port ! {self(), close},
+ receive
+ _ ->
+ []
+ end
end.
-
%%% X == parameters to erlsrv
%%% returns command output without stderr
do_command(X) ->
@@ -99,11 +80,11 @@ do_command(X) ->
Port = open_port({spawn, erlsrv() ++ " " ++ X}, [stream, {line, 100}, eof, in]),
Res = recv_prog_output(Port),
case Res of
- [] ->
- failed;
- _Y ->
- %%io:format("~p~n",[_Y]),
- ok
+ [] ->
+ failed;
+ _Y ->
+ %%io:format("~p~n",[_Y]),
+ ok
end.
@@ -122,13 +103,13 @@ do_wait_for_it(_,0) ->
false;
do_wait_for_it(FullName,N) ->
case net_adm:ping(FullName) of
- pong ->
- true;
- _ ->
- receive
- after 1000 ->
- do_wait_for_it(FullName,N-1)
- end
+ pong ->
+ true;
+ _ ->
+ receive
+ after 1000 ->
+ do_wait_for_it(FullName,N-1)
+ end
end.
wait_for_node(Name) ->
@@ -138,309 +119,282 @@ wait_for_node(Name) ->
make_full_name(Name) ->
[_,Suffix] = string:tokens(atom_to_list(node()),"@"),
list_to_atom(Name ++ "@" ++ Suffix).
-
+
%%% The following tests are only run on NT:
-service_basic(doc) ->
- ["Check some basic (cosmetic) service parameters"];
-service_basic(suite) -> [];
+%% Check some basic (cosmetic) service parameters
service_basic(Config) when is_list(Config) ->
- ?line Name = "test_service_20",
- ?line IntName = Name++"_internal",
- ?line Service = [{servicename,Name},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]},
- {internalservicename,IntName},
- {comment,"Epic comment"}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line S2 = erlsrv:get_service(Name),
- ?line {value,{comment,"Epic comment"}} = lists:keysearch(comment,1,S2),
- ?line {value,{internalservicename,IntName}} =
- lists:keysearch(internalservicename,1,S2),
- ?line S3 = lists:keyreplace(comment,1,S2,{comment,"Basic comment"}),
- ?line S4 = lists:keyreplace(internalservicename,1,S3,
- {internalservicename,"WillNotHappen"}),
- ?line ok = erlsrv:store_service(S4),
- ?line S5 = erlsrv:get_service(Name),
- ?line {value,{comment,"Basic comment"}} = lists:keysearch(comment,1,S5),
- ?line {value,{internalservicename,IntName}} =
- lists:keysearch(internalservicename,1,S5),
- ?line NewName = "test_service_21",
- ?line S6 = erlsrv:new_service(NewName,S5,[]), % should remove
- % internalservicename
- ?line ok = erlsrv:store_service(S6),
- ?line S7 = erlsrv:get_service(NewName),
- ?line {value,{comment,"Basic comment"}} = lists:keysearch(comment,1,S7),
- ?line {value,{internalservicename,[$t,$e,$s,$t | _]}} =
- lists:keysearch(internalservicename,1,S7),
- ?line remove_service(Name),
- ?line remove_service(NewName),
+ Name = "test_service_20",
+ IntName = Name++"_internal",
+ Service = [{servicename,Name},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]},
+ {internalservicename,IntName},
+ {comment,"Epic comment"}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ S2 = erlsrv:get_service(Name),
+ {value,{comment,"Epic comment"}} = lists:keysearch(comment,1,S2),
+ {value,{internalservicename,IntName}} =
+ lists:keysearch(internalservicename,1,S2),
+ S3 = lists:keyreplace(comment,1,S2,{comment,"Basic comment"}),
+ S4 = lists:keyreplace(internalservicename,1,S3,
+ {internalservicename,"WillNotHappen"}),
+ ok = erlsrv:store_service(S4),
+ S5 = erlsrv:get_service(Name),
+ {value,{comment,"Basic comment"}} = lists:keysearch(comment,1,S5),
+ {value,{internalservicename,IntName}} =
+ lists:keysearch(internalservicename,1,S5),
+ NewName = "test_service_21",
+ S6 = erlsrv:new_service(NewName,S5,[]), % should remove
+ % internalservicename
+ ok = erlsrv:store_service(S6),
+ S7 = erlsrv:get_service(NewName),
+ {value,{comment,"Basic comment"}} = lists:keysearch(comment,1,S7),
+ {value,{internalservicename,[$t,$e,$s,$t | _]}} =
+ lists:keysearch(internalservicename,1,S7),
+ remove_service(Name),
+ remove_service(NewName),
ok.
-service_env(doc) ->
- ["Check that service name and executable is in the environment of the " ++
- "erlang process created by erlsrv."];
-service_env(suite) -> [];
+%% Check that service name and executable is in the environment of the
+%% erlang process created by erlsrv.
service_env(Config) when is_list(Config) ->
- ?line Name = "test_service_2",
- ?line Service = [{servicename,Name},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line Name = rpc:call(make_full_name(Name),os,getenv,
- ["ERLSRV_SERVICE_NAME"]),
- ?line "erlsrv.exe" = filename:basename(
- hd(
- string:tokens(
- rpc:call(make_full_name(Name),
- os,
- getenv,
- ["ERLSRV_EXECUTABLE"]),
- "\""))),
- ?line remove_service(Name),
+ Name = "test_service_2",
+ Service = [{servicename,Name},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ Name = rpc:call(make_full_name(Name),os,getenv,
+ ["ERLSRV_SERVICE_NAME"]),
+ "erlsrv.exe" = filename:basename(
+ hd(
+ string:tokens(
+ rpc:call(make_full_name(Name),
+ os,
+ getenv,
+ ["ERLSRV_EXECUTABLE"]),
+ "\""))),
+ remove_service(Name),
ok.
-user_env(doc) ->
- ["Check that the user defined environment is ADDED to the service's"++
- " normal dito."];
-user_env(suite) -> [];
+
+%% Check that the user defined environment is ADDED to the service's
+%% normal dito.
user_env(Config) when is_list(Config) ->
- ?line Name = "test_service_3",
- ?line Service = [{servicename,Name},{env,[{"HUBBA","BUBBA"}]},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line true = rpc:call(make_full_name(Name),os,getenv,
- ["SystemDrive"]) =/= false,
- ?line "BUBBA" = rpc:call(make_full_name(Name),os,getenv,["HUBBA"]),
- ?line remove_service(Name),
+ Name = "test_service_3",
+ Service = [{servicename,Name},{env,[{"HUBBA","BUBBA"}]},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ true = rpc:call(make_full_name(Name),os,getenv,
+ ["SystemDrive"]) =/= false,
+ "BUBBA" = rpc:call(make_full_name(Name),os,getenv,["HUBBA"]),
+ remove_service(Name),
ok.
-synced(doc) ->
- ["Check that services are stopped and started syncronous and that"++
- " failed stopactions kill the erlang machine anyway."];
-synced(suite) -> [];
+
+%% Check that services are stopped and started syncronous and that
+%% failed stopactions kill the erlang machine anyway.
synced(Config) when is_list(Config) ->
- ?line Name0 = "test_service_4",
- ?line Service0 = [{servicename,Name0},
- {machine, "N:\\nickeNyfikenPaSjukhus"}],
- ?line ok = erlsrv:store_service(Service0),
- ?line true = (catch start_service(Name0)) =/= ok,
- ?line remove_service(Name0),
- ?line Name = "test_service_5",
- ?line Service = [{servicename,Name},
- {stopaction,"erlang:info(garbage_collection)."},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line T1 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()),
- ?line stop_service(Name),
- ?line Diff1 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()) - T1,
- ?line true = Diff1 > 30,
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line T2 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()),
- ?line remove_service(Name),
- ?line Diff2 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()) - T2,
- ?line true = Diff2 > 30,
+ Name0 = "test_service_4",
+ Service0 = [{servicename,Name0},
+ {machine, "N:\\nickeNyfikenPaSjukhus"}],
+ ok = erlsrv:store_service(Service0),
+ true = (catch start_service(Name0)) =/= ok,
+ remove_service(Name0),
+ Name = "test_service_5",
+ Service = [{servicename,Name},
+ {stopaction,"erlang:info(garbage_collection)."},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ T1 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()),
+ stop_service(Name),
+ Diff1 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()) - T1,
+ true = Diff1 > 30,
+ start_service(Name),
+ true = wait_for_node(Name),
+ T2 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()),
+ remove_service(Name),
+ Diff2 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()) - T2,
+ true = Diff2 > 30,
ok.
-service_prio(doc) ->
- ["Check that a service with higher prio create port programs with "
- "higher prio."];
-service_prio(suite) -> [];
+
+%% Check that a service with higher prio create port programs with
+%% higher prio.
service_prio(Config) when is_list(Config) ->
- ?line Name = "test_service_6",
- ?line Service = [{servicename,Name},{prio,"high"},
- {env, [{"HEART_COMMAND","echo off"}]},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie()),
- "-heart"]}],
- ?line ok = erlsrv:store_service(Service),
- ?line {ok, OldProcs} = get_current_procs(Config),
- ?line start_service(Name),
- ?line {ok, NewProcs} = get_current_procs(Config),
+ Name = "test_service_6",
+ Service = [{servicename,Name},{prio,"high"},
+ {env, [{"HEART_COMMAND","echo off"}]},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie()),
+ "-heart"]}],
+ ok = erlsrv:store_service(Service),
+ {ok, OldProcs} = get_current_procs(Config),
+ start_service(Name),
+ {ok, NewProcs} = get_current_procs(Config),
timer:sleep(2000),
- ?line {ok, NewProcs2} = get_current_procs(Config),
- ?line remove_service(Name),
- ?line Diff = arrived_procs(OldProcs,NewProcs),
+ {ok, NewProcs2} = get_current_procs(Config),
+ remove_service(Name),
+ Diff = arrived_procs(OldProcs,NewProcs),
io:format("NewProcs ~p~n after sleep~n ~p~n",[Diff, arrived_procs(OldProcs,NewProcs2)]),
%% Not really correct, could fail if another heart is
%% started at the same time...
- ?line {value, {"heart.exe",_,"high"}} =
- lists:keysearch("heart.exe",1,Diff),
+ {value, {"heart.exe",_,"high"}} = lists:keysearch("heart.exe",1,Diff),
ok.
-logout(doc) ->
- ["Check that logout does not kill services"];
-logout(suite) -> [];
+
+%% Check that logout does not kill services
logout(Config) when is_list(Config) ->
- ?line {comment, "Have to be run manually by registering a service with " ++
- "heart, logout and log in again and then examine that the heart " ++
- "process id is not changed."}.
-debug(doc) ->
- ["Check the debug options to erlsrv."];
-debug(suite) -> [];
+ {comment, "Have to be run manually by registering a service with " ++
+ "heart, logout and log in again and then examine that the heart " ++
+ "process id is not changed."}.
+
+%% Check the debug options to erlsrv.
debug(Config) when is_list(Config) ->
- ?line Name0 = "test_service_7",
+ Name0 = "test_service_7",
%% We used to set the privdir as temporary directory, but for some
%% reason we don't seem to have write access to that directory,
%% so we'll use the directory specified in the next line.
- ?line TempDir = "C:/TEMP",
- ?line Service0 = [{servicename,Name0},
- {workdir,filename:nativename(TempDir)},
- {debugtype,"reuse"},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service0),
- ?line T1 = calendar:datetime_to_gregorian_seconds(
- calendar:local_time()),
+ TempDir = "C:/TEMP",
+ Service0 = [{servicename,Name0},
+ {workdir,filename:nativename(TempDir)},
+ {debugtype,"reuse"},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service0),
+ T1 = calendar:datetime_to_gregorian_seconds(
+ calendar:local_time()),
%% sleep a little
- ?line receive after 2000 -> ok end,
- ?line start_service(Name0),
- ?line true = wait_for_node(Name0),
- ?line LF = filename:join(TempDir, Name0++".debug"),
- ?line {ok,Info0} = file:read_file_info(LF),
- ?line T2 = calendar:datetime_to_gregorian_seconds(
- Info0#file_info.mtime),
- ?line true = T2 > T1,
- ?line remove_service(Name0),
- ?line file:delete(LF),
- ?line Name1 = "test_service_8",
- ?line Service1 = [{servicename,Name1},
- {workdir, filename:nativename(TempDir)},
- {debugtype,"new"},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service1),
- ?line T3 = calendar:datetime_to_gregorian_seconds(
- calendar:local_time()),
+ receive after 2000 -> ok end,
+ start_service(Name0),
+ true = wait_for_node(Name0),
+ LF = filename:join(TempDir, Name0++".debug"),
+ {ok,Info0} = file:read_file_info(LF),
+ T2 = calendar:datetime_to_gregorian_seconds(
+ Info0#file_info.mtime),
+ true = T2 > T1,
+ remove_service(Name0),
+ file:delete(LF),
+ Name1 = "test_service_8",
+ Service1 = [{servicename,Name1},
+ {workdir, filename:nativename(TempDir)},
+ {debugtype,"new"},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service1),
+ T3 = calendar:datetime_to_gregorian_seconds(
+ calendar:local_time()),
%% sleep a little
- ?line receive after 2000 -> ok end,
- ?line NF = next_logfile(TempDir, Name1),
- ?line start_service(Name1),
- ?line true = wait_for_node(Name1),
- ?line {ok,Info1} = file:read_file_info(NF),
- ?line T4 = calendar:datetime_to_gregorian_seconds(
- Info1#file_info.mtime),
- ?line true = T4 > T3,
- ?line remove_service(Name1),
- ?line file:delete(NF),
+ receive after 2000 -> ok end,
+ NF = next_logfile(TempDir, Name1),
+ start_service(Name1),
+ true = wait_for_node(Name1),
+ {ok,Info1} = file:read_file_info(NF),
+ T4 = calendar:datetime_to_gregorian_seconds(
+ Info1#file_info.mtime),
+ true = T4 > T3,
+ remove_service(Name1),
+ file:delete(NF),
ok.
-restart(doc) ->
- ["Check the restart options to erlsrv"];
-restart(suite) -> [];
+%% Check the restart options to erlsrv
restart(Config) when is_list(Config) ->
- ?line Name = "test_service_9",
- ?line Service = [{servicename,Name},
- {workdir, filename:nativename(logdir(Config))},
- {onfail,"restart"},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line receive after 20000 -> ok end,
- ?line rpc:call(make_full_name(Name),erlang,halt,[]),
- ?line receive after 1000 -> ok end,
- ?line true = wait_for_node(Name),
- ?line rpc:call(make_full_name(Name),erlang,halt,[]),
- ?line receive after 1000 -> ok end,
- ?line false = wait_for_node(Name),
- ?line remove_service(Name),
+ Name = "test_service_9",
+ Service = [{servicename,Name},
+ {workdir, filename:nativename(logdir(Config))},
+ {onfail,"restart"},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ receive after 20000 -> ok end,
+ rpc:call(make_full_name(Name),erlang,halt,[]),
+ receive after 1000 -> ok end,
+ true = wait_for_node(Name),
+ rpc:call(make_full_name(Name),erlang,halt,[]),
+ receive after 1000 -> ok end,
+ false = wait_for_node(Name),
+ remove_service(Name),
ok.
-restart_always(doc) ->
- ["Check the restart options to erlsrv"];
-restart_always(suite) -> [];
+%% Check the restart options to erlsrv
restart_always(Config) when is_list(Config) ->
- ?line Name = "test_service_10",
- ?line Service = [{servicename,Name},
- {workdir, filename:nativename(logdir(Config))},
- {onfail,"restart_always"},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line rpc:call(make_full_name(Name),erlang,halt,[]),
- ?line receive after 1000 -> ok end,
- ?line true = wait_for_node(Name),
- ?line rpc:call(make_full_name(Name),erlang,halt,[]),
- ?line receive after 1000 -> ok end,
- ?line true = wait_for_node(Name),
- ?line remove_service(Name),
+ Name = "test_service_10",
+ Service = [{servicename,Name},
+ {workdir, filename:nativename(logdir(Config))},
+ {onfail,"restart_always"},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ rpc:call(make_full_name(Name),erlang,halt,[]),
+ receive after 1000 -> ok end,
+ true = wait_for_node(Name),
+ rpc:call(make_full_name(Name),erlang,halt,[]),
+ receive after 1000 -> ok end,
+ true = wait_for_node(Name),
+ remove_service(Name),
ok.
-stopaction(doc) ->
- ["Check that stopaction does not hang output while shutting down"];
-stopaction(suite) -> [];
+
+%% Check that stopaction does not hang output while shutting down
stopaction(Config) when is_list(Config) ->
- ?line Name = "test_service_11",
+ Name = "test_service_11",
%% Icky, I prepend the first element in the codepath, cause
%% I "suppose" it's the one to where I am.
- ?line Service = [{servicename,Name},
- {stopaction,atom_to_list(?MODULE) ++ ":shutdown_io()."},
- {args, ["-setcookie",
- atom_to_list(erlang:get_cookie()),
- "-pa", hd(code:get_path())]}],
- ?line ok = erlsrv:store_service(Service),
- ?line start_service(Name),
- ?line true = wait_for_node(Name),
- ?line T1 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()),
- ?line stop_service(Name),
- ?line Diff1 = calendar:datetime_to_gregorian_seconds(
- calendar:universal_time()) - T1,
- ?line true = Diff1 < 30,
- ?line remove_service(Name),
+ Service = [{servicename,Name},
+ {stopaction,atom_to_list(?MODULE) ++ ":shutdown_io()."},
+ {args, ["-setcookie", atom_to_list(erlang:get_cookie()),
+ "-pa", hd(code:get_path())]}],
+ ok = erlsrv:store_service(Service),
+ start_service(Name),
+ true = wait_for_node(Name),
+ T1 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()),
+ stop_service(Name),
+ Diff1 = calendar:datetime_to_gregorian_seconds(
+ calendar:universal_time()) - T1,
+ true = Diff1 < 30,
+ remove_service(Name),
ok.
%%% This test is run on all platforms, but just gives a comment on
%%% other platforms than NT.
-nt(doc) ->
- ["Run NT specific tests."];
-nt(suite) ->
- [];
nt(Config) when is_list(Config) ->
- case os:type() of
- {win32,nt} ->
+ case {os:type(), os:version()} of
+ {{win32, nt}, Vsn} when Vsn =< {6,1,999999} ->
nt_run();
+ {{win32, nt}, _} ->
+ {skipped, "This test case requires admin privileges on Win 8 and later."};
_ ->
{skipped, "This test case is intended for Win NT only."}
end.
nt_run() ->
- ?line start_all(),
- ?line create_service("test_service_1"),
- ?line R = start_look_for_single("System","ErlSrv","Informational",
- ".*test_service_1.*started.*"),
- ?line start_service("test_service_1"),
- ?line Res = look_for_single(R),
- ?line io:format("Result from eventlog: ~p~n",
- [Res]),
- ?line remove_service("test_service_1"),
- ?line stop_all(),
+ start_all(),
+ create_service("test_service_1"),
+ R = start_look_for_single("System","ErlSrv","Informational",
+ ".*test_service_1.*started.*"),
+ start_service("test_service_1"),
+ Res = look_for_single(R),
+ io:format("Result from eventlog: ~p~n",
+ [Res]),
+ remove_service("test_service_1"),
+ stop_all(),
ok.
start_all() ->
Pid1 = spawn_link(?MODULE,middleman,[[]]),
register(?MODULE,Pid1),
_Pid2 = nteventlog:start("log_testing",
- {?MODULE,handle_eventlog,[Pid1]}).
+ {?MODULE,handle_eventlog,[Pid1]}).
stop_all() ->
?MODULE ! stop,
@@ -453,10 +407,10 @@ start_look_for_single(Cat,Fac,Sev,MessRE) ->
look_for_single(Ref) ->
receive
- {Ref,Time,Mes} ->
- {Time,Mes}
+ {Ref,Time,Mes} ->
+ {Time,Mes}
after 60000 ->
- timeout
+ timeout
end.
@@ -467,25 +421,25 @@ handle_eventlog(Mes,Pid) ->
%%% Waitfor = [{Pid, Ref, {Category,Facility,Severity,MessageRE}} ...]
middleman(Waitfor) ->
receive
- {Time,Category,Facility,Severity,Message} ->
- io:format("Middleman got ~s...", [Message]),
- case match_event({Time,Category,Facility,Severity,Message},
- Waitfor) of
- {ok, {Pid,Ref,Time,Mes}, Rest} ->
- io:format("matched~n"),
- Pid ! {Ref,Time,Mes},
- middleman(Rest);
- _ ->
- io:format("no match~n"),
- middleman(Waitfor)
- end;
- {lookfor, X} ->
- io:format("Middleman told to look for ~p~n", [X]),
- middleman([X|Waitfor]);
- stop ->
- stopped;
- _ ->
- middleman(Waitfor)
+ {Time,Category,Facility,Severity,Message} ->
+ io:format("Middleman got ~s...", [Message]),
+ case match_event({Time,Category,Facility,Severity,Message},
+ Waitfor) of
+ {ok, {Pid,Ref,Time,Mes}, Rest} ->
+ io:format("matched~n"),
+ Pid ! {Ref,Time,Mes},
+ middleman(Rest);
+ _ ->
+ io:format("no match~n"),
+ middleman(Waitfor)
+ end;
+ {lookfor, X} ->
+ io:format("Middleman told to look for ~p~n", [X]),
+ middleman([X|Waitfor]);
+ stop ->
+ stopped;
+ _ ->
+ middleman(Waitfor)
end.
@@ -494,81 +448,81 @@ match_event(_X, []) ->
nomatch;
match_event({Time,Cat,Fac,Sev,Mes},[{Pid,Ref,{Cat,Fac,Sev,MesRE}} | Tail]) ->
case re:run(Mes,MesRE,[{capture,none}]) of
- match ->
- %%io:format("Match!~n"),
- {ok,{Pid,Ref,Time,Mes},Tail};
- nomatch ->
- %%io:format("No match~n"),
- case match_event({Time,Cat,Fac,Sev,Mes},Tail) of
- {ok,X,Rest} ->
- {ok,X,[{Pid,Ref,{Cat,Fac,Sev,MesRE}} | Rest]};
- X ->
- X
- end
+ match ->
+ %%io:format("Match!~n"),
+ {ok,{Pid,Ref,Time,Mes},Tail};
+ nomatch ->
+ %%io:format("No match~n"),
+ case match_event({Time,Cat,Fac,Sev,Mes},Tail) of
+ {ok,X,Rest} ->
+ {ok,X,[{Pid,Ref,{Cat,Fac,Sev,MesRE}} | Rest]};
+ X ->
+ X
+ end
end;
match_event(X,[Y | T]) ->
%%io:format("X == ~p, Y == ~p~n",[X,Y]),
case match_event(X,T) of
- {ok,Z,R} ->
- {ok,Z,[Y|R]};
- XX ->
- XX
+ {ok,Z,R} ->
+ {ok,Z,[Y|R]};
+ XX ->
+ XX
end.
arrived_procs(_,[]) ->
[];
arrived_procs(OldProcs,[{Executable, Pid, Priority} | TNewProcs]) ->
case lists:keysearch(Pid,2,OldProcs) of
- {value, _} ->
- arrived_procs(OldProcs, TNewProcs);
- false ->
- [{Executable, Pid, Priority} | arrived_procs(OldProcs, TNewProcs)]
+ {value, _} ->
+ arrived_procs(OldProcs, TNewProcs);
+ false ->
+ [{Executable, Pid, Priority} | arrived_procs(OldProcs, TNewProcs)]
end.
-
+
get_current_procs(Config) ->
- ?line P = open_port({spawn,nt_info(Config) ++ " -E"},
- [{line,10000}]),
- ?line L = receive
- {P,{data,{eol,D}}} ->
- D;
- _ -> "error. "
- end,
- ?line P ! {self(), close},
- ?line receive
- {P, closed} -> ok
- end,
- ?line {done,{ok,Tok,_},_} = erl_scan:tokens([],L,0),
- ?line erl_parse:parse_term(Tok).
+ P = open_port({spawn,nt_info(Config) ++ " -E"},
+ [{line,10000}]),
+ L = receive
+ {P,{data,{eol,D}}} ->
+ D;
+ _ -> "error. "
+ end,
+ P ! {self(), close},
+ receive
+ {P, closed} -> ok
+ end,
+ {done,{ok,Tok,_},_} = erl_scan:tokens([],L,0),
+ erl_parse:parse_term(Tok).
nt_info(Config) when is_list(Config) ->
- ?line filename:join(?config(data_dir, Config), "nt_info").
+ "\"" ++ filename:join(proplists:get_value(data_dir, Config), "nt_info") ++ "\"".
logdir(Config) ->
- ?line ?config(priv_dir, Config).
+ proplists:get_value(priv_dir, Config).
look_for_next(Template,L,N) ->
- ?line FN = Template ++ integer_to_list(N),
- ?line case lists:member(FN,L) of
- true ->
- ?line look_for_next(Template,L,N+1);
- false ->
- ?line FN
+ FN = Template ++ integer_to_list(N),
+ case lists:member(FN,L) of
+ true ->
+ look_for_next(Template,L,N+1);
+ false ->
+ FN
end.
next_logfile(LD, Servicename) ->
- ?line {ok, Files} = file:list_dir(LD),
- ?line Ftmpl = Servicename ++ ".debug.",
- ?line filename:join(LD,look_for_next(Ftmpl,Files,1)).
+ {ok, Files} = file:list_dir(LD),
+ Ftmpl = Servicename ++ ".debug.",
+ filename:join(LD,look_for_next(Ftmpl,Files,1)).
%%% Functions run by the service
do_shutdown_io() ->
receive
after 2000 ->
- io:format("IO in shutting down...~n"),
- erlang:halt()
+ io:format("IO in shutting down...~n"),
+ erlang:halt()
end.
shutdown_io() ->
diff --git a/erts/test/nt_SUITE_data/Makefile.src b/erts/test/nt_SUITE_data/Makefile.src
index b26666252e..2317828337 100644
--- a/erts/test/nt_SUITE_data/Makefile.src
+++ b/erts/test/nt_SUITE_data/Makefile.src
@@ -1,18 +1,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 1998-2009. All Rights Reserved.
+# Copyright Ericsson AB 1998-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
diff --git a/erts/test/nt_SUITE_data/nt_info.c b/erts/test/nt_SUITE_data/nt_info.c
index 33cf046bb6..8ef52cad2d 100644
--- a/erts/test/nt_SUITE_data/nt_info.c
+++ b/erts/test/nt_SUITE_data/nt_info.c
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1998-2009. All Rights Reserved.
+ * Copyright Ericsson AB 1998-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*/
diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl
index 2317b4f6a4..54fcfd935f 100644
--- a/erts/test/otp_SUITE.erl
+++ b/erts/test/otp_SUITE.erl
@@ -1,89 +1,82 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2000-2013. All Rights Reserved.
+%% Copyright Ericsson AB 2000-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
-module(otp_SUITE).
--export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2,
- init_per_suite/1,end_per_suite/1]).
+-export([all/0, suite/0,
+ init_per_suite/1,end_per_suite/1]).
-export([undefined_functions/1,deprecated_not_in_obsolete/1,
- obsolete_but_not_deprecated/1,call_to_deprecated/1,
- call_to_size_1/1,strong_components/1]).
+ obsolete_but_not_deprecated/1,call_to_deprecated/1,
+ call_to_size_1/1,call_to_now_0/1,strong_components/1,
+ erl_file_encoding/1,xml_file_encoding/1,runtime_dependencies/1]).
--include_lib("test_server/include/test_server.hrl").
+-include_lib("common_test/include/ct.hrl").
-import(lists, [filter/2,foldl/3,foreach/2]).
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 10}}].
all() ->
[undefined_functions, deprecated_not_in_obsolete,
obsolete_but_not_deprecated, call_to_deprecated,
- call_to_size_1, strong_components].
-
-groups() ->
- [].
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
+ call_to_size_1, call_to_now_0, strong_components,
+ erl_file_encoding, xml_file_encoding,
+ runtime_dependencies].
init_per_suite(Config) ->
- Dog = test_server:timetrap(?t:minutes(10)),
Root = code:root_dir(),
Server = daily_xref,
- ?line xref:start(Server),
- ?line xref:set_default(Server, [{verbose,false},
- {warnings,false},
- {builtins,true}]),
- ?line {ok,_Relname} = xref:add_release(Server, Root, {name,otp}),
+ xref:start(Server),
+ xref:set_default(Server, [{verbose,false},
+ {warnings,false},
+ {builtins,true}]),
+ {ok,_Relname} = xref:add_release(Server, Root, {name,otp}),
%% If we are running the tests in the source tree, the ERTS application
%% is not in the code path. We must add it explicitly.
case code:lib_dir(erts) of
- {error,bad_name} ->
- Erts = filename:join([code:root_dir(),"erts","preloaded","ebin"]),
- ?line {ok,_} = xref:add_directory(Server, Erts, []);
- _ ->
- ok
+ {error,bad_name} ->
+ Erts = filename:join([code:root_dir(),"erts","preloaded","ebin"]),
+ {ok,_} = xref:add_directory(Server, Erts, []);
+ _ ->
+ ok
end,
-
- ?line ?t:timetrap_cancel(Dog),
[{xref_server,Server}|Config].
end_per_suite(Config) ->
- Server = ?config(xref_server, Config),
+ Server = proplists:get_value(xref_server, Config),
catch xref:stop(Server),
Config.
undefined_functions(Config) when is_list(Config) ->
- Server = ?config(xref_server, Config),
+ Server = proplists:get_value(xref_server, Config),
%% Exclude calls from generated modules in the SSL application.
ExcludeFrom = "SSL-PKIX|PKIX.*|ssl_pkix_oid",
- ?line UndefS = xref_base:analysis(undefined_function_calls),
- ?line Q = io_lib:format("Undef = ~s,"
- "ExcludedFrom = ~p:_/_,"
- "Undef - Undef | ExcludedFrom",
- [UndefS,ExcludeFrom]),
+ UndefS = xref_base:analysis(undefined_function_calls),
+ Q = io_lib:format("Undef = ~s,"
+ "ExcludedFrom = ~p:_/_,"
+ "Undef - Undef | ExcludedFrom",
+ [UndefS,ExcludeFrom]),
{ok,Undef0} = xref:q(Server, lists:flatten(Q)),
Undef1 = hipe_filter(Undef0),
Undef2 = ssl_crypto_filter(Undef1),
@@ -91,239 +84,437 @@ undefined_functions(Config) when is_list(Config) ->
Undef4 = eunit_filter(Undef3),
Undef5 = dialyzer_filter(Undef4),
Undef6 = wx_filter(Undef5),
- Undef = gs_filter(Undef6),
+ Undef7 = gs_filter(Undef6),
+ Undef = diameter_filter(Undef7),
case Undef of
- [] -> ok;
- _ ->
- Fd = open_log(Config, "undefined_functions"),
- foreach(fun ({MFA1,MFA2}) ->
- io:format("~s calls undefined ~s",
- [format_mfa(Server, MFA1),
- format_mfa(MFA2)]),
- io:format(Fd, "~s ~s\n",
- [format_mfa(Server, MFA1),
- format_mfa(MFA2)])
- end, Undef),
- close_log(Fd),
- ?line ?t:fail({length(Undef),undefined_functions_in_otp})
+ [] -> ok;
+ _ ->
+ Fd = open_log(Config, "undefined_functions"),
+ foreach(fun ({MFA1,MFA2}) ->
+ io:format("~s calls undefined ~s",
+ [format_mfa(Server, MFA1),
+ format_mfa(MFA2)]),
+ io:format(Fd, "~s ~s\n",
+ [format_mfa(Server, MFA1),
+ format_mfa(MFA2)])
+ end, Undef),
+ close_log(Fd),
+ ct:fail({length(Undef),undefined_functions_in_otp})
end.
hipe_filter(Undef) ->
case erlang:system_info(hipe_architecture) of
- undefined ->
- filter(fun ({_,{hipe_bifs,_,_}}) -> false;
- ({_,{hipe,_,_}}) -> false;
- ({_,{hipe_consttab,_,_}}) -> false;
- ({_,{hipe_converters,_,_}}) -> false;
- ({{code,_,_},{Mod,_,_}}) ->
- not is_hipe_module(Mod);
- ({{code_server,_,_},{Mod,_,_}}) ->
- not is_hipe_module(Mod);
- ({{compile,_,_},{Mod,_,_}}) ->
- not is_hipe_module(Mod);
- ({{hipe,_,_},{Mod,_,_}}) ->
- %% See comment for the next clause.
- not is_hipe_module(Mod);
- ({{cerl_to_icode,translate_flags1,2},
- {hipe_rtl_arch,endianess,0}}) ->
- false;
- ({{Caller,_,_},{Callee,_,_}}) ->
- %% Part of the hipe application is here
- %% for the sake of Dialyzer. There are many
- %% undefined calls within the hipe application.
- not is_hipe_module(Caller) orelse
- not is_hipe_module(Callee);
- (_) -> true
- end, Undef);
- _Arch ->
- filter(fun ({{Mod,_,_},{hipe_bifs,write_u64,2}}) ->
- %% Unavailable except in 64 bit AMD. Ignore it.
- not is_hipe_module(Mod);
- (_) -> true
- end, Undef)
+ undefined ->
+ filter(fun ({_,{hipe_bifs,_,_}}) -> false;
+ ({_,{hipe,_,_}}) -> false;
+ ({_,{hipe_consttab,_,_}}) -> false;
+ ({_,{hipe_converters,_,_}}) -> false;
+ ({{code,_,_},{Mod,_,_}}) ->
+ not is_hipe_module(Mod);
+ ({{code_server,_,_},{Mod,_,_}}) ->
+ not is_hipe_module(Mod);
+ ({{compile,_,_},{Mod,_,_}}) ->
+ not is_hipe_module(Mod);
+ ({{hipe,_,_},{Mod,_,_}}) ->
+ %% See comment for the next clause.
+ not is_hipe_module(Mod);
+ ({{cerl_to_icode,translate_flags1,2},
+ {hipe_rtl_arch,endianess,0}}) ->
+ false;
+ ({{Caller,_,_},{Callee,_,_}}) ->
+ %% Part of the hipe application is here
+ %% for the sake of Dialyzer. There are many
+ %% undefined calls within the hipe application.
+ not is_hipe_module(Caller) orelse
+ not is_hipe_module(Callee);
+ (_) -> true
+ end, Undef);
+ _Arch ->
+ filter(fun ({{Mod,_,_},{hipe_bifs,write_u64,2}}) ->
+ %% Unavailable except in 64 bit AMD. Ignore it.
+ not is_hipe_module(Mod);
+ (_) -> true
+ end, Undef)
end.
is_hipe_module(Mod) ->
case atom_to_list(Mod) of
- "hipe_"++_ -> true;
- _ -> false
+ "hipe_"++_ -> true;
+ _ -> false
end.
ssl_crypto_filter(Undef) ->
case {app_exists(crypto),app_exists(ssl)} of
- {false,false} ->
- filter(fun({_,{ssl,_,_}}) -> false;
- ({_,{crypto,_,_}}) -> false;
- ({_,{ssh,_,_}}) -> false;
- ({_,{ssh_connection,_,_}}) -> false;
- ({_,{ssh_sftp,_,_}}) -> false;
- (_) -> true
- end, Undef);
- {_,_} -> Undef
+ {false,false} ->
+ filter(fun({_,{ssl,_,_}}) -> false;
+ ({_,{crypto,_,_}}) -> false;
+ ({_,{ssh,_,_}}) -> false;
+ ({_,{ssh_connection,_,_}}) -> false;
+ ({_,{ssh_sftp,_,_}}) -> false;
+ (_) -> true
+ end, Undef);
+ {_,_} -> Undef
end.
edoc_filter(Undef) ->
%% Filter away function call that is catched.
filter(fun({{edoc_lib,uri_get_http,1},{http,request_sync,2}}) -> false;
- (_) -> true
- end, Undef).
+ (_) -> true
+ end, Undef).
eunit_filter(Undef) ->
filter(fun({{eunit_test,wrapper_test_exported_,0},
- {eunit_test,nonexisting_function,0}}) -> false;
- (_) -> true
- end, Undef).
+ {eunit_test,nonexisting_function,0}}) -> false;
+ (_) -> true
+ end, Undef).
dialyzer_filter(Undef) ->
case app_exists(dialyzer) of
- false ->
- filter(fun({_,{dialyzer_callgraph,_,_}}) -> false;
- ({_,{dialyzer_codeserver,_,_}}) -> false;
- ({_,{dialyzer_contracts,_,_}}) -> false;
- ({_,{dialyzer_cl_parse,_,_}}) -> false;
- ({_,{dialyzer_timing,_,_}}) -> false;
- ({_,{dialyzer_plt,_,_}}) -> false;
- ({_,{dialyzer_succ_typings,_,_}}) -> false;
- ({_,{dialyzer_utils,_,_}}) -> false;
- (_) -> true
- end, Undef);
- _ -> Undef
+ false ->
+ filter(fun({_,{dialyzer_callgraph,_,_}}) -> false;
+ ({_,{dialyzer_codeserver,_,_}}) -> false;
+ ({_,{dialyzer_contracts,_,_}}) -> false;
+ ({_,{dialyzer_cl_parse,_,_}}) -> false;
+ ({_,{dialyzer_timing,_,_}}) -> false;
+ ({_,{dialyzer_plt,_,_}}) -> false;
+ ({_,{dialyzer_succ_typings,_,_}}) -> false;
+ ({_,{dialyzer_utils,_,_}}) -> false;
+ (_) -> true
+ end, Undef);
+ _ -> Undef
end.
wx_filter(Undef) ->
case app_exists(wx) of
- false ->
- filter(fun({_,{MaybeWxModule,_,_}}) ->
- case atom_to_list(MaybeWxModule) of
- "wx"++_ -> false;
- _ -> true
- end
- end, Undef);
- _ -> Undef
+ false ->
+ filter(fun({_,{MaybeWxModule,_,_}}) ->
+ case atom_to_list(MaybeWxModule) of
+ "wx"++_ -> false;
+ _ -> true
+ end
+ end, Undef);
+ _ -> Undef
end.
-
+
gs_filter(Undef) ->
case code:lib_dir(gs) of
- {error,bad_name} ->
- filter(fun({_,{gs,_,_}}) -> false;
- ({_,{gse,_,_}}) -> false;
+ {error,bad_name} ->
+ filter(fun({_,{gs,_,_}}) -> false;
+ ({_,{gse,_,_}}) -> false;
({_,{tool_utils,_,_}}) -> false;
- (_) -> true
- end, Undef);
- _ -> Undef
+ (_) -> true
+ end, Undef);
+ _ -> Undef
end.
+diameter_filter(Undef) ->
+ %% Filter away function calls that are catched.
+ filter(fun({{diameter_lib,_,_},{erlang,convert_time_unit,3}}) ->
+ false;
+ ({{diameter_lib,_,_},{erlang,monotonic_time,0}}) ->
+ false;
+ ({{diameter_lib,_,_},{erlang,unique_integer,0}}) ->
+ false;
+ ({{diameter_lib,_,_},{erlang,time_offset,0}}) ->
+ false;
+ (_) -> true
+ end, Undef).
+
deprecated_not_in_obsolete(Config) when is_list(Config) ->
- ?line Server = ?config(xref_server, Config),
- ?line {ok,DeprecatedFunctions} = xref:q(Server, "DF"),
-
- ?line L = foldl(fun({M,F,A}=MFA, Acc) ->
- case otp_internal:obsolete(M, F, A) of
- no -> [MFA|Acc];
- _ -> Acc
- end
- end, [], DeprecatedFunctions),
+ Server = proplists:get_value(xref_server, Config),
+ {ok,DeprecatedFunctions} = xref:q(Server, "DF"),
+
+ L = foldl(fun({M,F,A}=MFA, Acc) ->
+ case otp_internal:obsolete(M, F, A) of
+ no -> [MFA|Acc];
+ _ -> Acc
+ end
+ end, [], DeprecatedFunctions),
case L of
- [] -> ok;
- _ ->
- io:put_chars("The following functions have -deprecated() attributes,\n"
- "but are not listed in otp_internal:obsolete/3.\n"),
- print_mfas(group_leader(), Server, L),
- Fd = open_log(Config, "deprecated_not_obsolete"),
- print_mfas(Fd, Server, L),
- close_log(Fd),
- ?line ?t:fail({length(L),deprecated_but_not_obsolete})
+ [] -> ok;
+ _ ->
+ io:put_chars("The following functions have -deprecated() attributes,\n"
+ "but are not listed in otp_internal:obsolete/3.\n"),
+ print_mfas(group_leader(), Server, L),
+ Fd = open_log(Config, "deprecated_not_obsolete"),
+ print_mfas(Fd, Server, L),
+ close_log(Fd),
+ ct:fail({length(L),deprecated_but_not_obsolete})
end.
obsolete_but_not_deprecated(Config) when is_list(Config) ->
- ?line Server = ?config(xref_server, Config),
- ?line {ok,NotDeprecated} = xref:q(Server, "X - DF"),
+ Server = proplists:get_value(xref_server, Config),
+ {ok,NotDeprecated} = xref:q(Server, "X - DF"),
- ?line L = foldl(fun({M,F,A}=MFA, Acc) ->
- case otp_internal:obsolete(M, F, A) of
- no -> Acc;
- _ -> [MFA|Acc]
- end
- end, [], NotDeprecated),
+ L = foldl(fun({M,F,A}=MFA, Acc) ->
+ case otp_internal:obsolete(M, F, A) of
+ no -> Acc;
+ _ -> [MFA|Acc]
+ end
+ end, [], NotDeprecated),
case L of
- [] -> ok;
- _ ->
- io:put_chars("The following functions are listed "
- "in otp_internal:obsolete/3,\n"
- "but don't have -deprecated() attributes.\n"),
- print_mfas(group_leader(), Server, L),
- Fd = open_log(Config, "obsolete_not_deprecated"),
- print_mfas(Fd, Server, L),
- close_log(Fd),
- ?line ?t:fail({length(L),obsolete_but_not_deprecated})
+ [] -> ok;
+ _ ->
+ io:put_chars("The following functions are listed "
+ "in otp_internal:obsolete/3,\n"
+ "but don't have -deprecated() attributes.\n"),
+ print_mfas(group_leader(), Server, L),
+ Fd = open_log(Config, "obsolete_not_deprecated"),
+ print_mfas(Fd, Server, L),
+ close_log(Fd),
+ ct:fail({length(L),obsolete_but_not_deprecated})
end.
-
+
call_to_deprecated(Config) when is_list(Config) ->
- Server = ?config(xref_server, Config),
- ?line {ok,DeprecatedCalls} = xref:q(Server, "strict(E || DF)"),
+ Server = proplists:get_value(xref_server, Config),
+ {ok,DeprecatedCalls} = xref:q(Server, "strict(E || DF)"),
foreach(fun ({MFA1,MFA2}) ->
- io:format("~s calls deprecated ~s",
- [format_mfa(MFA1),format_mfa(MFA2)])
- end, DeprecatedCalls),
+ io:format("~s calls deprecated ~s",
+ [format_mfa(MFA1),format_mfa(MFA2)])
+ end, DeprecatedCalls),
{comment,integer_to_list(length(DeprecatedCalls))++" calls to deprecated functions"}.
call_to_size_1(Config) when is_list(Config) ->
- Server = ?config(xref_server, Config),
-
%% Applications that do not call erlang:size/1:
Apps = [asn1,compiler,debugger,kernel,observer,parsetools,
- runtime_tools,stdlib,tools,webtool],
+ runtime_tools,stdlib,tools],
+ not_recommended_calls(Config, Apps, {erlang,size,1}).
- Fs = [{erlang,size,1}],
+call_to_now_0(Config) when is_list(Config) ->
+ %% Applications that do not call erlang:now/1:
+ Apps = [asn1,common_test,compiler,debugger,dialyzer,
+ gs,kernel,mnesia,observer,parsetools,reltool,
+ runtime_tools,sasl,stdlib,syntax_tools,
+ tools],
+ not_recommended_calls(Config, Apps, {erlang,now,0}).
+
+not_recommended_calls(Config, Apps0, MFA) ->
+ Server = proplists:get_value(xref_server, Config),
+
+ Apps = [App || App <- Apps0, is_present_application(App, Server)],
+
+ Fs = [MFA],
Q1 = io_lib:format("E || ~p : Fun", [Fs]),
- ?line {ok,AllCallsToSize1} = xref:q(Server, lists:flatten(Q1)),
+ {ok,AllCallsToMFA} = xref:q(Server, lists:flatten(Q1)),
Q2 = io_lib:format("E | ~p : App || ~p : Fun", [Apps,Fs]),
- ?line {ok,CallsToSize1} = xref:q(Server, lists:flatten(Q2)),
+ {ok,CallsToMFA} = xref:q(Server, lists:flatten(Q2)),
- case CallsToSize1 of
- [] ->
+ case CallsToMFA of
+ [] ->
ok;
- _ ->
- io:format("These calls cause an error:~n"),
- foreach(fun ({MFA1,MFA2}) ->
- io:format("~s calls soon to be deprecated ~s",
- [format_mfa(MFA1),format_mfa(MFA2)])
- end, CallsToSize1)
+ _ ->
+ io:format("These calls are not allowed:\n"),
+ foreach(fun ({MFA1,MFA2}) ->
+ io:format("~s calls non-recommended ~s",
+ [format_mfa(MFA1),format_mfa(MFA2)])
+ end, CallsToMFA)
end,
- %% Enumerate calls to erlang:size/1 from other applications than
- %% the ones known not to call erlang:size/1:
- case AllCallsToSize1--CallsToSize1 of
+ %% Enumerate calls to MFA from other applications than
+ %% the ones known not to call MFA:
+ case AllCallsToMFA--CallsToMFA of
[] ->
ok;
Calls ->
- io:format("~n~nThese calls do not cause an error (yet):~n"),
+ io:format("~n~nThese calls are allowed for now:\n"),
foreach(fun ({MFA1,MFA2}) ->
- io:format("~s calls soon to be deprecated ~s",
+ io:format("~s calls non-recommended ~s",
[format_mfa(MFA1),format_mfa(MFA2)])
end, Calls)
end,
- case CallsToSize1 of
- [] ->
- ok;
- _ ->
- ?line ?t:fail({length(CallsToSize1),calls_to_size_1})
+ case CallsToMFA of
+ [] ->
+ SkippedApps = ordsets:subtract(ordsets:from_list(Apps0),
+ ordsets:from_list(Apps)),
+ case SkippedApps of
+ [] ->
+ ok;
+ _ ->
+ AppStrings = [atom_to_list(A) || A <- SkippedApps],
+ Mess = io_lib:format("Application(s) not present: ~s\n",
+ [string:join(AppStrings, ", ")]),
+ {comment, Mess}
+ end;
+ _ ->
+ ct:fail({length(CallsToMFA),calls_to_size_1})
+ end.
+
+is_present_application(Name, Server) ->
+ Q = io_lib:format("~w : App", [Name]),
+ case xref:q(Server, lists:flatten(Q)) of
+ {ok,[Name]} -> true;
+ {error,_,_} -> false
end.
strong_components(Config) when is_list(Config) ->
- Server = ?config(xref_server, Config),
- ?line {ok,Cs} = xref:q(Server, "components AE"),
+ Server = proplists:get_value(xref_server, Config),
+ {ok,Cs} = xref:q(Server, "components AE"),
io:format("\n\nStrong components:\n\n~p\n", [Cs]),
ok.
+erl_file_encoding(_Config) ->
+ Root = code:root_dir(),
+ Wc = filename:join([Root,"**","*.erl"]),
+ ErlFiles = ordsets:subtract(ordsets:from_list(filelib:wildcard(Wc)),
+ release_files(Root, "*.erl")),
+ {ok, MP} = re:compile(".*lib/(ic)|(orber)|(cos).*", [unicode]),
+ Fs = [F || F <- ErlFiles,
+ filter_use_latin1_coding(F, MP),
+ case epp:read_encoding(F) of
+ none -> false;
+ _ -> true
+ end],
+ case Fs of
+ [] ->
+ ok;
+ [_|_] ->
+ io:put_chars("Files with \"coding:\":\n"),
+ [io:put_chars(F) || F <- Fs],
+ ct:fail(failed)
+ end.
+
+filter_use_latin1_coding(F, MP) ->
+ case re:run(F, MP) of
+ nomatch ->
+ true;
+ {match, _} ->
+ false
+ end.
+
+xml_file_encoding(_Config) ->
+ XmlFiles = xml_files(),
+ Fs = [F || F <- XmlFiles, is_bad_encoding(F)],
+ case Fs of
+ [] ->
+ ok;
+ [_|_] ->
+ io:put_chars("Encoding should be \"utf-8\" or \"UTF-8\":\n"),
+ [io:put_chars(F) || F <- Fs],
+ ct:fail(failed)
+ end.
+
+xml_files() ->
+ Root = code:root_dir(),
+ AllWc = filename:join([Root,"**","*.xml"]),
+ AllXmlFiles = ordsets:from_list(filelib:wildcard(AllWc)),
+ TestsWc = filename:join([Root,"lib","*","test","**","*.xml"]),
+ TestXmlFiles = ordsets:from_list(filelib:wildcard(TestsWc)),
+ XmerlWc = filename:join([Root,"lib","xmerl","**","*.xml"]),
+ XmerlXmlFiles = ordsets:from_list(filelib:wildcard(XmerlWc)),
+ Ignore = ordsets:union([TestXmlFiles,XmerlXmlFiles,
+ release_files(Root, "*.xml")]),
+ ordsets:subtract(AllXmlFiles, Ignore).
+
+release_files(Root, Ext) ->
+ Wc = filename:join([Root,"release","**",Ext]),
+ filelib:wildcard(Wc).
+
+is_bad_encoding(File) ->
+ {ok,Bin} = file:read_file(File),
+ case Bin of
+ <<"<?xml version=\"1.0\" encoding=\"utf-8\"",_/binary>> ->
+ false;
+ <<"<?xml version=\"1.0\" encoding=\"UTF-8\"",_/binary>> ->
+ false;
+ _ ->
+ true
+ end.
+
+runtime_dependencies(Config) ->
+ %% Ignore applications intentionally not declaring dependencies
+ %% found by xref.
+ IgnoreApps = [diameter],
+
+
+ %% Verify that (at least) OTP application runtime dependencies found
+ %% by xref are listed in the runtime_dependencies field of the .app file
+ %% of each application.
+ Server = proplists:get_value(xref_server, Config),
+ {ok, AE} = xref:q(Server, "AE"),
+ SAE = lists:keysort(1, AE),
+ put(ignored_failures, []),
+ {AppDep, AppDeps} = lists:foldl(fun ({App, App}, Acc) ->
+ Acc;
+ ({App, Dep}, {undefined, []}) ->
+ {{App, [Dep]}, []};
+ ({App, Dep}, {{App, Deps}, AppDeps}) ->
+ {{App, [Dep|Deps]}, AppDeps};
+ ({App, Dep}, {AppDep, AppDeps}) ->
+ {{App, [Dep]}, [AppDep | AppDeps]}
+ end,
+ {undefined, []},
+ SAE),
+ check_apps_deps([AppDep|AppDeps], IgnoreApps),
+ case IgnoreApps of
+ [] ->
+ ok;
+ _ ->
+ Comment = lists:flatten(io_lib:format("Ignored applications: ~p "
+ "Ignored failures: ~p",
+ [IgnoreApps,
+ get(ignored_failures)])),
+ {comment, Comment}
+ end.
+
+have_rdep(_App, [], _Dep) ->
+ false;
+have_rdep(App, [RDep | RDeps], Dep) ->
+ [AppStr, _VsnStr] = string:tokens(RDep, "-"),
+ case Dep == list_to_atom(AppStr) of
+ true ->
+ io:format("~p -> ~s~n", [App, RDep]),
+ true;
+ false ->
+ have_rdep(App, RDeps, Dep)
+ end.
+
+check_app_deps(_App, _AppFile, _AFDeps, [], _IgnoreApps) ->
+ [];
+check_app_deps(App, AppFile, AFDeps, [XRDep | XRDeps], IgnoreApps) ->
+ ResOtherDeps = check_app_deps(App, AppFile, AFDeps, XRDeps, IgnoreApps),
+ case have_rdep(App, AFDeps, XRDep) of
+ true ->
+ ResOtherDeps;
+ false ->
+ Failure = {missing_runtime_dependency, AppFile, XRDep},
+ case lists:member(App, IgnoreApps) of
+ true ->
+ put(ignored_failures, [Failure | get(ignored_failures)]),
+ ResOtherDeps;
+ false ->
+ [Failure | ResOtherDeps]
+ end
+ end.
+
+check_apps_deps([], _IgnoreApps) ->
+ [];
+check_apps_deps([{App, Deps}|AppDeps], IgnoreApps) ->
+ ResOtherApps = check_apps_deps(AppDeps, IgnoreApps),
+ AppFile = code:where_is_file(atom_to_list(App) ++ ".app"),
+ {ok,[{application, App, Info}]} = file:consult(AppFile),
+ case lists:keyfind(runtime_dependencies, 1, Info) of
+ {runtime_dependencies, RDeps} ->
+ check_app_deps(App, AppFile, RDeps, Deps, IgnoreApps)
+ ++ ResOtherApps;
+ false ->
+ Failure = {missing_runtime_dependencies_key, AppFile},
+ case lists:member(App, IgnoreApps) of
+ true ->
+ put(ignored_failures, [Failure | get(ignored_failures)]),
+ ResOtherApps;
+ false ->
+ [Failure | ResOtherApps]
+ end
+ end.
+
%%%
%%% Common help functions.
%%%
-
+
print_mfas(Fd, Server, MFAs) ->
[io:format(Fd, "~s\n", [format_mfa(Server, MFA)]) || MFA <- MFAs],
ok.
@@ -335,13 +526,13 @@ format_mfa(Server, MFA) ->
MFAString = format_mfa(MFA),
AQ = "(App)" ++ MFAString,
AppPrefix = case xref:q(Server, AQ) of
- {ok,[App]} -> "[" ++ atom_to_list(App) ++ "]";
- _ -> ""
- end,
+ {ok,[App]} -> "[" ++ atom_to_list(App) ++ "]";
+ _ -> ""
+ end,
AppPrefix ++ MFAString.
open_log(Config, Name) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
RunDir = filename:dirname(filename:dirname(PrivDir)),
Path = filename:join(RunDir, "system_"++Name++".log"),
{ok,Fd} = file:open(Path, [write]),
@@ -352,13 +543,13 @@ close_log(Fd) ->
app_exists(AppAtom) ->
case code:lib_dir(AppAtom) of
- {error,bad_name} ->
- false;
- Path ->
- case file:read_file_info(filename:join(Path,"ebin")) of
- {ok,_} ->
- true;
- _ ->
- false
- end
+ {error,bad_name} ->
+ false;
+ Path ->
+ case file:read_file_info(filename:join(Path,"ebin")) of
+ {ok,_} ->
+ true;
+ _ ->
+ false
+ end
end.
diff --git a/erts/test/run_erl_SUITE.erl b/erts/test/run_erl_SUITE.erl
index de05e6f206..47d38bde7c 100644
--- a/erts/test/run_erl_SUITE.erl
+++ b/erts/test/run_erl_SUITE.erl
@@ -1,61 +1,38 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
-module(run_erl_SUITE).
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
- init_per_testcase/2,end_per_testcase/2,
- basic/1,heavy/1,heavier/1,defunct/1]).
+-export([all/0, suite/0]).
+-export([basic/1,heavy/1,heavier/1,defunct/1]).
-export([ping_me_back/1]).
--include_lib("test_server/include/test_server.hrl").
-
-init_per_testcase(_Case, Config) ->
- Dog = ?t:timetrap(?t:minutes(2)),
- [{watchdog, Dog}|Config].
-
-end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
- ok.
+-include_lib("common_test/include/ct.hrl").
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 2}}].
all() ->
[basic, heavy, heavier, defunct].
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
basic(Config) when is_list(Config) ->
case os:type() of
@@ -64,16 +41,16 @@ basic(Config) when is_list(Config) ->
end.
basic_1(Config) ->
- ?line {Node,Pipe} = do_run_erl(Config, "basic"),
+ {Node,Pipe} = do_run_erl(Config, "basic"),
- ?line ToErl = open_port({spawn,"to_erl "++Pipe}, []),
- ?line erlang:port_command(ToErl, "halt().\r\n"),
+ ToErl = open_port({spawn,"to_erl "++Pipe}, []),
+ erlang:port_command(ToErl, "halt().\r\n"),
receive
{nodedown,Node} ->
- ?line io:format("Down: ~p\n", [Node])
+ io:format("Down: ~p\n", [Node])
after 10000 ->
- ?line ?t:fail()
+ ct:fail(timeout)
end,
ok.
@@ -85,29 +62,28 @@ heavy(Config) when is_list(Config) ->
end.
heavy_1(Config) ->
- ?line {Node,Pipe} = do_run_erl(Config, "heavy"),
+ {Node,Pipe} = do_run_erl(Config, "heavy"),
- ?line ToErl = open_port({spawn,"to_erl "++Pipe}, []),
+ ToErl = open_port({spawn,"to_erl "++Pipe}, []),
IoFormat = "io:format(\"~s\n\", [lists:duplicate(10000, 10)]).\r\n",
- ?line erlang:port_command(ToErl, IoFormat),
- ?line erlang:port_command(ToErl, IoFormat),
- ?line erlang:port_command(ToErl, IoFormat),
- ?line erlang:port_command(ToErl, "init:stop().\r\n"),
+ erlang:port_command(ToErl, IoFormat),
+ erlang:port_command(ToErl, IoFormat),
+ erlang:port_command(ToErl, IoFormat),
+ erlang:port_command(ToErl, "init:stop().\r\n"),
receive
{nodedown,Node} ->
- ?line io:format("Down: ~p\n", [Node])
+ io:format("Down: ~p\n", [Node])
after 10000 ->
- ?line ?t:fail()
+ ct:fail(timeout)
end,
- ?line case count_new_lines(ToErl, 0) of
- Nls when Nls > 30000 ->
- ok;
- Nls ->
- ?line io:format("new_lines: ~p\n", [Nls]),
- ?line ?t:fail()
- end.
+ case count_new_lines(ToErl, 0) of
+ Nls when Nls > 30000 ->
+ ok;
+ Nls ->
+ ct:fail("new_lines: ~p\n", [Nls])
+ end.
ping_me_back([Node]) when is_atom(Node) ->
@@ -136,18 +112,16 @@ heavier(Config) when is_list(Config) ->
end.
heavier_1(Config) ->
- ?line {Node,Pipe} = do_run_erl(Config, "heavier"),
+ {Node,Pipe} = do_run_erl(Config, "heavier"),
- ?line ToErl = open_port({spawn,"to_erl "++Pipe}, []),
+ ToErl = open_port({spawn,"to_erl "++Pipe}, []),
io:format("ToErl = ~p\n", [ToErl]),
- X = 1,
- Y = 555,
- Z = 42,
- ?line random:seed(X, Y, Z),
- SeedCmd = lists:flatten(io_lib:format("random:seed(~p, ~p, ~p). \r\n",
- [X,Y,Z])),
- ?line io:format("~p\n", [SeedCmd]),
- ?line erlang:port_command(ToErl, SeedCmd),
+ Seed = {1,555,42},
+ rand:seed(exsplus, Seed),
+ SeedCmd = lists:flatten(io_lib:format("rand:seed(exsplus, ~p). \r\n",
+ [Seed])),
+ io:format("~p\n", [SeedCmd]),
+ erlang:port_command(ToErl, SeedCmd),
Iter = 1000,
MaxLen = 2048,
@@ -156,9 +130,9 @@ heavier_1(Config) ->
"F = fun(F,0) -> ok; "++
"(F,N) -> " ++
"io:format(\"\\\"~s\\\"~n\","++
- "[[35|[random:uniform(25)+65 || " ++
+ "[[35|[rand:uniform(25)+65 || " ++
"_ <- lists:seq(1, "++
- "random:uniform("++
+ "rand:uniform("++
integer_to_list(MaxLen)++
"))]]]), "++
"F(F,N-1) "++
@@ -166,19 +140,19 @@ heavier_1(Config) ->
"F(F,"++integer_to_list(Iter)++")."++" \r\n",
- ?line io:format("~p\n", [Random]),
- ?line erlang:port_command(ToErl, Random),
+ io:format("~p\n", [Random]),
+ erlang:port_command(ToErl, Random),
%% Finish.
- ?line erlang:port_command(ToErl, "init:stop().\r\n"),
- ?line receive_all(Iter, ToErl, MaxLen),
+ erlang:port_command(ToErl, "init:stop().\r\n"),
+ receive_all(Iter, ToErl, MaxLen),
receive
{nodedown,Node} ->
- ?line io:format("Down: ~p\n", [Node])
+ io:format("Down: ~p\n", [Node])
after 10000 ->
- ?line c:flush(),
- ?line ?t:fail()
+ c:flush(),
+ ct:fail(timeout)
end,
ok.
@@ -188,8 +162,8 @@ receive_all(Iter, ToErl, MaxLen) ->
receive_all_1(0, _, _, _) -> ok;
receive_all_1(Iter, Line, ToErl, MaxLen) ->
- NumChars = random:uniform(MaxLen),
- Pattern = [random:uniform(25)+65 || _ <- lists:seq(1, NumChars)],
+ NumChars = rand:uniform(MaxLen),
+ Pattern = [rand:uniform(25)+65 || _ <- lists:seq(1, NumChars)],
receive_all_2(Iter, {NumChars,Pattern}, Line, ToErl, MaxLen).
@@ -205,9 +179,7 @@ receive_all_2(Iter, {NumChars,Pattern}, Line0, ToErl, MaxLen) ->
%%io:format("Recv: ~p\n", [S]),
receive_all_2(Iter, {NumChars,Pattern}, Line++S, ToErl, MaxLen)
after 10000 ->
- io:format("Timeout waiting for\n~p\ngot\n~p\n",
- [Pattern, Line]),
- ?line ?t:fail()
+ ct:fail("Timeout waiting for\n~p\ngot\n~p\n", [Pattern, Line])
end
end.
@@ -242,49 +214,47 @@ defunct_1(Config) ->
end.
defunct_2(Config, Perl) ->
- ?line Data = ?config(data_dir, Config),
- ?line RunErlTest = filename:join(Data, "run_erl_test.pl"),
- ?line Defuncter = filename:join(Data, "defuncter.pl"),
- ?line Priv = ?config(priv_dir, Config),
- ?line LogDir = filename:join(Priv, "defunct"),
- ?line ok = file:make_dir(LogDir),
- ?line Pipe = LogDir ++ "/",
- ?line RunErl = os:find_executable(run_erl),
- ?line Cmd = Perl ++ " " ++ RunErlTest ++ " \"" ++ RunErl ++ "\" " ++
+ Data = proplists:get_value(data_dir, Config),
+ RunErlTest = filename:join(Data, "run_erl_test.pl"),
+ Defuncter = filename:join(Data, "defuncter.pl"),
+ Priv = proplists:get_value(priv_dir, Config),
+ LogDir = filename:join(Priv, "defunct"),
+ ok = file:make_dir(LogDir),
+ Pipe = LogDir ++ "/",
+ RunErl = os:find_executable(run_erl),
+ Cmd = Perl ++ " " ++ RunErlTest ++ " \"" ++ RunErl ++ "\" " ++
Defuncter ++ " " ++ Pipe ++ " " ++ LogDir,
- ?line io:format("~p", [Cmd]),
- ?line Res = os:cmd(Cmd),
- ?line io:format("~p\n", [Res]),
+ io:format("~p", [Cmd]),
+ Res = os:cmd(Cmd),
+ io:format("~p\n", [Res]),
"OK"++_ = Res,
ok.
%%% Utilities.
do_run_erl(Config, Case) ->
- ?line Priv = ?config(priv_dir, Config),
- ?line LogDir = filename:join(Priv, Case),
- ?line ok = file:make_dir(LogDir),
- ?line Pipe = LogDir ++ "/",
- ?line NodeName = "run_erl_node_" ++ Case,
- ?line Cmd = "run_erl "++Pipe++" "++LogDir++" \"erl -sname " ++ NodeName ++
+ Priv = proplists:get_value(priv_dir, Config),
+ LogDir = filename:join(Priv, Case),
+ ok = file:make_dir(LogDir),
+ Pipe = LogDir ++ "/",
+ NodeName = "run_erl_node_" ++ Case,
+ Cmd = "run_erl "++Pipe++" "++LogDir++" \"erl -sname " ++ NodeName ++
" -pa " ++ filename:dirname(code:which(?MODULE)) ++
" -s " ++ ?MODULE_STRING ++ " ping_me_back " ++
atom_to_list(node()) ++ "\"",
- ?line io:format("~p\n", [Cmd]),
+ io:format("~p\n", [Cmd]),
- ?line net_kernel:monitor_nodes(true),
- ?line open_port({spawn,Cmd}, []),
- ?line [_,Host] = string:tokens(atom_to_list(node()), "@"),
- ?line Node = list_to_atom(NodeName++"@"++Host),
+ net_kernel:monitor_nodes(true),
+ open_port({spawn,Cmd}, []),
+ [_,Host] = string:tokens(atom_to_list(node()), "@"),
+ Node = list_to_atom(NodeName++"@"++Host),
receive
{nodeup,Node} ->
- ?line io:format("Up: ~p\n", [Node]);
+ io:format("Up: ~p\n", [Node]);
Other ->
- ?line io:format("Unexpected: ~p\n", [Other]),
- ?line ?t:fail()
+ ct:fail("Unexpected: ~p\n", [Other])
after 10000 ->
- ?line ?t:fail()
+ ct:fail(timeout)
end,
-
{Node,Pipe}.
diff --git a/erts/test/run_erl_SUITE_data/defuncter.pl b/erts/test/run_erl_SUITE_data/defuncter.pl
index 261f1b8061..0b6771a8bb 100644
--- a/erts/test/run_erl_SUITE_data/defuncter.pl
+++ b/erts/test/run_erl_SUITE_data/defuncter.pl
@@ -1,18 +1,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2006-2009. All Rights Reserved.
+# Copyright Ericsson AB 2006-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
diff --git a/erts/test/run_erl_SUITE_data/run_erl_test.pl b/erts/test/run_erl_SUITE_data/run_erl_test.pl
index 2155225e7f..9560fa3c14 100644
--- a/erts/test/run_erl_SUITE_data/run_erl_test.pl
+++ b/erts/test/run_erl_SUITE_data/run_erl_test.pl
@@ -1,18 +1,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2006-2009. All Rights Reserved.
+# Copyright Ericsson AB 2006-2016. 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.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
diff --git a/erts/test/system_smoke.spec b/erts/test/system_smoke.spec
new file mode 100644
index 0000000000..933d1ba22d
--- /dev/null
+++ b/erts/test/system_smoke.spec
@@ -0,0 +1,3 @@
+{suites,"../system_test",[ethread_SUITE]}.
+{cases,"../system_test",otp_SUITE,[undefined_functions]}.
+{skip_cases,"../system_test",ethread_SUITE,[max_threads],"Skip"}.
diff --git a/erts/test/upgrade_SUITE.erl b/erts/test/upgrade_SUITE.erl
new file mode 100644
index 0000000000..174c028ac7
--- /dev/null
+++ b/erts/test/upgrade_SUITE.erl
@@ -0,0 +1,452 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2014-2016. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+-module(upgrade_SUITE).
+
+-compile(export_all).
+
+-include_lib("common_test/include/ct.hrl").
+-include_lib("kernel/include/file.hrl").
+
+-define(upgr_sname,otp_upgrade).
+
+%% Applications that are excluded from this test because they can not
+%% just be started in a new node with out specific configuration.
+-define(start_exclude,
+ [cosEvent,cosEventDomain,cosFileTransfer,cosNotification,
+ cosProperty,cosTime,cosTransactions,erts,ic,netconf,orber,
+ safe]).
+
+%% Applications that are excluded from this test because their appup
+%% file don't support the upgrade.
+%% In specific:
+%% - hipe does not support any upgrade at all
+%% - dialyzer requires hipe (in the .app file)
+%% - typer requires hipe (in the .app file)
+%% - erl_interface, jinterface support no upgrade
+-define(appup_exclude,
+ [dialyzer,hipe,typer,erl_interface,jinterface,ose]).
+
+init_per_suite(Config) ->
+ %% Check that a real release is running, not e.g. cerl
+ ok = application:ensure_started(sasl),
+ case release_handler:which_releases() of
+ [{_,_,[],_}] ->
+ %% Fake release, no applications
+ {skip, "Need a real release running to create other releases"};
+ _ ->
+ rm_rf(filename:join([proplists:get_value(data_dir,Config),priv_dir])),
+ Config
+ end.
+
+init_per_testcase(Case,Config) ->
+ PrivDir = filename:join([proplists:get_value(data_dir,Config),priv_dir,Case]),
+ CreateDir = filename:join([PrivDir,create]),
+ InstallDir = filename:join([PrivDir,install]),
+ ok = filelib:ensure_dir(filename:join(CreateDir,"*")),
+ ok = filelib:ensure_dir(filename:join(InstallDir,"*")),
+ Config1 = lists:keyreplace(priv_dir,1,Config,{priv_dir,PrivDir}),
+ [{create_dir,CreateDir},{install_dir,InstallDir}|Config1].
+
+end_per_testcase(_Case,Config) ->
+ Nodes = nodes(),
+ [test_server:stop_node(Node) || Node <- Nodes],
+ case proplists:get_value(tc_status,Config) of
+ ok ->
+ %% Note that priv_dir here is per test case!
+ rm_rf(proplists:get_value(priv_dir,Config));
+ _fail ->
+ %% Test case data can be found under DataDir/priv_dir/Case
+ ok
+ end,
+ ok.
+
+all() ->
+ [minor,major].
+
+%% If this is major release X, then this test performs an upgrade from
+%% major release X-1 to the current release.
+major(Config) ->
+ Current = erlang:system_info(otp_release),
+ PreviousMajor = previous_major(Current),
+ upgrade_test(PreviousMajor,Current,Config).
+
+%% If this is a patched version of major release X, then this test
+%% performs an upgrade from major release X to the current release.
+minor(Config) ->
+ CurrentMajor = erlang:system_info(otp_release),
+ Current = CurrentMajor++"_patched",
+ upgrade_test(CurrentMajor,Current,Config).
+
+%%%-----------------------------------------------------------------
+upgrade_test(FromVsn,ToVsn,Config) ->
+ OldRel =
+ case test_server:is_release_available(FromVsn) of
+ true ->
+ {release,FromVsn};
+ false ->
+ case ct:get_config({otp_releases,list_to_atom(FromVsn)}) of
+ undefined ->
+ false;
+ Prog0 ->
+ case os:find_executable(Prog0) of
+ false ->
+ false;
+ Prog ->
+ {prog,Prog}
+ end
+ end
+ end,
+ case OldRel of
+ false ->
+ %% Note that priv_dir here is per test case!
+ rm_rf(proplists:get_value(priv_dir,Config)),
+ {skip, "no previous release available"};
+ _ ->
+ upgrade_test1(FromVsn,ToVsn,[{old_rel,OldRel}|Config])
+ end.
+
+upgrade_test1(FromVsn,ToVsn,Config) ->
+ CreateDir = proplists:get_value(create_dir,Config),
+ InstallDir = proplists:get_value(install_dir,Config),
+ FromRelName = "otp-"++FromVsn,
+ ToRelName = "otp-"++ToVsn,
+
+ {FromRel,FromApps} = target_system(FromRelName, FromVsn,
+ CreateDir, InstallDir,Config),
+ {ToRel,ToApps} = upgrade_system(FromRel, ToRelName, ToVsn,
+ CreateDir, InstallDir),
+ do_upgrade(FromVsn, FromApps, ToRel, ToApps, InstallDir).
+
+%%%-----------------------------------------------------------------
+%%% This is similar to sasl/examples/src/target_system.erl, but with
+%%% the following adjustments:
+%%% - add a log directory
+%%% - use an own 'start' script
+%%% - chmod 'start' and 'start_erl'
+target_system(RelName0,RelVsn,CreateDir,InstallDir,Config) ->
+ {ok,Node} = test_server:start_node(list_to_atom(RelName0),peer,
+ [{erl,[proplists:get_value(old_rel,Config)]}]),
+
+ {RelName,Apps,ErtsVsn} = create_relfile(Node,CreateDir,RelName0,RelVsn),
+
+ %% Create .script and .boot
+ ok = rpc:call(Node,systools,make_script,[RelName]),
+
+ %% Create base tar file - i.e. erts and all apps
+ ok = rpc:call(Node,systools,make_tar,
+ [RelName,[{erts,rpc:call(Node,code,root_dir,[])}]]),
+
+ %% Unpack the tar to complete the installation
+ erl_tar:extract(RelName ++ ".tar.gz", [{cwd, InstallDir}, compressed]),
+
+ %% Add bin and log dirs
+ BinDir = filename:join([InstallDir, "bin"]),
+ file:make_dir(BinDir),
+ file:make_dir(filename:join(InstallDir,"log")),
+
+ %% Delete start scripts - they will be added later
+ ErtsBinDir = filename:join([InstallDir, "erts-" ++ ErtsVsn, "bin"]),
+ file:delete(filename:join([ErtsBinDir, "erl"])),
+ file:delete(filename:join([ErtsBinDir, "start"])),
+ file:delete(filename:join([ErtsBinDir, "start_erl"])),
+
+ %% Copy .boot to bin/start.boot
+ copy_file(RelName++".boot",filename:join([BinDir, "start.boot"])),
+
+ %% Copy scripts from erts-xxx/bin to bin
+ copy_file(filename:join([ErtsBinDir, "epmd"]),
+ filename:join([BinDir, "epmd"]), [preserve]),
+ copy_file(filename:join([ErtsBinDir, "run_erl"]),
+ filename:join([BinDir, "run_erl"]), [preserve]),
+ copy_file(filename:join([ErtsBinDir, "to_erl"]),
+ filename:join([BinDir, "to_erl"]), [preserve]),
+
+ %% create start_erl.data and sys.config
+ StartErlData = filename:join([InstallDir, "releases", "start_erl.data"]),
+ write_file(StartErlData, io_lib:fwrite("~s ~s~n", [ErtsVsn, RelVsn])),
+ SysConfig = filename:join([InstallDir, "releases", RelVsn, "sys.config"]),
+ write_file(SysConfig, "[]."),
+
+ %% Insert 'start' script from data_dir - modified to add sname and heart
+ copy_file(filename:join(proplists:get_value(data_dir,Config),"start.src"),
+ filename:join(ErtsBinDir,"start.src")),
+ ok = file:change_mode(filename:join(ErtsBinDir,"start.src"),8#0755),
+
+ %% Make start_erl executable
+ %% (this has been fixed in OTP 17 - is is now installed with
+ %% $INSTALL_SCRIPT instead of $INSTALL_DATA and should therefore
+ %% be executable from the start)
+ ok = file:change_mode(filename:join(ErtsBinDir,"start_erl.src"),8#0755),
+
+ %% Substitute variables in erl.src, start.src and start_erl.src
+ %% (.src found in erts-xxx/bin - result stored in bin)
+ subst_src_scripts(["erl", "start", "start_erl"], ErtsBinDir, BinDir,
+ [{"FINAL_ROOTDIR", InstallDir}, {"EMU", "beam"}],
+ [preserve]),
+
+ %% Create RELEASES
+ RelFile = filename:join([InstallDir, "releases",
+ filename:basename(RelName) ++ ".rel"]),
+ release_handler:create_RELEASES(InstallDir, RelFile),
+
+ true = test_server:stop_node(Node),
+
+ {RelName,Apps}.
+
+%%%-----------------------------------------------------------------
+%%% Create a release containing the current (the test node) OTP
+%%% release, including relup to allow upgrade from an earlier OTP
+%%% release.
+upgrade_system(FromRel, ToRelName0, ToVsn,
+ CreateDir, InstallDir) ->
+
+ {RelName,Apps,_} = create_relfile(node(),CreateDir,ToRelName0,ToVsn),
+ FromPath = filename:join([InstallDir,lib,"*",ebin]),
+
+ ok = systools:make_script(RelName),
+ ok = systools:make_relup(RelName,[FromRel],[FromRel],
+ [{path,[FromPath]},
+ {outdir,CreateDir}]),
+ SysConfig = filename:join([CreateDir, "sys.config"]),
+ write_file(SysConfig, "[]."),
+
+ ok = systools:make_tar(RelName,[{erts,code:root_dir()}]),
+
+ {RelName,Apps}.
+
+%%%-----------------------------------------------------------------
+%%% Start a new node running the release from target_system/5
+%%% above. Then upgrade to the system from upgrade_system/5.
+do_upgrade(FromVsn,FromApps,ToRel,ToApps,InstallDir) ->
+ Start = filename:join([InstallDir,bin,start]),
+ {ok,Node} = start_node(Start,permanent,FromVsn,FromApps),
+
+ [{"OTP upgrade test",FromVsn,_,permanent}] =
+ rpc:call(Node,release_handler,which_releases,[]),
+ ToRelName = filename:basename(ToRel),
+ copy_file(ToRel++".tar.gz",
+ filename:join([InstallDir,releases,ToRelName++".tar.gz"])),
+ {ok,ToVsn} = rpc:call(Node,release_handler,unpack_release,[ToRelName]),
+ [{"OTP upgrade test",ToVsn,_,unpacked},
+ {"OTP upgrade test",FromVsn,_,permanent}] =
+ rpc:call(Node,release_handler,which_releases,[]),
+ case rpc:call(Node,release_handler,install_release,[ToVsn]) of
+ {ok,FromVsn,_} ->
+ ok;
+ {continue_after_restart,FromVsn,_} ->
+ wait_node_up(current,ToVsn,ToApps)
+ end,
+ [{"OTP upgrade test",ToVsn,_,current},
+ {"OTP upgrade test",FromVsn,_,permanent}] =
+ rpc:call(Node,release_handler,which_releases,[]),
+ ok = rpc:call(Node,release_handler,make_permanent,[ToVsn]),
+ [{"OTP upgrade test",ToVsn,_,permanent},
+ {"OTP upgrade test",FromVsn,_,old}] =
+ rpc:call(Node,release_handler,which_releases,[]),
+
+ erlang:monitor_node(Node,true),
+ _ = rpc:call(Node,init,stop,[]),
+ receive {nodedown,Node} -> ok end,
+
+ ok.
+
+%%%-----------------------------------------------------------------
+%%% Library functions
+previous_major("17") ->
+ "r16b";
+previous_major(Rel) ->
+ integer_to_list(list_to_integer(Rel)-1).
+
+create_relfile(Node,CreateDir,RelName0,RelVsn) ->
+ LibDir = rpc:call(Node,code,lib_dir,[]),
+ SplitLibDir = filename:split(LibDir),
+ Paths = rpc:call(Node,code,get_path,[]),
+ Exclude = ?start_exclude ++ ?appup_exclude,
+ Apps = lists:flatmap(
+ fun(Path) ->
+ case lists:prefix(LibDir,Path) of
+ true ->
+ case filename:split(Path) -- SplitLibDir of
+ [AppVsn,"ebin"] ->
+ case string:tokens(AppVsn,"-") of
+ [AppStr,Vsn] ->
+ App = list_to_atom(AppStr),
+ case lists:member(App,Exclude) of
+ true ->
+ [];
+ false ->
+ [{App,Vsn,restart_type(App)}]
+ end;
+ _ ->
+ []
+ end;
+ _ ->
+ []
+ end;
+ false ->
+ []
+ end
+ end,
+ Paths),
+
+ ErtsVsn = rpc:call(Node, erlang, system_info, [version]),
+
+ %% Create the .rel file
+ RelContent = {release, {"OTP upgrade test", RelVsn}, {erts, ErtsVsn}, Apps},
+ RelName = filename:join(CreateDir,RelName0),
+ RelFile = RelName++".rel",
+ {ok,Fd} = file:open(RelFile,[write,{encoding,utf8}]),
+ io:format(Fd,"~tp.~n",[RelContent]),
+ ok = file:close(Fd),
+ {RelName,Apps,ErtsVsn}.
+
+restart_type(App) when App==kernel; App==stdlib; App==sasl ->
+ permanent;
+restart_type(_) ->
+ temporary.
+
+copy_file(Src, Dest) ->
+ copy_file(Src, Dest, []).
+
+copy_file(Src, Dest, Opts) ->
+ {ok,_} = file:copy(Src, Dest),
+ case lists:member(preserve, Opts) of
+ true ->
+ {ok, FileInfo} = file:read_file_info(Src),
+ file:write_file_info(Dest, FileInfo);
+ false ->
+ ok
+ end.
+
+
+write_file(FName, Conts) ->
+ Enc = file:native_name_encoding(),
+ {ok, Fd} = file:open(FName, [write]),
+ file:write(Fd, unicode:characters_to_binary(Conts,Enc,Enc)),
+ file:close(Fd).
+
+
+subst_src_scripts(Scripts, SrcDir, DestDir, Vars, Opts) ->
+ lists:foreach(fun(Script) ->
+ subst_src_script(Script, SrcDir, DestDir,
+ Vars, Opts)
+ end, Scripts).
+
+subst_src_script(Script, SrcDir, DestDir, Vars, Opts) ->
+ subst_file(filename:join([SrcDir, Script ++ ".src"]),
+ filename:join([DestDir, Script]),
+ Vars, Opts).
+
+subst_file(Src, Dest, Vars, Opts) ->
+ {ok, Bin} = file:read_file(Src),
+ Conts = binary_to_list(Bin),
+ NConts = subst(Conts, Vars),
+ write_file(Dest, NConts),
+ case lists:member(preserve, Opts) of
+ true ->
+ {ok, FileInfo} = file:read_file_info(Src),
+ file:write_file_info(Dest, FileInfo);
+ false ->
+ ok
+ end.
+
+%% subst(Str, Vars)
+%% Vars = [{Var, Val}]
+%% Var = Val = string()
+%% Substitute all occurrences of %Var% for Val in Str, using the list
+%% of variables in Vars.
+%%
+subst(Str, Vars) ->
+ subst(Str, Vars, []).
+
+subst([$%, C| Rest], Vars, Result) when $A =< C, C =< $Z ->
+ subst_var([C| Rest], Vars, Result, []);
+subst([$%, C| Rest], Vars, Result) when $a =< C, C =< $z ->
+ subst_var([C| Rest], Vars, Result, []);
+subst([$%, C| Rest], Vars, Result) when C == $_ ->
+ subst_var([C| Rest], Vars, Result, []);
+subst([C| Rest], Vars, Result) ->
+ subst(Rest, Vars, [C| Result]);
+subst([], _Vars, Result) ->
+ lists:reverse(Result).
+
+subst_var([$%| Rest], Vars, Result, VarAcc) ->
+ Key = lists:reverse(VarAcc),
+ case lists:keysearch(Key, 1, Vars) of
+ {value, {Key, Value}} ->
+ subst(Rest, Vars, lists:reverse(Value, Result));
+ false ->
+ subst(Rest, Vars, [$%| VarAcc ++ [$%| Result]])
+ end;
+subst_var([C| Rest], Vars, Result, VarAcc) ->
+ subst_var(Rest, Vars, Result, [C| VarAcc]);
+subst_var([], Vars, Result, VarAcc) ->
+ subst([], Vars, [VarAcc ++ [$%| Result]]).
+
+
+%%%-----------------------------------------------------------------
+%%%
+start_node(Start,ExpStatus,ExpVsn,ExpApps) ->
+ case open_port({spawn_executable, Start}, []) of
+ Port when is_port(Port) ->
+ unlink(Port),
+ erlang:port_close(Port),
+ wait_node_up(ExpStatus,ExpVsn,ExpApps);
+ Error ->
+ Error
+ end.
+
+wait_node_up(ExpStatus,ExpVsn,ExpApps0) ->
+ ExpApps = [{A,V} || {A,V,_T} <- ExpApps0],
+ Node = node_name(?upgr_sname),
+ wait_node_up(Node,ExpStatus,ExpVsn,lists:keysort(1,ExpApps),60).
+
+wait_node_up(Node,ExpStatus,ExpVsn,ExpApps,0) ->
+ ct:fail({app_check_failed,ExpVsn,ExpApps,
+ rpc:call(Node,release_handler,which_releases,[ExpStatus]),
+ rpc:call(Node,application,which_applications,[])});
+wait_node_up(Node,ExpStatus,ExpVsn,ExpApps,N) ->
+ timer:sleep(2000),
+ case {rpc:call(Node,release_handler,which_releases,[ExpStatus]),
+ rpc:call(Node, application, which_applications, [])} of
+ {[{_,ExpVsn,_,_}],Apps} when is_list(Apps) ->
+ case [{A,V} || {A,_,V} <- lists:keysort(1,Apps)] of
+ ExpApps -> {ok,Node};
+ _ -> wait_node_up(Node,ExpStatus,ExpVsn,ExpApps,N-1)
+ end;
+ _ ->
+ wait_node_up(Node,ExpStatus,ExpVsn,ExpApps,N-1)
+ end.
+
+node_name(Sname) ->
+ {ok,Host} = inet:gethostname(),
+ list_to_atom(atom_to_list(Sname) ++ "@" ++ Host).
+
+rm_rf(Dir) ->
+ case file:read_file_info(Dir) of
+ {ok, #file_info{type = directory}} ->
+ {ok, Content} = file:list_dir_all(Dir),
+ [rm_rf(filename:join(Dir,C)) || C <- Content],
+ ok=file:del_dir(Dir),
+ ok;
+ {ok, #file_info{}} ->
+ ok=file:delete(Dir);
+ _ ->
+ ok
+ end.
diff --git a/erts/test/upgrade_SUITE_data/start.src b/erts/test/upgrade_SUITE_data/start.src
new file mode 100644
index 0000000000..67d8de8c9e
--- /dev/null
+++ b/erts/test/upgrade_SUITE_data/start.src
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2014-2016. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# %CopyrightEnd%
+#
+# This program invokes the erlang emulator by calling run_erl.
+# It should only be used at an embedded target system.
+# It should be modified to give the correct flags to erl (via start_erl),
+# e.g -mode embedded -sname XXX
+#
+# Usage: start [Data]
+#
+ROOTDIR=%FINAL_ROOTDIR%
+
+if [ -z "$RELDIR" ]
+then
+ RELDIR=$ROOTDIR/releases
+fi
+
+START_ERL_DATA=${1:-$RELDIR/start_erl.data}
+
+$ROOTDIR/bin/run_erl -daemon /tmp/ $ROOTDIR/log "exec $ROOTDIR/bin/start_erl $ROOTDIR $RELDIR $START_ERL_DATA -sname otp_upgrade -heart"
diff --git a/erts/test/utils/gccifier.c b/erts/test/utils/gccifier.c
index 7e4ffc7281..0c3ef915fb 100644
--- a/erts/test/utils/gccifier.c
+++ b/erts/test/utils/gccifier.c
@@ -1,18 +1,19 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2004-2012. All Rights Reserved.
+ * Copyright Ericsson AB 2004-2016. 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
* %CopyrightEnd%
*
diff --git a/erts/test/utils/gccifier.sh b/erts/test/utils/gccifier.sh
index 978aecf424..9311e34300 100755
--- a/erts/test/utils/gccifier.sh
+++ b/erts/test/utils/gccifier.sh
@@ -2,18 +2,19 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2005-2012. All Rights Reserved.
+# Copyright Ericsson AB 2005-2016. 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/.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
-# 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.
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# %CopyrightEnd%
#
diff --git a/erts/test/z_SUITE.erl b/erts/test/z_SUITE.erl
index ccf22a9b6b..281a47134f 100644
--- a/erts/test/z_SUITE.erl
+++ b/erts/test/z_SUITE.erl
@@ -1,18 +1,19 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2013. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2016. 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/.
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
%%
-%% 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.
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
%%
%% %CopyrightEnd%
%%
@@ -23,8 +24,6 @@
%% This suite expects to be run as the last suite of all suites.
%%
-%-define(line_trace, 1).
-
-include_lib("kernel/include/file.hrl").
-record(core_search_conf, {search_dir,
@@ -33,52 +32,19 @@
file,
run_by_ts}).
--define(DEFAULT_TIMEOUT, ?t:minutes(5)).
-
--export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
- init_per_group/2,end_per_group/2,
- init_per_testcase/2, end_per_testcase/2]).
+-export([all/0, suite/0]).
-export([search_for_core_files/1, core_files/1]).
-include_lib("common_test/include/ct.hrl").
-
-init_per_testcase(Case, Config) ->
- Dog = ?t:timetrap(?DEFAULT_TIMEOUT),
- [{testcase, Case}, {watchdog, Dog} |Config].
-
-end_per_testcase(_Case, Config) ->
- Dog = ?config(watchdog, Config),
- ?t:timetrap_cancel(Dog),
- ok.
-
-suite() -> [{ct_hooks,[ts_install_cth]}].
+suite() ->
+ [{ct_hooks,[ts_install_cth]},
+ {timetrap, {minutes, 5}}].
all() ->
[core_files].
-groups() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_group(_GroupName, Config) ->
- Config.
-
-end_per_group(_GroupName, Config) ->
- Config.
-
-
-
-core_files(doc) ->
- [];
-core_files(suite) ->
- [];
core_files(Config) when is_list(Config) ->
case os:type() of
{win32, _} ->
@@ -116,7 +82,7 @@ find_cerl(false) ->
end;
find_cerl(DBTop) ->
case catch filelib:wildcard(filename:join([DBTop,
- "otp_src_R*",
+ "otp_src_*",
"bin",
"cerl"])) of
[Cerl | _ ] ->
@@ -231,6 +197,20 @@ mod_time_list(F) ->
str_strip(S) ->
string:strip(string:strip(string:strip(S), both, $\n), both, $\r).
+dump_core(#core_search_conf{ cerl = false }, _) ->
+ ok;
+dump_core(_, {ignore, _Core}) ->
+ ok;
+dump_core(#core_search_conf{ cerl = Cerl }, Core) ->
+ Dump = case test_server:is_debug() of
+ true ->
+ os:cmd(Cerl ++ " -debug -dump " ++ Core);
+ _ ->
+ os:cmd(Cerl ++ " -dump " ++ Core)
+ end,
+ ct:log("~ts~n~n~ts",[Core,Dump]).
+
+
format_core(Conf, {ignore, Core}) ->
format_core(Conf, Core, "[ignored] ");
format_core(Conf, Core) ->
@@ -254,11 +234,16 @@ core_file_search(#core_search_conf{search_dir = Base,
extra_search_dir = XBase,
cerl = Cerl,
run_by_ts = RunByTS} = Conf) ->
- case Cerl of
- false -> ok;
- _ -> catch io:format("A cerl script that probably can be used for "
- "inspection of emulator cores:~n ~s~n",
- [Cerl])
+ case {Cerl,test_server:is_debug()} of
+ {false,_} -> ok;
+ {_,true} ->
+ catch io:format("A cerl script that probably can be used for "
+ "inspection of emulator cores:~n ~s -debug~n",
+ [Cerl]);
+ _ ->
+ catch io:format("A cerl script that probably can be used for "
+ "inspection of emulator cores:~n ~s~n",
+ [Cerl])
end,
io:format("Searching for core-files in: ~s~s~n",
[case XBase of
@@ -329,10 +314,12 @@ core_file_search(#core_search_conf{search_dir = Base,
["Ignored core-files found:",
lists:reverse(ICores)]
end]),
+
+ lists:foreach(fun(C) -> dump_core(Conf,C) end, Cores),
case {RunByTS, ICores, FCores} of
{true, [], []} -> ok;
{true, _, []} -> {comment, Res};
- {true, _, _} -> ?t:fail(Res);
+ {true, _, _} -> ct:fail(Res);
_ -> Res
end
end.