ld/testsuite: add support for remote testing in ld-cdtest

Message ID 20260529135252.2094804-1-chigot@adacore.com
State New
Headers
Series ld/testsuite: add support for remote testing in ld-cdtest |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Clément Chigot May 29, 2026, 1:52 p.m. UTC
  This converts the existing to code to use "remote_load" allowing
execution on both native and remote targets.

The "diff" between the output and the expected result has been
transformed to the usual regexp_diff. The previous could have been
transformed into `remote_exec build diff` but tends to be fickled with
new lines.
---
 ld/testsuite/ld-cdtest/cdtest-nrv.dat | 26 ++++----
 ld/testsuite/ld-cdtest/cdtest.dat     | 30 ++++-----
 ld/testsuite/ld-cdtest/cdtest.exp     | 96 +++++++++++++--------------
 3 files changed, 73 insertions(+), 79 deletions(-)
  

Comments

Clément Chigot June 16, 2026, 2:12 p.m. UTC | #1
On Fri, May 29, 2026 at 3:52 PM Clément Chigot <chigot@adacore.com> wrote:
>
> This converts the existing to code to use "remote_load" allowing
> execution on both native and remote targets.
>
> The "diff" between the output and the expected result has been
> transformed to the usual regexp_diff. The previous could have been
> transformed into `remote_exec build diff` but tends to be fickled with
> new lines.
> ---
>  ld/testsuite/ld-cdtest/cdtest-nrv.dat | 26 ++++----
>  ld/testsuite/ld-cdtest/cdtest.dat     | 30 ++++-----
>  ld/testsuite/ld-cdtest/cdtest.exp     | 96 +++++++++++++--------------
>  3 files changed, 73 insertions(+), 79 deletions(-)
>
> diff --git a/ld/testsuite/ld-cdtest/cdtest-nrv.dat b/ld/testsuite/ld-cdtest/cdtest-nrv.dat
> index d3f871ff108..76fcbaa03d4 100644
> --- a/ld/testsuite/ld-cdtest/cdtest-nrv.dat
> +++ b/ld/testsuite/ld-cdtest/cdtest-nrv.dat
> @@ -1,13 +1,13 @@
> -Constructing Foo(1) "static_foo"
> -Constructing Foo(2) "static_foo"
> -Constructing Foo(3) "automatic_foo"
> -Constructing Foo(4) "default-foo"
> -Constructing Foo(5) "other_foo1"
> -Constructing Foo(6) "other_foo2"
> -Copying Foo(5) "other_foo1" to Foo(6)
> -Destructing Foo(6) "other_foo1" (remaining foos: 5)
> -Destructing Foo(5) "other_foo1" (remaining foos: 4)
> -Destructing Foo(4) "default-foo" (remaining foos: 3)
> -Destructing Foo(3) "automatic_foo" (remaining foos: 2)
> -Destructing Foo(2) "static_foo" (remaining foos: 1)
> -Destructing Foo(1) "static_foo" (remaining foos: 0)
> +Constructing Foo\(1\) "static_foo"
> +Constructing Foo\(2\) "static_foo"
> +Constructing Foo\(3\) "automatic_foo"
> +Constructing Foo\(4\) "default-foo"
> +Constructing Foo\(5\) "other_foo1"
> +Constructing Foo\(6\) "other_foo2"
> +Copying Foo\(5\) "other_foo1" to Foo\(6\)
> +Destructing Foo\(6\) "other_foo1" \(remaining foos: 5\)
> +Destructing Foo\(5\) "other_foo1" \(remaining foos: 4\)
> +Destructing Foo\(4\) "default-foo" \(remaining foos: 3\)
> +Destructing Foo\(3\) "automatic_foo" \(remaining foos: 2\)
> +Destructing Foo\(2\) "static_foo" \(remaining foos: 1\)
> +Destructing Foo\(1\) "static_foo" \(remaining foos: 0\)
> diff --git a/ld/testsuite/ld-cdtest/cdtest.dat b/ld/testsuite/ld-cdtest/cdtest.dat
> index 39be0dbc2c7..c0bdffb3c26 100644
> --- a/ld/testsuite/ld-cdtest/cdtest.dat
> +++ b/ld/testsuite/ld-cdtest/cdtest.dat
> @@ -1,15 +1,15 @@
> -Constructing Foo(1) "static_foo"
> -Constructing Foo(2) "static_foo"
> -Constructing Foo(3) "automatic_foo"
> -Constructing Foo(4) "default-foo"
> -Initializing Foo(5) "default-foo" with Foo(4)
> -Destructing Foo(4) "default-foo" (remaining foos: 4)
> -Constructing Foo(5) "other_foo1"
> -Constructing Foo(6) "other_foo2"
> -Copying Foo(5) "other_foo1" to Foo(6)
> -Destructing Foo(6) "other_foo1" (remaining foos: 5)
> -Destructing Foo(5) "other_foo1" (remaining foos: 4)
> -Destructing Foo(5) "default-foo" (remaining foos: 3)
> -Destructing Foo(3) "automatic_foo" (remaining foos: 2)
> -Destructing Foo(2) "static_foo" (remaining foos: 1)
> -Destructing Foo(1) "static_foo" (remaining foos: 0)
> +Constructing Foo\(1\) "static_foo"
> +Constructing Foo\(2\) "static_foo"
> +Constructing Foo\(3\) "automatic_foo"
> +Constructing Foo\(4\) "default-foo"
> +Initializing Foo\(5\) "default-foo" with Foo\(4\)
> +Destructing Foo\(4\) "default-foo" \(remaining foos: 4\)
> +Constructing Foo\(5\) "other_foo1"
> +Constructing Foo\(6\) "other_foo2"
> +Copying Foo\(5\) "other_foo1" to Foo\(6\)
> +Destructing Foo\(6\) "other_foo1" \(remaining foos: 5\)
> +Destructing Foo\(5\) "other_foo1" \(remaining foos: 4\)
> +Destructing Foo\(5\) "default-foo" \(remaining foos: 3\)
> +Destructing Foo\(3\) "automatic_foo" \(remaining foos: 2\)
> +Destructing Foo\(2\) "static_foo" \(remaining foos: 1\)
> +Destructing Foo\(1\) "static_foo" \(remaining foos: 0\)
> diff --git a/ld/testsuite/ld-cdtest/cdtest.exp b/ld/testsuite/ld-cdtest/cdtest.exp
> index 89fdd581abb..ccfcbaf226a 100644
> --- a/ld/testsuite/ld-cdtest/cdtest.exp
> +++ b/ld/testsuite/ld-cdtest/cdtest.exp
> @@ -27,11 +27,6 @@
>  set test1 "cdtest"
>  set test2 "cdtest with -Ur"
>
> -# This test requires running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  if { [which $CXX_FOR_TARGET] == 0 } {
>      untested $test1
>      untested $test2
> @@ -51,44 +46,39 @@ set expected_output "$srcdir/$subdir/cdtest.dat"
>  if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o"] {
>      fail $test1
>  } else {
> -    send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
> -    verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
> -    catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
> +    set failed 0
>
> -    if ![string match "" $exec_output] then {
> +    send_log "Running: tmpdir/cdtest\n"
> +    verbose "Running: tmpdir/cdtest"
> +    set state [remote_load target tmpdir/cdtest]
> +    set status [lindex $state 0]
> +    set exec_output [lindex $state 1]
> +
> +    if { $status != "pass"  } {
>         send_log "$exec_output\n"
>         verbose "$exec_output" 1
> -
> -       fail $test1
> +       set failed 1
>      } else {
> -       send_log   "diff tmpdir/cdtest.out $expected_output\n"
> -       verbose    "diff tmpdir/cdtest.out $expected_output"
> -       catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
> -       set exec_output [prune_warnings $exec_output]
> -
> -       if ![string match "" $exec_output] then {
> -           send_log "$exec_output\n"
> -           verbose  "$exec_output" 1
> +       set output_filename "tmpdir/cdtest.out"
> +       set_file_contents $output_filename $exec_output
>
> +       send_log [file_contents $output_filename]
> +       verbose [file_contents $output_filename] 2
> +       if [regexp_diff $output_filename $expected_output] {
>             send_log "Checking against Named Return Value optimization\n"
>             verbose  "Checking against Named Return Value optimization" 1
>
>             set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
> -
> -           send_log   "diff tmpdir/cdtest.out $expected_output\n"
> -           verbose    "diff tmpdir/cdtest.out $expected_output"
> -           catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
> -           set exec_output [prune_warnings $exec_output]
> +           if [regexp_diff $output_filename $expected_output] {
> +               set failed 1
> +           }
>         }
> +    }
>
> -       if [string match "" $exec_output] then {
> -           pass $test1
> -       } else {
> -           send_log "$exec_output\n"
> -           verbose  "$exec_output" 1
> -
> -           fail $test1
> -       }
> +    if { $failed != 0 } {
> +       fail $test1
> +    } else {
> +       pass $test1
>      }
>  }
>
> @@ -103,29 +93,33 @@ if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.
>      if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest.o"] {
>         fail $test2

There is a minor mistake here, it should be "set failed 1". Otherwise,
we get a duplicate FAIL.
@Alan Modra  still ok for master ?

>      } else {
> -       send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
> -       verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
> -       catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
> +       set failed 0
>
> -       if ![string match "" $exec_output] then {
> -           send_log "$exec_output\n"
> -           verbose  "$exec_output" 1
> +       send_log "Running: tmpdir/cdtest\n"
> +       verbose "Running: tmpdir/cdtest"
> +       set state [remote_load target tmpdir/cdtest]
> +       set status [lindex $state 0]
> +       set exec_output [lindex $state 1]
>
> -           fail $test2
> +       if { $status != "pass" } {
> +           send_log "$exec_output\n"
> +           verbose "$exec_output" 1
> +           set failed 1
>         } else {
> -           send_log   "diff tmpdir/cdtest.out $expected_output\n"
> -           verbose    "diff tmpdir/cdtest.out $expected_output"
> -           catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
> -           set exec_output [prune_warnings $exec_output]
> -
> -           if [string match "" $exec_output] then {
> -               pass $test2
> -           } else {
> -               send_log "$exec_output\n"
> -               verbose  "$exec_output" 1
> -
> -               fail $test2
> +           set output_filename "tmpdir/cdtest.out"
> +           set_file_contents $output_filename $exec_output
> +
> +           send_log [file_contents $output_filename]
> +           verbose [file_contents $output_filename] 2
> +           if [regexp_diff $output_filename $expected_output] {
> +               set failed 1
>             }
>         }
>      }
> +
> +    if { $failed != 0 } {
> +       fail $test2
> +    } else {
> +       pass $test2
> +    }
>  }
> --
> 2.43.0
>
  
Alan Modra June 17, 2026, 1:09 a.m. UTC | #2
On Tue, Jun 16, 2026 at 04:12:06PM +0200, Clément Chigot wrote:
> There is a minor mistake here, it should be "set failed 1". Otherwise,
> we get a duplicate FAIL.
> @Alan Modra  still ok for master ?

I was hoping someone who is more expert in the testsuite would review
this.  When I apply your patch locally, I see the following so I think
you have a little more work to do.

aarch64-linux-gnu  +FAIL: cdtest
aarch64-linux-gnu  +FAIL: cdtest with -Ur
alpha-linux-gnu  +FAIL: cdtest
alpha-linux-gnu  +FAIL: cdtest with -Ur
arm-linux-gnueabi  +FAIL: cdtest
arm-linux-gnueabi  +FAIL: cdtest with -Ur
hppa-linux-gnu  +FAIL: cdtest
hppa-linux-gnu  +FAIL: cdtest with -Ur
ia64-linux-gnu  +FAIL: cdtest
ia64-linux-gnu  +FAIL: cdtest with -Ur
m68k-linux-gnu  +FAIL: cdtest
m68k-linux-gnu  +FAIL: cdtest with -Ur
microblaze-linux-gnu  +FAIL: cdtest
microblaze-linux-gnu  +FAIL: cdtest with -Ur
mips64-linux-gnuabi64  +FAIL: cdtest
mips64-linux-gnuabi64  +FAIL: cdtest with -Ur
mips-linux-gnu  +FAIL: cdtest
mips-linux-gnu  +FAIL: cdtest with -Ur
powerpc64le-linux-gnu  +FAIL: cdtest
powerpc64le-linux-gnu  +FAIL: cdtest with -Ur
powerpc64-linux-gnu  +FAIL: cdtest
powerpc64-linux-gnu  +FAIL: cdtest with -Ur
powerpc-linux-gnu  +FAIL: cdtest
powerpc-linux-gnu  +FAIL: cdtest with -Ur
riscv64-linux-gnu  +FAIL: cdtest
riscv64-linux-gnu  +FAIL: cdtest with -Ur
s390-linux-gnu  +FAIL: cdtest
s390-linux-gnu  +FAIL: cdtest with -Ur
s390x-linux-gnu  +FAIL: cdtest
s390x-linux-gnu  +FAIL: cdtest with -Ur
sh4-linux-gnu  +FAIL: cdtest
sh4-linux-gnu  +FAIL: cdtest with -Ur
sparc64-linux-gnu  +FAIL: cdtest
sparc64-linux-gnu  +FAIL: cdtest with -Ur
sparc64-linux-gnu  -FAIL: Build pr29655
tilepro-linux-gnu  +FAIL: cdtest
tilepro-linux-gnu  +FAIL: cdtest with -Ur
x86_64-w64-mingw32  +ERROR: tmpdir/cdtest does not exist in unix_load.
x86_64-w64-mingw32  +ERROR: tmpdir/cdtest does not exist in unix_load.
  
Alan Modra June 17, 2026, 1:27 a.m. UTC | #3
Typical log file shows:
Running: tmpdir/cdtest
Setting LD_LIBRARY_PATH to :
Execution timeout is: 300
spawn [open ...]
tmpdir/cdtest: 1: ELF@°4H@4: not found
tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")
tmpdir/cdtest: 1: ELF@°4H@4: not found
tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")

FAIL: cdtest
  
Clément Chigot June 17, 2026, 7:05 a.m. UTC | #4
On Wed, Jun 17, 2026 at 3:27 AM Alan Modra <amodra@gmail.com> wrote:
>
> Typical log file shows:
> Running: tmpdir/cdtest
> Setting LD_LIBRARY_PATH to :
> Execution timeout is: 300
> spawn [open ...]
> tmpdir/cdtest: 1:  ELF       @ °4H@  4: not found
> tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")
> tmpdir/cdtest: 1:  ELF       @ °4H@  4: not found
> tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")
>
> FAIL: cdtest

Hum indeed. I don't see those errors during our internal testing
(using remote obviously) nor when I've tried with master on my laptop
(x86_64-linux-gnu but it seems ok on our side too).
I'll investigate.

Thanks
Clément

> Alan Modra
  
Alan Modra June 17, 2026, 1:51 p.m. UTC | #5
On Wed, Jun 17, 2026 at 09:05:44AM +0200, Clément Chigot wrote:
> On Wed, Jun 17, 2026 at 3:27 AM Alan Modra <amodra@gmail.com> wrote:
> >
> > Typical log file shows:
> > Running: tmpdir/cdtest
> > Setting LD_LIBRARY_PATH to :
> > Execution timeout is: 300
> > spawn [open ...]
> > tmpdir/cdtest: 1:  ELF       @ °4H@  4: not found
> > tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")
> > tmpdir/cdtest: 1:  ELF       @ °4H@  4: not found
> > tmpdir/cdtest: 2: Syntax error: word unexpected (expecting ")")
> >
> > FAIL: cdtest
> 
> Hum indeed. I don't see those errors during our internal testing
> (using remote obviously) nor when I've tried with master on my laptop
> (x86_64-linux-gnu but it seems ok on our side too).
> I'll investigate.

I was testing without any remote.

> Thanks
> Clément
> 
> > Alan Modra
  

Patch

diff --git a/ld/testsuite/ld-cdtest/cdtest-nrv.dat b/ld/testsuite/ld-cdtest/cdtest-nrv.dat
index d3f871ff108..76fcbaa03d4 100644
--- a/ld/testsuite/ld-cdtest/cdtest-nrv.dat
+++ b/ld/testsuite/ld-cdtest/cdtest-nrv.dat
@@ -1,13 +1,13 @@ 
-Constructing Foo(1) "static_foo"
-Constructing Foo(2) "static_foo"
-Constructing Foo(3) "automatic_foo"
-Constructing Foo(4) "default-foo"
-Constructing Foo(5) "other_foo1"
-Constructing Foo(6) "other_foo2"
-Copying Foo(5) "other_foo1" to Foo(6)
-Destructing Foo(6) "other_foo1" (remaining foos: 5)
-Destructing Foo(5) "other_foo1" (remaining foos: 4)
-Destructing Foo(4) "default-foo" (remaining foos: 3)
-Destructing Foo(3) "automatic_foo" (remaining foos: 2)
-Destructing Foo(2) "static_foo" (remaining foos: 1)
-Destructing Foo(1) "static_foo" (remaining foos: 0)
+Constructing Foo\(1\) "static_foo"
+Constructing Foo\(2\) "static_foo"
+Constructing Foo\(3\) "automatic_foo"
+Constructing Foo\(4\) "default-foo"
+Constructing Foo\(5\) "other_foo1"
+Constructing Foo\(6\) "other_foo2"
+Copying Foo\(5\) "other_foo1" to Foo\(6\)
+Destructing Foo\(6\) "other_foo1" \(remaining foos: 5\)
+Destructing Foo\(5\) "other_foo1" \(remaining foos: 4\)
+Destructing Foo\(4\) "default-foo" \(remaining foos: 3\)
+Destructing Foo\(3\) "automatic_foo" \(remaining foos: 2\)
+Destructing Foo\(2\) "static_foo" \(remaining foos: 1\)
+Destructing Foo\(1\) "static_foo" \(remaining foos: 0\)
diff --git a/ld/testsuite/ld-cdtest/cdtest.dat b/ld/testsuite/ld-cdtest/cdtest.dat
index 39be0dbc2c7..c0bdffb3c26 100644
--- a/ld/testsuite/ld-cdtest/cdtest.dat
+++ b/ld/testsuite/ld-cdtest/cdtest.dat
@@ -1,15 +1,15 @@ 
-Constructing Foo(1) "static_foo"
-Constructing Foo(2) "static_foo"
-Constructing Foo(3) "automatic_foo"
-Constructing Foo(4) "default-foo"
-Initializing Foo(5) "default-foo" with Foo(4)
-Destructing Foo(4) "default-foo" (remaining foos: 4)
-Constructing Foo(5) "other_foo1"
-Constructing Foo(6) "other_foo2"
-Copying Foo(5) "other_foo1" to Foo(6)
-Destructing Foo(6) "other_foo1" (remaining foos: 5)
-Destructing Foo(5) "other_foo1" (remaining foos: 4)
-Destructing Foo(5) "default-foo" (remaining foos: 3)
-Destructing Foo(3) "automatic_foo" (remaining foos: 2)
-Destructing Foo(2) "static_foo" (remaining foos: 1)
-Destructing Foo(1) "static_foo" (remaining foos: 0)
+Constructing Foo\(1\) "static_foo"
+Constructing Foo\(2\) "static_foo"
+Constructing Foo\(3\) "automatic_foo"
+Constructing Foo\(4\) "default-foo"
+Initializing Foo\(5\) "default-foo" with Foo\(4\)
+Destructing Foo\(4\) "default-foo" \(remaining foos: 4\)
+Constructing Foo\(5\) "other_foo1"
+Constructing Foo\(6\) "other_foo2"
+Copying Foo\(5\) "other_foo1" to Foo\(6\)
+Destructing Foo\(6\) "other_foo1" \(remaining foos: 5\)
+Destructing Foo\(5\) "other_foo1" \(remaining foos: 4\)
+Destructing Foo\(5\) "default-foo" \(remaining foos: 3\)
+Destructing Foo\(3\) "automatic_foo" \(remaining foos: 2\)
+Destructing Foo\(2\) "static_foo" \(remaining foos: 1\)
+Destructing Foo\(1\) "static_foo" \(remaining foos: 0\)
diff --git a/ld/testsuite/ld-cdtest/cdtest.exp b/ld/testsuite/ld-cdtest/cdtest.exp
index 89fdd581abb..ccfcbaf226a 100644
--- a/ld/testsuite/ld-cdtest/cdtest.exp
+++ b/ld/testsuite/ld-cdtest/cdtest.exp
@@ -27,11 +27,6 @@ 
 set test1 "cdtest"
 set test2 "cdtest with -Ur"
 
-# This test requires running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 if { [which $CXX_FOR_TARGET] == 0 } {
     untested $test1
     untested $test2
@@ -51,44 +46,39 @@  set expected_output "$srcdir/$subdir/cdtest.dat"
 if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o"] {
     fail $test1
 } else {
-    send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
-    verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
-    catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
+    set failed 0
 
-    if ![string match "" $exec_output] then {
+    send_log "Running: tmpdir/cdtest\n"
+    verbose "Running: tmpdir/cdtest"
+    set state [remote_load target tmpdir/cdtest]
+    set status [lindex $state 0]
+    set exec_output [lindex $state 1]
+
+    if { $status != "pass"  } {
 	send_log "$exec_output\n"
 	verbose "$exec_output" 1
-
-	fail $test1
+	set failed 1
     } else {
-	send_log   "diff tmpdir/cdtest.out $expected_output\n"
-	verbose    "diff tmpdir/cdtest.out $expected_output"
-	catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
-	set exec_output [prune_warnings $exec_output]
-
-	if ![string match "" $exec_output] then {
-	    send_log "$exec_output\n"
-	    verbose  "$exec_output" 1
+	set output_filename "tmpdir/cdtest.out"
+	set_file_contents $output_filename $exec_output
 
+	send_log [file_contents $output_filename]
+	verbose [file_contents $output_filename] 2
+	if [regexp_diff $output_filename $expected_output] {
 	    send_log "Checking against Named Return Value optimization\n"
 	    verbose  "Checking against Named Return Value optimization" 1
 
 	    set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
-
-	    send_log   "diff tmpdir/cdtest.out $expected_output\n"
-	    verbose    "diff tmpdir/cdtest.out $expected_output"
-	    catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
-	    set exec_output [prune_warnings $exec_output]
+	    if [regexp_diff $output_filename $expected_output] {
+		set failed 1
+	    }
 	}
+    }
 
-	if [string match "" $exec_output] then {
-	    pass $test1
-	} else {
-	    send_log "$exec_output\n"
-	    verbose  "$exec_output" 1
-
-	    fail $test1
-	}
+    if { $failed != 0 } {
+	fail $test1
+    } else {
+	pass $test1
     }
 }
 
@@ -103,29 +93,33 @@  if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.
     if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest.o"] {
 	fail $test2
     } else {
-	send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
-	verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
-	catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
+	set failed 0
 
-	if ![string match "" $exec_output] then {
-	    send_log "$exec_output\n"
-	    verbose  "$exec_output" 1
+	send_log "Running: tmpdir/cdtest\n"
+	verbose "Running: tmpdir/cdtest"
+	set state [remote_load target tmpdir/cdtest]
+	set status [lindex $state 0]
+	set exec_output [lindex $state 1]
 
-	    fail $test2
+	if { $status != "pass" } {
+	    send_log "$exec_output\n"
+	    verbose "$exec_output" 1
+	    set failed 1
 	} else {
-	    send_log   "diff tmpdir/cdtest.out $expected_output\n"
-	    verbose    "diff tmpdir/cdtest.out $expected_output"
-	    catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
-	    set exec_output [prune_warnings $exec_output]
-
-	    if [string match "" $exec_output] then {
-		pass $test2
-	    } else {
-		send_log "$exec_output\n"
-		verbose  "$exec_output" 1
-
-		fail $test2
+	    set output_filename "tmpdir/cdtest.out"
+	    set_file_contents $output_filename $exec_output
+
+	    send_log [file_contents $output_filename]
+	    verbose [file_contents $output_filename] 2
+	    if [regexp_diff $output_filename $expected_output] {
+		set failed 1
 	    }
 	}
     }
+
+    if { $failed != 0 } {
+	fail $test2
+    } else {
+	pass $test2
+    }
 }