From fb472529347b066d5b60f9e4f1d2554ecb733aca Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 21 Mar 2024 15:13:26 -0400 Subject: [PATCH] tests/lib/conds: make `condMain()` take a span for args 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/12118 Reviewed-by: Philippe Proulx Tested-by: jenkins --- tests/lib/conds/conds-triggers.cpp | 3 ++- tests/lib/conds/utils.cpp | 6 +++--- tests/lib/conds/utils.hpp | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/lib/conds/conds-triggers.cpp b/tests/lib/conds/conds-triggers.cpp index 26603cdc..857cfbcc 100644 --- a/tests/lib/conds/conds-triggers.cpp +++ b/tests/lib/conds/conds-triggers.cpp @@ -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); } diff --git a/tests/lib/conds/utils.cpp b/tests/lib/conds/utils.cpp index f1d9969e..b7d2c487 100644 --- a/tests/lib/conds/utils.cpp +++ b/tests/lib/conds/utils.cpp @@ -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 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]); diff --git a/tests/lib/conds/utils.hpp b/tests/lib/conds/utils.hpp index aa44bba4..d8abfafe 100644 --- a/tests/lib/conds/utils.hpp +++ b/tests/lib/conds/utils.hpp @@ -16,6 +16,7 @@ #include #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; * 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 argv, const CondTriggers& triggers) noexcept; #endif /* TESTS_LIB_CONDS_UTILS_HPP */ -- 2.34.1