tests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests

* tests/futimesat.c: Print tv_sec and tv_usec fields as signed types.
* tests/utimes.c: Likewise.
This commit is contained in:
Eugene Syromyatnikov 2016-11-27 18:46:31 +03:00 committed by Dmitry V. Levin
parent 7491519823
commit 0bf550423c
2 changed files with 10 additions and 17 deletions

View File

@ -32,14 +32,11 @@
#ifdef __NR_futimesat
# include <stdint.h>
# include <stdio.h>
# include <sys/time.h>
# include <unistd.h>
#define CAST_NUM(n) \
(sizeof(n) == sizeof(long) ? \
(unsigned long long) (unsigned long) (n) : \
(unsigned long long) (n))
int
main(void)
@ -69,10 +66,10 @@ main(void)
(void) close(0);
rc = syscall(__NR_futimesat, 0, "", ts);
printf("futimesat(0, \"\", [{tv_sec=%llu, tv_usec=%llu}, "
"{tv_sec=%llu, tv_usec=%llu}]) = %ld %s (%m)\n",
CAST_NUM(ts[0].tv_sec), CAST_NUM(ts[0].tv_usec),
CAST_NUM(ts[1].tv_sec), CAST_NUM(ts[1].tv_usec),
printf("futimesat(0, \"\", [{tv_sec=%jd, tv_usec=%jd}, "
"{tv_sec=%jd, tv_usec=%jd}]) = %ld %s (%m)\n",
(intmax_t) ts[0].tv_sec, (intmax_t) ts[0].tv_usec,
(intmax_t) ts[1].tv_sec, (intmax_t) ts[1].tv_usec,
rc, errno2name());
puts("+++ exited with 0 +++");

View File

@ -32,15 +32,11 @@
#ifdef __NR_utimes
# include <stdint.h>
# include <stdio.h>
# include <sys/time.h>
# include <unistd.h>
#define CAST_NUM(n) \
(sizeof(n) == sizeof(long) ? \
(unsigned long long) (unsigned long) (n) : \
(unsigned long long) (n))
int
main(void)
{
@ -66,10 +62,10 @@ main(void)
ts[1].tv_usec = tv.tv_usec + 1;
rc = syscall(__NR_utimes, "", ts);
printf("utimes(\"\", [{tv_sec=%llu, tv_usec=%llu}, "
"{tv_sec=%llu, tv_usec=%llu}]) = %ld %s (%m)\n",
CAST_NUM(ts[0].tv_sec), CAST_NUM(ts[0].tv_usec),
CAST_NUM(ts[1].tv_sec), CAST_NUM(ts[1].tv_usec),
printf("utimes(\"\", [{tv_sec=%jd, tv_usec=%jd}, "
"{tv_sec=%jd, tv_usec=%jd}]) = %ld %s (%m)\n",
(intmax_t) ts[0].tv_sec, (intmax_t) ts[0].tv_usec,
(intmax_t) ts[1].tv_sec, (intmax_t) ts[1].tv_usec,
rc, errno2name());
puts("+++ exited with 0 +++");