From 4fa173cfd79f8a00c091f8a5a119bc2b064cc716 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 24 Apr 2023 22:08:53 +0200 Subject: [PATCH] [gdb/testsuite] Fix -wrap in presence of -prompt in gdb_test_multiple While writing a gdb_test_multiple call in a test-case I tried to use -wrap in combination with -prompt and found out that it doesn't work, because -wrap uses "$gdb_prompt $" instead of $prompt_regexp. Fix this by making -wrap use $prompt_regexp. Tested on x86_64-linux. --- gdb/testsuite/gdb.testsuite/gdb-test.exp | 11 +++++++++++ gdb/testsuite/lib/gdb.exp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.testsuite/gdb-test.exp b/gdb/testsuite/gdb.testsuite/gdb-test.exp index a582b1b125f..e19f2a8de4a 100644 --- a/gdb/testsuite/gdb.testsuite/gdb-test.exp +++ b/gdb/testsuite/gdb.testsuite/gdb-test.exp @@ -48,3 +48,14 @@ with_test_prefix "cmd with trailing control code" { gdb_assert { [string equal $output $expected_error_msg] } } } + +# Change the prompt. +set prompt "(GDB) " +set prompt_re "\\(GDB\\) $" +gdb_test -prompt $prompt_re "set prompt $prompt" + +gdb_test_multiple "print 1" "" -prompt $prompt_re { + -re -wrap " = 1" { + pass $gdb_test_name + } +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 45588d85aea..d30e2a5e6c7 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1126,7 +1126,7 @@ proc gdb_test_multiple { command message args } { if { $wrap_pattern } { # Wrap subst_item as is done for the gdb_test PATTERN argument. lappend $current_list \ - "\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $" + "\[\r\n\]*(?:$subst_item)\[\r\n\]+$prompt_regexp" set wrap_pattern 0 } else { lappend $current_list $subst_item -- 2.30.2