]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Don't trim trailing newline in run_host_cmd
authorAlan Modra <amodra@gmail.com>
Sun, 21 Jul 2024 11:33:22 +0000 (21:03 +0930)
committerAlan Modra <amodra@gmail.com>
Sun, 21 Jul 2024 22:38:18 +0000 (08:08 +0930)
Testcases like ld-elf/pr19719a.c that
    printf ("PASS\n");
on success ought to see the whole output for "string match".
Similarly, the ld-pe/ pdb*.d files shouldn't need to remove the last
newline to match.  For most of the testsuite it doesn't matter whether
the trailing newline is present or not, and there are only a few cases
where we need to remove it.

* testsuite/lib/ld-lib.exp (run_host_cmd): Don't regsub away
output trailing newline.  Do string trim for gcc/ld version checks.
* testsuite/config/default.exp (plug_so): Do string trim output of
run_host_cmd.
* testsuite/ld-elf/shared.exp (mix_pic_and_non_pic): Adjust
string match to include trailing newline.
* testsuite/ld-i386/i386.exp (undefined_weak): Likewise.
* testsuite/ld-x86-64/x86-64.exp (undefined_weak): Likewise.
* testsuite/ld-plugin/libdep.exp (run_test): Likewise.
* testsuite/ld-plugin/lto.exp (PR ld/28138 run): Likewise.
* testsuite/ld-pe/pdb-strings.d,
* testsuite/ld-pe/pdb-syms1-globals.d,
* testsuite/ld-pe/pdb-syms1-records.d,
* testsuite/ld-pe/pdb-syms1-symbols1.d,
* testsuite/ld-pe/pdb-syms1-symbols2.d,
* testsuite/ld-pe/pdb-syms2-symbols1.d,
* testsuite/ld-pe/pdb-types1-hashlist.d,
* testsuite/ld-pe/pdb-types1-skiplist.d,
* testsuite/ld-pe/pdb-types1-typelist.d,
* testsuite/ld-pe/pdb-types2-hashlist.d,
* testsuite/ld-pe/pdb-types2-skiplist.d,
* testsuite/ld-pe/pdb-types2-typelist.d,
* testsuite/ld-pe/pdb-types3-hashlist.d,
* testsuite/ld-pe/pdb-types3-skiplist.d,
* testsuite/ld-pe/pdb-types3-typelist.d,
* testsuite/ld-pe/pdb1-publics.d,
* testsuite/ld-pe/pdb1-sym-record.d,
* testsuite/ld-pe/pdb2-section-contrib.d,
* testsuite/ld-pe/pdb3-c13-info1.d,
* testsuite/ld-pe/pdb3-c13-info2.d,
* testsuite/ld-pe/pdb3-source-info.d: Add trailing newline.

28 files changed:
ld/testsuite/config/default.exp
ld/testsuite/ld-elf/shared.exp
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-pe/pdb-strings.d
ld/testsuite/ld-pe/pdb-syms1-globals.d
ld/testsuite/ld-pe/pdb-syms1-records.d
ld/testsuite/ld-pe/pdb-syms1-symbols1.d
ld/testsuite/ld-pe/pdb-syms1-symbols2.d
ld/testsuite/ld-pe/pdb-syms2-symbols1.d
ld/testsuite/ld-pe/pdb-types1-hashlist.d
ld/testsuite/ld-pe/pdb-types1-skiplist.d
ld/testsuite/ld-pe/pdb-types1-typelist.d
ld/testsuite/ld-pe/pdb-types2-hashlist.d
ld/testsuite/ld-pe/pdb-types2-skiplist.d
ld/testsuite/ld-pe/pdb-types2-typelist.d
ld/testsuite/ld-pe/pdb-types3-hashlist.d
ld/testsuite/ld-pe/pdb-types3-skiplist.d
ld/testsuite/ld-pe/pdb-types3-typelist.d
ld/testsuite/ld-pe/pdb1-publics.d
ld/testsuite/ld-pe/pdb1-sym-record.d
ld/testsuite/ld-pe/pdb2-section-contrib.d
ld/testsuite/ld-pe/pdb3-c13-info1.d
ld/testsuite/ld-pe/pdb3-c13-info2.d
ld/testsuite/ld-pe/pdb3-source-info.d
ld/testsuite/ld-plugin/libdep.exp
ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-x86-64/x86-64.exp
ld/testsuite/lib/ld-lib.exp

