From patchwork Fri May 29 13:52:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Cl=C3=A9ment_Chigot?= X-Patchwork-Id: 136080 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 557F74BA23DB for ; Fri, 29 May 2026 13:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 557F74BA23DB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Iaeknayc X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 0300E4BA23C8 for ; Fri, 29 May 2026 13:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0300E4BA23C8 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0300E4BA23C8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780062783; cv=none; b=A9w73Ps+fxEJG+8ZQozxwXqMxwy2iakJIeELdXRolV+T32ptHCRr8ldLs9204pG88psACPXI8zFnQRGf7nmcJfYpyBBWGSOwZE0I2yOPELVT70vrZPqkuNz+ebS7WDo8wSTbeyPUL/hTwlyWSNj8zPPAiickdCkBg2n6idLgN+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780062783; c=relaxed/simple; bh=aq8AHYtUS9IpP20k9hkXbeM59Cad+V3E7S1UVvvZBNI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=OV6sEsFkF0L1BsfDcSHYrOIalJwnut6S6En+SrD0BT17V7FV6xRg7l0sMBx2NQ/IrgZLOUrqO8LziTeocDpi6iQlH4toj5MG0TmwwdkQQVB2Iavk3V2rohClvpMV3rY0SugooZKbBe9RAZFRM/3dIDJHWJcW1QHlie8q20qo8Eo= ARC-Authentication-Results: i=1; sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-490426d72f7so71076595e9.3 for ; Fri, 29 May 2026 06:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1780062775; x=1780667575; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UgjKLnB/hZilKsAlrOiXFHv62vo8yqFa32hUGcFkS80=; b=IaeknaycI44tFqSH9IGsuy+PZABWaIwgat/FJS8F7GqsXsTpbbnYG7XYrJM1qHRfrY BTiYC2xAtJmtjXcsXEGzfpxBaqMqdlldiZ+NKkYKzXttpQDlX6gR4T9ZMpDcO886l4Uf A/Mr8FJBM1JMO+HmFwyavmFKTpGtQ1tu/ddsZB0TgdY4IP79HxvtpByjpf9yd0l/Ix02 s19WMtBjymGDjxUcP8gmK7rxTE/8y47AUDBF/VxCV6uM8K9fA2RpfESC0qBFfXtFiqHQ aArO264tcuPja0KGkKGr2+FUILmYRS2xKqxEUV45jFdg3ry1YsWxvDX6Q4an1cvVObBX B+Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780062775; x=1780667575; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UgjKLnB/hZilKsAlrOiXFHv62vo8yqFa32hUGcFkS80=; b=K+AXEvACNk1wRRgoflSAVQj3Zltrml6DgrUIt0Fc5+tUKaFU60NdP1I219ZzwDUqOt kjoD5RfROZp11c4IitYhAhqbX5smGP8j4BrgqP2FnARwjUe4miFw992duFI+JIOZyEcA F6PwlApvDiERQXXlPwdpoAlJ94+FqdNjZdVItcHLNO0sHehzQGXFX0bObgVQu4jKkx9X O/3JvGu1pcPWaMTjLJ39FZ8suRSdxO1CraZCFcUUkxO1sdkEYFc5rUsFzFQPieid52Bf SqwHc1YF9x0dXRBmzAeL20/4FEH9+SgVPWVOqabXRHjuZFLTWkGoliLrL1aqTs/wq7BY B63A== X-Gm-Message-State: AOJu0YxwyEXNJE9EMUkJdkyzo4weyihcdvMslR8hZgvrE/j37N61ppF4 rlhfugi2JM3h976u4L7btDugWcrhThOZilKB+0/Uq17lIYIHjK5jVB15liFWAFs0rTPHdWL2Xl5 Dqkg= X-Gm-Gg: Acq92OEnMPE5QPql9DwLhifF51hiBml1UcWxFTBqJPwdaibr7X8ZcbQvNH0dQ04Jqet XGXr6RKnc0R/4tb/082Xzxa7bSJ3CQAhDaHwpARqbxtudHfHpaj6nmY3IMvJE3og59kYAAS2xWF AALxb7Bu25qMeOZZ5lSJWrcqPiJoGeGqpu1sLzYigSbc5JapGj9aQqnHY7+4A3Wb7byijSOpWbf 3GpyOJ8Gd2kIsx9T1D3noH2zE52yS4zs/hQhvAr3F8QRuoJSTVFkOJanDHZy0BUwylFdJZosIYY MauZ8vut2LlnCjwL7pb23BCQ8Y5oinD5SWTy/JocryKwDMMXw2zFYAU0lifB4nTU0lTFJtzd1BP cEgTjLWjqzHwY9aYWQ+x7gX37YfPMy1oAhF+hJRcndw0no/k9CEAaD4y1fZIHfNYqC+ZFYWN45M YzS26LIQfFsxB1yQiTcUQAzJKm4HhHFWBKbGtWq+WjE3Y= X-Received: by 2002:a05:600c:37c9:b0:490:9d1b:f06b with SMTP id 5b1f17b1804b1-4909d1bf12bmr47314935e9.26.1780062775553; Fri, 29 May 2026 06:52:55 -0700 (PDT) Received: from chigot-Dell.home ([2a01:cb15:80db:7c00:acc5:3ad0:efae:aaf5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909c128dacsm14593855e9.32.2026.05.29.06.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 06:52:55 -0700 (PDT) From: =?utf-8?q?Cl=C3=A9ment_Chigot?= To: binutils@sourceware.org Cc: amodra@gmail.com, =?utf-8?q?Cl=C3=A9ment_Chigot?= Subject: [PATCH] ld/testsuite: add support for remote testing in ld-cdtest Date: Fri, 29 May 2026 15:52:52 +0200 Message-ID: <20260529135252.2094804-1-chigot@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, PROLO_LEO2, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org 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 } 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 + } }