openat: work around AIX 7.1 fstatat issue
[gnulib.git] / tests / test-getcwd.c
index 14a526f..e9832f0 100644 (file)
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include "pathmax.h"
 #include "macros.h"
 
 #if ! HAVE_GETPAGESIZE
@@ -48,10 +49,12 @@ test_abort_bug (void)
   size_t desired_depth;
   size_t d;
 
+#ifdef PATH_MAX
   /* The bug is triggered when PATH_MAX < getpagesize (), so skip
      this relatively expensive and invasive test if that's not true.  */
   if (getpagesize () <= PATH_MAX)
     return 0;
+#endif
 
   cwd = getcwd (NULL, 0);
   if (cwd == NULL)
@@ -65,7 +68,8 @@ test_abort_bug (void)
     {
       if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
         {
-          fail = 3; /* Unable to construct deep hierarchy.  */
+          if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT))
+            fail = 3; /* Unable to construct deep hierarchy.  */
           break;
         }
     }
@@ -74,7 +78,8 @@ test_abort_bug (void)
      results in a failed assertion.  */
   cwd = getcwd (NULL, 0);
   if (cwd == NULL)
-    fail = 4; /* getcwd failed.  This is ok, and expected.  */
+    fail = 4; /* getcwd didn't assert, but it failed for a long name
+                 where the answer could have been learned.  */
   free (cwd);
 
   /* Call rmdir first, in case the above chdir failed.  */
@@ -146,7 +151,7 @@ test_long_name (void)
          errors, be pessimistic and consider that as a failure, too.  */
       if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0)
         {
-          if (! (errno == ERANGE || errno == ENAMETOOLONG))
+          if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT))
             fail = 20;
           break;
         }