diff options
author | Rickard Green <rickard@erlang.org> | 2020-02-11 18:06:10 +0100 |
---|---|---|
committer | Rickard Green <rickard@erlang.org> | 2020-02-11 18:06:10 +0100 |
commit | a9d73ffe26c41b498fa4e01525aad0e0290ea6b2 (patch) | |
tree | 4fe834820c175ec7ff8412111d594b1aab413644 /erts | |
parent | adde3ae6c8681f211c2768b495f56ed06491e9a0 (diff) | |
parent | 83564c66a4b3aa464b49b5aeab86cca19dc303ab (diff) | |
download | erlang-a9d73ffe26c41b498fa4e01525aad0e0290ea6b2.tar.gz |
Merge branch 'maint'
* maint:
Test case verifying exit signal kill to killed mapping
Fix typo in ct_slave documentation
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/test/signal_SUITE.erl | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/erts/emulator/test/signal_SUITE.erl b/erts/emulator/test/signal_SUITE.erl index 4e6baa9e0e..016e035991 100644 --- a/erts/emulator/test/signal_SUITE.erl +++ b/erts/emulator/test/signal_SUITE.erl @@ -34,7 +34,8 @@ -export([init_per_testcase/2, end_per_testcase/2]). % Test cases --export([xm_sig_order/1]). +-export([xm_sig_order/1, + kill2killed/1]). init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> [{testcase, Func}|Config]. @@ -89,6 +90,68 @@ xm_sig_order_proc() -> end, xm_sig_order_proc(). +kill2killed(Config) when is_list(Config) -> + process_flag(trap_exit, true), + kill2killed_test(node()), + {ok, Node} = start_node(Config), + kill2killed_test(Node), + stop_node(Node), + ok. + +kill2killed_test(Node) -> + if Node == node() -> + io:format("Testing against local node", []); + true -> + io:format("Testing against remote node ~p", [Node]) + end, + check_exit(Node, other_exit2, 1), + check_exit(Node, other_exit2, 2), + check_exit(Node, other_exit2, 9), + check_exit(Node, other_exit2, 10), + check_exit(Node, exit2, 1), + check_exit(Node, exit2, 2), + check_exit(Node, exit2, 9), + check_exit(Node, exit2, 10), + check_exit(Node, exit1, 1), + check_exit(Node, exit1, 2), + check_exit(Node, exit1, 9), + check_exit(Node, exit1, 10), + ok. + +check_exit(Node, Type, N) -> + io:format("Testing ~p length ~p~n", [Type, N]), + P = spawn_link_line(Node, node(), Type, N, self()), + if Type == other_exit2 -> + receive + {end_of_line, EOL} -> + exit(EOL, kill) + end; + true -> ok + end, + receive + {'EXIT', P, Reason} -> + if Type == exit1 -> + kill = Reason; + true -> + killed = Reason + end + end. + +spawn_link_line(_NodeA, _NodeB, other_exit2, 0, Tester) -> + Tester ! {end_of_line, self()}, + receive after infinity -> ok end; +spawn_link_line(_NodeA, _NodeB, exit1, 0, _Tester) -> + exit(kill); +spawn_link_line(_NodeA, _NodeB, exit2, 0, _Tester) -> + exit(self(), kill); +spawn_link_line(NodeA, NodeB, Type, N, Tester) -> + spawn_link(NodeA, + fun () -> + spawn_link_line(NodeB, NodeA, Type, N-1, Tester), + receive after infinity -> ok end + end). + + %% %% -- Internal utils -------------------------------------------------------- %% |