Module Name: src Committed By: riastradh Date: Tue May 14 15:54:16 UTC 2024
Modified Files: src/tests/kernel: h_segv.c Log Message: tests/kernel/h_segv: Disable SIGFPE test on RISC-V. No floating-point exception traps on RISC-V. Also don't pass the result of divide-by-zero converted to integer to usleep. Although the floating-point result of divide-by-zero is well-defined by IEEE 754 (+/-infinity), the outcome of C conversion to integer is not. And while on some architectures this might return zero, on RISC-V it looks like it'll return all bits set. And as of PR 58184, usleep now honours sleeps longer than 1sec, which means this will be waiting at least two billion microseconds, or about half an hour... So instead, just write the result to a volatile variable. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/kernel/h_segv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/kernel/h_segv.c diff -u src/tests/kernel/h_segv.c:1.14 src/tests/kernel/h_segv.c:1.15 --- src/tests/kernel/h_segv.c:1.14 Thu Apr 25 19:37:09 2019 +++ src/tests/kernel/h_segv.c Tue May 14 15:54:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: h_segv.c,v 1.14 2019/04/25 19:37:09 kamil Exp $ */ +/* $NetBSD: h_segv.c,v 1.15 2024/05/14 15:54:16 riastradh 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.14 2019/04/25 19:37:09 kamil Exp $"); +__RCSID("$NetBSD: h_segv.c,v 1.15 2024/05/14 15:54:16 riastradh Exp $"); #define __TEST_FENV @@ -121,10 +121,15 @@ check_fpe(void) printf("FPU does not implement traps on FP exceptions\n"); exit(EXIT_FAILURE); } +#elif defined __riscv__ + printf("RISC-V does not support floating-point exception traps\n"); + exit(EXIT_FAILURE); #endif exit(EXIT_SUCCESS); } +volatile int ignore_result; + static void trigger_fpe(void) { @@ -135,7 +140,13 @@ trigger_fpe(void) feenableexcept(FE_ALL_EXCEPT); #endif - usleep((int)(a/b)); + /* + * Try to trigger SIGFPE either by dividing by zero (which is + * defined to raise FE_DIVBYZERO, but may just return infinity + * without trapping the exception) or by converting infinity to + * integer. + */ + ignore_result = (int)(a/b); } static void