]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-verbs: dispatch via _dispatch_verb_with_args() directly
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Fri, 15 May 2026 19:29:37 +0000 (21:29 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Sat, 16 May 2026 16:36:08 +0000 (18:36 +0200)
Drops the global-optind dependency from the test helper. Verb fixtures
stay inline as static const Verb[] — the section-based VERB() macro
would force unique verb names across the three test cases, which they
deliberately share to exercise overlap.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
src/test/test-verbs.c

index 41ae5a87f3766fc431549633fc8365d6807fa149..cfff6ec728490c99f5615cb04077e986c7b7ba47 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <getopt.h>
-
 #include "strv.h"
 #include "tests.h"
 #include "verbs.h"
@@ -11,8 +9,7 @@ static int noop_dispatcher(int argc, char *argv[], uintptr_t _data, void *userda
 }
 
 #define test_dispatch_one(argv, verbs, expected) \
-        optind = 0; \
-        assert_se(dispatch_verb(strv_length(argv), argv, verbs, NULL) == expected);
+        assert_se(_dispatch_verb_with_args(argv, verbs, verbs + ELEMENTSOF(verbs) - 1, NULL) == expected);
 
 TEST(verbs) {
         static const Verb verbs[] = {