diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-12-21 09:16:28 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-12-21 09:16:44 -0500 |
commit | ca01f1bf3d9e5f5bcddf72bd83f574395e859d1c (patch) | |
tree | fa7611a83a69acf0c1af2970472fc955b4b09546 /gdb/testsuite/gdb.base | |
parent | 0fe69a94d4c4793d7247442e0611e5d3b8f542f5 (diff) | |
download | gdb-ca01f1bf3d9e5f5bcddf72bd83f574395e859d1c.zip gdb-ca01f1bf3d9e5f5bcddf72bd83f574395e859d1c.tar.gz gdb-ca01f1bf3d9e5f5bcddf72bd83f574395e859d1c.tar.bz2 |
gdb/testsuite: use gdb_test in gdb.base/list.exp
Use gdb_test instead of send_gdb + gdb_expect. Use proc_with_prefix to
help with name uniqueness.
gdb/testsuite/ChangeLog:
* gdb.base/list.exp: Replace send_gdb + gdb_expect with
gdb_test. Use proc_with_prefix.
Change-Id: Ieee8fb2c80f596f60397fab7633773a7f8c8c879
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/list.exp | 181 |
1 files changed, 30 insertions, 151 deletions
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index b7d0e98..4be28e0 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -144,54 +144,18 @@ proc test_list_include_file {} { # Test "list filename:number" for C source file # -proc test_list_filename_and_number {} { - global gdb_prompt - - set testcnt 0 - - send_gdb "list list0.c:1\n" - gdb_expect { - -re "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" { - incr testcnt - } - -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests } - timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests } - } - send_gdb "list list0.c:10\n" - gdb_expect { - -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" { - incr testcnt - } - -re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests } - timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests } - } - send_gdb "list list1.c:1\n" - gdb_expect { - -re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" { - incr testcnt - } - -re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests } - timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests } - } - send_gdb "list list1.c:12\n" - gdb_expect { - -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { - incr testcnt - } - -re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests } - timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests } - } - pass "list filename:number ($testcnt tests)" - gdb_stop_suppressing_tests +proc_with_prefix test_list_filename_and_number {} { + gdb_test "list list0.c:1" "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+foo .x\[+)\]+;" + gdb_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;" + gdb_test "list list1.c:1" "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*" + gdb_test "list list1.c:12" "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*" } # # Test "list function" for C source file # -proc test_list_function {} { - global gdb_prompt - +proc_with_prefix test_list_function {} { # gcc appears to generate incorrect debugging information for code # in include files, which breaks this test. # SunPRO cc is the second case below, it's also correct. @@ -207,46 +171,18 @@ proc test_list_function {} { gdb_test "list -q foo" "(3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;|2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;|1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;)" "list function in include file" } -proc test_list_forward {} { - global gdb_prompt +proc_with_prefix test_list_forward {} { global last_line_re - set testcnt 0 - - send_gdb "list list0.c:10\n" - gdb_expect { - -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } - timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list\n" - gdb_expect { - -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } - timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list\n" - gdb_expect { - -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } - timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list\n" - gdb_expect { - -re "35\[ \t\]+foo \\(.*\\);.*${last_line_re}\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } - timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } - } - - pass "successive list commands to page forward ($testcnt tests)" - + gdb_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" + gdb_test "list" "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 15-24" + gdb_test "list" "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 25-34" + gdb_test "list" "35\[ \t\]+foo \\(.*\\);.*${last_line_re}" \ + "list 35-42" gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \ "end of file error after \"list\" command" - - gdb_stop_suppressing_tests } # Test that repeating the list linenum command doesn't print the same @@ -254,87 +190,30 @@ proc test_list_forward {} { # linenum is dropped, when we repeat the previous command. 'x/5i $pc' # works the same way. -proc test_repeat_list_command {} { - global gdb_prompt +proc_with_prefix test_repeat_list_command {} { global last_line_re - set testcnt 0 - - send_gdb "list list0.c:10\n" - gdb_expect { - -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } - timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "\n" - gdb_expect { - -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } - timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "\n" - gdb_expect { - -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } - timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "\n" - gdb_expect { - -re "35\[ \t\]+foo \\(.*\\);.*${last_line_re}\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } - timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } - } - - pass "repeat list commands to page forward using 'return' ($testcnt tests)" - + gdb_test "list list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" + gdb_test " " "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 15-24" + gdb_test " " "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 25-34" + gdb_test " " "35\[ \t\]+foo \\(.*\\);.*${last_line_re}" \ + "list 35-42" gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \ "end of file error after using 'return' to repeat the list command" - - gdb_stop_suppressing_tests } -proc test_list_backwards {} { - global gdb_prompt - - set testcnt 0 - - send_gdb "list list0.c:33\n" - gdb_expect { - -re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests } - timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list -\n" - gdb_expect { - -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests } - timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list -\n" - gdb_expect { - -re "8\[ \t\]+foo \[(\]+.*\[)\]+;.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests } - timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests } - } - - send_gdb "list -\n" - gdb_expect { - -re "1\[ \t\]+#include .*7\[ \t\]+x = 0;\r\n$gdb_prompt $" { incr testcnt } - -re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests } - timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests } - } - - pass "$testcnt successive \"list -\" commands to page backwards" - +proc_with_prefix test_list_backwards {} { + gdb_test "list list0.c:33" "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}" + gdb_test "list -" "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 18-27" + gdb_test "list -" "8\[ \t\]+foo \[(\]+.*\[)\]+;.*17\[ \t\]+foo \[(\]+.*\[)\]+;" \ + "list 8-17" + gdb_test "list -" "1\[ \t\]+#include .*7\[ \t\]+x = 0;" \ + "list 1-7" gdb_test "list -" "Already at the start of .*\." \ "beginning of file error after \"list -\" command" - - gdb_stop_suppressing_tests } # |