[PATCH 3/3] LD/testsuite: Enable execution with remote targets

Maciej W. Rozycki macro@orcam.me.uk
Thu Feb 12 12:46:23 GMT 2026


From: Maciej W. Rozycki <macro@redhat.com>

Lift target execution limitation from `run_ld_link_exec_tests' procedure 
and also handle remote targets, albeit in a restricted way, as follows.

Numerous test cases have been written such that they refer to a shared 
library using a relative path, precluding the use of the runtime library 
search path for the dependency to be found at run time.  Consequently a 
test affected has to be run on the target such that the shared library 
required is present at the same relative path rooted at the program's 
current working directory.

Additionally any shared library dependencies are not handled across the 
test suite in an organised way, so test invocations only have names of 
direct dependencies buried within the linker options supplied.

Therefore assert that the linker test directory is located at the same 
absolute path both on the test host and the test target, typically via 
sharing the directory over NFS, and use the DejaGNU `remotedir' feature 
to start execution on the target with that location as the test case's 
current working directory.
---
 ld/testsuite/lib/ld-lib.exp |   45 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 11 deletions(-)

binutils-ld-test-run-ld-link-exec-tests-remote.diff
Index: binutils-gdb/ld/testsuite/lib/ld-lib.exp
===================================================================
--- binutils-gdb.orig/ld/testsuite/lib/ld-lib.exp
+++ binutils-gdb/ld/testsuite/lib/ld-lib.exp
@@ -849,27 +849,50 @@ proc run_ld_link_exec_tests { ldtests ar
 	    }
 	}
 
-	if { $failed == 0 && [isnative] } {
-	    send_log "Running: $binfile > $binfile.out\n"
-	    verbose "Running: $binfile > $binfile.out"
-	    catch "exec $binfile > $binfile.out" exec_output
+	# For remote targets this relies on the LD test subdirectory
+	# being identity mapped between the test host and the test
+	# target, e.g. mounted over NFS.  This is due to shared module
+	# dependencies using a relative path, which implies the need
+	# for execution to start in the same directory, arranged via
+	# the `remotedir' setting, the link has been made in.
+	if { $failed == 0 && [check_execution_available] } {
+	    global board_info
 
-	    if ![string match "" $exec_output] then {
-		send_log "$exec_output\n"
-		verbose "$exec_output" 1
-		set failed 1
-	    } else {
+	    set board [target_info name]
+	    if { [info exists board_info($board,remotedir)] } {
+		set remotedir board_info($board,remotedir)
+	    }
+	    set board_info($board,remotedir) [pwd]
+
+	    send_log "Running: $binfile\n"
+	    verbose "Running: $binfile"
+	    set result [remote_load target $binfile]
+	    set status [lindex $result 0]
+	    set exec_output [lindex $result 1]
+
+	    if { $status == "pass" } {
+		set_file_contents $binfile.out $exec_output
 		send_log [file_contents $binfile.out]
 		verbose [file_contents $binfile.out] 2
-		if [regexp_diff "$binfile.out" "$srcdir/$subdir/$expfile"] {
+		if [regexp_diff $binfile.out $srcdir/$subdir/$expfile] {
 		    set failed 1
 		}
+	    } else {
+		send_log "$exec_output\n"
+		verbose "$exec_output" 1
+		set failed 1
+	    }
+
+	    if { [info exists remotedir] } {
+		set board_info($board,remotedir) $remotedir
+	    } else {
+		unset board_info($board,remotedir)
 	    }
 	}
 
 	if { $failed != 0 } {
 	    fail $testname
-	} elseif ![isnative] {
+	} elseif ![check_execution_available] {
 	    unsupported $testname
 	} else {
 	    set errcnt 0


More information about the Binutils mailing list