]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
openat2 tests: Avoid test failure on native Windows.
authorBruno Haible <bruno@clisp.org>
Sat, 1 Nov 2025 13:17:10 +0000 (14:17 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 1 Nov 2025 13:17:10 +0000 (14:17 +0100)
* tests/test-openat2.c (do_prepare_symlinks): New function, extracted
from do_prepare.
(main): Invoke it before do_test_resolve, do_test_basic. Disable these
tests on native Windows.

ChangeLog
tests/test-openat2.c

index 116b967c541c84ea4b87e12ff3b59602b4988ed9..bf7345152d549294823f0fd0c1f38c90171b26ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-11-01  Bruno Haible  <bruno@clisp.org>
+
+       openat2 tests: Avoid test failure on native Windows.
+       * tests/test-openat2.c (do_prepare_symlinks): New function, extracted
+       from do_prepare.
+       (main): Invoke it before do_test_resolve, do_test_basic. Disable these
+       tests on native Windows.
+
 2025-11-01  Bruno Haible  <bruno@clisp.org>
 
        openat2: Fix invalid memory access on Cygwin.
index a3832992ec91e16d7faf96079ed7b14a594c0099..e22c461c7cd65b67ae936e38135e15f1516ec2c6 100644 (file)
@@ -75,11 +75,21 @@ do_prepare ()
   /* Remove any leftovers from a previous partial run.  */
   ignore_value (system ("rm -rf " BASE "*"));
 
+  ASSERT (mkdirat (AT_FDCWD, temp_dir, 0700) == 0);
+  dfd = openat2 (AT_FDCWD, temp_dir,
+                 (&(struct open_how) { .flags = O_RDONLY | O_DIRECTORY }),
+                 sizeof (struct open_how));
+  ASSERT (0 <= dfd);
+}
+
+static void
+do_prepare_symlinks ()
+{
   /*
      Construct a test directory with the following structure:
 
      temp_dir/
-        |- escaping_link -> /tmp
+        |- escaping_link -> /
         |- escaping_link_2 -> escaping_link
         |- some_file
         |- invalid_link -> some_file/invalid
@@ -88,11 +98,6 @@ do_prepare ()
           |- some_file
   */
 
-  ASSERT (mkdirat (AT_FDCWD, temp_dir, 0700) == 0);
-  dfd = openat2 (AT_FDCWD, temp_dir,
-                 (&(struct open_how) { .flags = O_RDONLY | O_DIRECTORY }),
-                 sizeof (struct open_how));
-  ASSERT (0 <= dfd);
   ASSERT (symlinkat ("/", dfd, "escaping_link") == 0);
   ASSERT (symlinkat ("escaping_link", dfd, "escaping_link_2") == 0);
   ASSERT (symlinkat ("some_file/invalid", dfd, "invalid_link") == 0);
@@ -522,11 +527,15 @@ main ()
   ASSERT (test_open (do_open, false) == result);
   ASSERT (close (dfd) == 0);
 
-  do_prepare ();
   do_test_struct ();
+
+  do_prepare ();
   do_test_flags ();
+#if !(defined _WIN32 && !defined __CYGWIN__)
+  do_prepare_symlinks ();
   do_test_resolve ();
   do_test_basic ();
+#endif
 
   /* Check that even when *-safer modules are in use, plain openat2 can
      land in fd 0.  Do this test last, since it is destructive to