Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Switch ATF_REQUIRE() to more appropriate ...



details:   https://anonhg.NetBSD.org/src/rev/3fa258177edd
branches:  trunk
changeset: 348805:3fa258177edd
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Nov 08 15:21:34 2016 +0000

description:
Switch ATF_REQUIRE() to more appropriate ATF_REQUIRE_ERRNO()

Simplify the code of t_wait_noproc

Sponsored by <The NetBSD Foundation>

diffstat:

 tests/lib/libc/sys/t_wait_noproc.c |  31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)

diffs (87 lines):

diff -r c22a9463d7dd -r 3fa258177edd tests/lib/libc/sys/t_wait_noproc.c
--- a/tests/lib/libc/sys/t_wait_noproc.c        Tue Nov 08 14:49:04 2016 +0000
+++ b/tests/lib/libc/sys/t_wait_noproc.c        Tue Nov 08 15:21:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $ */
+/* $NetBSD: t_wait_noproc.c,v 1.3 2016/11/08 15:21:34 kamil Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $");
+__RCSID("$NetBSD: t_wait_noproc.c,v 1.3 2016/11/08 15:21:34 kamil Exp $");
 
 #include <sys/wait.h>
 #include <sys/resource.h>
@@ -50,9 +50,7 @@
 
 ATF_TC_BODY(wait, tc)
 {
-       errno = 0;
-       ATF_REQUIRE(wait(NULL) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1);
 }
 #endif
 
@@ -70,9 +68,7 @@
        /* wait4() (and friends) with WNOHANG and no children does not error */
        atf_tc_expect_fail("PR standards/51606");
 #endif
-       errno = 0;
-       ATF_REQUIRE(waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1);
 }
 
 ATF_TC(waitid);
@@ -89,9 +85,8 @@
        /* wait4() (and friends) with WNOHANG and no children does not error */
        atf_tc_expect_fail("PR standards/51606");
 #endif
-       errno = 0;
-       ATF_REQUIRE(waitid(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD,
+           waitid(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION) == -1);
 }
 
 ATF_TC(wait3);
@@ -107,9 +102,7 @@
        /* wait4() (and friends) with WNOHANG and no children does not error */
        atf_tc_expect_fail("PR standards/51606");
 #endif
-       errno = 0;
-       ATF_REQUIRE(wait3(NULL, TWAIT_OPTION, NULL) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1);
 }
 
 ATF_TC(wait4);
@@ -126,9 +119,8 @@
        /* wait4() (and friends) with WNOHANG and no children does not error */
        atf_tc_expect_fail("PR standards/51606");
 #endif
-       errno = 0;
-       ATF_REQUIRE(wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD,
+           wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1);
 }
 
 ATF_TC(wait6);
@@ -145,9 +137,8 @@
        /* wait4() (and friends) with WNOHANG and no children does not error */
        atf_tc_expect_fail("PR standards/51606");
 #endif
-       errno = 0;
-       ATF_REQUIRE(wait6(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION, NULL, NULL) == -1);
-       ATF_REQUIRE(errno == ECHILD);
+       ATF_REQUIRE_ERRNO(ECHILD,
+           wait6(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION, NULL, NULL) == -1);
 }
 
 ATF_TP_ADD_TCS(tp)



Home | Main Index | Thread Index | Old Index