+2025-10-28 Paul Eggert <eggert@cs.ucla.edu>
+
+ openat2-tests: port to FreeBSD, NetBSD
+ Problem reported by Bruno Haible in:
+ https://lists.gnu.org/r/bug-gnulib/2025-10/msg00117.html
+ * tests/test-openat2.c (is_nofollow_error): New function.
+ (do_test_resolve): Use it.
+
2025-10-28 Bruno Haible <bruno@clisp.org>
posix_spawn_file_actions_addclose: Fix test failure on NetBSD 10.0.
}
}
+static bool
+is_nofollow_error (int err)
+{
+#ifdef EFTYPE /* NetBSD openat+O_NOFOLLOW on symlink */
+ if (err == EFTYPE)
+ return true;
+#endif
+#ifdef EMLINK /* FreeBSD openat+O_NOFOLLOW on symlink */
+ if (err == EMLINK)
+ return true;
+#endif
+ return err == ELOOP;
+}
+
static void
do_test_resolve (void)
{
.resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP || errno == EXDEV);
+ ASSERT ((errno == EXDEV) | is_nofollow_error (errno));
ASSERT (fd == -1);
/* Same as before, ESCAPING_LINK_2 links to ESCAPING_LINK. */
.resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP || errno == EXDEV);
+ ASSERT ((errno == EXDEV) | is_nofollow_error (errno));
ASSERT (fd == -1);
/* ESCAPING_LINK links to the temporary directory itself (dfd). */
.resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP || errno == EXDEV);
+ ASSERT ((errno == EXDEV) | is_nofollow_error (errno));
ASSERT (fd == -1);
/* Although it points to a valid file in same path, the link refers to
.resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP || errno == EXDEV);
+ ASSERT ((errno == EXDEV) | is_nofollow_error (errno));
ASSERT (fd == -1);
fd = openat2 (dfd,
.resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP);
+ ASSERT (is_nofollow_error (errno));
ASSERT (fd == -1);
fd = openat2 (dfd,
.resolve = RESOLVE_IN_ROOT | RESOLVE_NO_SYMLINKS,
}),
sizeof (struct open_how));
- ASSERT (errno == ELOOP | errno == ENOENT);
+ ASSERT ((errno == ENOENT) | is_nofollow_error (errno));
ASSERT (fd == -1);
{