You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.7 KiB
62 lines
2.7 KiB
2 months ago
|
From 36b71213e9f734fbf5ab3b032f61614c79737dac Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||
|
Date: Thu, 19 Oct 2023 16:46:56 +0200
|
||
|
Subject: [PATCH] test-recurse-dir: work around nftw() ignoring symlinks()
|
||
|
|
||
|
We have a test where we compare the results from nftw() and our own
|
||
|
resurce_dit_at(). nftw() skips a dangling symlink when running under mkosi and
|
||
|
the test fails. I don't understand why nftw() does that, but in our code we
|
||
|
don't need to test and care about the details of nftw(), which we don't use,
|
||
|
outside of the one test, so let's just skip symlinks in the test.
|
||
|
|
||
|
Closes #29603.
|
||
|
|
||
|
(cherry picked from commit 974959e6f6352b76355b76ab550c0e729b2a8c21)
|
||
|
|
||
|
Related: RHEL-27512
|
||
|
---
|
||
|
src/test/test-recurse-dir.c | 15 ++++++++-------
|
||
|
1 file changed, 8 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/src/test/test-recurse-dir.c b/src/test/test-recurse-dir.c
|
||
|
index 2c2120b136..c194896a1b 100644
|
||
|
--- a/src/test/test-recurse-dir.c
|
||
|
+++ b/src/test/test-recurse-dir.c
|
||
|
@@ -26,8 +26,7 @@ static int nftw_cb(
|
||
|
break;
|
||
|
|
||
|
case FTW_SL:
|
||
|
- log_debug("ftw found symlink %s", fpath);
|
||
|
- assert_se(strv_extendf(&list_nftw, "%s→", fpath) >= 0);
|
||
|
+ log_debug("ftw found symlink %s, ignoring.", fpath);
|
||
|
break;
|
||
|
|
||
|
case FTW_D:
|
||
|
@@ -71,11 +70,10 @@ static int recurse_dir_callback(
|
||
|
case RECURSE_DIR_ENTRY:
|
||
|
assert_se(!IN_SET(de->d_type, DT_UNKNOWN, DT_DIR));
|
||
|
|
||
|
- log_debug("found %s", path);
|
||
|
+ log_debug("found %s%s", path,
|
||
|
+ de->d_type == DT_LNK ? ", ignoring." : "");
|
||
|
|
||
|
- if (de->d_type == DT_LNK)
|
||
|
- assert_se(strv_extendf(l, "%s→", path) >= 0);
|
||
|
- else
|
||
|
+ if (de->d_type != DT_LNK)
|
||
|
assert_se(strv_extend(l, path) >= 0);
|
||
|
break;
|
||
|
|
||
|
@@ -131,7 +129,10 @@ int main(int argc, char *argv[]) {
|
||
|
else
|
||
|
p = "/usr/share/man"; /* something hopefully reasonably stable while we run (and limited in size) */
|
||
|
|
||
|
- /* Enumerate the specified dirs in full, once via nftw(), and once via recurse_dir(), and ensure the results are identical */
|
||
|
+ /* Enumerate the specified dirs in full, once via nftw(), and once via recurse_dir(), and ensure the
|
||
|
+ * results are identical. nftw() sometimes skips symlinks (see
|
||
|
+ * https://github.com/systemd/systemd/issues/29603), so ignore them to avoid bogus errors. */
|
||
|
+
|
||
|
t1 = now(CLOCK_MONOTONIC);
|
||
|
r = recurse_dir_at(AT_FDCWD, p, 0, UINT_MAX, RECURSE_DIR_SORT|RECURSE_DIR_ENSURE_TYPE|RECURSE_DIR_SAME_MOUNT, recurse_dir_callback, &list_recurse_dir);
|
||
|
t2 = now(CLOCK_MONOTONIC);
|