summaryrefslogtreecommitdiff
path: root/tests/test-chown.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-02-10 13:46:22 +0100
committerBruno Haible <bruno@clisp.org>2023-02-10 13:46:22 +0100
commiteecd8afd696055cf39ef934208724bfe850c5760 (patch)
treedbe4500d4a78dffab4c4f6eef418f543f175d336 /tests/test-chown.h
parent36f06b07d9cfb3974c160ecc22def3cb1b117106 (diff)
downloadgnulib-eecd8afd696055cf39ef934208724bfe850c5760.tar.gz
chown, lchown, fchownat tests: Avoid test failure on macOS 12.
* tests/test-chown.h (test_chown): Skip some assertions if getgid() == (gid_t)-1. * tests/test-lchown.h (test_lchown): Likewise.
Diffstat (limited to 'tests/test-chown.h')
-rw-r--r--tests/test-chown.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/test-chown.h b/tests/test-chown.h
index e8c3d49ff9..4c7b6eec33 100644
--- a/tests/test-chown.h
+++ b/tests/test-chown.h
@@ -72,7 +72,10 @@ test_chown (int (*func) (char const *, uid_t, gid_t), bool print)
ASSERT (stat (BASE "dir/file", &st1) == 0);
ASSERT (st1.st_uid != (uid_t) -1);
ASSERT (st1.st_gid != (gid_t) -1);
- ASSERT (st1.st_gid == getegid ());
+ /* On macOS 12, when logged in through ssh, getgid () and getegid () are both
+ == (gid_t) -1. */
+ if (getgid () != (gid_t) -1)
+ ASSERT (st1.st_gid == getegid ());
/* Sanity check of error cases. */
errno = 0;
@@ -132,7 +135,8 @@ test_chown (int (*func) (char const *, uid_t, gid_t), bool print)
if (1 < gids_count)
{
ASSERT (gids[1] != st1.st_gid);
- ASSERT (gids[1] != (gid_t) -1);
+ if (getgid () != (gid_t) -1)
+ ASSERT (gids[1] != (gid_t) -1);
ASSERT (lstat (BASE "dir/link", &st2) == 0);
ASSERT (st1.st_uid == st2.st_uid);
ASSERT (st1.st_gid == st2.st_gid);
@@ -156,7 +160,8 @@ test_chown (int (*func) (char const *, uid_t, gid_t), bool print)
ASSERT (func (BASE "dir/link2", -1, gids[1]) == 0);
ASSERT (stat (BASE "dir/file", &st2) == 0);
ASSERT (st1.st_uid == st2.st_uid);
- ASSERT (gids[1] == st2.st_gid);
+ if (getgid () != (gid_t) -1)
+ ASSERT (gids[1] == st2.st_gid);
ASSERT (lstat (BASE "dir/link", &st2) == 0);
ASSERT (st1.st_uid == st2.st_uid);
ASSERT (st1.st_gid == st2.st_gid);