X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-dirent-safer.c;h=13bf02e14df957ceb743deea354b2de1c64842ce;hb=refs%2Ftags%2Fstable%2F20111211;hp=aeb8342d9ecba8e547f0268e5ae09fd88b0853bf;hpb=4f1227bdeac3e4e18c9b3efb27623875e02d681d;p=gnulib.git diff --git a/tests/test-dirent-safer.c b/tests/test-dirent-safer.c index aeb8342d9..13bf02e14 100644 --- a/tests/test-dirent-safer.c +++ b/tests/test-dirent-safer.c @@ -1,5 +1,5 @@ /* Test that directory streams leave standard fds alone. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "unistd-safer.h" @@ -33,22 +32,13 @@ duplicate the original stderr. */ #define BACKUP_STDERR_FILENO 10 -static FILE *myerr; +#define ASSERT_STREAM myerr +#include "macros.h" -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (myerr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (myerr); \ - abort (); \ - } \ - } \ - while (0) +static FILE *myerr; int -main () +main (void) { int i; DIR *dp; @@ -58,7 +48,7 @@ main () gnulib version of fdopendir is unable to guarantee that dirfd(fdopendir(fd))==fd, but we can at least guarantee that if they are not equal, the fd returned by dirfd is safe. */ -#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR int dfd; #endif @@ -67,7 +57,7 @@ main () || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) return 2; -#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR dfd = open (".", O_RDONLY); ASSERT (STDERR_FILENO < dfd); #endif @@ -83,7 +73,7 @@ main () ASSERT (dirfd (dp) == -1 || STDERR_FILENO < dirfd (dp)); ASSERT (closedir (dp) == 0); -#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR { int fd = dup_safer (dfd); ASSERT (STDERR_FILENO < fd); @@ -98,7 +88,7 @@ main () #endif } -#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR +#if HAVE_FDOPENDIR || GNULIB_TEST_FDOPENDIR ASSERT (close (dfd) == 0); #endif