From: Paul Eggert Date: Wed, 29 Oct 2025 00:03:28 +0000 (-0700) Subject: openat2-tests: port to FreeBSD, NetBSD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c706216fec5a509bf9b1214892de01aa9303ade0;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 415568a156..3ccd074a4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2025-10-28 Paul Eggert + + 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 posix_spawn_file_actions_addclose: Fix test failure on NetBSD 10.0. diff --git a/tests/test-openat2.c b/tests/test-openat2.c index 0ac7aca6f3..fc93a7a9a9 100644 --- a/tests/test-openat2.c +++ b/tests/test-openat2.c @@ -317,6 +317,20 @@ do_test_flags (void) } } +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) { @@ -331,7 +345,7 @@ 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. */ @@ -342,7 +356,7 @@ 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); /* ESCAPING_LINK links to the temporary directory itself (dfd). */ @@ -353,7 +367,7 @@ 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); /* Although it points to a valid file in same path, the link refers to @@ -365,7 +379,7 @@ 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); fd = openat2 (dfd, @@ -375,7 +389,7 @@ do_test_resolve (void) .resolve = RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS, }), sizeof (struct open_how)); - ASSERT (errno == ELOOP); + ASSERT (is_nofollow_error (errno)); ASSERT (fd == -1); fd = openat2 (dfd, @@ -385,7 +399,7 @@ do_test_resolve (void) .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); {