test-stat: don't allocate PATH_MAX bytes
authorEric Blake <eblake@redhat.com>
Mon, 20 Jun 2011 21:12:10 +0000 (15:12 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 20 Jun 2011 21:38:42 +0000 (15:38 -0600)
POSIX allows systems (like Hurd) that don't define PATH_MAX, or
which define it larger than a reasonable stack allocation should
be.  The test originally used stack allocation to avoid portability
problems with getcwd, but the getcwd-lgpl module solves those.

* tests/test-stat.h (test_stat_func): Don't stack-allocate a
PATH_MAX-sized buffer.
* modules/openat-tests (Depends-on): Add getcwd-lgpl, drop pathmax.
* modules/stat-tests (Depends-on): Likewise.
* tests/test-fstatat.c (includes): Drop pathmax.h.
* tests/test-stat.c (includes): Likewise.
Reported by Bruno Haible.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
modules/openat-tests
modules/stat-tests
tests/test-fstatat.c
tests/test-stat.c
tests/test-stat.h

index 7fe9017..1758d67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-06-20  Eric Blake  <eblake@redhat.com>
+
+       test-stat: don't allocate PATH_MAX bytes
+       * tests/test-stat.h (test_stat_func): Don't stack-allocate a
+       PATH_MAX-sized buffer.
+       * modules/openat-tests (Depends-on): Add getcwd-lgpl, drop pathmax.
+       * modules/stat-tests (Depends-on): Likewise.
+       * tests/test-fstatat.c (includes): Drop pathmax.h.
+       * tests/test-stat.c (includes): Likewise.
+       Reported by Bruno Haible.
+
 2011-06-20  Bruno Haible  <bruno@clisp.org>
 
        float: Work around <float.h> bugs on FreeBSD/x86, AIX with GCC, IRIX.
index 8b0a2b9..b83fb72 100644 (file)
@@ -16,9 +16,9 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+getcwd-lgpl
 ignore-value
 mgetgroups
-pathmax
 progname
 usleep
 stat-time
index 74d558c..9c00ce5 100644 (file)
@@ -5,7 +5,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
-pathmax
+getcwd-lgpl
 same-inode
 stdbool
 symlink
index dda0cd2..aef1136 100644 (file)
@@ -31,7 +31,6 @@ SIGNATURE_CHECK (fstatat, int, (int, char const *, struct stat *, int));
 #include <unistd.h>
 
 #include "openat.h"
-#include "pathmax.h"
 #include "progname.h"
 #include "same-inode.h"
 #include "ignore-value.h"
index 4cda089..cd74491 100644 (file)
@@ -33,7 +33,6 @@ SIGNATURE_CHECK (stat, int, (char const *, struct stat *));
 #include <stdio.h>
 #include <unistd.h>
 
-#include "pathmax.h"
 #include "same-inode.h"
 #include "macros.h"
 
index 22552dc..3c8f7ad 100644 (file)
@@ -27,9 +27,9 @@ test_stat_func (int (*func) (char const *, struct stat *), bool print)
 {
   struct stat st1;
   struct stat st2;
-  char cwd[PATH_MAX];
+  char *cwd = getcwd (NULL, 0);
 
-  ASSERT (getcwd (cwd, PATH_MAX) == cwd);
+  ASSERT (cwd);
   ASSERT (func (".", &st1) == 0);
   ASSERT (func ("./", &st2) == 0);
   ASSERT (SAME_INODE (st1, st2));