]> granicus.if.org Git - strace/commitdiff
tests: use fixed timestamps in utime related tests
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 16 Apr 2017 17:28:00 +0000 (17:28 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 16 Apr 2017 17:28:00 +0000 (17:28 +0000)
* tests/clock.test: Remove futimesat, utime, utimensat, and utimes tests
from the list of exceptions.
* tests/utime.c (main): Do not use time(), use fixed timestamp instead.
* tests/futimesat.c (main): Do not use gettimeofday(), use fixed
timestamps instead.
* tests/utimensat.c (main): Likewise.
* tests/utimes.c (main): Likewise.

tests/clock.test
tests/futimesat.c
tests/utime.c
tests/utimensat.c
tests/utimes.c

index 0edc150481a5105154040d4979fb0935ca1cb177..5ed96c28613a4ecb3f9a9c1a234a64ef3ef60975 100755 (executable)
@@ -39,9 +39,8 @@ while read w s; do {
 36 clock_xettime
 EOF
 
-# Surprised that fcntl*, futimesat, utime, utimensat, and utimes tests
-# linked with musl use clock_gettime?  Me too!
-grep -E -v '^(#|clock_|times$|fcntl|futimesat$|utime)' \
+# Surprised that fcntl* tests linked with musl use clock_gettime?  Me too!
+grep -E -v '^(#|clock_|times$|fcntl)' \
        < "$srcdir/pure_executables.list" > negative.list
 
 while read s; do {
index c3566291265928690f19f9fdff49c7080c7da66a..b8a245ae4c609250f014927f0ea12b7949d305ce 100644 (file)
 int
 main(void)
 {
-       struct timeval tv;
-       if (gettimeofday(&tv, NULL))
-               perror_msg_and_fail("gettimeofday");
-
        static const char sample[] = "futimesat_sample";
        unsigned long dirfd = (unsigned long) 0xdeadbeef00000000ULL | -100U;
 
@@ -55,10 +51,10 @@ main(void)
        struct timeval *const ts = tail_alloc(sizeof(*ts) * 2);
        dirfd = (unsigned long) 0xdeadbeefffffffffULL;
 
-       ts[0].tv_sec = tv.tv_sec;
-       ts[0].tv_usec = tv.tv_usec;
-       ts[1].tv_sec = tv.tv_sec - 1;
-       ts[1].tv_usec = tv.tv_usec + 1;
+       ts[0].tv_sec = 1492356708;
+       ts[0].tv_usec = 567891234;
+       ts[1].tv_sec = 1492357086;
+       ts[1].tv_usec = 678902345;
 
        rc = syscall(__NR_futimesat, dirfd, 0, ts + 2);
        printf("futimesat(%d, NULL, %p) = %ld %s (%m)\n",
index ba8ae32633cf8d34a8d97e63de9fa50d0202beed..a8d366451ea1e6689056ad8d3bffa61b09221579 100644 (file)
@@ -49,7 +49,7 @@ main(void)
 {
        static const char *const dummy_str = "dummy filename";
 
-       const time_t t = time(NULL);
+       const time_t t = 1492350678;
        const struct utimbuf u = { .actime = t, .modtime = t };
        const struct utimbuf *const tail_u = tail_memdup(&u, sizeof(u));
        const char *const dummy_filename =
index 6d9faac2989996fe4bbae27da5740bccdc3b1fe1..e1ebc97a87a2d943610807934615849fb1c78a4d 100644 (file)
@@ -59,16 +59,11 @@ main(void)
        #define PREFIX "utimensat(AT_FDCWD, \"utimensat\\nfilename\", "
        printf(PREFIX "NULL, 0) = -1 ENOENT (%m)\n");
 
-       struct timeval tv;
        struct timespec ts[2];
-
-       if (gettimeofday(&tv, NULL))
-               perror_msg_and_skip("gettimeofday");
-
-       ts[0].tv_sec = tv.tv_sec;
-       ts[0].tv_nsec = tv.tv_usec;
-       ts[1].tv_sec = tv.tv_sec - 1;
-       ts[1].tv_nsec = tv.tv_usec + 1;
+       ts[0].tv_sec = 1492358706;
+       ts[0].tv_nsec = 123456789;
+       ts[1].tv_sec = 1492357068;
+       ts[1].tv_nsec = 234567890;
 
        printf(PREFIX "[");
        print_ts(&ts[0]);
index bbfa03105408efbafb7e00349b98a0fdfa3b2126..b4d8065ef8e3c26e6c6e2aee203c3deb3883f718 100644 (file)
 int
 main(void)
 {
-       struct timeval tv;
-       if (gettimeofday(&tv, NULL))
-               perror_msg_and_fail("gettimeofday");
-
        static const char sample[] = "utimes_sample";
 
        long rc = syscall(__NR_utimes, sample, 0);
@@ -52,10 +48,10 @@ main(void)
 
        struct timeval *const ts = tail_alloc(sizeof(*ts) * 2);
 
-       ts[0].tv_sec = tv.tv_sec;
-       ts[0].tv_usec = tv.tv_usec;
-       ts[1].tv_sec = tv.tv_sec - 1;
-       ts[1].tv_usec = tv.tv_usec + 1;
+       ts[0].tv_sec = 1492358607;
+       ts[0].tv_usec = 345678912;
+       ts[1].tv_sec = 1492356078;
+       ts[1].tv_usec = 456789023;
 
        rc = syscall(__NR_utimes, 0, ts + 2);
        printf("utimes(NULL, %p) = %ld %s (%m)\n", ts + 2, rc, errno2name());