From: Dmitry V. Levin Date: Wed, 6 Jan 2016 10:01:20 +0000 (+0000) Subject: tests/userfaultfd.c: use libtests X-Git-Tag: v4.12~710 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a68d7aca2a2381cbb188a7232f5ad698e865c6e7;p=strace tests/userfaultfd.c: use libtests * tests/userfaultfd.c: Use SKIP_MAIN_UNDEFINED. (main): Use assert. --- diff --git a/tests/userfaultfd.c b/tests/userfaultfd.c index be19dd62..5dc294bc 100644 --- a/tests/userfaultfd.c +++ b/tests/userfaultfd.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,25 +26,28 @@ */ #include "tests.h" -#include #include -#include -#include #include +#if defined __NR_userfaultfd && defined O_CLOEXEC + +# include +# include +# include +# include + int main(void) { -#if defined __NR_userfaultfd && defined O_CLOEXEC - if (syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) != -1) - return 77; - printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s\n", - errno == ENOSYS ? - "ENOSYS (Function not implemented)" : - "EINVAL (Invalid argument)"); + assert(syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) == -1); + printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s (%m)\n", + errno == ENOSYS ? "ENOSYS" : "EINVAL"); puts("+++ exited with 0 +++"); return 0; +} + #else - return 77; + +SKIP_MAIN_UNDEFINED("__NR_userfaultfd && O_CLOEXEC") + #endif -}