Source-Changes-HG archive

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

[src/trunk]: src/tests/kernel Test that fpu state is preserved by fork.



details:   https://anonhg.NetBSD.org/src/rev/bb327ad3cb6a
branches:  trunk
changeset: 969190:bb327ad3cb6a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Feb 11 03:15:10 2020 +0000

description:
Test that fpu state is preserved by fork.

diffstat:

 distrib/sets/lists/tests/mi |   4 ++-
 tests/kernel/Makefile       |   4 ++-
 tests/kernel/h_fpufork.c    |  64 +++++++++++++++++++++++++++++++++++++++++++++
 tests/kernel/t_fpufork.sh   |  41 ++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 2 deletions(-)

diffs (163 lines):

diff -r 3aa9183ff7b9 -r bb327ad3cb6a distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Feb 11 03:14:49 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Feb 11 03:15:10 2020 +0000
@@ -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
diff -r 3aa9183ff7b9 -r bb327ad3cb6a tests/kernel/Makefile
--- a/tests/kernel/Makefile     Tue Feb 11 03:14:49 2020 +0000
+++ b/tests/kernel/Makefile     Tue Feb 11 03:15:10 2020 +0000
@@ -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_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_strings2
 PROGS+=                h_segv
 PROGS+=                h_getprocpath
+PROGS+=                h_fpufork
 
 SCRIPTSDIR=    ${TESTSDIR}
 SCRIPTS=       h_interpreter.sh
diff -r 3aa9183ff7b9 -r bb327ad3cb6a tests/kernel/h_fpufork.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/h_fpufork.c  Tue Feb 11 03:15:10 2020 +0000
@@ -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);
+}
diff -r 3aa9183ff7b9 -r bb327ad3cb6a tests/kernel/t_fpufork.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_fpufork.sh Tue Feb 11 03:15:10 2020 +0000
@@ -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
+}



Home | Main Index | Thread Index | Old Index