[3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames
Commit Message
This patch fixes some testcases that formerly had patterns with
hardwired "/" pathname separators in them, which broke when testing on
(remote) Windows host.
---
.../maint-expand-symbols-header-file.exp | 4 +--
gdb/testsuite/gdb.base/setshow.exp | 14 ++++++--
gdb/testsuite/gdb.dwarf2/dw2-filename.exp | 2 +-
gdb/testsuite/gdb.mi/mi-info-sources.exp | 32 +++++++++----------
4 files changed, 30 insertions(+), 22 deletions(-)
Comments
>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:
Sandra> This patch fixes some testcases that formerly had patterns with
Sandra> hardwired "/" pathname separators in them, which broke when testing on
Sandra> (remote) Windows host.
Sandra> + set STRINGHOME ""
Sandra> set test "show environment HOME"
Sandra> gdb_test_multiple $test $test {
Sandra> -re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$::gdb_prompt $" {
Sandra> set HOME $expect_out(1,string)
Sandra> + if { [ishost *-*-mingw*] } {
Sandra> + # Backslashes in the pathname must be escaped for the patterns
Sandra> + # that match quoted string output.
Sandra> + regsub -all {\\} $HOME {\\\\} STRINGHOME
I don't understand this one, because the uses all use string_to_regexp.
But if the computed value of HOME doesn't work in that context, then it
seems like that means there is a bug in string_to_regexp, because the
contract of string_to_regexp is to return a regexp that will exactly
match the input, no matter what it is.
Sandra> - "The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
Sandra> + "The filename in which to record the command history is \"[string_to_regexp $HOME].foobar.baz\"..*" \
Also why didn't this one need to be changed? (Though if there really is
a bug in string_to_regexp then it's irrelevant.)
Tom
On 4/21/23 08:44, Tom Tromey wrote:
>>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:
>
> Sandra> This patch fixes some testcases that formerly had patterns with
> Sandra> hardwired "/" pathname separators in them, which broke when testing on
> Sandra> (remote) Windows host.
>
> Sandra> + set STRINGHOME ""
> Sandra> set test "show environment HOME"
> Sandra> gdb_test_multiple $test $test {
> Sandra> -re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$::gdb_prompt $" {
> Sandra> set HOME $expect_out(1,string)
> Sandra> + if { [ishost *-*-mingw*] } {
> Sandra> + # Backslashes in the pathname must be escaped for the patterns
> Sandra> + # that match quoted string output.
> Sandra> + regsub -all {\\} $HOME {\\\\} STRINGHOME
>
> I don't understand this one, because the uses all use string_to_regexp.
> But if the computed value of HOME doesn't work in that context, then it
> seems like that means there is a bug in string_to_regexp, because the
> contract of string_to_regexp is to return a regexp that will exactly
> match the input, no matter what it is.
The output of the two commands it is trying to match using STRINGHOME
(as opposed to HOME) is
p $_gdb_setting("history filename")
$1 = "C:\\cygwin\\home\\sandra/foobar.baz"
p $_gdb_setting_str("history filename")
$2 = "C:\\cygwin\\home\\sandra/foobar.baz"
E.g., the output is printed with C string syntax, in which every
backslash is doubled. So the thing passed to string_to_regexp also
needs to have doubled backslashes.
>
> Sandra> - "The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
> Sandra> + "The filename in which to record the command history is \"[string_to_regexp $HOME].foobar.baz\"..*" \
>
> Also why didn't this one need to be changed? (Though if there really is
> a bug in string_to_regexp then it's irrelevant.)
Because in this case the output it is trying to match does is *not*
printed with C string escapes in spite of the surrounding quotes.
Maybe this just needs more comments? Or is there a utility function to
add C escapes to a string that should be used on non-Windows hosts too?
-Sandra
Sandra> The output of the two commands it is trying to match using STRINGHOME
Sandra> (as opposed to HOME) is
Sandra> p $_gdb_setting("history filename")
Sandra> $1 = "C:\\cygwin\\home\\sandra/foobar.baz"
Sandra> p $_gdb_setting_str("history filename")
Sandra> $2 = "C:\\cygwin\\home\\sandra/foobar.baz"
Ok, I get it now. Thanks.
Sandra> Maybe this just needs more comments? Or is there a utility function
Sandra> to add C escapes to a string that should be used on non-Windows hosts
Sandra> too?
I think a comment by the setting of STRINGHOME would be great.
Tom
@@ -40,13 +40,13 @@ gdb_test_no_output "maint info symtabs" $test
gdb_test_no_output "maint expand-symtabs maint-expand-symbols-header-file.h"
# Check that the include symtab was in fact expanded.
-set file_re "\[^\r\n\]*/maint-expand-symbols-header-file.h"
+set file_re "\[^\r\n\]*maint-expand-symbols-header-file.h"
gdb_test "maint info symtabs" \
"\r\n\t{ symtab $file_re \\(\\(struct symtab \\*\\) $hex\\)\r\n.*" \
"check header file psymtab expansion"
# Check that the symtab the include symtab was referring to was expanded.
-set file_re "\[^\r\n\]*/maint-expand-symbols-header-file.c"
+set file_re "\[^\r\n\]*maint-expand-symbols-header-file.c"
gdb_test "maint info symtabs" \
"\r\n\t{ symtab $file_re \\(\\(struct symtab \\*\\) $hex\\)\r\n.*" \
"check source file psymtab expansion"
@@ -280,10 +280,18 @@ proc_with_prefix test_setshow_history {} {
#get home directory path
set HOME ""
+ set STRINGHOME ""
set test "show environment HOME"
gdb_test_multiple $test $test {
-re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$::gdb_prompt $" {
set HOME $expect_out(1,string)
+ if { [ishost *-*-mingw*] } {
+ # Backslashes in the pathname must be escaped for the patterns
+ # that match quoted string output.
+ regsub -all {\\} $HOME {\\\\} STRINGHOME
+ } else {
+ set STRINGHOME $HOME
+ }
pass $test
}
}
@@ -294,13 +302,13 @@ proc_with_prefix test_setshow_history {} {
#test show history filename ~/foobar.baz
gdb_test "show history filename" \
- "The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+ "The filename in which to record the command history is \"[string_to_regexp $HOME].foobar.baz\"..*" \
"show history filename (~/foobar.baz)"
gdb_test "p \$_gdb_setting(\"history filename\")" \
- " = \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+ " = \"[string_to_regexp $STRINGHOME].foobar.baz\".*" \
"_gdb_setting history filename"
gdb_test "p \$_gdb_setting_str(\"history filename\")" \
- " = \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+ " = \"[string_to_regexp $STRINGHOME].foobar.baz\".*" \
"_gdb_setting_str history filename"
#get current working directory
@@ -38,4 +38,4 @@ gdb_test "interpreter-exec mi -file-list-exec-source-files" \
".*{file=\"file1\\.txt\",fullname=\".+file1\\.txt\",debug-fully-read=\"\[^\"\]+\"}.*"
# And `info sources' should return the fullname incl. the directories.
-gdb_test "info sources" {[/]file1\.txt.*}
+gdb_test "info sources" {.+file1\.txt.*}
@@ -118,16 +118,16 @@ proc check_info_sources { debug_fully_read } {
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
} else {
@@ -135,16 +135,16 @@ proc check_info_sources { debug_fully_read } {
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
}
@@ -156,8 +156,8 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]]]
mi_gdb_test "-file-list-exec-source-files --basename -- base" ".*\\^done,${p}" \
"-file-list-exec-source-files --basename -- base"
@@ -171,13 +171,13 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
+ [mi_field "filename" "\[^\"\]+mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]]]
mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \
@@ -186,13 +186,13 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
+ [mi_field "filename" "\[^\"\]+mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]]]
mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \