File 6053-erpc-tests-for-always_spawn.patch of Package erlang

From e5eb2528a19967d7443590145ebc993fd28a6bf7 Mon Sep 17 00:00:00 2001
From: Jan Uhlig <juhlig@hnc-agency.org>
Date: Tue, 27 Aug 2024 10:33:59 +0200
Subject: [PATCH 3/3] erpc tests for always_spawn

---
 lib/kernel/test/erpc_SUITE.erl | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/lib/kernel/test/erpc_SUITE.erl b/lib/kernel/test/erpc_SUITE.erl
index ea749b54e8..d67cf33cb8 100644
--- a/lib/kernel/test/erpc_SUITE.erl
+++ b/lib/kernel/test/erpc_SUITE.erl
@@ -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,
@@ -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]).
@@ -65,6 +67,7 @@ all() ->
      call_from_old_node,
      call_reqtmo,
      call_against_ei_node,
+     call_always_spawn,
      cast,
      send_request,
      send_request_fun,
@@ -80,6 +83,7 @@ all() ->
      multicall_recv_opt,
      multicall_recv_opt2,
      multicall_recv_opt3,
+     multicall_always_spawn,
      multicast,
      timeout_limit].
 
@@ -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]),
@@ -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(),
-- 
2.43.0

openSUSE Build Service is sponsored by