summaryrefslogtreecommitdiff
path: root/tests/test-stat.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-11-07 16:59:11 -0700
committerEric Blake <ebb9@byu.net>2009-11-09 06:16:05 -0700
commit349396ebfcce12ee8f927fedf82067414c427093 (patch)
treeebc0f680a8f44e92daa6ea293b9b4c7994a0caee /tests/test-stat.c
parent6553be82a4a522e50ece1a430e82a9b1dfd0f471 (diff)
downloadgnulib-349396ebfcce12ee8f927fedf82067414c427093.tar.gz
stat: detect FreeBSD bug
Like Solaris 9, FreeBSD 7.2 mistakenly allows stat("link-to-file/"). Unlike Solaris, it correctly forbids stat("file/"). A number of interfaces are affected (such as utimes), but replacing stat is enough to catch several by reusing the Solaris 9 fixes. * m4/stat.m4 (gl_FUNC_STAT): Also detect FreeBSD bug with slash on symlink. * doc/posix-functions/stat.texi (stat): Document the bug. * tests/test-stat.h (test_stat_func): Add argument. * tests/test-stat.c (main): Adjust caller. * tests/test-fstatat.c (main): Likewise. * modules/stat-tests (Depends-on): Add stdbool, symlink. Reported by Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests/test-stat.c')
-rw-r--r--tests/test-stat.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/test-stat.c b/tests/test-stat.c
index 61a9d90182..fc11731467 100644
--- a/tests/test-stat.c
+++ b/tests/test-stat.c
@@ -22,6 +22,7 @@
#include <fcntl.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -33,11 +34,11 @@
do \
{ \
if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
} \
while (0)
@@ -56,5 +57,5 @@ do_stat (char const *name, struct stat *st)
int
main (void)
{
- return test_stat_func (do_stat);
+ return test_stat_func (do_stat, true);
}