File 6294-snmp-test-Tweak-timeout-calculation.patch of Package erlang

From b5ef46fa4bbbfbbe2304b93626d66c5cd0e071f4 Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Wed, 10 Jul 2024 17:46:28 +0200
Subject: [PATCH 4/6] [snmp|test] Tweak timeout calculation

---
 lib/snmp/test/snmp_manager_SUITE.erl | 15 +++++++++------
 lib/snmp/test/snmp_test_lib.erl      | 15 +++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/snmp/test/snmp_manager_SUITE.erl b/lib/snmp/test/snmp_manager_SUITE.erl
index 8420ef9955..fba9b527d7 100644
--- a/lib/snmp/test/snmp_manager_SUITE.erl
+++ b/lib/snmp/test/snmp_manager_SUITE.erl
@@ -1335,6 +1335,8 @@ do_notify_started02(Config) ->
     ?IPRINT("starting with Config: "
             "~n      ~p", [Config]),
 
+    Factor  = ?config(snmp_factor,        Config),
+
     SCO     = ?config(socket_create_opts, Config),
     ConfDir = ?config(manager_conf_dir,   Config),
     DbDir   = ?config(manager_db_dir,     Config),
@@ -1359,7 +1361,7 @@ do_notify_started02(Config) ->
     ApproxStartTime =
         case ns02_client_await_approx_runtime(Pid1) of
             {ok, T} ->
-                T;
+                ?LIB:ftime(T, Factor);
             {error, Reason} ->
                 %% Attempt cleanup just in case
                 exit(Pid1, kill),
@@ -1385,13 +1387,14 @@ do_notify_started02(Config) ->
 	    ?FAIL({client, Reason1});
 	{'EXIT', Pid1, Reason1} ->
 	    ?FAIL({client, Reason1})
-    after ApproxStartTime + 10000 ->
+    after ApproxStartTime + 15000 ->
             exit(Pid1, kill),
             exit(Pid2, kill),
 	    ?FAIL(timeout)
     end,
-	
-    ?IPRINT("await snmpm starter process exit"),
+
+    Timeout2 = ?LIB:ftime(5000, Factor),
+    ?IPRINT("await (~w msec) snmpm starter process exit", [Timeout2]),
     receive 
 	{'EXIT', Pid2, normal} ->
 	    ok;
@@ -1400,7 +1403,7 @@ do_notify_started02(Config) ->
 	    ?SKIP(SkipReason2);
 	{'EXIT', Pid2, Reason2} ->
 	    ?FAIL({ctrl, Reason2})
-    after 5000 ->
+    after Timeout2 ->
             exit(Pid2, kill),
 	    ?FAIL(timeout)
     end,
@@ -1515,7 +1518,7 @@ ns02_ctrl_loop(Opts, N) ->
     end,
     ?SLEEP(2000),
     ?IPRINT("stop manager"),
-    ?SLEEP(100), % Give the verbosity to take effect...
+    ?SLEEP(100), % Give the verbosity time to take effect...
     TS3 = erlang:system_time(millisecond),
     case snmpm:stop(5000) of
         ok ->
diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl
index acaa383c7a..5c3176b45d 100644
--- a/lib/snmp/test/snmp_test_lib.erl
+++ b/lib/snmp/test/snmp_test_lib.erl
@@ -52,6 +52,7 @@
 -export([eprint/2, wprint/2, nprint/2, iprint/2]).
 -export([explicit_inet_backend/0, test_inet_backends/0]).
 -export([which_host_ip/2]).
+-export([ftime/2]).
 
 %% Convenient exports...
 -export([analyze_and_print_host_info/0]).
@@ -3272,6 +3273,20 @@ timetrap_scale_factor() ->
 	    N
     end.
 
+ftime(BaseTime, Factor)
+  when is_integer(BaseTime) andalso (BaseTime > 0) andalso
+       is_integer(Factor) andalso (0 < Factor) andalso (Factor < 3) ->
+    BaseTime;
+ftime(BaseTime, Factor)
+  when is_integer(BaseTime) andalso (BaseTime > 0) andalso
+       is_integer(Factor) andalso (3 =< Factor) andalso (Factor =< 10) ->
+    BaseTime + (Factor-2) * (BaseTime div 4);
+ftime(BaseTime, Factor)
+  when is_integer(BaseTime) andalso (BaseTime > 0) andalso
+       is_integer(Factor) andalso (10 < Factor) ->
+    3*BaseTime + (Factor-10) * (BaseTime div 10).
+    
+    
     
 %% ----------------------------------------------------------------------
 %% file & dir functions
-- 
2.43.0

openSUSE Build Service is sponsored by