Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel Some arm CPUs do not implement traps on floatin...
details: https://anonhg.NetBSD.org/src/rev/6ab806c4dd03
branches: trunk
changeset: 448204:6ab806c4dd03
user: martin <martin%NetBSD.org@localhost>
date: Sat Jan 26 16:44:30 2019 +0000
description:
Some arm CPUs do not implement traps on floating point exceptions.
diffstat:
tests/kernel/h_segv.c | 35 +++++++++++++++++++++++++++++++----
tests/kernel/t_trapsignal.sh | 20 +++++++++++++++++++-
2 files changed, 50 insertions(+), 5 deletions(-)
diffs (167 lines):
diff -r e0d6cdced010 -r 6ab806c4dd03 tests/kernel/h_segv.c
--- a/tests/kernel/h_segv.c Sat Jan 26 15:46:27 2019 +0000
+++ b/tests/kernel/h_segv.c Sat Jan 26 16:44:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_segv.c,v 1.10 2018/11/12 05:02:00 riastradh Exp $ */
+/* $NetBSD: h_segv.c,v 1.11 2019/01/26 16:44:30 martin Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: h_segv.c,v 1.10 2018/11/12 05:02:00 riastradh Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.11 2019/01/26 16:44:30 martin Exp $");
#define __TEST_FENV
@@ -39,6 +39,7 @@
#include <err.h>
#include <fenv.h>
+#include <ieeefp.h> /* only need for ARM Cortex/Neon hack */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -50,6 +51,7 @@
#define F_HANDLE 2
#define F_MASK 4
#define F_IGNORE 8
+#define F_CHECK 16
static struct {
const char *n;
@@ -58,7 +60,8 @@
{ "recurse", F_RECURSE },
{ "handle", F_HANDLE },
{ "mask", F_MASK },
- { "ignore", F_IGNORE }
+ { "ignore", F_IGNORE },
+ { "check", F_CHECK }
};
static int sig;
@@ -104,6 +107,23 @@
}
static void
+check_fpe(void)
+{
+#if (__arm__ && !__SOFTFP__) || __aarch64__
+ /*
+ * Some NEON fpus do not implement IEEE exception handling,
+ * skip these tests if running on them and compiled for
+ * hard float.
+ */
+ if (0 == fpsetmask(fpsetmask(FP_X_INV))) {
+ printf("FPU does not implement exception handling\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ exit(EXIT_SUCCESS);
+}
+
+static void
trigger_fpe(void)
{
volatile double a = getpid();
@@ -185,7 +205,7 @@
const char *pname = getprogname();
fprintf(stderr, "Usage: %s segv|trap|ill|fpe|bus "
- "[recurse|mask|handle|ignore] ...\n", pname);
+ "[recurse|mask|handle|ignore|check] ...\n", pname);
exit(EXIT_FAILURE);
}
@@ -221,6 +241,13 @@
if (flags == 0 || sig == 0)
usage();
+ if (flags & F_CHECK && sig != SIGFPE) {
+ fprintf(stderr, "can only check for fpe support\n");
+ return 1;
+ }
+ if (flags & F_CHECK)
+ check_fpe();
+
if (flags & F_HANDLE) {
struct sigaction sa;
diff -r e0d6cdced010 -r 6ab806c4dd03 tests/kernel/t_trapsignal.sh
--- a/tests/kernel/t_trapsignal.sh Sat Jan 26 15:46:27 2019 +0000
+++ b/tests/kernel/t_trapsignal.sh Sat Jan 26 16:44:30 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_trapsignal.sh,v 1.4 2018/05/27 17:04:45 kamil Exp $
+# $NetBSD: t_trapsignal.sh,v 1.5 2019/01/26 16:44:30 martin Exp $
#
# Copyright (c) 2017 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -172,6 +172,18 @@
# SIGFPE
+fpe_available()
+{
+ if ${HELPER} fpe check > msg.$$
+ then
+ rm -f msg.$$
+ else
+ msg=$( cat msg.$$ )
+ rm -f msg.$$
+ atf_skip "$msg"
+ fi
+}
+
atf_test_case fpe_simple
fpe_simple()
{
@@ -179,6 +191,7 @@
}
fpe_simple_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe recurse
}
@@ -190,6 +203,7 @@
}
fpe_handle_body()
{
+ fpe_available
atf_check -s exit:0 -o "inline:" -e "inline:got 8\n" \
${HELPER} fpe handle
}
@@ -201,6 +215,7 @@
}
fpe_mask_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe mask
}
@@ -212,6 +227,7 @@
}
fpe_handle_mask_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe mask handle
}
@@ -224,6 +240,7 @@
fpe_handle_recurse_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:got 8\n" \
${HELPER} fpe handle recurse
}
@@ -236,6 +253,7 @@
fpe_ignore_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe ignore
}
Home |
Main Index |
Thread Index |
Old Index