From: Luca Boccassi Date: Fri, 26 Apr 2024 12:30:31 +0000 (+0100) Subject: test: do not fail if mknod() fails in a build system X-Git-Tag: v256-rc2~189^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d967aacce70a8704c5ec91b7ec637a51b7d8309;p=thirdparty%2Fsystemd.git test: do not fail if mknod() fails in a build system mknod fails in a Salsa container when building Debian packages, skip the check Follow-up for 6a57d86bf9d7f8d6f5d339f57665dfb2e1d191c5 --- diff --git a/src/test/test-dirent-util.c b/src/test/test-dirent-util.c index 8192a53e6fe..5d4886241da 100644 --- a/src/test/test-dirent-util.c +++ b/src/test/test-dirent-util.c @@ -136,7 +136,11 @@ TEST (test_dirent_is_file_with_suffix) { assert_se(touch(name) >= 0); assert_se(touch(dotfile) >= 0); assert_se(touch(dotdot) >= 0); - assert_se(mknod(chr, 0775 | S_IFCHR, makedev(0, 0)) >= 0); + /* This can fail in containers/build systems */ + if (mknod(chr, 0775 | S_IFCHR, makedev(0, 0)) < 0) { + assert(ERRNO_IS_PRIVILEGE(errno)); + chr = NULL; + } if (symlink(name, name_alias) < 0) { assert_se(IN_SET(errno, EINVAL, ENOSYS, ENOTTY, EPERM)); @@ -169,13 +173,16 @@ TEST (test_dirent_is_file_with_suffix) { if (strcmp(de_dotdot->d_name, "..dotdot") == 0) break; - rewinddir(dir); - while ((de_chr = readdir(dir)) != NULL) - if (strcmp(de_chr->d_name, "test_chr") == 0) - break; + if (chr) { + rewinddir(dir); + while ((de_chr = readdir(dir)) != NULL) + if (strcmp(de_chr->d_name, "test_chr") == 0) + break; - /* Test when d_type is not DT_REG, DT_LNK, or DT_UNKNOWN */ - assert_se(!dirent_is_file_with_suffix(de_chr, NULL)); + /* Test when d_type is not DT_REG, DT_LNK, or DT_UNKNOWN */ + assert(de_chr); + assert_se(!dirent_is_file_with_suffix(de_chr, NULL)); + } /* Test when suffix is NULL */ assert_se(dirent_is_file_with_suffix(de_reg, NULL) == true);