[v2] binutils: testsuite: Fix "objdump --source-comment" test case on Windows.

Message ID 20260920153850.6958-1-jdx@o2.pl
State New
Headers
Series [v2] binutils: testsuite: Fix "objdump --source-comment" test case on Windows. |

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

Jan Dubiec Sept. 20, 2026, 3:38 p.m. UTC
  One of the objdump test cases fails on Windows:
[...]
Running /d/Works/binutils/binutils/testsuite/binutils-all/objdump.exp ...
Version /d/Works/xcomp/build-binutils-h8300-mingw/binutils/objdump 2.47.50.20260913
FAIL: objdump --source-comment
[...]

This is because, under Windows/MSYS2, command-line arguments are subject
to automatic conversion of Unix-style paths to Windows-style paths, as
described on https://www.msys2.org/docs/filesystem-paths/. As a result,
only one slash is passed to objdump, which emits "/static int local = 2"
instead of the expected "//static int local = 2".

This patch fixes the issue using the method described on the aforementioned
page.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
---
 binutils/testsuite/binutils-all/objdump.exp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
  

Comments

Jan Beulich Sept. 25, 2026, 6:44 a.m. UTC | #1
On 20.09.2026 17:38, Jan Dubiec wrote:
> --- a/binutils/testsuite/binutils-all/objdump.exp
> +++ b/binutils/testsuite/binutils-all/objdump.exp
> @@ -939,7 +939,29 @@ proc test_objdump_S { } {
>  
>      set test "objdump --source-comment"
>  
> -    set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
> +    if { [ishost *-*-mingw*] } then {
> +	# Under Windows/MSYS2, command-line arguments are subject to automatic
> +	# conversion of Unix-style paths to Windows-style paths, which can
> +	# sometimes cause problems, as in this case.
> +
> +	# Save the current value of MSYS2_ARG_CONV_EXCL.
> +	set conv_excl_was_set [info exists ::env(MSYS2_ARG_CONV_EXCL)]
> +	if {$conv_excl_was_set} {
> +	    set conv_excl $::env(MSYS2_ARG_CONV_EXCL)
> +	}
> +
> +	set ::env(MSYS2_ARG_CONV_EXCL) "--source-comment="
> +	set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
> +
> +	# Restore the previous value of MSYS2_ARG_CONV_EXCL.
> +	if {$conv_excl_was_set} {
> +	    set ::env(MSYS2_ARG_CONV_EXCL) $conv_excl
> +	} else {
> +	    unset ::env(MSYS2_ARG_CONV_EXCL)
> +	}
> +    } else {
> +	set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
> +    }
>  
>      set want "//static int local = 2"
>  

This isn't pretty, but what do you do: Okay.

Jan
  

Patch

diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 734f93298ed..99c74c4fd57 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -939,7 +939,29 @@  proc test_objdump_S { } {
 
     set test "objdump --source-comment"
 
-    set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
+    if { [ishost *-*-mingw*] } then {
+	# Under Windows/MSYS2, command-line arguments are subject to automatic
+	# conversion of Unix-style paths to Windows-style paths, which can
+	# sometimes cause problems, as in this case.
+
+	# Save the current value of MSYS2_ARG_CONV_EXCL.
+	set conv_excl_was_set [info exists ::env(MSYS2_ARG_CONV_EXCL)]
+	if {$conv_excl_was_set} {
+	    set conv_excl $::env(MSYS2_ARG_CONV_EXCL)
+	}
+
+	set ::env(MSYS2_ARG_CONV_EXCL) "--source-comment="
+	set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
+
+	# Restore the previous value of MSYS2_ARG_CONV_EXCL.
+	if {$conv_excl_was_set} {
+	    set ::env(MSYS2_ARG_CONV_EXCL) $conv_excl
+	} else {
+	    unset ::env(MSYS2_ARG_CONV_EXCL)
+	}
+    } else {
+	set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
+    }
 
     set want "//static int local = 2"