Fully anchor mi_gdb_test expected results.

Bob Rossi bob@brasko.net
Thu Aug 4 23:50:00 GMT 2005


On Thu, Aug 04, 2005 at 06:43:51PM -0400, Daniel Jacobowitz wrote:
> On Thu, Aug 04, 2005 at 06:40:44PM -0400, Bob Rossi wrote:
> > Here are my testsuite results. The first one looks like a bug I
> > introduced, and the others look like random thread pass/failures. Is
> > that correct?
> 
> Yes.  Does removing two backslashes in sizeof.exp fix it?  They
> shouldn't have been there at all.

Geez Daniel, thanks for all the help. Here is the patch that plays
nicely with the testsuite. I captured both the MI input command and the
MI output command. Eventually testing can be done on the MI input
command also.

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
+	* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .* 
+	from test.  Escape the | in mi_gdb_test call.
+	* lib/mi-support.exp: Remove arbitrary .* from tests.
+	(mi_gdb_test): Fully anchor GDB/MI expected results in mi_gdb_test.
+	* lib/gdb.exp (string_to_regexp): Escape the ] character.
+	* gdb.base/sizeof.exp: Remove escape character. Correct test.

Index: gdb/testsuite/gdb.base/sizeof.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sizeof.exp,v
retrieving revision 1.7
diff -u -r1.7 sizeof.exp
--- gdb/testsuite/gdb.base/sizeof.exp	13 Jul 2004 17:08:36 -0000	1.7
+++ gdb/testsuite/gdb.base/sizeof.exp	4 Aug 2005 23:47:58 -0000
@@ -131,7 +131,7 @@
 set signof_signed_char [get_valueof "/d" "(int) (signed char) -1" -1]
 set signof_unsigned_char [get_valueof "/d" "(int) (unsigned char) -1" -1]
 
-check_valueof "'\\\\377'" ${signof_byte}
+check_valueof "'\\377'" ${signof_byte}
 check_valueof "(int) (char) -1" ${signof_char}
 check_valueof "(int) (signed char) -1" ${signof_signed_char}
 check_valueof "(int) (unsigned char) -1" ${signof_unsigned_char}
Index: gdb/testsuite/gdb.mi/mi-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-disassemble.exp,v
retrieving revision 1.13
diff -u -r1.13 mi-disassemble.exp
--- gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-disassemble.exp	4 Aug 2005 23:47:58 -0000
@@ -163,7 +163,7 @@
     # -data-disassembly -f basics.c -l 32 -- 9
 
     mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
-             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
+             "123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
              "data-disassemble bogus filename"
 
     mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: gdb/testsuite/gdb.mi/mi2-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-disassemble.exp,v
retrieving revision 1.3
diff -u -r1.3 mi2-disassemble.exp
--- gdb/testsuite/gdb.mi/mi2-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.3
+++ gdb/testsuite/gdb.mi/mi2-disassemble.exp	4 Aug 2005 23:47:58 -0000
@@ -163,7 +163,7 @@
     # -data-disassembly -f basics.c -l 32 -- 9
 
     mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
-             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
+             "123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
              "data-disassemble bogus filename"
 
     mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.63
diff -u -r1.63 gdb.exp
--- gdb/testsuite/lib/gdb.exp	8 May 2005 13:42:04 -0000	1.63
+++ gdb/testsuite/lib/gdb.exp	4 Aug 2005 23:47:59 -0000
@@ -864,7 +864,7 @@
 
 proc string_to_regexp {str} {
     set result $str
-    regsub -all {[]*+.|()^$\[]} $str {\\&} result
+    regsub -all {[]*+.|()^$\[\\]} $str {\\&} result
     return $result
 }
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.29
diff -u -r1.29 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	4 Aug 2005 01:52:31 -0000	1.29
+++ gdb/testsuite/lib/mi-support.exp	4 Aug 2005 23:47:59 -0000
@@ -246,7 +246,7 @@
 	    send_gdb "y\n";
 	    exp_continue
          }
-	 -re ".*102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
+	 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
             # This happens if there were no breakpoints
 	 }
 	 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
@@ -596,6 +596,8 @@
 
     set result -1
     set string "${command}\n";
+    set string_regex [string_to_regexp $command]
+
     if { $command != "" } {
 	while { "$string" != "" } {
 	    set foo [string first "\n" "$string"];
@@ -659,7 +661,10 @@
 	    gdb_start
 	    set result -1
 	}
-	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
+	 -re "^(.*$string_regex.*)($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)$" {
+	    # At this point, $expect_out(1,string) is the MI input command.
+	    # and $expect_out(2,string) is the MI output command.
+
 	    if ![string match "" $message] then {
 		pass "$message"
 	    }
@@ -917,11 +922,11 @@
     global fullname_syntax
     send_gdb "220-$cmd\n"
     gdb_expect {
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
 	    pass "$test"
 	    return 0
 	}
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
 	    fail "$test (stopped at wrong place)"
 	    return -1
 	}



More information about the Gdb-patches mailing list