From: Dmitry V. Levin Date: Sun, 16 Apr 2017 17:28:00 +0000 (+0000) Subject: tests: use fixed timestamps in utime related tests X-Git-Tag: v4.17~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27638f632e8849e72d98d0f6e194e97c9ad0344e;p=strace tests: use fixed timestamps in utime related tests * 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. --- diff --git a/tests/clock.test b/tests/clock.test index 0edc1504..5ed96c28 100755 --- a/tests/clock.test +++ b/tests/clock.test @@ -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 { diff --git a/tests/futimesat.c b/tests/futimesat.c index c3566291..b8a245ae 100644 --- a/tests/futimesat.c +++ b/tests/futimesat.c @@ -41,10 +41,6 @@ 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", diff --git a/tests/utime.c b/tests/utime.c index ba8ae326..a8d36645 100644 --- a/tests/utime.c +++ b/tests/utime.c @@ -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 = diff --git a/tests/utimensat.c b/tests/utimensat.c index 6d9faac2..e1ebc97a 100644 --- a/tests/utimensat.c +++ b/tests/utimensat.c @@ -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]); diff --git a/tests/utimes.c b/tests/utimes.c index bbfa0310..b4d8065e 100644 --- a/tests/utimes.c +++ b/tests/utimes.c @@ -40,10 +40,6 @@ 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());