ld: Run tmpdir/pr28138 only for native build

Message ID 20210728143422.669050-1-hjl.tools@gmail.com
State New
Headers show
Series
  • ld: Run tmpdir/pr28138 only for native build
Related show

Commit Message

Alan Modra via Binutils July 28, 2021, 2:34 p.m.
* PR ld/28138
	* testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for
	native build.
---
 ld/testsuite/ld-plugin/lto.exp | 64 ++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 30 deletions(-)

-- 
2.31.1

Comments

Alan Modra via Binutils Aug. 11, 2021, 9:14 a.m. | #1
Hi H.J.

> 	* PR ld/28138

> 	* testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for

> 	native build.


Approved - please apply - but I do have one small suggestion:

> +	if [string match "PASS" $exec_output] then {

> +	    pass "PR ld/28138"

> +	} else {

> +	    fail "PR ld/28138"

> +	}

> +    } else {

> +	pass "PR ld/28138"

> +    }

> +} else {

> +    fail "PR ld/28138"

I think that it would be nice if the pass and fail strings mentioned
which part of the test passed/failed.  ie:

   pass "PR ld/28138 (build & run)"
   fail "PR ld/28138 (built ok, run failed)"
   pass "PR ld/28138 (build only)"
   fail "PR ld/28138 (did not build)"

Cheers
   Nick
Alan Modra via Binutils Aug. 11, 2021, 12:59 p.m. | #2
On Wed, Aug 11, 2021 at 2:14 AM Nick Clifton <nickc@redhat.com> wrote:
>

> Hi H.J.

>

> >       * PR ld/28138

> >       * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for

> >       native build.

>

> Approved - please apply - but I do have one small suggestion:

>

> > +     if [string match "PASS" $exec_output] then {

> > +         pass "PR ld/28138"

> > +     } else {

> > +         fail "PR ld/28138"

> > +     }

> > +    } else {

> > +     pass "PR ld/28138"

> > +    }

> > +} else {

> > +    fail "PR ld/28138"

> I think that it would be nice if the pass and fail strings mentioned

> which part of the test passed/failed.  ie:

>

>    pass "PR ld/28138 (build & run)"

>    fail "PR ld/28138 (built ok, run failed)"

>    pass "PR ld/28138 (build only)"

>    fail "PR ld/28138 (did not build)"


Done.  I am checking in this.

Thans.

-- 
H.J.
From b95fc325b7300056cae4dc135fb7ad96ea2fb6ad Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 11 Aug 2021 05:53:56 -0700
Subject: [PATCH] ld: Update the pass and fail strings of PR ld/28138 test

	PR ld/28138
	* testsuite/ld-plugin/lto.exp: Update the pass and fail strings
	of PR ld/28138 test to indicate which part of the test passed
	and failed.
---
 ld/testsuite/ld-plugin/lto.exp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 999d911ce6a..68d2db1caeb 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -710,15 +710,15 @@ if [string match "" $exec_output] then {
     if { [isnative] } {
 	set exec_output [run_host_cmd "tmpdir/pr28138" ""]
 	if [string match "PASS" $exec_output] then {
-	    pass "PR ld/28138"
+	    pass "PR ld/28138 (build & run)"
 	} else {
-	    fail "PR ld/28138"
+	    fail "PR ld/28138 (built ok, run failed)"
 	}
     } else {
-	pass "PR ld/28138"
+	pass "PR ld/28138 (build only)"
     }
 } else {
-    fail "PR ld/28138"
+    fail "PR ld/28138 (build only)"
 }
 
 set testname "Build liblto-11.a"

Patch

diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 63be062032b..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@  if { [is_elf_format] && [check_lto_shared_available] } {
     }
 }
 
+run_cc_link_tests [list \
+    [list \
+	"Build pr28138.a" \
+	"-T" "" \
+	{pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+	 pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+    ] \
+    [list \
+	"Build pr28138.o" \
+	"" "" \
+	{pr28138.c} {} \
+    ] \
+]
+
+set exec_output [run_host_cmd "sh" \
+			      "-c \"ulimit -n 20; \
+			      $CC -Btmpdir/ld -o tmpdir/pr28138 \
+			      tmpdir/pr28138.o tmpdir/pr28138.a\""]
+set exec_output [prune_warnings $exec_output]
+if [string match "" $exec_output] then {
+    if { [isnative] } {
+	set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+	if [string match "PASS" $exec_output] then {
+	    pass "PR ld/28138"
+	} else {
+	    fail "PR ld/28138"
+	}
+    } else {
+	pass "PR ld/28138"
+    }
+} else {
+    fail "PR ld/28138"
+}
+
 set testname "Build liblto-11.a"
 remote_file host delete "tmpdir/liblto-11.a"
 set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
@@ -930,34 +964,4 @@  if { [check_lto_fat_available] } {
     }
 }
 
-run_cc_link_tests [list \
-    [list \
-	"Build pr28138.a" \
-	"-T" "" \
-	{pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
-	 pr28138-6.c pr28138-7.c} {} "pr28138.a" \
-    ] \
-    [list \
-	"Build pr28138.o" \
-	"" "" \
-	{pr28138.c} {} \
-    ] \
-]
-
-set exec_output [run_host_cmd "sh" \
-			      "-c \"ulimit -n 20; \
-			      $CC -Btmpdir/ld -o tmpdir/pr28138 \
-			      tmpdir/pr28138.o tmpdir/pr28138.a\""]
-set exec_output [prune_warnings $exec_output]
-if [string match "" $exec_output] then {
-    set exec_output [run_host_cmd "tmpdir/pr28138" ""]
-    if [string match "PASS" $exec_output] then {
-	pass "PR ld/28138"
-    } else {
-	fail "PR ld/28138"
-    }
-} else {
-    fail "PR ld/28138"
-}
-
 restore_notify