[gdb/testsuite] Add -lbl option in gdb_test_multiple Add gdb_test_multiple option -lbl, that adds a regexp after the user code that reads one line, and discards it: ... -re "\r\n\[^\r\n\]*(?=\r\n)" { exp_continue } ... In order to be able to write: ... gdb_test_multiple "command" "testname" { ... } -lbl ... as opposed to having to insert the "" for the prompt_regexp arguments: ... gdb_test_multiple "command" "testname" { ... } "" -lbl ... rewrite the promp_regexp argument usage into: ... gdb_test_multiple "command" "testname" { ... } -prompt $prompt_regexp ... gdb/testsuite/ChangeLog: 2020-02-2120 Pedro Alves Tom de Vries * lib/gdb.exp (gdb_test_multiple): Handle prompt_regexp option using -prompt prefix. Add -lbl option. (skip_python_tests_prompt, skip_libstdcxx_probe_tests_prompt) (gdb_is_target_1): Add -prompt prefix. * gdb.base/corefile-buildid.exp: Use -lbl option. Rewrite regexps to have "\r\n" at start-of-line, instead of at end-of-line. --- gdb/testsuite/gdb.base/corefile-buildid.exp | 27 ++++++-------------------- gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/gdb/testsuite/gdb.base/corefile-buildid.exp b/gdb/testsuite/gdb.base/corefile-buildid.exp index b9844ee354..b91550bc82 100644 --- a/gdb/testsuite/gdb.base/corefile-buildid.exp +++ b/gdb/testsuite/gdb.base/corefile-buildid.exp @@ -114,17 +114,11 @@ proc check_exec_file {file} { # Get line with "Local exec file:". set ok 0 gdb_test_multiple "info files" "" { - -re "^Local exec file:\r\n" { + -re "\r\nLocal exec file:" { set test_name $gdb_test_name set ok 1 } - -re "^$gdb_prompt $" { - fail $gdb_test_name - } - -re "^\[^\r\n\]*\r\n" { - exp_continue - } - } + } -lbl if { $ok == 0 } { return @@ -133,16 +127,10 @@ proc check_exec_file {file} { # Get subsequent line with $file. set ok 0 gdb_test_multiple "" $test_name { - -re "^\[\t\ \]+`[string_to_regexp $file]'\[^\r\n\]*\r\n" { + -re "\r\n\[\t\ \]+`[string_to_regexp $file]'\[^\r\n\]*" { set ok 1 } - -re "^$gdb_prompt $" { - fail $gdb_test_name - } - -re "^\[^\r\n\]*\r\n" { - exp_continue - } - } + } -lbl if { $ok == 0 } { return @@ -150,13 +138,10 @@ proc check_exec_file {file} { # Skip till prompt. gdb_test_multiple "" $test_name { - -re "^$gdb_prompt $" { + -re "\r\n$gdb_prompt $" { pass $gdb_test_name } - -re "^\[^\r\n\]*\r\n" { - exp_continue - } - } + } -lbl } # Test whether gdb can find an exec file from a core file's build-id. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 81518b9646..caa64f36f1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -792,7 +792,7 @@ proc gdb_internal_error_resync {} { # } # } # -proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { +proc gdb_test_multiple { command message user_code args } { global verbose use_gdb_stub global gdb_prompt pagination_prompt global GDB @@ -802,6 +802,18 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { upvar expect_out expect_out global any_spawn_id + set line_by_line 0 + set prompt_regexp "" + for {set i 0} {$i < [llength $args]} {incr i} { + set opt [lindex $args $i] + if { $opt == "-prompt" } { + incr i + set prompt_regexp [lindex $args $i] + } elseif { $opt == "-lbl" } { + set line_by_line 1 + } + } + if { "$prompt_regexp" == "" } { set prompt_regexp "$gdb_prompt $" } @@ -1070,6 +1082,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { } } + if {$line_by_line} { + append code { + -re "\r\n\[^\r\n\]*(?=\r\n)" { + exp_continue + } + } + } + # Now patterns that apply to any spawn id specified. append code { -i $any_spawn_id @@ -2005,7 +2025,7 @@ proc skip_python_tests_prompt { prompt_regexp } { return 1 } -re "$prompt_regexp" {} - } "$prompt_regexp" + } -prompt "$prompt_regexp" gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" { -re "3.*$prompt_regexp" { @@ -2014,7 +2034,7 @@ proc skip_python_tests_prompt { prompt_regexp } { -re ".*$prompt_regexp" { set gdb_py_is_py3k 0 } - } "$prompt_regexp" + } -prompt "$prompt_regexp" return 0 } @@ -3274,7 +3294,7 @@ proc skip_libstdcxx_probe_tests_prompt { prompt_regexp } { } -re "\r\n$prompt_regexp" { } - } "$prompt_regexp" + } -prompt "$prompt_regexp" set skip [expr !$supported] return $skip } @@ -3322,7 +3342,7 @@ proc gdb_is_target_1 { target_name target_stack_regexp prompt_regexp } { -re "$prompt_regexp" { pass $test } - } "$prompt_regexp" + } -prompt "$prompt_regexp" return 0 }