File 4096-snmp-test-Tweaked-simple-start-and-stop-test-case.patch of Package erlang
From b8f93c635b410ac3711c43d330a1590558ee58be Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Tue, 6 Aug 2024 18:58:21 +0200
Subject: [PATCH 6/6] [snmp|test] Tweaked simple start and stop test case
Try to ensure manager config process is not already running.
---
lib/snmp/test/snmp_manager_config_SUITE.erl | 30 ++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/lib/snmp/test/snmp_manager_config_SUITE.erl b/lib/snmp/test/snmp_manager_config_SUITE.erl
index 074941ab12..c800da28b9 100644
--- a/lib/snmp/test/snmp_manager_config_SUITE.erl
+++ b/lib/snmp/test/snmp_manager_config_SUITE.erl
@@ -331,20 +331,44 @@ simple_start_and_stop(doc) ->
"Start the snmp manager config process with the \n"
"minimum setof options (config dir).";
simple_start_and_stop(Conf) when is_list(Conf) ->
- put(tname, "SIME-START_AND_STOP"),
- ?IPRINT("start"),
+ put(tname, "SIMPLE_START_AND_STOP"),
process_flag(trap_exit, true),
+ Pre = fun() ->
+ %% Since this is the first test case in this
+ %% suite, we (possibly) need to do some cleanup...
+ ?IPRINT("~w:pre -> ensure config not already running",
+ [?FUNCTION_NAME]),
+ config_ensure_not_running()
+ end,
+ TC = fun(_) ->
+ ?IPRINT("~w:tc -> begin", [?FUNCTION_NAME]),
+ do_simple_start_and_stop(Conf)
+ end,
+ Post = fun(_) ->
+ ?IPRINT("~w:post -> ensure config not still running",
+ [?FUNCTION_NAME]),
+ config_ensure_not_running()
+ end,
+ ?TC_TRY(?FUNCTION_NAME, Pre, TC, Post).
+
+do_simple_start_and_stop(Conf) when is_list(Conf) ->
ConfDir = ?config(manager_conf_dir, Conf),
- DbDir = ?config(manager_db_dir, Conf),
+ DbDir = ?config(manager_db_dir, Conf),
+ ?IPRINT("~w -> try write \"standard\" manager config to"
+ "~n ~p", [?FUNCTION_NAME, ConfDir]),
write_manager_conf(ConfDir),
Opts = [{versions, [v1]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
+ ?IPRINT("~w -> try start with basic opts", [?FUNCTION_NAME]),
{ok, _Pid} = snmpm_config:start_link(Opts),
+
+ ?IPRINT("~w -> try stop", [?FUNCTION_NAME]),
ok = snmpm_config:stop(),
+ ?IPRINT("~w -> done", [?FUNCTION_NAME]),
ok.
--
2.43.0