# expected error. If WARNING_OR_ERROR is empty, it is expected that
# GDB prints no text other than the print result.
proc test_shift {lang cmd result_re {warning_or_error ""}} {
- set cmd_re [string_to_regexp $cmd]
-
if {$lang == "go"} {
if {$warning_or_error != ""} {
set error_re "[string_to_regexp $warning_or_error]"
gdb_test_multiple $cmd "" {
- -re -wrap "^$cmd_re\r\n$error_re" {
+ -re -wrap "^$error_re" {
pass $gdb_test_name
}
}
} else {
gdb_test_multiple $cmd "" {
- -re -wrap "^$cmd_re\r\n\\$$::decimal$result_re" {
+ -re -wrap "^\\$$::decimal$result_re" {
pass $gdb_test_name
}
}
}
gdb_test_multiple $cmd "" {
- -re -wrap "^$cmd_re\r\n$warning_re\\$$::decimal$result_re" {
+ -re -wrap "^$warning_re\\$$::decimal$result_re" {
pass $gdb_test_name
}
}
if {$variant != "filename"} {
# This odd expected output here is because we expect GDB to
# emit a single blank line as a result of this command.
- gdb_test "$show_cmd" "^" "$show_cmd: show default"
+ gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: show default"
} else {
gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default"
}
gdb_test_no_output "$set_cmd"
# This odd expected output here is because we expect GDB to
# emit a single blank line as a result of this command.
- gdb_test "$show_cmd" "^" "$show_cmd: empty second time"
+ gdb_test -nonl "$show_cmd" "^\r\n" "$show_cmd: empty second time"
}
}
# pass $gdb_test_name
# }
# }
+# The special handling of '^' that is available in gdb_test is also
+# supported in gdb_test_multiple when -wrap is used.
#
# In EXPECT_ARGUMENTS, a pattern flag -early can be used. It makes sure the
# pattern is inserted before any implicit pattern added by gdb_test_multiple.
set expecting_action 1
if { $wrap_pattern } {
# Wrap subst_item as is done for the gdb_test PATTERN argument.
+ if {[string range $subst_item 0 0] eq "^"} {
+ if {$command ne ""} {
+ set command_regex [string_to_regexp $command]
+ set subst_item [string range $subst_item 1 end]
+ if {[string length "$subst_item"] > 0} {
+ # We have an output pattern (other than the '^'),
+ # add a newline at the start, this will eventually
+ # sit between the command and the output pattern.
+ set subst_item "\r\n${subst_item}"
+ }
+ set subst_item "^${command_regex}${subst_item}"
+ }
+ }
lappend $current_list \
"(?:$subst_item)\r\n$prompt_regexp"
set wrap_pattern 0
# additional pattern that matches the command immediately after
# the '^'.
if {[string range $pattern 0 0] eq "^"} {
- set command_regex [string_to_regexp $command]
- set pattern [string range $pattern 1 end]
- if {$command_regex ne ""} {
- set pattern "^${command_regex}\r\n$pattern"
+ if {$command ne ""} {
+ set command_regex [string_to_regexp $command]
+ set pattern [string range $pattern 1 end]
+ if {[string length "$pattern"] > 0} {
+ # We have an output pattern (other than the '^'), add a
+ # newline at the start, this will eventually sit between the
+ # command and the output pattern.
+ set pattern "\r\n$pattern"
+ }
+ set pattern "^${command_regex}${pattern}"
}
}
perror "Did not manage to set $var"
} else {
# Set var.
- set cmd "set $var $val"
- gdb_test_multiple $cmd "" {
- -re -wrap "^$cmd" {
+ gdb_test_multiple "set $var $val" "" {
+ -re -wrap "^" {
}
-re -wrap " is set to \"?$val\"?\\." {
}
# Restore saved setting.
if { $save != "" } {
- set cmd "set $var $save"
- gdb_test_multiple $cmd "" {
- -re -wrap "^$cmd" {
+ gdb_test_multiple "set $var $save" "" {
+ -re -wrap "^" {
}
-re -wrap "is set to \"?$save\"?( \\(\[^)\]*\\))?\\." {
}
set val ${default}
gdb_test_multiple "print${fmt} ${exp}" "$test" {
- -re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+ -re -wrap "^\\$\[0-9\]* = (\[^\r\n\]*)" {
set val $expect_out(1,string)
pass "$test"
}
set val ${default}
gdb_test_multiple "print /d ${exp}" "$test" {
- -re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
+ -re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
set val $expect_out(1,string)
pass "$test"
}