On 4/2/26 18:15, Torbjörn SVENSSON wrote:
Changes since v2:

- Call check_fork_available instead of duplicating the target chesk

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

typo -> exists

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.

LGTM, but I cannot approve.

Thanks,

Christophe


Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
  gcc/testsuite/lib/target-supports-dg.exp | 12 +++++++++---
  gcc/testsuite/lib/target-supports.exp    | 21 +++++++++++++++++++++
  2 files changed, 30 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..d34fd034f0e 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3802,6 +3802,27 @@ proc check_fork_available {} {
      return [check_function_available "fork"]
  }
+# Returns true iff "fork" is working on the target system.
+
+proc check_fork_runtime {} {
+    if { ![check_fork_available] } {
+       return 0
+    }
+
+    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 {} {

Reply via email to