]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-specifier: replace /dev/initctl with /dev/fd
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Apr 2025 00:24:39 +0000 (09:24 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 14 May 2025 20:33:39 +0000 (21:33 +0100)
To make the test work even when systemd is built without SysV compat.

(cherry picked from commit b4d51152648fe9c1cd89b04ab84806756f453084)

src/test/test-specifier.c

index 7d25969bb07a7cda663f1e0062feb80d4c70ed76..f2f2f057c15c5774610dd9c961dca3b90347fdf8 100644 (file)
@@ -89,25 +89,27 @@ TEST(specifier_printf) {
 
 TEST(specifier_real_path) {
         static const Specifier table[] = {
-                { 'p', specifier_string,         "/dev/initctl" },
-                { 'y', specifier_real_path,      "/dev/initctl" },
-                { 'Y', specifier_real_directory, "/dev/initctl" },
+                { 'p', specifier_string,         "/dev/fd" },
+                { 'y', specifier_real_path,      "/dev/fd" },
+                { 'Y', specifier_real_directory, "/dev/fd" },
                 { 'w', specifier_real_path,      "/dev/tty" },
                 { 'W', specifier_real_directory, "/dev/tty" },
                 {}
         };
 
-        _cleanup_free_ char *w = NULL;
+        _cleanup_free_ char *w = NULL, *expected = NULL;
         int r;
 
         r = specifier_printf("p=%p y=%y Y=%Y w=%w W=%W", SIZE_MAX, table, NULL, NULL, &w);
-        assert_se(r >= 0 || r == -ENOENT);
-        assert_se(w || r == -ENOENT);
-        puts(strnull(w));
+        if (r < 0) {
+                ASSERT_ERROR(r, ENOENT);
+                return (void) log_tests_skipped_errno(r, "/dev/fd and/or /dev/tty do not exist");
+        }
 
-        /* /dev/initctl should normally be a symlink to /run/initctl */
-        if (inode_same("/dev/initctl", "/run/initctl", 0) > 0)
-                ASSERT_STREQ(w, "p=/dev/initctl y=/run/initctl Y=/run w=/dev/tty W=/dev");
+        ASSERT_OK(asprintf(&expected,
+                           "p=/dev/fd y=/proc/"PID_FMT"/fd Y=/proc/"PID_FMT" w=/dev/tty W=/dev",
+                           getpid_cached(), getpid_cached()));
+        ASSERT_STREQ(w, expected);
 }
 
 TEST(specifier_real_path_missing_file) {