From: gvenugo3 Date: Sat, 10 Jan 2026 19:46:18 +0000 (+0000) Subject: test: add test case for masked files in cat_files() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f187dc7c1d4808b3878a1231016b7d4e7cc660f;p=thirdparty%2Fsystemd.git test: add test case for masked files in cat_files() Add a test case to verify that cat_files() correctly handles symlinks to /dev/null (masked configuration files) and returns success (0) instead of failing. This test complements the fix for issue #40313. Co-authored-by: Yu Watanabe (cherry picked from commit 01efa01dd28b9c47c1f5fe84c684d9d13192ec96) --- diff --git a/src/test/test-pretty-print.c b/src/test/test-pretty-print.c index 71d8799cbfd..073930df09d 100644 --- a/src/test/test-pretty-print.c +++ b/src/test/test-pretty-print.c @@ -4,8 +4,11 @@ #include #include "alloc-util.h" +#include "path-util.h" #include "pretty-print.h" +#include "rm-rf.h" #include "tests.h" +#include "tmpfile-util.h" #define CYLON_WIDTH 6 @@ -53,6 +56,13 @@ TEST(cat_files) { if (access("/etc/fstab", R_OK) >= 0) assert_se(cat_files("/etc/fstab", STRV_MAKE("/etc/fstab", "/etc/fstab"), 0) == 0); + + /* Test masked file (symlink to /dev/null) - should succeed with exit code 0 */ + _cleanup_(rm_rf_physical_and_freep) char *tmp = NULL; + ASSERT_OK(mkdtemp_malloc("/tmp/test-cat-files-XXXXXX", &tmp)); + _cleanup_free_ char *masked_file = ASSERT_NOT_NULL(path_join(tmp, "masked.conf")); + ASSERT_OK_ERRNO(symlink("/dev/null", masked_file)); + ASSERT_OK(cat_files(masked_file, /* dropins= */ NULL, /* flags= */ 0)); } TEST(red_green_cross_check_mark) {