summaryrefslogtreecommitdiff
path: root/tests/kernel
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2012-02-13 21:03:06 +0000
committermartin <martin@NetBSD.org>2012-02-13 21:03:06 +0000
commit9633fa7dfa38eddf2f5dc7576c5f82aaa7701d82 (patch)
treee0f221777f8913ffdaf568355636d99759cc2488 /tests/kernel
parent3eda5a4b313259e16bd6ffbf6c32441612c81a40 (diff)
Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests themselfs. Ok: releng
Diffstat (limited to 'tests/kernel')
-rw-r--r--tests/kernel/Makefile4
-rw-r--r--tests/kernel/posix_spawn/Makefile28
-rw-r--r--tests/kernel/posix_spawn/Makefile.inc1
-rw-r--r--tests/kernel/posix_spawn/h_fileactions.c104
-rw-r--r--tests/kernel/posix_spawn/h_nonexec.sh3
-rw-r--r--tests/kernel/posix_spawn/h_spawn.c50
-rw-r--r--tests/kernel/posix_spawn/h_spawnattr.c90
-rw-r--r--tests/kernel/posix_spawn/t_fileactions.c92
-rw-r--r--tests/kernel/posix_spawn/t_spawn.c184
-rw-r--r--tests/kernel/posix_spawn/t_spawnattr.c173
10 files changed, 2 insertions, 727 deletions
diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile
index 081008fd920..579afbaca22 100644
--- a/tests/kernel/Makefile
+++ b/tests/kernel/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.23 2012/02/11 23:31:24 martin Exp $
+# $NetBSD: Makefile,v 1.24 2012/02/13 21:03:06 martin Exp $
NOMAN= # defined
@@ -6,7 +6,7 @@ NOMAN= # defined
TESTSDIR= ${TESTSBASE}/kernel
-TESTS_SUBDIRS= posix_spawn kqueue tty
+TESTS_SUBDIRS= kqueue tty
TESTS_C= t_lock
TESTS_C+= t_lwpctl
diff --git a/tests/kernel/posix_spawn/Makefile b/tests/kernel/posix_spawn/Makefile
deleted file mode 100644
index 1e6e29e7fb3..00000000000
--- a/tests/kernel/posix_spawn/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-# $NetBSD: Makefile,v 1.1 2012/02/11 23:31:24 martin Exp $
-
-NOMAN= # defined
-
-.include <bsd.own.mk>
-
-TESTSDIR= ${TESTSBASE}/kernel/posix_spawn
-
-TESTS_C= t_spawn
-TESTS_C+= t_fileactions
-TESTS_C+= t_spawnattr
-
-BINDIR= ${TESTSDIR}
-SCRIPTSDIR= ${TESTSDIR}
-
-PROGS= h_fileactions
-PROGS+= h_spawn
-PROGS+= h_spawnattr
-SCRIPTS= h_nonexec h_zero
-
-h_zero:
- dd if=/dev/zero of=h_zero bs=1k count=2
- chmod a+x h_zero
-
-CLEANFILES+= h_nonexec h_zero
-
-.include <bsd.test.mk>
-
diff --git a/tests/kernel/posix_spawn/Makefile.inc b/tests/kernel/posix_spawn/Makefile.inc
deleted file mode 100644
index 01b5f23410c..00000000000
--- a/tests/kernel/posix_spawn/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-.include "../Makefile.inc"
diff --git a/tests/kernel/posix_spawn/h_fileactions.c b/tests/kernel/posix_spawn/h_fileactions.c
deleted file mode 100644
index 1cf2182680d..00000000000
--- a/tests/kernel/posix_spawn/h_fileactions.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* $NetBSD: h_fileactions.c,v 1.1 2012/02/11 23:31:24 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-#define BUFSIZE 16
-
-/*
- * This checks (hardcoded) the assumptions that are setup from the
- * main test program via posix spawn file actions.
- * Program exits with EXIT_SUCCESS or EXIT_FAILURE accordingly
- * (and does some stderr diagnostics in case of errors).
- */
-int
-main(int argc, char **argv)
-{
- int res = EXIT_SUCCESS;
- char buf[BUFSIZE];
- struct stat sb0, sb1;
-
- strcpy(buf, "test...");
- /* file desc 3 should be closed via addclose */
- if (read(3, buf, BUFSIZE) != -1 || errno != EBADF) {
- fprintf(stderr, "%s: filedesc 3 is not closed\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- /* file desc 4 should be closed via closeonexec */
- if (read(4, buf, BUFSIZE) != -1 || errno != EBADF) {
- fprintf(stderr, "%s: filedesc 4 is not closed\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- /* file desc 5 remains open */
- if (write(5, buf, BUFSIZE) <= 0) {
- fprintf(stderr, "%s: could not write to filedesc 5\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- /* file desc 6 should be open (via addopen) */
- if (write(6, buf, BUFSIZE) <= 0) {
- fprintf(stderr, "%s: could not write to filedesc 6\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- /* file desc 7 should refer to stdout */
- fflush(stdout);
- if (fstat(fileno(stdout), &sb0) != 0) {
- fprintf(stderr, "%s: could not fstat stdout\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- if (fstat(7, &sb1) != 0) {
- fprintf(stderr, "%s: could not fstat filedesc 7\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- if (write(7, buf, strlen(buf)) <= 0) {
- fprintf(stderr, "%s: could not write to filedesc 7\n",
- getprogname());
- res = EXIT_FAILURE;
- }
- if (memcmp(&sb0, &sb1, sizeof sb0) != 0) {
- fprintf(stderr, "%s: stat results differ\n", getprogname());
- res = EXIT_FAILURE;
- }
-
- return res;
-}
-
diff --git a/tests/kernel/posix_spawn/h_nonexec.sh b/tests/kernel/posix_spawn/h_nonexec.sh
deleted file mode 100644
index deee6fe720f..00000000000
--- a/tests/kernel/posix_spawn/h_nonexec.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /nonexistent
-
-# this is just a dummy script, trying to be non-executable
diff --git a/tests/kernel/posix_spawn/h_spawn.c b/tests/kernel/posix_spawn/h_spawn.c
deleted file mode 100644
index 0e2c6c03794..00000000000
--- a/tests/kernel/posix_spawn/h_spawn.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: h_spawn.c,v 1.1 2012/02/11 23:31:24 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char **argv)
-{
- unsigned long ret;
- char *endp;
-
- if (argc < 2) {
- fprintf(stderr, "usage:\n\t%s (retcode)\n", getprogname());
- exit(255);
- }
- ret = strtoul(argv[1], &endp, 10);
-
- fprintf(stderr, "%s exiting with status %lu\n", getprogname(), ret);
- return ret;
-}
diff --git a/tests/kernel/posix_spawn/h_spawnattr.c b/tests/kernel/posix_spawn/h_spawnattr.c
deleted file mode 100644
index 67c1820f95b..00000000000
--- a/tests/kernel/posix_spawn/h_spawnattr.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $NetBSD: h_spawnattr.c,v 1.1 2012/02/11 23:31:25 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-
-/*
- * Helper to test the hardcoded assumptions from t_spawnattr.c
- * Exit with apropriate exit status and print diagnostics to
- * stderr explaining what is wrong.
- */
-int
-main(int argc, char **argv)
-{
- int parent_pipe, res = EXIT_SUCCESS;
- sigset_t sig;
- struct sigaction act;
- ssize_t rd;
- char tmp;
-
- sigemptyset(&sig);
- if (sigprocmask(0, NULL, &sig) < 0) {
- fprintf(stderr, "%s: sigprocmask error\n", getprogname());
- res = EXIT_FAILURE;
- }
- if (!sigismember(&sig, SIGUSR1)) {
- fprintf(stderr, "%s: SIGUSR not in procmask\n", getprogname());
- res = EXIT_FAILURE;
- }
- if (sigaction(SIGUSR1, NULL, &act) < 0) {
- fprintf(stderr, "%s: sigaction error\n", getprogname());
- res = EXIT_FAILURE;
- }
- if (act.sa_sigaction != (void *)SIG_DFL) {
- fprintf(stderr, "%s: SIGUSR1 action != SIG_DFL\n",
- getprogname());
- res = EXIT_FAILURE;
- }
-
- if (argc >= 2) {
- parent_pipe = atoi(argv[1]);
- if (parent_pipe > 2) {
- printf("%s: waiting for command from parent on pipe "
- "%d\n", getprogname(), parent_pipe);
- rd = read(parent_pipe, &tmp, 1);
- if (rd == 1) {
- printf("%s: got command %c from parent\n",
- getprogname(), tmp);
- } else if (rd == -1) {
- printf("%s: %d is no pipe, errno %d\n",
- getprogname(), parent_pipe, errno);
- res = EXIT_FAILURE;
- }
- }
- }
-
- return res;
-}
diff --git a/tests/kernel/posix_spawn/t_fileactions.c b/tests/kernel/posix_spawn/t_fileactions.c
deleted file mode 100644
index d038928df26..00000000000
--- a/tests/kernel/posix_spawn/t_fileactions.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* $NetBSD: t_fileactions.c,v 1.1 2012/02/11 23:31:25 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <atf-c.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <spawn.h>
-#include <unistd.h>
-#include <sys/wait.h>
-
-ATF_TC(t_spawn_fileactions);
-
-ATF_TC_HEAD(t_spawn_fileactions, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Tests posix_spawn with fileactions");
-}
-
-ATF_TC_BODY(t_spawn_fileactions, tc)
-{
- int fd1, fd2, fd3, status, err;
- pid_t pid;
- char * const args[2] = { __UNCONST("h_fileactions"), NULL };
- char helper[FILENAME_MAX];
- posix_spawn_file_actions_t fa;
-
- posix_spawn_file_actions_init(&fa);
-
- closefrom(fileno(stderr)+1);
-
- fd1 = open("/dev/null", O_RDONLY);
- ATF_REQUIRE(fd1 == 3);
-
- fd2 = open("/dev/null", O_WRONLY, O_CLOEXEC);
- ATF_REQUIRE(fd2 == 4);
-
- fd3 = open("/dev/null", O_WRONLY);
- ATF_REQUIRE(fd3 == 5);
-
- posix_spawn_file_actions_addclose(&fa, fd1);
- posix_spawn_file_actions_addopen(&fa, 6, "/dev/null", O_RDWR, 0);
- posix_spawn_file_actions_adddup2(&fa, 1, 7);
-
- snprintf(helper, sizeof helper, "%s/h_fileactions",
- atf_tc_get_config_var(tc, "srcdir"));
- err = posix_spawn(&pid, helper, &fa, NULL, args, NULL);
- ATF_REQUIRE(err == 0);
-
- waitpid(pid, &status, 0);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS);
-
- posix_spawn_file_actions_destroy(&fa);
-}
-
-ATF_TP_ADD_TCS(tp)
-{
- ATF_TP_ADD_TC(tp, t_spawn_fileactions);
-
- return atf_no_error();
-}
diff --git a/tests/kernel/posix_spawn/t_spawn.c b/tests/kernel/posix_spawn/t_spawn.c
deleted file mode 100644
index e465c453a58..00000000000
--- a/tests/kernel/posix_spawn/t_spawn.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* $NetBSD: t_spawn.c,v 1.1 2012/02/11 23:31:25 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <atf-c.h>
-#include <spawn.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/wait.h>
-
-ATF_TC(t_spawn_ls);
-
-ATF_TC_HEAD(t_spawn_ls, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Tests a simple posix_spawn executing /bin/ls");
-}
-
-ATF_TC_BODY(t_spawn_ls, tc)
-{
- char * const args[] = { __UNCONST("ls"), __UNCONST("-la"), NULL };
- int err;
-
- err = posix_spawn(NULL, "/bin/ls", NULL, NULL, args, NULL);
- ATF_REQUIRE(err == 0);
-}
-
-ATF_TC(t_spawnp_ls);
-
-ATF_TC_HEAD(t_spawnp_ls, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Tests a simple posix_spawnp executing ls via $PATH");
-}
-
-ATF_TC_BODY(t_spawnp_ls, tc)
-{
- char * const args[] = { __UNCONST("ls"), __UNCONST("-la"), NULL };
- int err;
-
- err = posix_spawnp(NULL, "ls", NULL, NULL, args, NULL);
- ATF_REQUIRE(err == 0);
-}
-
-ATF_TC(t_spawn_zero);
-
-ATF_TC_HEAD(t_spawn_zero, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "posix_spawn an invalid binary");
-}
-
-ATF_TC_BODY(t_spawn_zero, tc)
-{
- char buf[FILENAME_MAX];
- char * const args[] = { __UNCONST("h_zero"), NULL };
- int err;
-
- snprintf(buf, sizeof buf, "%s/h_zero", atf_tc_get_config_var(tc, "srcdir"));
- err = posix_spawn(NULL, buf, NULL, NULL, args, NULL);
- ATF_REQUIRE_MSG(err == ENOEXEC, "expected error %d, got %d when spawning %s", ENOEXEC, err, buf);
-}
-
-ATF_TC(t_spawn_missing);
-
-ATF_TC_HEAD(t_spawn_missing, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "posix_spawn a non existant binary");
-}
-
-ATF_TC_BODY(t_spawn_missing, tc)
-{
- char buf[FILENAME_MAX];
- char * const args[] = { __UNCONST("h_nonexist"), NULL };
- int err;
-
- snprintf(buf, sizeof buf, "%s/h_nonexist",
- atf_tc_get_config_var(tc, "srcdir"));
- err = posix_spawn(NULL, buf, NULL, NULL, args, NULL);
- ATF_REQUIRE_MSG(err == ENOENT, "expected error %d, got %d when spawning %s", ENOENT, err, buf);
-}
-
-ATF_TC(t_spawn_nonexec);
-
-ATF_TC_HEAD(t_spawn_nonexec, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "posix_spawn a script with non existing interpreter");
-}
-
-ATF_TC_BODY(t_spawn_nonexec, tc)
-{
- char buf[FILENAME_MAX];
- char * const args[] = { __UNCONST("h_nonexec"), NULL };
- int err;
-
- snprintf(buf, sizeof buf, "%s/h_nonexec",
- atf_tc_get_config_var(tc, "srcdir"));
- err = posix_spawn(NULL, buf, NULL, NULL, args, NULL);
- ATF_REQUIRE_MSG(err == ENOENT, "expected error %d, got %d when spawning %s", ENOENT, err, buf);
-}
-
-ATF_TC(t_spawn_child);
-
-ATF_TC_HEAD(t_spawn_child, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "posix_spawn a child and get it's return code");
-}
-
-ATF_TC_BODY(t_spawn_child, tc)
-{
- char buf[FILENAME_MAX];
- char * const args0[] = { __UNCONST("h_spawn"), __UNCONST("0"), NULL };
- char * const args1[] = { __UNCONST("h_spawn"), __UNCONST("1"), NULL };
- char * const args7[] = { __UNCONST("h_spawn"), __UNCONST("7"), NULL };
- int err, status;
- pid_t pid;
-
- snprintf(buf, sizeof buf, "%s/h_spawn",
- atf_tc_get_config_var(tc, "srcdir"));
-
- err = posix_spawn(&pid, buf, NULL, NULL, args0, NULL);
- ATF_REQUIRE(err == 0);
- ATF_REQUIRE(pid > 0);
- waitpid(pid, &status, 0);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 0);
-
- err = posix_spawn(&pid, buf, NULL, NULL, args1, NULL);
- ATF_REQUIRE(err == 0);
- ATF_REQUIRE(pid > 0);
- waitpid(pid, &status, 0);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 1);
-
- err = posix_spawn(&pid, buf, NULL, NULL, args7, NULL);
- ATF_REQUIRE(err == 0);
- ATF_REQUIRE(pid > 0);
- waitpid(pid, &status, 0);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 7);
-}
-
-ATF_TP_ADD_TCS(tp)
-{
- ATF_TP_ADD_TC(tp, t_spawn_ls);
- ATF_TP_ADD_TC(tp, t_spawnp_ls);
- ATF_TP_ADD_TC(tp, t_spawn_zero);
- ATF_TP_ADD_TC(tp, t_spawn_missing);
- ATF_TP_ADD_TC(tp, t_spawn_nonexec);
- ATF_TP_ADD_TC(tp, t_spawn_child);
-
- return atf_no_error();
-}
diff --git a/tests/kernel/posix_spawn/t_spawnattr.c b/tests/kernel/posix_spawn/t_spawnattr.c
deleted file mode 100644
index 4bf5dacd70b..00000000000
--- a/tests/kernel/posix_spawn/t_spawnattr.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* $NetBSD: t_spawnattr.c,v 1.1 2012/02/11 23:31:25 martin Exp $ */
-
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles Zhang <charles@NetBSD.org> and
- * Martin Husemann <martin@NetBSD.org>.
- *
- * 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 <atf-c.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <signal.h>
-#include <spawn.h>
-#include <unistd.h>
-#include <sys/wait.h>
-
-#define MAX(a, b) (a) > (b) ? (a) : (b)
-#define MIN(a, b) (a) > (b) ? (b) : (a)
-
-static int get_different_scheduler(void);
-static int get_different_priority(void);
-
-static int
-get_different_scheduler()
-{
- int scheduler, max, min, new;
-
- max = MAX(MAX(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
- min = MIN(MIN(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
-
- /* get current schedule policy */
- scheduler = sched_getscheduler(0);
-
- /* new scheduler */
- new = (scheduler + 1);
- if (new > max)
- new = min;
-
- return new;
-}
-
-static int
-get_different_priority()
-{
- int scheduler, max, min, new, priority;
- struct sched_param param;
-
- /* get current schedule policy */
- scheduler = sched_getscheduler(0);
-
- max = sched_get_priority_max(scheduler);
- min = sched_get_priority_min(scheduler);
-
- sched_getparam(0, &param);
- priority = param.sched_priority;
-
- /* new schedule policy */
- new = (priority + 1);
- if (new > max)
- new = min;
-
- return new;
-}
-
-ATF_TC(t_spawnattr);
-
-ATF_TC_HEAD(t_spawnattr, tc)
-{
- atf_tc_set_md_var(tc, "require.user", "root");
- atf_tc_set_md_var(tc, "descr",
- "Tests posix_spawn with scheduler attributes");
-}
-
-ATF_TC_BODY(t_spawnattr, tc)
-{
- int pid, scheduler, child_scheduler, priority, status, err, pfd[2];
- char helper_arg[128];
- char * const args[] = { __UNCONST("h_spawnattr"), helper_arg, NULL };
- struct sched_param sp, child_sp;
- sigset_t sig;
- posix_spawnattr_t attr;
- char helper[FILENAME_MAX];
-
- /*
- * create a pipe to controll the child
- */
- err = pipe(pfd);
- ATF_REQUIRE_MSG(err == 0, "could not create pipe, errno %d", errno);
- sprintf(helper_arg, "%d", pfd[0]);
-
- posix_spawnattr_init(&attr);
-
- scheduler = get_different_scheduler();
- priority = get_different_priority();
- sp.sched_priority = priority;
-
- sigemptyset(&sig);
- sigaddset(&sig, SIGUSR1);
-
- posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSCHEDULER |
- POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETPGROUP |
- POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF |
- POSIX_SPAWN_SETSIGDEF);
- posix_spawnattr_setpgroup(&attr, 0);
- posix_spawnattr_setschedparam(&attr, &sp);
- posix_spawnattr_setschedpolicy(&attr, scheduler);
- posix_spawnattr_setsigmask(&attr, &sig);
- posix_spawnattr_setsigdefault(&attr, &sig);
-
- sprintf(helper, "%s/h_spawnattr",
- atf_tc_get_config_var(tc, "srcdir"));
- err = posix_spawn(&pid, helper, NULL, &attr, args, NULL);
- ATF_REQUIRE_MSG(err == 0, "error %d", err);
-
- child_scheduler = sched_getscheduler(pid);
- ATF_REQUIRE_MSG(scheduler == child_scheduler,
- "scheduler = %d, child_scheduler = %d, pid %d, errno %d",
- scheduler, child_scheduler, pid, errno);
-
- sched_getparam(pid, &child_sp);
- ATF_REQUIRE_MSG(child_sp.sched_priority == sp.sched_priority,
- "priority is: %d, but we requested: %d",
- child_sp.sched_priority, sp.sched_priority);
-
- ATF_REQUIRE_MSG(pid == getpgid(pid), "child pid: %d, child pgid: %d",
- pid, getpgid(pid));
-
- /* ready, let child go */
- write(pfd[1], "q", 1);
- close(pfd[0]);
- close(pfd[1]);
-
- /* wait and check result from child */
- waitpid(pid, &status, 0);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS);
-
- posix_spawnattr_destroy(&attr);
-}
-
-ATF_TP_ADD_TCS(tp)
-{
- ATF_TP_ADD_TC(tp, t_spawnattr);
-
- return atf_no_error();
-}