From a68f7e9844208ad8cd498f89b5100084ece7d0f6 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 9 May 2023 10:28:42 +0100 Subject: gdb/testsuite: extend special '^' handling to gdb_test_multiple The commit: commit 08ec06d6440745ef9204d39197aa1e732df41056 Date: Wed Mar 29 10:41:07 2023 +0100 gdb/testsuite: special case '^' in gdb_test pattern Added some special handling of '^' to gdb_test -- a leading '^' will cause the command regexp to automatically be included in the expected output pattern. It was pointed out that the '-wrap' flag of gdb_test_multiple is supposed to work in the same way as gdb_test, and that the recent changes for '^' had not been replicated for gdb_test_multiple. This patch addresses this issue. So, after this commit, the following two constructs should have the same meaning: gdb_test "command" "^output" "test name" gdb_test_multiple "command" "test name" { -re -wrap "^output" { pass $gdb_test_name } } In both cases the '^' will case gdb.exp to inject a regexp that matches 'command' after the '^' and before the 'output', this is in addition to adding the $gdb_prompt pattern after 'output' in the normal way. The special '^' handling is only applied when '-wrap' is used, as this is the only mode that aims to mimic gdb_test. While working on this patch I realised that I could actually improve the logic for the special '^' handling in the case where the expected output pattern is empty. I replicated these updates for both gdb_test and gdb_test_multiple in order to keep these two paths in sync. There were a small number of tests that needed adjustment after this change, mostly just removing command regexps that are now added automatically, but the gdb.base/settings.exp case was a little weird as it turns out trying to match a single blank line is probably harder now than it used to be -- still, I suspect this is a pretty rare case, so I think the benefits (improved anchoring) outweigh this small downside (IMHO). --- gdb/testsuite/gdb.base/bitshift.exp | 8 +++----- gdb/testsuite/gdb.base/maint-print-frame-id.exp | 4 ---- gdb/testsuite/gdb.base/settings.exp | 4 ++-- gdb/testsuite/gdb.base/wrap-line.exp | 3 +-- 4 files changed, 6 insertions(+), 13 deletions(-) (limited to 'gdb/testsuite/gdb.base') diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp index adc5996d736..5ea0cd870ed 100644 --- a/gdb/testsuite/gdb.base/bitshift.exp +++ b/gdb/testsuite/gdb.base/bitshift.exp @@ -24,19 +24,17 @@ clean_restart # 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 } } @@ -49,7 +47,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} { } 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 } } diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp index 2ad9b6ddfd7..9e88f37205f 100644 --- a/gdb/testsuite/gdb.base/maint-print-frame-id.exp +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp @@ -33,10 +33,6 @@ proc get_frame_id { level } { set id "**unknown**" gdb_test_multiple "maint print frame-id ${level}" "" { - -re "^maint print frame-id\[^\r\n\]+\r\n" { - exp_continue - } - -wrap -re "^frame-id for frame #\[0-9\]+: (\[^\r\n\]+)" { set id $expect_out(1,string) pass $gdb_test_name diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index 6248ba3e495..ac885d838a1 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -542,7 +542,7 @@ proc test-string {variant} { 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" } @@ -574,7 +574,7 @@ proc test-string {variant} { 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" } } diff --git a/gdb/testsuite/gdb.base/wrap-line.exp b/gdb/testsuite/gdb.base/wrap-line.exp index 03d94720c9c..81c1514cfb4 100644 --- a/gdb/testsuite/gdb.base/wrap-line.exp +++ b/gdb/testsuite/gdb.base/wrap-line.exp @@ -57,8 +57,7 @@ proc get_screen_width { } { set cmd "maint info screen" set re \ [multi_line \ - ^$cmd \ - $re1 \ + ^$re1 \ $re2 \ "(?:$re3" \ ")?$re4" \ -- cgit v1.2.1