Debian Codegraph @

src/test/test-qrcode-util.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <stdlib.h>
4
5 #include "main-func.h"
6 #include "qrcode-util.h"
7 #include "tests.h"
8
9 static int run(int argc, char **argv) {
10 const char *arg = argv[1] ?: "TEST";
11 _cleanup_free_ char *header = NULL;
12 int r;
13
14 test_setup_logging(LOG_DEBUG);
15
16 ASSERT_OK_ERRNO(setenv("SYSTEMD_COLORS", "24bit", 1)); /* Force the qrcode to be printed */
17
18 ASSERT_OK_POSITIVE(asprintf(&header, "This should say \"%s\"", arg));
19
20 r = print_qrcode(stdout, header, arg);
21 if (r == -EOPNOTSUPP)
22 return log_tests_skipped("not supported");
23 if (r < 0)
24 return log_error_errno(r, "Failed to print QR code: %m");
25 return 0;
26 }
27
28 DEFINE_MAIN_FUNCTION(run);