gdb/testsuite: fix list.exp test cases

PR testsuite/7142 -- old enough to have been converted from Gnats --
points out that test_list_filename_and_function in gdb.base/list.exp
has "fails" that are unmatched with passes.  This patch cleans this up
a little.

Co-authored-by: Tom Tromey <tromey@adacore.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7142
This commit is contained in:
Andrew Burgess
2022-02-24 08:40:29 -07:00
parent 0f94906fba
commit 13cd9508af

@ -251,36 +251,28 @@ proc test_list_filename_and_function {} {
global gdb_prompt global gdb_prompt
global last_line_re global last_line_re
set testcnt 0
# gcc appears to generate incorrect debugging information for code # gcc appears to generate incorrect debugging information for code
# in include files, which breaks this test. # in include files, which breaks this test.
# SunPRO cc is the second case below, it's also correct. # SunPRO cc is the second case below, it's also correct.
send_gdb "list list0.c:main\n" gdb_test_multiple "list list0.c:main" "" {
gdb_expect { -re -wrap "1\[ \t\]+#include .*10\[ \t\]+foo \[(\]+.*\[)\]+;" {
-re "1\[ \t\]+#include .*10\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { pass $gdb_test_name
incr testcnt
} }
-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { -re -wrap "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" {
pass "list function in source file 1" pass $gdb_test_name
} }
-re ".*$gdb_prompt $" { fail "list list0.c:main" }
timeout { fail "list list0.c:main (timeout)" }
} }
# Not sure what the point of having this function be unused is. # Not sure what the point of having this function be unused is.
# AIX is legitimately removing it. # AIX is legitimately removing it.
setup_xfail "rs6000-*-aix*" setup_xfail "rs6000-*-aix*"
send_gdb "list list0.c:unused\n" gdb_test_multiple "list list0.c:unused" "" {
gdb_expect { -re -wrap "40\[ \t\]+unused.*${last_line_re}" {
-re "40\[ \t\]+unused.*${last_line_re}\r\n$gdb_prompt $" { pass $gdb_test_name
incr testcnt
} }
-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" { -re -wrap "37.*42\[ \t\]+\}" {
incr testcnt pass $gdb_test_name
} }
-re ".*$gdb_prompt $" { fail "list list0.c:unused" }
timeout { fail "list list0.c:unused (timeout)" }
} }
clear_xfail "rs6000-*-aix*" clear_xfail "rs6000-*-aix*"
@ -290,58 +282,47 @@ proc test_list_filename_and_function {} {
# SunPRO cc is the third case. # SunPRO cc is the third case.
setup_xfail "rs6000-*-*" 1804 setup_xfail "rs6000-*-*" 1804
setup_xfail_format "COFF" setup_xfail_format "COFF"
send_gdb "list list0.h:foo\n" gdb_test_multiple "list list0.h:foo" "" {
gdb_expect { -re -wrap "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;" {
-re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { pass $gdb_test_name
incr testcnt
} }
-re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { -re -wrap "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;" {
incr testcnt pass $gdb_test_name
} }
-re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { -re -wrap "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;" {
incr testcnt pass $gdb_test_name
} }
-re "No source file named list0.h.\r\n$gdb_prompt $" { -re -wrap "No source file named list0.h." {
fail "list list0.h:foo" fail $gdb_test_name
} }
-re ".*$gdb_prompt $" { fail "list list0.h:foo" }
timeout { fail "list list0.h:foo (timeout)" }
} }
# Ultrix gdb is the second case. # Ultrix gdb is the second case.
send_gdb "list list1.c:bar\n" gdb_test_multiple "list list1.c:bar" "" {
gdb_expect { -re -wrap "4\[ \t\]+void.*13\[ \t\]+\}" {
-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" { pass $gdb_test_name
incr testcnt
} }
-re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" { -re -wrap "4\[ \t\]+void.*12\[ \t\]*long_line ..;" {
incr testcnt pass $gdb_test_name
} }
-re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" { -re -wrap "4\[ \t\]+void.*11\[ \t\]*" {
incr testcnt pass $gdb_test_name
} }
-re ".*$gdb_prompt $" { fail "list list1.c:bar" }
timeout { fail "list list1.c:bar (timeout)" }
} }
# Not sure what the point of having this function be unused is. # Not sure what the point of having this function be unused is.
# AIX is legitimately removing it. # AIX is legitimately removing it.
setup_xfail "rs6000-*-aix*" setup_xfail "rs6000-*-aix*"
send_gdb "list list1.c:unused\n" gdb_test_multiple "list list1.c:unused" "" {
gdb_expect { -re -wrap "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}.*" {
-re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { pass $gdb_test_name
incr testcnt
} }
-re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" { -re -wrap "14.*19\[ \t\]+\}.*" {
incr testcnt pass $gdb_test_name
} }
-re ".*$gdb_prompt $" { fail "list list1.c:unused" }
timeout { fail "list list1.c:unused (timeout)" }
} }
clear_xfail "rs6000-*-aix*" clear_xfail "rs6000-*-aix*"
pass "list filename:function ($testcnt tests)"
# Test with quoting. # Test with quoting.
gdb_test "list 'list0.c:main'" "int main.*" gdb_test "list 'list0.c:main'" "int main.*"