From: Maciej W. Rozycki Date: Tue, 17 Feb 2026 10:42:47 +0000 (+0000) Subject: LD/testsuite: Enable execution with remote targets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fbinutils-gdb.git LD/testsuite: Enable execution with remote targets 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. --- diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 67bd3d8b184..f2053fd0f62 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -849,27 +849,50 @@ proc run_ld_link_exec_tests { ldtests args } { } } - 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 + + set board [target_info name] + if { [info exists board_info($board,remotedir)] } { + set remotedir board_info($board,remotedir) + } + set board_info($board,remotedir) [pwd] - if ![string match "" $exec_output] then { - send_log "$exec_output\n" - verbose "$exec_output" 1 - set failed 1 - } else { + 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