aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/erts_test_utils.erl
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 /erts/emulator/test/erts_test_utils.erl
parent043d9e406fc0ffae447b245b853014c7c739b31d (diff)
downloadotp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.tar.gz
otp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.tar.bz2
otp-3379747ece9a9d87ddb29dff5bf2a9b6e9b1cd9d.zip
erts: Always run fds check after each testcase
Diffstat (limited to 'erts/emulator/test/erts_test_utils.erl')
-rw-r--r--erts/emulator/test/erts_test_utils.erl77
1 files changed, 77 insertions, 0 deletions
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).