Module Name: src Committed By: riastradh Date: Tue Feb 11 03:15:10 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/tests/kernel: Makefile Added Files: src/tests/kernel: h_fpufork.c t_fpufork.sh Log Message: Test that fpu state is preserved by fork. To generate a diff of this commit: cvs rdiff -u -r1.828 -r1.829 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.64 -r1.65 src/tests/kernel/Makefile cvs rdiff -u -r0 -r1.1 src/tests/kernel/h_fpufork.c \ src/tests/kernel/t_fpufork.sh 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/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.828 src/distrib/sets/lists/tests/mi:1.829 --- src/distrib/sets/lists/tests/mi:1.828 Sat Jan 18 17:18:41 2020 +++ src/distrib/sets/lists/tests/mi Tue Feb 11 03:15:10 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.828 2020/01/18 17:18:41 kre Exp $ +# $NetBSD: mi,v 1.829 2020/02/11 03:15:10 riastradh Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2142,6 +2142,7 @@ ./usr/tests/kernel/arch/i386/t_ptrace_waitpid tests-obsolete obsolete ./usr/tests/kernel/arch/x86 tests-obsolete obsolete ./usr/tests/kernel/h_fexecve tests-kernel-tests compattestfile,atf +./usr/tests/kernel/h_fpufork tests-kernel-tests compattestfile,atf ./usr/tests/kernel/h_getprocpath tests-kernel-tests compattestfile,atf ./usr/tests/kernel/h_interpreter tests-kernel-tests compattestfile,atf ./usr/tests/kernel/h_ps_strings1 tests-kernel-tests compattestfile,atf @@ -2185,6 +2186,7 @@ ./usr/tests/kernel/t_fcntl tests-kernel-tests atf ./usr/tests/kernel/t_fexecve tests-kernel-tests atf ./usr/tests/kernel/t_filedesc tests-kernel-tests atf,rump +./usr/tests/kernel/t_fpufork tests-kernel-tests atf ./usr/tests/kernel/t_interp tests-kernel-tests atf ./usr/tests/kernel/t_kauth_pr_47598 tests-kernel-tests compattestfile,atf ./usr/tests/kernel/t_ksem tests-kernel-tests atf Index: src/tests/kernel/Makefile diff -u src/tests/kernel/Makefile:1.64 src/tests/kernel/Makefile:1.65 --- src/tests/kernel/Makefile:1.64 Sun Sep 29 23:45:00 2019 +++ src/tests/kernel/Makefile Tue Feb 11 03:15:10 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.64 2019/09/29 23:45:00 mrg Exp $ +# $NetBSD: Makefile,v 1.65 2020/02/11 03:15:10 riastradh Exp $ NOMAN= # defined @@ -29,6 +29,7 @@ TESTS_SH+= t_interp TESTS_SH+= t_origin TESTS_SH+= t_procpath TESTS_SH+= t_fexecve +TESTS_SH+= t_fpufork BINDIR= ${TESTSDIR} PROGS= h_fexecve @@ -36,6 +37,7 @@ PROGS+= h_ps_strings1 PROGS+= h_ps_strings2 PROGS+= h_segv PROGS+= h_getprocpath +PROGS+= h_fpufork SCRIPTSDIR= ${TESTSDIR} SCRIPTS= h_interpreter.sh Added files: Index: src/tests/kernel/h_fpufork.c diff -u /dev/null src/tests/kernel/h_fpufork.c:1.1 --- /dev/null Tue Feb 11 03:15:11 2020 +++ src/tests/kernel/h_fpufork.c Tue Feb 11 03:15:10 2020 @@ -0,0 +1,64 @@ +/* $NetBSD: h_fpufork.c,v 1.1 2020/02/11 03:15:10 riastradh Exp $ */ + +/*- + * Copyright (c) 2020 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: h_fpufork.c,v 1.1 2020/02/11 03:15:10 riastradh Exp $"); + +#include <sys/wait.h> + +#include <err.h> +#include <sched.h> +#include <stdio.h> +#include <unistd.h> + +int +main(void) +{ + pid_t child, pid; + volatile double x = 1; + register double y = 2*x; + int status; + + pid = fork(); + switch (pid) { + case -1: /* error */ + err(1, "fork"); + case 0: /* child */ + _exit(y == 2 ? 0 : 1); + default: /* parent */ + break; + } + + if ((child = wait(&status)) == -1) + err(1, "wait"); + if (WIFSIGNALED(status)) + errx(1, "child exited on signal %d", WTERMSIG(status)); + if (!WIFEXITED(status)) + errx(1, "child didn't exit"); + return WEXITSTATUS(status); +} Index: src/tests/kernel/t_fpufork.sh diff -u /dev/null src/tests/kernel/t_fpufork.sh:1.1 --- /dev/null Tue Feb 11 03:15:11 2020 +++ src/tests/kernel/t_fpufork.sh Tue Feb 11 03:15:10 2020 @@ -0,0 +1,41 @@ +# $NetBSD: t_fpufork.sh,v 1.1 2020/02/11 03:15:10 riastradh Exp $ +# +# Copyright (c) 2020 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. + +atf_test_case fpufork +fpufork_head() +{ + atf_set "descr" "Verify fork preserves fpu" +} +fpufork_body() +{ + atf_check -s exit:0 -o inline: -e inline: \ + $(atf_get_srcdir)/h_fpufork +} + +atf_init_test_cases() +{ + atf_add_test_case fpufork +}