Module Name: src Committed By: kamil Date: Sun Nov 6 15:03:31 UTC 2016
Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi Added Files: src/tests/lib/libc/sys: t_wait_noproc.c t_wait_noproc_wnohang.c Log Message: Add new tests: tests/lib/libc/sys/t_wait_noproc and t_wait_noproc_wnohang The t_wait_noproc test checks whether wait(2)-family of functions return error and set ECHILD for lack of childs. The t_wait_noproc_wnohang adds to options (except wait(2), wait3(2)) new parameter WNOHANG and verifies that error is still signaled and errno set to ECHILD. Currently t_wait_noproc_wnohang reports failures, these have been marked as expected and referenced to PR standards/51606. The problem report is authored by Robert Elz, and the initial regression has been notified by Nicolas Joly. Remove redundant test in tests/lib/libc/sys/t_wait for wait6(2) with no WNOHANG specified. Sponsored by <The NetBSD Foundation>. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.692 -r1.693 src/distrib/sets/lists/tests/mi cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_wait_noproc.c \ src/tests/lib/libc/sys/t_wait_noproc_wnohang.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.170 src/distrib/sets/lists/debug/mi:1.171 --- src/distrib/sets/lists/debug/mi:1.170 Wed Nov 2 12:51:22 2016 +++ src/distrib/sets/lists/debug/mi Sun Nov 6 15:03:30 2016 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.170 2016/11/02 12:51:22 kamil Exp $ +# $NetBSD: mi,v 1.171 2016/11/06 15:03:30 kamil Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -2063,6 +2063,8 @@ ./usr/libdata/debug/usr/tests/lib/libc/sys/t_umask.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libc/sys/t_unlink.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait.debug tests-lib-debug debug,atf,compattestfile +./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc.debug tests-lib-debug debug,atf,compattestfile +./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc_wnohang.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libc/sys/t_write.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libc/t_cdb.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libc/t_cerror.debug tests-obsolete obsolete,compattestfile Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.692 src/distrib/sets/lists/tests/mi:1.693 --- src/distrib/sets/lists/tests/mi:1.692 Sun Nov 6 10:54:42 2016 +++ src/distrib/sets/lists/tests/mi Sun Nov 6 15:03:30 2016 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.692 2016/11/06 10:54:42 alnsn Exp $ +# $NetBSD: mi,v 1.693 2016/11/06 15:03:30 kamil Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2735,6 +2735,8 @@ ./usr/tests/lib/libc/sys/t_umask tests-lib-tests compattestfile,atf ./usr/tests/lib/libc/sys/t_unlink tests-lib-tests compattestfile,atf ./usr/tests/lib/libc/sys/t_wait tests-lib-tests compattestfile,atf +./usr/tests/lib/libc/sys/t_wait_noproc tests-lib-tests compattestfile,atf +./usr/tests/lib/libc/sys/t_wait_noproc_wnohang tests-lib-tests compattestfile,atf ./usr/tests/lib/libc/sys/t_write tests-lib-tests compattestfile,atf ./usr/tests/lib/libc/t_atexit tests-obsolete obsolete ./usr/tests/lib/libc/t_cdb tests-lib-tests compattestfile,atf Added files: Index: src/tests/lib/libc/sys/t_wait_noproc.c diff -u /dev/null src/tests/lib/libc/sys/t_wait_noproc.c:1.1 --- /dev/null Sun Nov 6 15:03:31 2016 +++ src/tests/lib/libc/sys/t_wait_noproc.c Sun Nov 6 15:03:30 2016 @@ -0,0 +1,166 @@ +/* $NetBSD: t_wait_noproc.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__RCSID("$NetBSD: t_wait_noproc.c,v 1.1 2016/11/06 15:03:30 kamil Exp $"); + +#include <sys/wait.h> +#include <sys/resource.h> + +#include <errno.h> + +#include <atf-c.h> + +#ifndef TWAIT_OPTION +#define TWAIT_OPTION 0 +#endif + +#if TWAIT_OPTION == 0 +ATF_TC(wait); +ATF_TC_HEAD(wait, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait(2) returns ECHILD for no child"); +} + +ATF_TC_BODY(wait, tc) +{ + errno = 0; + ATF_REQUIRE(wait(NULL) == -1); + ATF_REQUIRE(errno == ECHILD); +} +#endif + +ATF_TC(waitpid); +ATF_TC_HEAD(waitpid, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitpid(2) returns ECHILD for WAIT_ANY and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(waitpid, tc) +{ +#if TWAIT_OPTION + /* 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_TC(waitid); +ATF_TC_HEAD(waitid, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitid(2) returns ECHILD for P_ALL and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(waitid, tc) +{ +#if TWAIT_OPTION + /* 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); +} + +#if TWAIT_OPTION == 0 +ATF_TC(wait3); +ATF_TC_HEAD(wait3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait3(2) returns ECHILD for no child"); +} + +ATF_TC_BODY(wait3, tc) +{ + errno = 0; + ATF_REQUIRE(wait3(NULL, 0, NULL) == -1); + ATF_REQUIRE(errno == ECHILD); +} +#endif + +ATF_TC(wait4); +ATF_TC_HEAD(wait4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait4, tc) +{ +#if TWAIT_OPTION + /* 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_TC(wait6); +ATF_TC_HEAD(wait6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait6(2) returns ECHILD for P_ALL and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait6, tc) +{ +#if TWAIT_OPTION + /* 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_TP_ADD_TCS(tp) +{ + +#if TWAIT_OPTION == 0 + ATF_TP_ADD_TC(tp, wait); +#endif + ATF_TP_ADD_TC(tp, waitpid); + ATF_TP_ADD_TC(tp, waitid); +#if TWAIT_OPTION == 0 + ATF_TP_ADD_TC(tp, wait3); +#endif + ATF_TP_ADD_TC(tp, wait4); + ATF_TP_ADD_TC(tp, wait6); + + return atf_no_error(); +} Index: src/tests/lib/libc/sys/t_wait_noproc_wnohang.c diff -u /dev/null src/tests/lib/libc/sys/t_wait_noproc_wnohang.c:1.1 --- /dev/null Sun Nov 6 15:03:31 2016 +++ src/tests/lib/libc/sys/t_wait_noproc_wnohang.c Sun Nov 6 15:03:30 2016 @@ -0,0 +1,30 @@ +/* $NetBSD: t_wait_noproc_wnohang.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#define TWAIT_OPTION WNOHANG +#include "t_wait_noproc.c"