From: Dmitry V. Levin Date: Wed, 6 Jan 2016 11:49:27 +0000 (+0000) Subject: tests/utimensat.c: use libtests X-Git-Tag: v4.12~694 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00777042c4c7f7554cb6f2e9360a5e3c1978dd78;p=strace tests/utimensat.c: use libtests * tests/utimensat.c: Use SKIP_MAIN_UNDEFINED. (main): Use assert and perror_msg_and_skip. --- diff --git a/tests/utimensat.c b/tests/utimensat.c index 5dae48da..58da81a6 100644 --- a/tests/utimensat.c +++ b/tests/utimensat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,8 +26,10 @@ */ #include "tests.h" -#include +#include +#include #include +#include #include #include #include @@ -49,15 +51,12 @@ main(void) struct timespec ts[2]; if (gettimeofday(&tv, NULL)) - return 77; + 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; - if (!utimensat(AT_FDCWD, "utimensat\nfilename", ts, - AT_SYMLINK_NOFOLLOW)) - return 77; #define PREFIX "utimensat(AT_FDCWD, \"utimensat\\nfilename\", [" @@ -65,27 +64,31 @@ main(void) print_ts(&ts[0]); printf(", "); print_ts(&ts[1]); - puts("], AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)"); + printf("], AT_SYMLINK_NOFOLLOW) = -1 ENOENT "); + + assert(utimensat(AT_FDCWD, "utimensat\nfilename", 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; - if (!utimensat(AT_FDCWD, "utimensat\nfilename", ts, - AT_SYMLINK_NOFOLLOW)) - return 77; + assert(utimensat(AT_FDCWD, "utimensat\nfilename", ts, + AT_SYMLINK_NOFOLLOW) == -1); + if (ENOENT != errno) + error_msg_and_skip("utimensat"); + printf("(%m)\n"); - printf(PREFIX); - puts("UTIME_NOW, UTIME_OMIT], AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)"); puts("+++ exited with 0 +++"); - return 0; } #else -int -main(void) -{ - return 77; -} +SKIP_MAIN_UNDEFINED("HAVE_UTIMENSAT && AT_FDCWD && AT_SYMLINK_NOFOLLOW" + " && UTIME_NOW && UTIME_OMIT") #endif