index 8374920c775b4ef9865a4644a8b3fdda94b2012c..9ffcc58779f2e2d3feb5c367b943072302efaaa4 100644 (file)
@@ -519,9 +519,9 @@ if { [check_compiler_available] } {
        cyglto_plugin-0.dll
     }
     foreach plug $plugin_names {
-       set plug_so [run_host_cmd $CC_FOR_TARGET "--print-prog-name $plug"]
+       set plug_so [string trim [run_host_cmd $CC_FOR_TARGET "--print-prog-name $plug"]]
        if { $plug_so eq $plug } then {
-           set plug_so [run_host_cmd $CC_FOR_TARGET "--print-file-name $plug"]
+           set plug_so [string trim [run_host_cmd $CC_FOR_TARGET "--print-file-name $plug"]]
        }
        if { $plug_so ne $plug } then {
            set plug_opt "--plugin $plug_so"
index 97ca778bc8e63699b25833ddfc2e2898ff9ce74e..281c3f5d93c6897e17a42b92040559e7c7a550fb 100644 (file)
@@ -1687,7 +1687,7 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
     }
 
     set exec_output [run_host_cmd "tmpdir/$exe" ""]
-    if {![string match "PASS" $exec_output]} {
+    if {![string match "PASS\n" $exec_output]} {
        fail "Run $exe fun undefined"
     } else {
        pass "Run $exe fun undefined"
index f96c514ccd497afff69dabf0c58e28931b2a0e8d..5c9153f9c9256321830529c2ac5714a7f307ca03 100644 (file)
@@ -553,9 +553,9 @@ proc undefined_weak {cflags ldflags} {
 
     if { [string match "*-fPIE*" $cflags]
         && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
-       set weak_symbol "Weak defined"
+       set weak_symbol "Weak defined\n"
     } else {
-       set weak_symbol "Weak undefined"
+       set weak_symbol "Weak undefined\n"
     }
 
     run_cc_link_tests [list \
index 8be853efb7202b2790f5a540be1efae41c2ad6af..2c9cd2e64dec97423174020d2d3203867fa8aa9f 100644 (file)
@@ -7,4 +7,4 @@ Contents of section .data:
  0020 7578000c 00000001 0000000a 00000000  ux..............
  0030 00000000 00000000 00000012 00000000  ................
  0040 00000000 00000002 00000006 00000000  ................
- 0050 0000000e 00000006 000000             ...........     
\ No newline at end of file
+ 0050 0000000e 00000006 000000             ...........     
index 450f3a2326c253b73be6f12d2a780463e5a5b96e..59f067bb428d5c4179718f56ecd2c1353ae534f9 100644 (file)
@@ -53,4 +53,4 @@ Contents of section .data:
  0300 54000000 60000000 6c000000 78000000  T...`...l...x...
  0310 90000000 9c000000 a8000000 b4000000  ................
  0320 c0000000 cc000000 d8000000 e4000000  ................
- 0330 f0000000 fc000000 14010000 2c010000  ............,...
\ No newline at end of file
+ 0330 f0000000 fc000000 14010000 2c010000  ............,...
index d0abb6d5b2e76ca54379e6522decc5832ce2e249..a0852ec5acd0b659382f4658a4932abdd000f279 100644 (file)
@@ -58,4 +58,4 @@ Contents of section .data:
  0350 1c000000 02006776 61723300 12000e11  ......gvar3.....
  0360 00000000 08000000 03006776 61723400  ..........gvar4.
  0370 12000e11 02000000 00000000 01006d61  ..............ma
- 0380 696e0000                             in..            
\ No newline at end of file
+ 0380 696e0000                             in..            
index 4de22acbd086ce69eb34422d5fc4585754b3dd6c..4c565086ea65e16d06526ff1a3265c434adcefd8 100644 (file)
@@ -5,4 +5,4 @@ Contents of section .data:
  0000 04000000 2e001011 00000000 34000000  ............4...
  0010 00000000 01000000 00000000 00000000  ................
  0020 02100000 06000000 01000070 726f6332  ...........proc2
- 0030 00f3f2f1 02000600 00000000           ............    
\ No newline at end of file
+ 0030 00f3f2f1 02000600 00000000           ............    
index c94d3ac0d0afb13be2ee48d825d11325cd1c02d7..22c2f309f391521d156b9c803c6781c56e5d249b 100644 (file)
@@ -53,4 +53,4 @@ Contents of section .data:
  0300 6f643400 02000600 12001211 00100000  od4.............
  0310 20000000 02006c76 61723500 12001211   .....lvar5.....
  0320 00100000 12000000 03006c76 61723600  ..........lvar6.
- 0330 00000000                             ....            
\ No newline at end of file
+ 0330 00000000                             ....            
index 34132d1264e57cc416da62fa3285bdc94e59701d..028545b19657b0bb2c161a759a27784da4694038 100644 (file)
@@ -35,4 +35,4 @@ Contents of section .data:
  01e0 02000600 1e000211 48000000 04020000  ........H.......
  01f0 00000000 06000000 01000100 00746875  .............thu
  0200 6e6b00f1 02000600 0e005e11 04000000  nk........^.....
- 0210 01000100 02100000 02000600 00000000  ................
\ No newline at end of file
+ 0210 01000100 02100000 02000600 00000000  ................
index 7d314edb670dcfcb0de55ef602eee5e4ec6a9144..f9d8a74bb6bdd2717730a2d29866930470b427b8 100644 (file)
@@ -12,4 +12,4 @@ Contents of section .data:
  0070 4d5e0200 8a940200 4b710300 6aa90300  *
  0080 0a2c0300 67e10300 4a3d0300 fa460300  *
  0090 db020200 ec4e0100 131e0300 fb120300  *
- 00a0 aece0200 1db70100 99a30000 a8010100  *
\ No newline at end of file
+ 00a0 aece0200 1db70100 99a30000 a8010100  *
index 52c10fa501dea3151e6c55a6fc74b56db1c56718..f13b1d8dfeb33ad9dba76ec28041be7a778ee7d7 100644 (file)
@@ -2,4 +2,4 @@
 *:     file format binary
 
 Contents of section .data:
- 0000 00100000 00000000                    *
\ No newline at end of file
+ 0000 00100000 00000000                    *
index 248dda50d2dc80d1feb572148e8e8b71fcac5f0c..db08b52859fc673164a22a6947f92010291387a6 100644 (file)
@@ -77,4 +77,4 @@ Contents of section .data:
  0480 3a001d15 2a100000 00000000 00000000  :...*...........
  0490 27000000 49556e6b 6e6f776e 00517565  '...IUnknown.Que
  04a0 7279496e 74657266 61636500 41646452  ryInterface.AddR
- 04b0 65660052 656c6561 736500f1           ef.Release..    
\ No newline at end of file
+ 04b0 65660052 656c6561 736500f1           ef.Release..    
index 71d9045fbbdc6c5b1ebedcbc093f46e0d6a3e87f..d09fb3e332c4b7a657ca2795f65dce5f75fcfb08 100644 (file)
@@ -5,4 +5,4 @@ Contents of section .data:
  0000 75cf0100 8d660300 f2a20300 aea00000  *
  0010 ef990300 223d0000 d6b60000 24070100  *
  0020 7f220100 f6d10200 16100200 010a0300  *
- 0030 0b4f0300 12690300 a56d0300           *
\ No newline at end of file
+ 0030 0b4f0300 12690300 a56d0300           *
index 52c10fa501dea3151e6c55a6fc74b56db1c56718..f13b1d8dfeb33ad9dba76ec28041be7a778ee7d7 100644 (file)
@@ -2,4 +2,4 @@
 *:     file format binary
 
 Contents of section .data:
- 0000 00100000 00000000                    *
\ No newline at end of file
+ 0000 00100000 00000000                    *
index d0fd26e0fa4933ab11974ee7bc19f9bb6027c450..d8a36cc71b2399c20d93448dba67d9cebfd07c8c 100644 (file)
@@ -17,4 +17,4 @@ Contents of section .data:
  00c0 6500f2f1 12000116 00000000 01100000  e...............
  00d0 66756e63 3100f2f1 12000116 0b100000  func1...........
  00e0 01100000 66756e63 3200f2f1 12000216  ....func2.......
- 00f0 02100000 04100000 6d657468 6f6400f1  ........method..
\ No newline at end of file
+ 00f0 02100000 04100000 6d657468 6f6400f1  ........method..
index 4a3775be42a0f31b26aeeaebee1edbe5535c5b50..eda23d781884258b124d2fac92116fa18619993f 100644 (file)
@@ -2,4 +2,4 @@
 *:     file format binary
 
 Contents of section .data:
- 0000 d4d90000 0c1c0000                    *
\ No newline at end of file
+ 0000 d4d90000 0c1c0000                    *
index 52c10fa501dea3151e6c55a6fc74b56db1c56718..f13b1d8dfeb33ad9dba76ec28041be7a778ee7d7 100644 (file)
@@ -2,4 +2,4 @@
 *:     file format binary
 
 Contents of section .data:
- 0000 00100000 00000000                    *
\ No newline at end of file
+ 0000 00100000 00000000                    *
index d6ffaadb24614bcf11101f3c95f6ff727af46c14..48d7dbdad85c346ae2b7ec3bda09142b66c58fc7 100644 (file)
@@ -4,4 +4,4 @@
 Contents of section .data:
  0000 0e000516 00000000 666f6f2e 6800f2f1  ........foo.h...
  0010 10000716 01100000 01000000 2a000000  ............*...
- 0020 0100                                 ..              
\ No newline at end of file
+ 0020 0100                                 ..              
index f7df2d90782281c569fc043276ae00a8bc6338cc..0882f1b85a4ce8a526d3824670ed1e285165184c 100644 (file)
@@ -38,4 +38,4 @@ Contents of section .data:
  0210 00000000 00000000 00000000 00000000  ................
  0220 00000000 00000000 00000000 00000000  ................
  0230 00000000 00000000 00000000 00000000  ................
- 0240 00000000 0c000000 00000000 14000000  ................
\ No newline at end of file
+ 0240 00000000 0c000000 00000000 14000000  ................
index 2078a5e8a57f0727db17f6f5751de735d87d12fa..88cc21e0fae86ff8cbbcd24bf77b281af83ce46f 100644 (file)
@@ -4,4 +4,4 @@
 Contents of section .data:
  0000 12000e11 02000000 08000000 0100666f  ..............fo
  0010 6f000000 12000e11 00000000 04000000  o...............
- 0020 02006261 72000000                    ..bar...        
\ No newline at end of file
+ 0020 02006261 72000000                    ..bar...        
index 65ed76dafdce7d783c51a6f8be87feee781cf259..5b1df9fd931af75a22e4acb20140e27f92354346 100644 (file)
@@ -9,4 +9,4 @@ Contents of section .data:
  0040 00000000 3d000000 40000040 00000000  ....=...@..@....
  0050 00000000 00000000 04000000 00000000  ................
  0060 0c000000 40000042 02000000 00000000  ....@..B........
- 0070 00000000                             ....            
\ No newline at end of file
+ 0070 00000000                             ....            
index 5a4f94861c78662daa57d46b53de838945aa9e1e..8c2f320f69272d5af3d7ff18f7db39ad616e50f7 100644 (file)
@@ -11,4 +11,4 @@ Contents of section .data:
  0060 04000000 02000080 18000000 02000000  ................
  0070 1c000000 08000000 03000080 0c000000  ................
  0080 04000080 00000000 01000000 14000000  ................
- 0090 10000000 05000080                    ........        
\ No newline at end of file
+ 0090 10000000 05000080                    ........        
index 1c33ce1e7986790a247fdfec20b41274bf3ef06b..f74af2f81af5e82d78c440d0b03937ced3a681d0 100644 (file)
@@ -5,4 +5,4 @@ Contents of section .data:
  0000 f4000000 30000000 06000000 100198ba  ....0...........
  0010 dcfe1023 45676745 2301efcd ab890000  ...#EggE#.......
  0020 0a000000 10013b2a 19087f6e 5d4c4c5d  ......;*...n]LL]
- 0030 6e7f0819 2a3b0000                    n...*;..        
\ No newline at end of file
+ 0030 6e7f0819 2a3b0000                    n...*;..        
index 5b7d58cfa0cf236ee29d106eead6f93e3a79c74d..4239c1cb9cf30cfea44d8349fcab36beb29a754a 100644 (file)
@@ -4,4 +4,4 @@
 Contents of section .data:
  0000 03000300 00000100 02000200 02000000  ................
  0010 00000000 04000000 04000000 08000000  ................
- 0020 666f6f00 62617200 62617a00           foo.bar.baz.    
\ No newline at end of file
+ 0020 666f6f00 62617200 62617a00           foo.bar.baz.    
index 6e56b6bab1829c00adcffd7c25acfd1223b1cde4..83b087279f4ac1c0a5a8d2e2ab4c3d1c81cb0f36 100644 (file)
@@ -104,7 +104,7 @@ proc run_test { } {
     set exec_output [run_host_cmd "$ld" "-plugin $libdep_plugin -o libdep.exe libdep-main.o -L libdep-a -la -e 0"]
     set exec_output [prune_warnings $exec_output]
 
-    set expected_output "got deps for library libdep-a/liba.a: -Llibdep-b -lc"
+    set expected_output "got deps for library libdep-a/liba.a: -Llibdep-b -lc\n"
     
     if ![string match $expected_output $exec_output] then {
        fail "$testname: did not get expected output from the linker"
index 9476caf7ab47183ba5baca1ecb71227c898f754c..ad59e2abd61fdf97b8e559f37982695685c278ad 100644 (file)
@@ -895,7 +895,7 @@ 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 {
+       if [string match "PASS\n" $exec_output] then {
            pass "PR ld/28138 (build & run)"
        } else {
            fail "PR ld/28138 (built ok, run failed)"
index 57a1cc44e2c0d4292549ba57167c298d7b15ce22..ea1a91a41cd7db5fbcd526dc66497416b5da887f 100644 (file)
@@ -774,9 +774,9 @@ proc undefined_weak {cflags ldflags} {
 
     if { [string match "*-fPIE*" $cflags]
         && ![string match "*nodynamic-undefined-weak*" $ldflags] } {
-       set weak_symbol "Weak defined"
+       set weak_symbol "Weak defined\n"
     } else {
-       set weak_symbol "Weak undefined"
+       set weak_symbol "Weak undefined\n"
     }
 
     run_cc_link_tests [list \
index e6e643ca3caad4b36a2b1997f4926074229dc2a4..aeef82a9ae2d88ba3824a165069b704dc42d9bb0 100644 (file)
@@ -109,12 +109,12 @@ proc run_host_cmd { prog command } {
        set gccflags "$gcc_B_opt $gccflags $ld_L_opt"
        if {![info exists gcc_ld_B_opt_tested]} {
            set gcc_ld_B_opt_tested 1
-           set ld_version_message [run_host_cmd "$ld" "--version"]
+           set ld_version_message [string trim [run_host_cmd "$ld" "--version"]]
            set ver "-Wl,--version"
            if [check_lto_available] {
                set ver "-fno-lto $ver"
            }
-           set gcc_ld_version_message [run_host_cmd "$prog" "$gccflags $ver"]
+           set gcc_ld_version_message [string trim [run_host_cmd "$prog" "$gccflags $ver"]]
            if {[string first $ld_version_message $gcc_ld_version_message] < 0} {
                perror "************************************************************************"
                perror "Your compiler apparently ignores -B when choosing ld."
@@ -123,7 +123,7 @@ proc run_host_cmd { prog command } {
                    perror "Hint: don't configure gcc using --with-ld (or --with-as)"
                }
                perror "You will not be testing the new ld in many of the following tests."
-               set gcc_ld_version [run_host_cmd "$prog" "$gccflags --print-prog-name=ld"]
+               set gcc_ld_version [string trim [run_host_cmd "$prog" "$gccflags --print-prog-name=ld"]]
                if {![string match "" $gcc_ld_version] && ![string match "ld" $gcc_ld_version]} {
                    perror "It seems you will be testing $gcc_ld_version instead."
                }
@@ -136,9 +136,8 @@ proc run_host_cmd { prog command } {
     set status [remote_exec host [concat sh -c [list "$prog $gccflags $command 2>&1"]] "" "/dev/null" "ld.tmp"]
     remote_upload host "ld.tmp"
     set link_output [file_contents "ld.tmp"]
-    regsub "\n$" $link_output "" link_output
     if { [lindex $status 0] != 0 && [string match "" $link_output] } then {
-       append link_output "child process exited abnormally"
+       set link_output "child process exited abnormally"
     }
     remote_file build delete ld.tmp
     remote_file host delete ld.tmp