On the Cygwin 3.3.6 and 3.5.3 machines at GitHub I see these test failures:

FAIL: test-access
=================

../../gltests/test-access.h:83: assertion 'func (BASE "f2", W_OK) == -1' failed

FAIL: test-euidaccess
=====================

../../gltests/test-access.h:83: assertion 'func (BASE "f2", W_OK) == -1' failed

So, apparently, there the permission W_OK is granted.

Whereas on my Cygwin installation (version 3.5.3 as well) these tests succeed.

The 'id' command reveals the cause: On the GitHub machines, the user is in
the groups 114(Local account and member of Administrators group)
and 544(Administrators), whereas on my installation, it isn't. All other
groups are the same.

This patch should avoid the test failures.


2024-05-23  Bruno Haible  <br...@clisp.org>

        access, euidaccess tests: Avoid test failures on Cygwin.
        * tests/test-access.h (test_access): On Cygwin, don't test for the
        absence of the W_OK permission.

diff --git a/tests/test-access.h b/tests/test-access.h
index 0f9a45fc65..ece89beb6b 100644
--- a/tests/test-access.h
+++ b/tests/test-access.h
@@ -77,12 +77,16 @@ test_access (int (*func) (const char * /*file*/, int 
/*mode*/))
 
     ASSERT (func (BASE "f2", R_OK) == 0);
 
+    /* On Cygwin, for users that are in the 'Administrators' group,
+       W_OK is allowed.  */
+#if !defined __CYGWIN__
     if (geteuid () != ROOT_UID)
       {
         errno = 0;
         ASSERT (func (BASE "f2", W_OK) == -1);
         ASSERT (errno == EACCES);
       }
+#endif
 
 #if defined _WIN32 && !defined __CYGWIN__
     /* X_OK works like R_OK.  */




Reply via email to