From: Pedro Alves Date: Tue, 7 Nov 2017 11:00:31 +0000 (+0000) Subject: Add base 'enable/disable invalid location range' tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cee62dbd8771e22856d950c2615fb463305a9fcb;p=binutils-gdb.git Add base 'enable/disable invalid location range' tests This adds tests that exercise the "bad breakpoint number" paths. Specifically: - malformed ranges - use of explicit 0 as bp/loc number. - inverted ranges I'm adding this as a baseline to improve. This shows that there's a lot of inconsistency in GDB's output (e.g., "bad" vs "Bad"). Also, IMO, the "0-0" and inverted range cases should be loud errors. That and more will all be addressed in the next patch. gdb/testsuite/ChangeLog: 2017-11-07 Pedro Alves * gdb.cp/ena-dis-br-range.exp: Add tests. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 76bd960221a..5698dac5f35 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-07 Pedro Alves + + * gdb.cp/ena-dis-br-range.exp: Add tests. + 2017-11-07 Pedro Alves * gdb.base/ena-dis-br.exp: Don't expect "warning:". diff --git a/gdb/testsuite/gdb.cp/ena-dis-br-range.exp b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp index 8873c4a5210..c2a3017e620 100644 --- a/gdb/testsuite/gdb.cp/ena-dis-br-range.exp +++ b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp @@ -130,3 +130,41 @@ gdb_test_no_output "disable 2.8-6" gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ "breakpoint info disable 2.8-6" + +# Check that invalid/open ranges are handled correctly. +with_test_prefix "open range" { + gdb_test "disable -" "bad breakpoint number at or near: '-'" + gdb_test "disable -1" "bad breakpoint number at or near: '-1'" + gdb_test "disable 1-" "bad breakpoint number at or near: '1-'" + gdb_test "disable 1.-2" "Bad breakpoint location number '-2'" + gdb_test "disable 1.2-" "bad breakpoint number at or near: '2-'" + gdb_test "disable 1.-2-3" "Bad breakpoint location number '-2'" + gdb_test "disable 1-2-3" "bad breakpoint number at or near: '1-2-3'" +} + +with_test_prefix "dangling period" { + gdb_test "disable 2." "bad breakpoint number at or near: '2.'" + gdb_test "disable .2" "bad breakpoint number at or near: '.2'" + gdb_test "disable 2.3.4" "bad breakpoint number at or near '2.3.4'" +} + +# Check that 0s are handled correctly. +with_test_prefix "zero" { + gdb_test "disable 0" "bad breakpoint number at or near '0'" + gdb_test "disable 0.0" "Bad breakpoint number '0.0'" + gdb_test "disable 0.1" "Bad breakpoint number '0.1'" + gdb_test "disable 0.1-2" "Bad breakpoint number '0.1-2'" + gdb_test "disable 2.0" "bad breakpoint number at or near '2.0'" + + # These should really fail... + gdb_test_no_output "disable 2.0-0" + gdb_test_no_output "enable 2.0-0" + + gdb_test "disable 2.0-1" "Bad breakpoint location number '0'" + + # Likewise, should fail. + gdb_test_no_output "disable 2.1-0" +} + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info after invalids"