From: Dmitry V. Levin Date: Mon, 8 Feb 2016 00:01:57 +0000 (+0000) Subject: tests: extend coverage of utimensat syscall X-Git-Tag: v4.12~576 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ee77b9e65938ecd2c3307c7fd25ef76b18de36e;p=strace tests: extend coverage of utimensat syscall * tests/utimensat.c (main): Check decoding of NULL struct timespec pointer. --- diff --git a/tests/utimensat.c b/tests/utimensat.c index 58da81a6..24e91062 100644 --- a/tests/utimensat.c +++ b/tests/utimensat.c @@ -1,4 +1,6 @@ /* + * This file is part of utimensat strace test. + * * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * @@ -47,6 +49,15 @@ print_ts(const struct timespec *ts) int main(void) { + static const char fname[] = "utimensat\nfilename"; + + assert(utimensat(AT_FDCWD, fname, NULL, 0) == -1); + if (ENOENT != errno) + error_msg_and_skip("utimensat"); + + #define PREFIX "utimensat(AT_FDCWD, \"utimensat\\nfilename\", " + printf(PREFIX "NULL, 0) = -1 ENOENT (%m)\n"); + struct timeval tv; struct timespec ts[2]; @@ -58,29 +69,24 @@ main(void) ts[1].tv_sec = tv.tv_sec - 1; ts[1].tv_nsec = tv.tv_usec + 1; - #define PREFIX "utimensat(AT_FDCWD, \"utimensat\\nfilename\", [" - - printf(PREFIX); + printf(PREFIX "["); print_ts(&ts[0]); printf(", "); print_ts(&ts[1]); printf("], AT_SYMLINK_NOFOLLOW) = -1 ENOENT "); - assert(utimensat(AT_FDCWD, "utimensat\nfilename", ts, - AT_SYMLINK_NOFOLLOW) == -1); + assert(utimensat(AT_FDCWD, fname, ts, AT_SYMLINK_NOFOLLOW) == -1); if (ENOENT != errno) error_msg_and_skip("utimensat"); printf("(%m)\n"); - printf(PREFIX "UTIME_NOW, UTIME_OMIT], AT_SYMLINK_NOFOLLOW) = -1 ENOENT "); - ts[0].tv_nsec = UTIME_NOW; ts[1].tv_nsec = UTIME_OMIT; - assert(utimensat(AT_FDCWD, "utimensat\nfilename", ts, - AT_SYMLINK_NOFOLLOW) == -1); + assert(utimensat(AT_FDCWD, fname, ts, AT_SYMLINK_NOFOLLOW) == -1); if (ENOENT != errno) error_msg_and_skip("utimensat"); - printf("(%m)\n"); + printf(PREFIX "[UTIME_NOW, UTIME_OMIT], AT_SYMLINK_NOFOLLOW)" + " = -1 ENOENT (%m)\n"); puts("+++ exited with 0 +++"); return 0;