File 0168-megaco-test-Make-bench-work.patch of Package erlang

From 7d48d17a97bbd29074fb20dd93ec1653ccc79b4a Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Thu, 11 Dec 2025 12:55:14 +0100
Subject: [PATCH 1/2] [megaco|test] Make bench work

Needed to tweak the bench handling to make it work (hopefully).
---
 lib/megaco/test/megaco_examples_SUITE.erl | 16 +++++++---------
 lib/megaco/test/megaco_test_lib.hrl       | 12 ++++++++++++
 lib/megaco/test/modules.mk                |  7 +++++--
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/lib/megaco/test/megaco_examples_SUITE.erl b/lib/megaco/test/megaco_examples_SUITE.erl
index b7fcaa287b..d6c740fc64 100644
--- a/lib/megaco/test/megaco_examples_SUITE.erl
+++ b/lib/megaco/test/megaco_examples_SUITE.erl
@@ -50,12 +50,14 @@
 
 -define(TEST_VERBOSITY, debug).
 
+-define(BENCH_SUITE, megaco_examples).
+
 
 %%======================================================================
 %% Common Test interface functions
 %%
-%% The difference between the bench cases and the meas cases is simply
-%% how the results are reported.
+%% The difference between the bench cases and the (standard) meas cases
+%% is simply how the results are reported.
 %%======================================================================
 
 suite() -> 
@@ -734,9 +736,7 @@ do_meas(Node,
 publish_bench_results(Pre, Results) when is_list(Results) ->
     publish_bench_results_multiple(Pre, Results);
 publish_bench_results(Pre, Result) when is_integer(Result) ->
-    Event = #event{name = Pre,
-                   data = [{suite, atom_to_list(?MODULE)},
-                           {value, Result}]},
+    Event = ?BENCH_EVENT(Pre, Result),
     ct_event:notify(Event),
     {comment, ?F("~w: ~p", [Pre, Result])}.
 
@@ -753,10 +753,8 @@ publish_bench_results_multiple(Pre, [], Acc) ->
         end,
     {comment, ?F("~w: ~w ~s", [Pre, Time, UnitStr])};
 publish_bench_results_multiple(Pre, [{Name, {_, Enc, Dec}} | Results], Acc) ->
-    Time = Enc + Dec,
-    Event = #event{name = list_to_atom(?F("~w_~w", [Pre, Name])),
-                   data = [{suite, atom_to_list(?MODULE)},
-                           {value, Time}]},
+    Time  = Enc + Dec,
+    Event = ?BENCH_EVENT(list_to_atom(?F("~w_~w", [Pre, Name])), Time),
     ct_event:notify(Event),
     publish_bench_results_multiple(Pre, Results, Acc + Time).
     
diff --git a/lib/megaco/test/megaco_test_lib.hrl b/lib/megaco/test/megaco_test_lib.hrl
index 2f9a3cc186..1213032e65 100644
--- a/lib/megaco/test/megaco_test_lib.hrl
+++ b/lib/megaco/test/megaco_test_lib.hrl
@@ -20,6 +20,9 @@
 %% %CopyrightEnd%
 %%
 
+-ifndef(megaco_test_lib_hrl).
+-define(megaco_test_lib_hrl, true).
+
 %%
 %%----------------------------------------------------------------------
 %% Purpose: Define common macros for testing
@@ -151,3 +154,12 @@
 
 -define(MEGACO_TRACE(C, D),    ?LIB:megaco_trace((C), (D))).
 -define(ENABLE_TRACE(C, L, D), ?LIB:enable_trace((C), (L), (D))).
+
+%% 'BENCH_SUITE' needs to be defined by the module using this macro
+-define(BENCH_EVENT(__N__, __V__),
+        #event{name = benchmark_data,
+               data = [{suite, ?BENCH_SUITE},
+                       {value, (__V__)},
+                       {name,  (__N__)}]}).
+
+-endif. % -ifdef(socket_test_lib_hrl).
diff --git a/lib/megaco/test/modules.mk b/lib/megaco/test/modules.mk
index c08bde84d3..41f84d8f7b 100644
--- a/lib/megaco/test/modules.mk
+++ b/lib/megaco/test/modules.mk
@@ -20,9 +20,12 @@
 #
 # %CopyrightEnd%
 
-TEST_SPEC_FILE = megaco.spec
+TEST_SPEC_FILE = \
+	megaco.spec \
+	megaco_bench.spec
 
-COVER_SPEC_FILE = megaco.cover
+COVER_SPEC_FILE = \
+	megaco.cover
 
 BEHAVIOUR_MODULES = \
 	megaco_test_generator
-- 
2.51.0

openSUSE Build Service is sponsored by