Source-Changes-HG archive

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

[src/trunk]: src Move the pipe(2) test to the right place.



details:   https://anonhg.NetBSD.org/src/rev/10abdfa360ab
branches:  trunk
changeset: 770376:10abdfa360ab
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sat Oct 15 06:17:02 2011 +0000

description:
Move the pipe(2) test to the right place.

diffstat:

 distrib/sets/lists/tests/mi |    8 +-
 tests/kernel/Makefile       |    3 +-
 tests/kernel/t_pipe.c       |  160 -------------------------------------------
 tests/lib/libc/sys/Makefile |    3 +-
 tests/lib/libc/sys/t_pipe.c |  162 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 170 insertions(+), 166 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r 318048ed9af5 -r 10abdfa360ab distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Oct 15 06:10:26 2011 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Oct 15 06:17:02 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.402 2011/10/15 06:10:26 jruoho Exp $
+# $NetBSD: mi,v 1.403 2011/10/15 06:17:02 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -325,7 +325,7 @@
 ./usr/libdata/debug/usr/tests/kernel/t_lock.debug                      tests-kernel-tests      debug,atf
 ./usr/libdata/debug/usr/tests/kernel/t_lwpctl.debug                    tests-kernel-tests      debug,atf
 ./usr/libdata/debug/usr/tests/kernel/t_mkdir.debug                     tests-kernel-tests      debug,atf
-./usr/libdata/debug/usr/tests/kernel/t_pipe.debug                      tests-kernel-tests      debug,atf
+./usr/libdata/debug/usr/tests/kernel/t_pipe.debug                      tests-obsolete          obsolete
 ./usr/libdata/debug/usr/tests/kernel/t_poll3w.debug                    tests-kernel-tests      debug,atf
 ./usr/libdata/debug/usr/tests/kernel/t_pollts.debug                    tests-obsolete          obsolete
 ./usr/libdata/debug/usr/tests/kernel/t_posix_fadvise.debug             tests-obsolete          obsolete
@@ -510,6 +510,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_mprotect.debug            tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_msync.debug               tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_nanosleep.debug           tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_pipe.debug                        tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_poll.debug                        tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_posix_fadvise.debug       tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_revoke.debug              tests-lib-debug         debug,atf
@@ -1849,7 +1850,7 @@
 ./usr/tests/kernel/t_lock                      tests-kernel-tests              atf
 ./usr/tests/kernel/t_lwpctl                    tests-kernel-tests              atf
 ./usr/tests/kernel/t_mkdir                     tests-kernel-tests              atf
-./usr/tests/kernel/t_pipe                      tests-kernel-tests              atf
+./usr/tests/kernel/t_pipe                      tests-obsolete                  obsolete
 ./usr/tests/kernel/t_poll3w                    tests-kernel-tests              atf
 ./usr/tests/kernel/t_pollts                    tests-obsolete                  obsolete
 ./usr/tests/kernel/t_posix_fadvise             tests-obsolete                  obsolete
@@ -2123,6 +2124,7 @@
 ./usr/tests/lib/libc/sys/t_mprotect            tests-lib-tests         atf
 ./usr/tests/lib/libc/sys/t_msync               tests-lib-tests         atf
 ./usr/tests/lib/libc/sys/t_nanosleep           tests-lib-tests         atf
+./usr/tests/lib/libc/sys/t_pipe                        tests-lib-tests         atf
 ./usr/tests/lib/libc/sys/t_poll                        tests-lib-tests         atf
 ./usr/tests/lib/libc/sys/t_posix_fadvise       tests-lib-tests         atf
 ./usr/tests/lib/libc/sys/t_revoke              tests-lib-tests         atf
diff -r 318048ed9af5 -r 10abdfa360ab tests/kernel/Makefile
--- a/tests/kernel/Makefile     Sat Oct 15 06:10:26 2011 +0000
+++ b/tests/kernel/Makefile     Sat Oct 15 06:17:02 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2011/10/15 06:10:26 jruoho Exp $
+# $NetBSD: Makefile,v 1.15 2011/10/15 06:17:02 jruoho Exp $
 
 NOMAN=         # defined
 
@@ -11,7 +11,6 @@
 TESTS_C=       t_lock
 TESTS_C+=      t_lwpctl
 TESTS_C+=      t_mkdir
-TESTS_C+=      t_pipe
 TESTS_C+=      t_poll3w
 TESTS_C+=      t_pty
 TESTS_C+=      t_rnd
