aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2019-03-18 15:06:36 +0100
committerLukas Larsson <[email protected]>2019-03-25 16:34:11 +0100
commit3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d (patch)
tree91f1b360d7c8e6bd69001cf5ea22f436559e5599
parent043d9e406fc0ffae447b245b853014c7c739b31d (diff)
downloadotp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.tar.gz
otp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.tar.bz2
otp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.zip
erts: Always run fds check after each testcase
-rw-r--r--erts/emulator/test/Makefile3
-rw-r--r--erts/emulator/test/bs_construct_SUITE.erl1
-rw-r--r--erts/emulator/test/driver_SUITE.erl3
-rw-r--r--erts/emulator/test/emulator.spec1
-rw-r--r--erts/emulator/test/erts_test_utils.erl77
-rw-r--r--lib/common_test/test_server/ts_install_cth.erl6
-rw-r--r--lib/common_test/test_server/ts_run.erl1
7 files changed, 90 insertions, 2 deletions
diff --git a/erts/emulator/test/Makefile b/erts/emulator/test/Makefile
index 8c2054cb51..e69120bf13 100644
--- a/erts/emulator/test/Makefile
+++ b/erts/emulator/test/Makefile
@@ -248,12 +248,13 @@ include $(ERL_TOP)/make/otp_release_targets.mk
release_spec:
-release_tests_spec: make_emakefile
+release_tests_spec: tests
$(INSTALL_DIR) "$(RELSYSDIR)"
$(INSTALL_DATA) $(EMAKEFILE) $(TEST_SPEC_FILES) \
$(ERL_FILES) $(HRL_FILES) "$(RELSYSDIR)"
$(INSTALL_DATA) $(NO_OPT_ERL_FILES) "$(RELSYSDIR)"
$(INSTALL_DATA) $(NATIVE_ERL_FILES) "$(RELSYSDIR)"
+ $(INSTALL_DATA) *.beam "$(RELSYSDIR)"
chmod -R u+w "$(RELSYSDIR)"
tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -)
diff --git a/erts/emulator/test/bs_construct_SUITE.erl b/erts/emulator/test/bs_construct_SUITE.erl
index ad05cb3689..a20592dadd 100644
--- a/erts/emulator/test/bs_construct_SUITE.erl
+++ b/erts/emulator/test/bs_construct_SUITE.erl
@@ -45,6 +45,7 @@ all() ->
bad_append, bs_add_overflow].
init_per_suite(Config) ->
+ application:ensure_all_started(os_mon),
Config.
end_per_suite(_Config) ->
diff --git a/erts/emulator/test/driver_SUITE.erl b/erts/emulator/test/driver_SUITE.erl
index bb0f3498ab..381c284bde 100644
--- a/erts/emulator/test/driver_SUITE.erl
+++ b/erts/emulator/test/driver_SUITE.erl
@@ -88,6 +88,9 @@
-export([get_check_io_total/1]). % for z_SUITE.erl
+-compile(export_all).
+
+
-include_lib("common_test/include/ct.hrl").
diff --git a/erts/emulator/test/emulator.spec b/erts/emulator/test/emulator.spec
index 7a6dd83020..4b1fec0bab 100644
--- a/erts/emulator/test/emulator.spec
+++ b/erts/emulator/test/emulator.spec
@@ -1,2 +1,3 @@
{enable_builtin_hooks, false}.
+{ct_hooks, [erts_test_utils]}.
{suites,"../emulator_test",all}.
diff --git a/erts/emulator/test/erts_test_utils.erl b/erts/emulator/test/erts_test_utils.erl
index e4e00a0a16..83bd3dadca 100644
--- a/erts/emulator/test/erts_test_utils.erl
+++ b/erts/emulator/test/erts_test_utils.erl
@@ -31,6 +31,83 @@
available_internal_state/1,
check_node_dist/0, check_node_dist/1, check_node_dist/3]).
+%% Suite Callbacks
+-export([id/1]).
+-export([init/2]).
+
+-export([pre_init_per_testcase/3]).
+-export([post_end_per_testcase/4]).
+
+-include_lib("kernel/include/file.hrl").
+
+-type config() :: proplists:proplist().
+-type reason() :: term().
+-type skip_or_fail() :: {skip, reason()} |
+ {auto_skip, reason()} |
+ {fail, reason()}.
+
+-record(state, { ts_conf_dir, target_system, install_opts, nodenames, nodes }).
+
+%% The id of this SCB
+-spec id(Opts :: term()) ->
+ Id :: term().
+id(_Opts) ->
+ ?MODULE.
+
+%% Always called before any other callback function.
+-spec init(Id :: term(), Opts :: proplists:proplist()) ->
+ {ok, State :: #state{}}.
+init(_Id, Opts) ->
+ {ok, []}.
+
+%% Called before each test case.
+-spec pre_init_per_testcase(TC :: atom(),
+ Config :: config(),
+ State :: #state{}) ->
+ {config() | skip_or_fail(), NewState :: #state{}}.
+pre_init_per_testcase(_TC,Config,State) ->
+ Before = available_internal_state(true),
+ CIOD = erts_debug:get_internal_state(check_io_debug),
+ available_internal_state(Before),
+ CIO = driver_SUITE:get_stable_check_io_info(),
+ 0 = element(1, CIOD),
+ ct:log("~s~n~n~s",[os:cmd("ls -la /proc/"++ os:getpid() ++"/fd/*"),
+ os:cmd("cat /proc/"++ os:getpid() ++"/fdinfo/*")]),
+ {Config, {CIO, CIOD}}.
+
+-spec post_end_per_testcase(TC :: atom(),
+ Config :: config(),
+ Return :: term(),
+ State :: #state{}) ->
+ {ok | skip_or_fail(), NewState :: #state{}}.
+post_end_per_testcase(_TC,_Config,Return,St) ->
+ {links, Links} = erlang:process_info(self(), links),
+ ToKill = [Pid || Pid <- Links,
+ try
+ is_port(Pid) orelse
+ begin
+ {_, Dict} = erlang:process_info(Pid,dictionary),
+ proplists:get_value(ct_process_type,Dict) /= system
+ end
+ catch _:_ ->
+ false
+ end],
+ ct:pal("Links To Kill: ~p", [ToKill]),
+ [ catch unlink(Pid) || Pid <- ToKill],
+ [ catch exit(Pid, die) || Pid <- ToKill],
+ timer:sleep(2000),
+ Before = available_internal_state(true),
+ AfterCIOD = erts_debug:get_internal_state(check_io_debug),
+ available_internal_state(Before),
+ AfterCIO = driver_SUITE:get_stable_check_io_info(),
+ case St of
+ {CIO, CIOD} ->
+ driver_SUITE:verify_chkio_state(CIO, AfterCIO),
+ 0 = element(1, CIOD);
+ _ ->
+ ok
+ end,
+ {Return, []}.
-define(VERSION_MAGIC, 131).
diff --git a/lib/common_test/test_server/ts_install_cth.erl b/lib/common_test/test_server/ts_install_cth.erl
index b6503fb864..5e284b1cdc 100644
--- a/lib/common_test/test_server/ts_install_cth.erl
+++ b/lib/common_test/test_server/ts_install_cth.erl
@@ -108,7 +108,11 @@ pre_init_per_suite(_Suite,Config,State) ->
{add_node_name(Config, State), State}
catch error:{badmatch,{error,enoent}} ->
{add_node_name(Config, State), State};
- Error:Reason:Stack ->
+ error:{badmatch,{error,emfile}}=Reason:Stack ->
+ FDInfo = os:cmd("cat /proc/"++ os:getpid() ++"/fdinfo/*"),
+ ct:pal("~p ~s failed! ~p:{~p,~p}",[?MODULE,FDInfo,error,Reason,Stack]),
+ {{fail,{?MODULE,{error,Reason, Stack}}},State};
+ Error:Reason:Stack ->
ct:pal("~p failed! ~p:{~p,~p}",[?MODULE,Error,Reason,Stack]),
{{fail,{?MODULE,{Error,Reason, Stack}}},State}
end.
diff --git a/lib/common_test/test_server/ts_run.erl b/lib/common_test/test_server/ts_run.erl
index 7e12b9652c..84ca87a626 100644
--- a/lib/common_test/test_server/ts_run.erl
+++ b/lib/common_test/test_server/ts_run.erl
@@ -247,6 +247,7 @@ make_command(Vars, Spec, State) ->
%% " -test_server_format_exception false",
" -boot start_sasl -sasl errlog_type error",
" -pz \"",Cwd,"\"",
+ " -pz \"",TestDir,"\"",
" -ct_test_vars ",TestVars,
" -eval \"ts_run:ct_run_test(\\\"",TestDir,"\\\", ",
backslashify(lists:flatten(State#state.test_server_args)),")\""