From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7862) id 92CD33857BBD; Fri, 15 Jul 2022 17:20:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92CD33857BBD Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Bruno Larsen To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: modernize gdb.base/maint.exp X-Act-Checkin: binutils-gdb X-Git-Author: Bruno Larsen X-Git-Refname: refs/heads/master X-Git-Oldrev: 3028a2dbbffb2e15cc2364d0c962951f6f2230f2 X-Git-Newrev: 13c3e10f98ff9b89c12161e85bd576ea77460a83 Message-Id: <20220715172012.92CD33857BBD@sourceware.org> Date: Fri, 15 Jul 2022 17:20:12 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2022 17:20:12 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D13c3e10f98ff= 9b89c12161e85bd576ea77460a83 commit 13c3e10f98ff9b89c12161e85bd576ea77460a83 Author: Bruno Larsen Date: Tue Jun 28 15:36:45 2022 -0300 gdb/testsuite: modernize gdb.base/maint.exp =20 gdb.base/maint.exp was using several gdb_expect statements, probably because this test case predates the existance of gdb_test_multiple. This commit updates the test case to use gdb_test_multiple, making it more resilient to internal errors and such. =20 The only gdb_expect left in the testcase is one that specifically looks for an internal error being triggered as a PASS. Diff: --- gdb/testsuite/gdb.base/maint.exp | 146 ++++++++++++-----------------------= ---- 1 file changed, 45 insertions(+), 101 deletions(-) diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/main= t.exp index 2817c6eafb9..16628b4a8b6 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -151,22 +151,24 @@ set have_psyms [expr ! ( $have_gdb_index || $readnow_= p )] # unless there is some problem with the symtabs and psymtabs # so that branch will really never be covered in this tests here!! # +# When there is a problem, there may be loads of output, which can +# overwhelm the expect buffer. Splitting it seems to fix those +# issues. + +set seen_command false +gdb_test_multiple "maint check-psymtabs" "" { + -re "^maint check-psymtabs\r\n" { + set seen_command true + exp_continue + } =20 -# guo: on linux this command output is huge. for some reason splitting up -# the regexp checks works. -# -send_gdb "maint check-psymtabs\n" -gdb_expect { - -re "^maint check-psymtabs" { - gdb_expect { - -re "$gdb_prompt $" { - pass "maint check-psymtabs" - } - timeout { fail "(timeout) maint check-psymtabs" } - } + -re "^$gdb_prompt $" { + gdb_assert { $seen_command } $gdb_test_name + } + + -re "^\[^\r\n\]+\r\n" { + exp_continue } - -re ".*$gdb_prompt $" { fail "maint check-psymtabs" } - timeout { fail "(timeout) maint check-psymtabs" } } =20 # This command does not produce any output unless there is some problem @@ -272,63 +274,29 @@ if { $have_psyms } { "maint print psymbols -pc" \ "maint print psymbols -pc main $psymbols_output"] foreach { test_name command } $test_list { - send_gdb "$command\n" - gdb_expect { - -re "^maint print psymbols \[^\n\]*\r\n$gdb_prompt $" { - send_gdb "shell ls $psymbols_output\n" - gdb_expect { - -re "$psymbols_output_re\r\n$gdb_prompt $" { - # We want this grep to be as specific as possible, - # so it's less likely to match symbol file names in - # psymbols_output. Yes, this actually happened; - # poor expect got tons of output, and timed out - # trying to match it. --- Jim Blandy - send_gdb "shell grep 'main.*function' $psymbols_output\n" - gdb_expect { - -re ".main., function, $hex.*$gdb_prompt $" { - pass "$test_name 1" - } - -re ".*main. .., function, $hex.*$gdb_prompt $" { - pass "$test_name 2" - } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } - gdb_test "shell rm -f $psymbols_output" ".*" \ - "${test_name}: shell rm -f psymbols_output" - } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } + gdb_test_no_output "$command" "collecting data for $test_name" + gdb_test_multiple "shell grep 'main.*function' $psymbols_output" "" { + -re -wrap ".main., function, $hex.*" { + pass "$test_name (pattern 1)" } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } + -re -wrap ".*main. .., function, $hex.*" { + pass "$test_name (pattern 2)" + } + } + gdb_test "shell rm -f $psymbols_output" ".*" \ + "${test_name}: shell rm -f psymbols_output" } } =20 =20 set msymbols_output [standard_output_file msymbols_output] set msymbols_output_re [string_to_regexp $msymbols_output] -send_gdb "maint print msymbols -objfile ${binfile} $msymbols_output\n" -gdb_expect { - -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { - send_gdb "shell ls $msymbols_output\n" - gdb_expect { - -re "$msymbols_output_re\r\n$gdb_prompt $" { - gdb_test "shell grep factorial $msymbols_output" \ - "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ - "maint print msymbols, absolute pathname" - gdb_test "shell rm -f $msymbols_output" ".*" \ - "shell rm -f msymbols_output" - } - -re ".*$gdb_prompt $" { fail "maint print msymbols" } - timeout { fail "maint print msymbols (timeout)" } - } - } - -re ".*$gdb_prompt $" { fail "maint print msymbols" } - timeout { fail "maint print msymbols (timeout)" } -} +gdb_test_no_output "maint print msymbols -objfile ${binfile} $msymbols_out= put" \ + "print msymbols to file, with absolute path" +gdb_test "shell grep factorial $msymbols_output" \ + "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ + "maint print msymbols, absolute pathname" +gdb_test "shell rm -f $msymbols_output" ".*" "remove absolute path msymbol= s" =20 # Check that maint print msymbols allows relative pathnames set mydir [pwd] @@ -336,18 +304,13 @@ gdb_test "cd [standard_output_file {}]" \ "Working directory .*\..*" \ "cd to objdir" =20 -gdb_test_multiple "maint print msymbols -objfile ${testfile} msymbols_outp= ut2" "maint print msymbols" { - -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { - gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" { - -re "msymbols_output2\r\n$gdb_prompt $" { - gdb_test "shell grep factorial msymbols_output2" \ - "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ - "maint print msymbols, relative pathname" - gdb_test "shell rm -f msymbols_output2" ".*" - } - } - } -} +gdb_test_no_output "maint print msymbols -objfile ${testfile} $msymbols_ou= tput"\ + "print msymbols to file, with relative path" +gdb_test "shell grep factorial $msymbols_output" \ + "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ + "maint print msymbols, relative pathname" +gdb_test "shell rm -f msymbols_output" ".*" "remove relative path msymbols" + gdb_test "cd ${mydir}" \ "Working directory [string_to_regexp ${mydir}]\..*" \ "cd to mydir" @@ -365,31 +328,12 @@ set test_list [list \ "maint print symbols -pc" \ "maint print symbols -pc main $symbols_output"] foreach { test_name command } $test_list { - send_gdb "$command\n" - gdb_expect { - -re "^maint print symbols \[^\n\]*\r\n$gdb_prompt $" { - send_gdb "shell ls $symbols_output\n" - gdb_expect { - -re "$symbols_output_re\r\n$gdb_prompt $" { - # See comments for `maint print psymbols'. - send_gdb "shell grep 'main(.*block' $symbols_output\n" - gdb_expect { - -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $"= { - pass "$test_name" - } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } - gdb_test "shell rm -f $symbols_output" ".*" \ - "$test_name: shell rm -f symbols_output" - } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } - } - -re ".*$gdb_prompt $" { fail "$test_name" } - timeout { fail "$test_name (timeout)" } - } + gdb_test_no_output "$command" "$test_name generate" + gdb_test "shell grep 'main(.*block' $symbols_output"\ + "int main\\(int, char \\*\\*, char \\*\\*\\); block.*"\ + "$test_name read" + gdb_test "shell rm -f $symbols_output" ".*" \ + "$test_name: shell rm -f symbols_output" } =20 set msg "maint print type"