diff -r 318048ed9af5 -r 10abdfa360ab tests/kernel/t_pipe.c
--- a/tests/kernel/t_pipe.c     Sat Oct 15 06:10:26 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-/* $NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */
-
-/*-
- * Copyright (c) 2001, 2008 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>
-__COPYRIGHT("@(#) Copyright (c) 2008\
- The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $");
-
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <errno.h>
-#include <poll.h>
-#include <sched.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <atf-c.h>
-
-#include "../h_macros.h"
-
-static pid_t pid;
-static int nsiginfo = 0;
-
-/*
- * This is used for both parent and child. Handle parent's SIGALRM,
- * the childs SIGINFO doesn't need anything.
- */
-static void
-sighand(int sig)
-{
-       if (sig == SIGALRM) {
-               kill(pid, SIGINFO);
-       }
-       if (sig == SIGINFO) {
-               nsiginfo++;
-       }
-}
-
-ATF_TC(pipe);
-ATF_TC_HEAD(pipe, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Checks that writing to pipe "
-           "works correctly after being interrupted and restarted "
-           "(kern/14087)");
-}
-ATF_TC_BODY(pipe, tc)
-{
-       int pp[2], st;
-       ssize_t sz, todo, done;
-       char *f;
-       sigset_t asigset, osigset, emptysigset;
-
-       /* Initialise signal masks */
-       RL(sigemptyset(&emptysigset));
-       RL(sigemptyset(&asigset));
-       RL(sigaddset(&asigset, SIGINFO));
-
-       /* Register signal handlers for both read and writer */
-       REQUIRE_LIBC(signal(SIGINFO, sighand), SIG_ERR);
-       REQUIRE_LIBC(signal(SIGALRM, sighand), SIG_ERR);
-
-       todo = 2 * 1024 * 1024;
-       REQUIRE_LIBC(f = malloc(todo), NULL);
-
-       RL(pipe(pp));
-
-       RL(pid = fork());
-       if (pid == 0) {
-               /* child */
-               RL(close(pp[1]));
-
-               /* Do inital write. This should succeed, make
-                * the other side do partial write and wait for us to pick
-                * rest up.
-                */
-               RL(done = read(pp[0], f, 128 * 1024));
-
-               /* Wait until parent is alarmed and awakens us */
-               RL(sigprocmask(SIG_BLOCK, &asigset, &osigset));
-               while (nsiginfo == 0) {
-                       if (sigsuspend(&emptysigset) != -1 || errno != EINTR)
-                               atf_tc_fail("sigsuspend(&emptysigset): %s", strerror(errno));
-               }
-               RL(sigprocmask(SIG_SETMASK, &osigset, NULL));
-
-               /* Read all what parent wants to give us */
-               while((sz = read(pp[0], f, 1024 * 1024)) > 0)
-                       done += sz;
-
-               /*
-                * Exit with 1 if number of bytes read doesn't match
-                * number of expected bytes
-                */
-               printf("Read:     %#zx\n", (size_t)done);
-               printf("Expected: %#zx\n", (size_t)todo);
-
-               exit(done != todo);
-
-               /* NOTREACHED */
-       } else {
-               RL(close(pp[0]));
-
-               /*
-                * Arrange for alarm after two seconds. Since we have
-                * handler setup for SIGARLM, the write(2) call should
-                * be restarted internally by kernel.
-                */
-               (void)alarm(2);
-
-               /* We write exactly 'todo' bytes. The very first write(2)
-                * should partially succeed, block and eventually
-                * be restarted by kernel
-                */
-               while(todo > 0 && ((sz = write(pp[1], f, todo)) > 0))
-                       todo -= sz;
-
-               /* Close the pipe, so that child would stop reading */
-               RL(close(pp[1]));
-
-               /* And pickup child's exit status */
-               RL(waitpid(pid, &st, 0));
-
-               ATF_REQUIRE_EQ(WEXITSTATUS(st), 0);
-       }
-}
-
-ATF_TP_ADD_TCS(tp)
-{
-       ATF_TP_ADD_TC(tp, pipe);
-
-       return atf_no_error();
-}
diff -r 318048ed9af5 -r 10abdfa360ab tests/lib/libc/sys/Makefile
--- a/tests/lib/libc/sys/Makefile       Sat Oct 15 06:10:26 2011 +0000
+++ b/tests/lib/libc/sys/Makefile       Sat Oct 15 06:17:02 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2011/10/15 06:10:26 jruoho Exp $
+# $NetBSD: Makefile,v 1.11 2011/10/15 06:17:02 jruoho Exp $
 
 MKMAN= no
 
@@ -31,6 +31,7 @@
 TESTS_C+=              t_mprotect
 TESTS_C+=              t_msync
 TESTS_C+=              t_nanosleep
+TESTS_C+=              t_pipe
 TESTS_C+=              t_posix_fadvise
 TESTS_C+=              t_poll
 TESTS_C+=              t_revoke
diff -r 318048ed9af5 -r 10abdfa360ab tests/lib/libc/sys/t_pipe.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/sys/t_pipe.c       Sat Oct 15 06:17:02 2011 +0000
@@ -0,0 +1,162 @@
+/* $NetBSD: t_pipe.c,v 1.1 2011/10/15 06:17:02 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2001, 2008 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>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_pipe.c,v 1.1 2011/10/15 06:17:02 jruoho Exp $");
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <poll.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "../../../h_macros.h"
+
+static pid_t pid;
+static int nsiginfo = 0;
+
+/*
+ * This is used for both parent and child. Handle parent's SIGALRM,
+ * the childs SIGINFO doesn't need anything.
+ */



Home | Main Index | Thread Index | Old Index