tests/lib/conds: make `condMain()` take a span for args
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 21 Mar 2024 19:13:26 +0000 (15:13 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
Make `argv` a span, instead of having `argc` + `argv`.  There is no
point in this change except that it seemed possible and I wanted to do
it.

Change-Id: I1e7e76638e9e6365df05bb5c7b175d44b6badf6f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12118
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/lib/conds/conds-triggers.cpp
tests/lib/conds/utils.cpp
tests/lib/conds/utils.hpp

index 26603cdcbd1d7b096320235e21f9852ef718e7ac..857cfbcc59284764ef82018c13f0714ae14a1a4b 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "cpp-common/bt2/graph.hpp"
 #include "cpp-common/bt2c/c-string-view.hpp"
+#include "cpp-common/bt2c/span.hpp"
 #include "cpp-common/bt2s/make-unique.hpp"
 
 #include "utils.hpp"
@@ -106,5 +107,5 @@ int main(const int argc, const char ** const argv)
         },
         CondTrigger::Type::PRE, "field-class-integer-set-field-value-range:not-null:field-class"));
 
-    condMain(argc, argv, triggers);
+    condMain(bt2c::makeSpan(argv, argc), triggers);
 }
index f1d9969e1ed24f2f8806349aa07b47c826866d94..b7d2c487e03504eac70ed44f47f8ebb826154b55 100644 (file)
@@ -50,9 +50,9 @@ void listCondTriggers(const CondTriggers& condTriggers) noexcept
 
 } /* namespace */
 
-void condMain(const int argc, const char ** const argv, const CondTriggers& condTriggers) noexcept
+void condMain(const bt2s::span<const char * const> argv, const CondTriggers& condTriggers) noexcept
 {
-    BT_ASSERT(argc >= 2);
+    BT_ASSERT(argv.size() >= 2);
 
     if (strcmp(argv[1], "list") == 0) {
         listCondTriggers(condTriggers);
@@ -65,7 +65,7 @@ void condMain(const int argc, const char ** const argv, const CondTriggers& cond
         g_unsetenv("BABELTRACE_EXEC_ON_ABORT");
 
         /* Call the trigger */
-        BT_ASSERT(argc >= 3);
+        BT_ASSERT(argv.size() >= 3);
 
         const auto index = atoi(argv[2]);
 
index aa44bba4059f97210e4ee16ba6056ea1b6f66e3c..d8abfafe11ac2ad2c2861146bbd80423c86dd58b 100644 (file)
@@ -16,6 +16,7 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "cpp-common/bt2c/c-string-view.hpp"
+#include "cpp-common/bt2s/span.hpp"
 
 #include "../utils/run-in.hpp"
 
@@ -177,6 +178,6 @@ using CondTriggers = std::vector<CondTrigger::UP>;
  *     The program is expected to abort through a libbabeltrace2
  *     condition failure.
  */
-void condMain(int argc, const char **argv, const CondTriggers& triggers) noexcept;
+void condMain(const bt2s::span<const char * const> argv, const CondTriggers& triggers) noexcept;
 
 #endif /* TESTS_LIB_CONDS_UTILS_HPP */
This page took 0.025636 seconds and 4 git commands to generate.