Changes since v1:
- Added proc to check that fork() actually succeeds on target.
- Updated dg-require-fork to call the right check depending on dg-do.
- Droped change in gcc.misc-tests/gcov-pr86536.c
Ok for trunk?
--
For an arm-none-eabi toolchain, at least built with newlib, the fork()
function exist, but it returns failure. The implementation is part of
libnosys.a and is there only to allow linking (runtime failure).
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_fork_runtime): New function to
check that target has a working fork() implementation.
* lib/target-supports-dg.exp (dg-require-fork): When test is
"run", then call check_fork_runtime, else check_fork_available.
Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
gcc/testsuite/lib/target-supports-dg.exp | 12 +++++++---
gcc/testsuite/lib/target-supports.exp | 28 ++++++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/gcc/testsuite/lib/target-supports-dg.exp
b/gcc/testsuite/lib/target-supports-dg.exp
index f5d386f8f07..aa26cefc05f 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -267,9 +267,15 @@ proc dg-require-effective-target { args } {
# If this target does not have fork, skip this test.
proc dg-require-fork { args } {
- if { ![check_fork_available] } {
- upvar dg-do-what dg-do-what
- set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ upvar dg-do-what dg-do-what
+
+ set doaction [lindex ${dg-do-what} 0]
+ if { $doaction == "run" } {
+ if { ![check_fork_runtime] } {
+ set dg-do-what [list $doaction "N" "P"]
+ }
+ } elseif { ![check_fork_available] } {
+ set dg-do-what [list $doaction "N" "P"]
}
}
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index c8791827556..6c5ffbc27d9 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3802,6 +3802,34 @@ proc check_fork_available {} {
return [check_function_available "fork"]
}
+# Returns true iff "fork" is working on the target system.
+
+proc check_fork_runtime {} {
+ if { [istarget *-*-vxworks*] } {
+ # VxWorks doesn't have fork but our way to test can't
+ # tell as we're doing partial links for kernel modules.
+ return 0
+ }
+ if { [istarget cris-*-*] } {
+ # Compiling and linking works, and an executable running e.g.
+ # gcc.dg/torture/ftrapv-1.c works on now-historical hardware,
+ # but the GNU simulator emits an error for the fork syscall.
+ return [check_effective_target_hw]
+ }
+ return [check_runtime fork_runtime {
+ #include <unistd.h>
+ #include <stdlib.h>
+
+ int main()
+ {
+ pid_t p = fork();
+ if (p < 0)
+ abort();
+ return 0;
+ }
+ }]
+}
+
# Returns true iff "mkfifo" is available on the target system.
proc check_mkfifo_available {} {
--
2.43.0