]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-qr-code: allow specifying the text to encode
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 25 Feb 2026 08:35:37 +0000 (09:35 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 26 Feb 2026 08:20:59 +0000 (09:20 +0100)
src/test/test-qrcode-util.c

index dc2573b4f8433abe1f612e1c27370abc7ba93bda..47887dbbb462f58e263499590bac0df610f7ab5e 100644 (file)
@@ -7,13 +7,17 @@
 #include "tests.h"
 
 static int run(int argc, char **argv) {
+        const char *arg = argv[1] ?: "TEST";
+        _cleanup_free_ char *header = NULL;
         int r;
 
         test_setup_logging(LOG_DEBUG);
 
-        assert_se(setenv("SYSTEMD_COLORS", "24bit", 1) == 0); /* Force the qrcode to be printed */
+        ASSERT_OK_ERRNO(setenv("SYSTEMD_COLORS", "24bit", 1)); /* Force the qrcode to be printed */
 
-        r = print_qrcode(stdout, "This should say \"TEST\"", "TEST");
+        ASSERT_OK_POSITIVE(asprintf(&header, "This should say \"%s\"", arg));
+
+        r = print_qrcode(stdout, header, arg);
         if (r == -EOPNOTSUPP)
                 return log_tests_skipped("not supported");
         if (r < 0)