]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: cp: fix always skipped nfs-removal-race.sh
authorPádraig Brady <P@draigBrady.com>
Tue, 6 Jan 2026 20:29:45 +0000 (20:29 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 6 Jan 2026 20:35:44 +0000 (20:35 +0000)
* tests/cp/nfs-removal-race.sh: This test was invalid since v8.32
as we now use fstatat() rather than stat().  Also since commit
v9.0-66-ge2daa8f79 we leverage the errno from open(O_DIRECTORY)
to avoid a stat, so pass --no-target-directory to ensure fstatat()
is called.
Discussed in https://github.com/coreutils/coreutils/pull/161

tests/cp/nfs-removal-race.sh

index da787e6bb97c4fe25715685d9d4743d2f285f48a..1bf59fe768830fa6e9a23f09a0e66e46a351397c 100755 (executable)
@@ -93,6 +93,18 @@ stat (const char *path, struct stat *st)
     real_stat = dlsym (RTLD_NEXT, "stat");
   return real_stat (redirect_path (path), st);
 }
+
+/* Since coreutils v8.32 we use fstatat() rather than stat()  */
+int fstatat(int dirfd, const char *restrict path,
+            struct stat *restrict statbuf, int flags)
+{
+  static int (*real_fstatat) (int dirfd, const char *restrict pathname,
+              struct stat *restrict statbuf, int flags) = NULL;
+  if (!real_fstatat)
+    real_fstatat = dlsym (RTLD_NEXT, "fstatat");
+  return real_fstatat (dirfd, redirect_path (path), statbuf, flags);
+}
+
 EOF
 
 # Then compile/link it:
@@ -103,7 +115,7 @@ touch d2 || framework_failure_
 echo xyz > src || framework_failure_
 
 # Finally, run the test:
-LD_PRELOAD=$LD_PRELOAD:./k.so cp src d || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so cp -T src d || fail=1
 
 test -f preloaded || skip_ 'LD_PRELOAD was ineffective?'