set test "info macro -a -- FOO"
gdb_test "$test" "$r1$r2$r3$r4"
-proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
- user_code } {
- with_read1_timeout_factor $factor {
- uplevel [list gdb_test_multiple $command $message $user_code]
- }
-}
-
set test "info macros"
-set r1 ".*#define FOO \"hello\""
-set r2 ".*#define ONE"
-set r3 ".*\r\n$gdb_prompt"
+set r1 "#define FOO \"hello\""
+set r2 "#define ONE"
set testname "$test 2"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
- -re "$r1$r2$r3" {
- pass $testname
- }
- -re ".*#define TWO.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define THREE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $testname
- }
-}
+gdb_test_lines $test $testname $r1.*$r2 \
+ -re-not "#define TWO" \
+ -re-not "#define THREE" \
+ -re-not "#define FOUR"
+
gdb_test "next" ".*" ""
-set r1 ".*#define FOO \" \""
-set r2 ".*#define ONE"
-set r3 ".*#define TWO"
-set r4 ".*\r\n$gdb_prompt"
+set r1 "#define FOO \" \""
+set r2 "#define ONE"
+set r3 "#define TWO"
set testname "$test 3"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
- -re ".*#define THREE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re "$r1$r2$r3$r4" {
- pass $testname
- }
-}
+gdb_test_lines $test $testname $r1.*$r2.*$r3 \
+ -re-not "#define THREE" \
+ -re-not "#define FOUR"
+
gdb_test "next" ".*" ""
# in alpabetical order...
-set r1 ".*#define FOO \"world\""
-set r2 ".*#define ONE"
-set r3 ".*#define THREE"
-set r4 ".*#define TWO"
-set r5 ".*\r\n$gdb_prompt"
+set r1 "#define FOO \"world\""
+set r2 "#define ONE"
+set r3 "#define THREE"
+set r4 "#define TWO"
set testname "$test 4"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re "$r1$r2$r3$r4$r5" {
- pass $testname
- }
-}
+gdb_test_lines $test $testname $r1.*$r2.*$r3.*$r4 \
+ -re-not "#define FOUR"
+
# same as above with a linespec.
set test "info macros *\$pc"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $test
- }
- -re "$r1$r2$r3$r4$r5" {
- pass $test
- }
-}
+gdb_test_lines $test "" $r1.*$r2.*$r3.*$r4 \
+ -re-not "#define FOUR"
gdb_test "next" ".*" ""
-set r1 ".*#define FOO \" \""
-set r2 ".*#define ONE"
-set r3 ".*#define TWO."
-set r4 ".*\r\n$gdb_prompt"
+set r1 "#define FOO \" \""
+set r2 "#define ONE"
+set r3 "#define TWO."
set test "info macros"
set testname "$test 5"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
- -re ".*#define THREE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re "$r1$r2$r3$r4" {
- pass $testname
- }
-}
+gdb_test_lines $test $testname $r1.*$r2.*$r3 \
+ -re-not "#define THREE" \
+ -re-not "#define FOUR"
gdb_test "next" ".*" ""
gdb_test "next" ".*" ""
-set r1 ".*#define DEF_MACROS"
-set r2 ".*\r\n$gdb_prompt"
+set r1 "#define DEF_MACROS"
set testname "$test 6"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
- -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOO\\(a\\) foo = a.*" {
- fail $testname
- }
- -re ".*#define ONE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define TWO.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define THREE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOUR.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re "$r1$r2" {
- pass $testname
- }
-}
+gdb_test_lines $test $testname $r1 \
+ -re-not "#define FOO" \
+ -re-not "#define ONE" \
+ -re-not "#define TWO" \
+ -re-not "#define THREE" \
+ -re-not "#define FOUR"
gdb_test "next" ".*" ""
-set r1 ".*#define DEF_MACROS"
-set r2 ".*#define FOO\\(a\\) foo = a"
-set r3 ".*#define FOUR"
-set r4 ".*\r\n$gdb_prompt"
+set r1 "#define DEF_MACROS"
+set r2 "#define FOO\\(a\\) foo = a"
+set r3 "#define FOUR"
set testname "$test 7"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
- -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define ONE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define TWO.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re ".*#define THREE.*\r\n$gdb_prompt" {
- fail $testname
- }
- -re "$r1$r2$r3$r4" {
- pass $testname
- }
-}
+gdb_test_lines $test $testname $r1.*$r2.*$r3 \
+ -re-not "#define FOO \" \"" \
+ -re-not "#define FOO \"hello\"" \
+ -re-not "#define FOO \"world\"" \
+ -re-not "#define ONE" \
+ -re-not "#define TWO" \
+ -re-not "#define THREE"
set test "info macros info-macros.c:42"
# '<line1>^M
# <line2>^M
# '
+#
+# Optionally, additional -re-not <regexp> arguments can be specified, to
+# ensure that a regexp is not match by the COMMAND output.
+# Such an additional argument generates an additional PASS/FAIL of the form:
+# PASS: test-case.exp: $message: pattern not matched: <regexp>
+
+proc gdb_test_lines { command message re args } {
+ set re_not [list]
+
+ for {set i 0} {$i < [llength $args]} {incr i} {
+ set arg [lindex $args $i]
+ if { $arg == "-re-not" } {
+ incr i
+ if { [llength $args] == $i } {
+ error "Missing argument for -re-not"
+ break
+ }
+ set arg [lindex $args $i]
+ lappend re_not $arg
+ } else {
+ error "Unhandled argument: $arg"
+ }
+ }
-proc gdb_test_lines { command message re } {
- set found 0
- set idx 0
if { $message == ""} {
set message $command
}
+
set lines ""
gdb_test_multiple $command $message {
-re "\r\n(\[^\r\n\]*)(?=\r\n)" {
}
gdb_assert { [regexp $re $lines] } $message
+
+ foreach re $re_not {
+ gdb_assert { ![regexp $re $lines] } "$message: pattern not matched: $re"
+ }
}
# Test that a command gives an error. For pass or fail, return