From: Dmitry V. Levin Date: Wed, 6 Jan 2016 11:44:32 +0000 (+0000) Subject: tests/ppoll.c: use libtests X-Git-Tag: v4.12~695 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=647e7953ce4d9fdc5b9a297a3e5fc1d3e69be86d;p=strace tests/ppoll.c: use libtests * tests/ppoll.c (main): Use assert, perror_msg_and_skip, and perror_msg_and_fail. --- diff --git a/tests/ppoll.c b/tests/ppoll.c index 84a957f3..46d7e816 100644 --- a/tests/ppoll.c +++ b/tests/ppoll.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,14 +26,14 @@ */ #include "tests.h" +#include #include #include #include -static int +static void test1(void) { - sigset_t mask; const struct timespec timeout = { .tv_sec = 42, .tv_nsec = 999999999 }; struct pollfd fds[] = { { .fd = 0, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND }, @@ -42,35 +42,41 @@ test1(void) { .fd = 4, .events = POLLOUT } }; + sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGUSR2); sigaddset(&mask, SIGCHLD); - return ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask) == 2 ? 0 : 77; + int rc = ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask); + if (rc < 0) + perror_msg_and_skip("ppoll"); + assert(rc == 2); } -static int +static void test2(void) { - sigset_t mask; const struct timespec timeout = { .tv_sec = 0, .tv_nsec = 999 }; struct pollfd fds[] = { { .fd = 1, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND }, { .fd = 0, .events = POLLOUT | POLLWRNORM | POLLWRBAND } }; + sigset_t mask; sigfillset(&mask); sigdelset(&mask, SIGHUP); sigdelset(&mask, SIGKILL); sigdelset(&mask, SIGSTOP); - return ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask) == 0 ? 0 : 77; + int rc = ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask); + if (rc < 0) + perror_msg_and_skip("ppoll"); + assert(rc == 0); } int main(void) { - int rc; int fds[2]; (void) close(0); @@ -78,14 +84,11 @@ main(void) (void) close(3); (void) close(4); if (pipe(fds) || pipe(fds)) - return 77; - - - if ((rc = test1())) - return rc; + perror_msg_and_fail("pipe"); - if ((rc = test2())) - return rc; + test1(); + test2(); - return ppoll(NULL, 42, NULL, NULL) < 0 ? 0 : 77; + assert(ppoll(NULL, 42, NULL, NULL) < 0); + return 0; }