Skip to content

Commit

Permalink
erpc tests for always_spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
juhlig committed Aug 27, 2024
1 parent 717e149 commit e5eb252
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion lib/kernel/test/erpc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
init_per_group/2,end_per_group/2]).
-export([call/1, call_against_old_node/1,
call_from_old_node/1,
call_reqtmo/1, call_against_ei_node/1, cast/1,
call_reqtmo/1, call_against_ei_node/1,
call_always_spawn/1, cast/1,
send_request/1, send_request_fun/1,
send_request_receive_reqtmo/1,
send_request_wait_reqtmo/1,
Expand All @@ -36,6 +37,7 @@
multicall_recv_opt/1,
multicall_recv_opt2/1,
multicall_recv_opt3/1,
multicall_always_spawn/1,
multicast/1,
timeout_limit/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
Expand Down Expand Up @@ -65,6 +67,7 @@ all() ->
call_from_old_node,
call_reqtmo,
call_against_ei_node,
call_always_spawn,
cast,
send_request,
send_request_fun,
Expand All @@ -80,6 +83,7 @@ all() ->
multicall_recv_opt,
multicall_recv_opt2,
multicall_recv_opt3,
multicall_always_spawn,
multicast,
timeout_limit].

Expand Down Expand Up @@ -467,6 +471,19 @@ reqtmo_test(Test) ->
"Timeout = " ++ integer_to_list(Timeout)
++ " Actual = " ++ integer_to_list(Time)}.

call_always_spawn(Config) when is_list(Config) ->
case self() =:= erpc:call(node(), erlang, self, [],
#{timeout => infinity,
always_spawn => false}) of
true ->
false = self() =:= erpc:call(node(), erlang, self, [],
#{timeout => infinity,
always_spawn => true}),
ok;
false ->
{skip, local_call_spawned}
end.

cast(Config) when is_list(Config) ->
%% silently fail
ok = erpc:cast(badnodename, erlang, send, [hej]),
Expand Down Expand Up @@ -1732,6 +1749,21 @@ do_time_multicall(Expect, Nodes, Fun, Tmo, N) ->
Expect = erpc:multicall(Nodes, Fun, Tmo),
do_time_multicall(Expect, Nodes, Fun, Tmo, N-1).

multicall_always_spawn(Config) when is_list(Config) ->
Replies1 = erpc:multicall([node(), node()], erlang, self, [],
#{timeout => infinity,
always_spawn => false}),
case lists:any(fun({ok, Pid}) -> self() =:= Pid end, Replies1) of
true ->
Replies2 = erpc:multicall([node(), node()], erlang, self, [],
#{timeout => infinity,
always_spawn => true}),
false = lists:any(fun({ok, Pid}) -> self() =:= Pid end, Replies2),
ok;
false ->
{skip, all_local_calls_spawned}
end.

multicast(Config) when is_list(Config) ->
{ok, _Peer, Node} = ?CT_PEER(),
{OldRelName, OldRel} = old_release(),
Expand Down

0 comments on commit e5eb252

Please sign in to comment.