[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] test-utime: port to noatime file systems
From: |
Bruno Haible |
Subject: |
Re: [PATCH] test-utime: port to noatime file systems |
Date: |
Mon, 12 Aug 2024 16:22:23 +0200 |
The CI reported 2 test failures on Cygwin:
FAIL: test-fdutimensat
======================
../../gltests/nap.h:79: assertion 'nap_fd != -1' failed
Stack trace:
0x100401510 nap_get_stat
../../gltests/nap.h:79
0x100401594 nap
../../gltests/nap.h:137
0x100401944 checkable_atime
../../gltests/test-utimens-common.h:92
0x10041a14f main
../../gltests/test-fdutimensat.c:129
FAIL: test-utimensat
====================
../../gltests/nap.h:79: assertion 'nap_fd != -1' failed
Stack trace:
0x100401310 nap_get_stat
../../gltests/nap.h:79
0x100401394 nap
../../gltests/nap.h:137
0x100401744 checkable_atime
../../gltests/test-utimens-common.h:92
0x1004188f0 main
../../gltests/test-utimensat.c:100
What's different with Cygwin than the other platforms? On Cygwin,
the witness file must be closed and then re-opened.
Why does that produce a failure now? Previously, nap() was only
called from the test's initial current directory. Now, it also
gets called from a subdirectory. The line
nap_fd = open (TEMPFILE, O_RDWR, 0600);
fails because there is no O_CREAT flag here. And if I add an O_CREAT
flag, there will be a secnond witness file in the subdirectory, and
the final rmdir() call fails.
The fix is to keep using the same witness file, regardless of chdir()
calls.
2024-08-12 Bruno Haible <bruno@clisp.org>
fdutimensat, utimensat tests: Fix test failures on Cygwin.
* tests/nap.h: Include concat-filename.h, xgetcwd.h.
(nap_file): New variable.
(nap_get_stat, clear_temp_file): Use nap_file, not TEMPFILE.
(nap): Initialize nap_file.
* modules/chown-tests (Depends-on): Add xconcat-filename, xgetcwd.
* modules/fchownat-tests (Depends-on): Likewise.
* modules/fdutimensat-tests (Depends-on): Likewise.
* modules/futimens-tests (Depends-on): Likewise.
* modules/lchown-tests (Depends-on): Likewise.
* modules/stat-time-tests (Depends-on): Likewise.
* modules/utime-tests (Depends-on): Likewise.
* modules/utimens-tests (Depends-on): Likewise.
* modules/utimensat-tests (Depends-on): Likewise.
diff --git a/modules/chown-tests b/modules/chown-tests
index d013be17e7..520c00dfb3 100644
--- a/modules/chown-tests
+++ b/modules/chown-tests
@@ -14,6 +14,8 @@ stat-time
stdbool
stdckdint
symlink
+xconcat-filename
+xgetcwd
configure.ac:
AC_CHECK_FUNCS_ONCE([getgid getegid])
diff --git a/modules/fchownat-tests b/modules/fchownat-tests
index f11d02cdde..2f804eccc1 100644
--- a/modules/fchownat-tests
+++ b/modules/fchownat-tests
@@ -15,6 +15,8 @@ openat-h
stat-time
stdckdint
symlink
+xconcat-filename
+xgetcwd
configure.ac:
AC_CHECK_FUNCS_ONCE([getgid getegid])
diff --git a/modules/fdutimensat-tests b/modules/fdutimensat-tests
index c2f0d59f3d..f4eb2ecc04 100644
--- a/modules/fdutimensat-tests
+++ b/modules/fdutimensat-tests
@@ -16,6 +16,8 @@ stdckdint
timespec
dup
utimecmp
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/modules/futimens-tests b/modules/futimens-tests
index c6f62d9d3c..7781dff3d3 100644
--- a/modules/futimens-tests
+++ b/modules/futimens-tests
@@ -15,6 +15,8 @@ stdckdint
timespec
dup
utimecmp
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/modules/lchown-tests b/modules/lchown-tests
index 2954701eeb..a66d624b30 100644
--- a/modules/lchown-tests
+++ b/modules/lchown-tests
@@ -14,6 +14,8 @@ stdckdint
stat-time
stdbool
symlink
+xconcat-filename
+xgetcwd
configure.ac:
AC_CHECK_FUNCS_ONCE([getgid getegid])
diff --git a/modules/stat-time-tests b/modules/stat-time-tests
index 0a8193783d..50addb33fc 100644
--- a/modules/stat-time-tests
+++ b/modules/stat-time-tests
@@ -8,6 +8,8 @@ nanosleep
stdckdint
time-h
unistd
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/modules/utime-tests b/modules/utime-tests
index 146180e04b..e354b476b8 100644
--- a/modules/utime-tests
+++ b/modules/utime-tests
@@ -13,6 +13,8 @@ stdckdint
symlink
timespec
utimecmp
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/modules/utimens-tests b/modules/utimens-tests
index 381139c8dd..3899bf08d4 100644
--- a/modules/utimens-tests
+++ b/modules/utimens-tests
@@ -16,6 +16,8 @@ stdckdint
symlink
timespec
utimecmp
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/modules/utimensat-tests b/modules/utimensat-tests
index 0ba5e09e02..03c8d9990f 100644
--- a/modules/utimensat-tests
+++ b/modules/utimensat-tests
@@ -13,6 +13,8 @@ nanosleep
stdckdint
timespec
utimecmp
+xconcat-filename
+xgetcwd
configure.ac:
diff --git a/tests/nap.h b/tests/nap.h
index cf7d998b80..1b9ae59287 100644
--- a/tests/nap.h
+++ b/tests/nap.h
@@ -20,9 +20,11 @@
# define GLTEST_NAP_H
# include <limits.h>
-
# include <stdckdint.h>
+# include "concat-filename.h"
+# include "xgetcwd.h"
+
/* Avoid a conflict with a function called nap() on UnixWare. */
# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /*
OpenServer, UnixWare */
# include <unistd.h>
@@ -33,6 +35,9 @@
/* Name of the witness file. */
#define TEMPFILE BASE "nap.tmp"
+/* Absolute name of the witness file. */
+static char *nap_file /* = NULL */;
+
/* File descriptor used for the witness file. */
static int nap_fd = -1;
@@ -75,7 +80,7 @@ nap_get_stat (struct stat *st, int do_write)
is closed. See
<https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-writefile>
*/
close (nap_fd);
- nap_fd = open (TEMPFILE, O_RDWR, 0600);
+ nap_fd = open (nap_file, O_RDWR, 0600);
ASSERT (nap_fd != -1);
lseek (nap_fd, 0, SEEK_END);
#endif
@@ -108,7 +113,7 @@ clear_temp_file (void)
if (0 <= nap_fd)
{
ASSERT (close (nap_fd) != -1);
- ASSERT (unlink (TEMPFILE) != -1);
+ ASSERT (unlink (nap_file) != -1);
}
}
@@ -127,8 +132,9 @@ nap (void)
if (-1 == nap_fd)
{
+ nap_file = xconcatenated_filename (xgetcwd (), TEMPFILE, NULL);
atexit (clear_temp_file);
- ASSERT ((nap_fd = creat (TEMPFILE, 0600)) != -1);
+ ASSERT ((nap_fd = creat (nap_file, 0600)) != -1);
nap_get_stat (&old_st, 0);
}
else