X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-stat-time.c;h=907ba4b9096cf8d1daca9272db2bf02b41801e1e;hb=11dbc24bbfd94e0e8d36754fe17bb1fdeb58fe5e;hp=c3262d0b92f31db0afd138ed06a7ffe50d50add9;hpb=735c00a2f3a5ce7aaec8517f5438ce37b48a936c;p=gnulib.git diff --git a/tests/test-stat-time.c b/tests/test-stat-time.c index c3262d0b9..907ba4b90 100644 --- a/tests/test-stat-time.c +++ b/tests/test-stat-time.c @@ -21,14 +21,23 @@ #include "stat-time.h" +#include #include #include #include #include -#include #include -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) enum { NFILES = 4 }; @@ -41,6 +50,9 @@ cleanup (int sig) unlink ("t-stt-stamp2"); unlink ("t-stt-renamed"); unlink ("t-stt-stamp3"); + + if (sig != 0) + _exit (1); } static int @@ -81,12 +93,12 @@ prepare_test (struct stat *statinfo, struct timespec *modtimes) sleep (2); create_file ("t-stt-stamp2"); sleep (2); - ASSERT (rename ("t-stt-testfile", "t-stt-renamed") == 0); + ASSERT (chmod ("t-stt-testfile", 0400) == 0); sleep (2); create_file ("t-stt-stamp3"); do_stat ("t-stt-stamp1", &statinfo[0]); - do_stat ("t-stt-renamed", &statinfo[1]); + do_stat ("t-stt-testfile", &statinfo[1]); do_stat ("t-stt-stamp2", &statinfo[2]); do_stat ("t-stt-stamp3", &statinfo[3]); @@ -132,10 +144,9 @@ test_birthtime (const struct stat *statinfo, /* Collect the birth times.. */ for (i = 0; i < NFILES; ++i) { - if (!get_stat_birthtime (&statinfo[i], &birthtimes[i])) - { - return; - } + birthtimes[i] = get_stat_birthtime (&statinfo[i]); + if (birthtimes[i].tv_nsec < 0) + return; } ASSERT (modtimes[0].tv_sec < birthtimes[1].tv_sec); /* mtime(stamp1) < birthtime(renamed) */ @@ -162,6 +173,7 @@ main () signal (SIGTERM, cleanup); #endif + cleanup (0); prepare_test (statinfo, modtimes); test_mtime (statinfo, modtimes); test_birthtime (statinfo, modtimes, birthtimes);