From ca57cb25167df588392674584396f82e61fca6e2 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 12 Aug 2024 16:15:50 +0200 Subject: [PATCH] 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. --- ChangeLog | 17 +++++++++++++++++ modules/chown-tests | 2 ++ modules/fchownat-tests | 2 ++ modules/fdutimensat-tests | 2 ++ modules/futimens-tests | 2 ++ modules/lchown-tests | 2 ++ modules/stat-time-tests | 2 ++ modules/utime-tests | 2 ++ modules/utimens-tests | 2 ++ modules/utimensat-tests | 2 ++ tests/nap.h | 14 ++++++++++---- 11 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62174deac9..2ca3538a9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2024-08-12 Bruno Haible + + 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. + 2024-08-10 Bruno Haible Make sure gperf-generated files are the same in VPATH builds. 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 - # include +# 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 @@ -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 */ 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 -- 2.39.5