This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Improve MI inferior output check / mi-console.exp


Hi,

The situation here is that the output from the target/inferior arrives
differently (or not at all) depending on permutations of local/remote
and the no-inferior-io setting.

The mi-console.c testcase writes a string 'Hello \"!' one char at a time.

In the case of a spawned inferior, to which we connect, we see that string. In the case of remote/semi-hosted target we see the following:

@"H"
@"e"
@"l"
@"l"
@"o"
@" "
@"\\"
@"\""
@"!"
@"\r"
@"\n"

In the case of a remote target with noinferiorio set, we assume no access to the output and thus this test is unsupported.

The attached patch modifies mi-console.exp to furnish the two different
patterns, and mi-support.exp to check for more cases.

Regression tested on x86-64.

Ok?
2013-10-27  Iain Sandoe  <iain@codesourcery.com>
	    Luis Machado  <lgustavo@codesourcery.com>

       gdb/testsuite
       * lib/mi-support.exp (mi_gdb_test): Expect different formats
       of inferior output for remote and native sessions.
       * gdb.mi/mi-console.exp: Check for additional inferior output
       pattern.

diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index b7643e7..d7b6db4 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -37,10 +37,20 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
+# The output we get from the target depends on how it is hosted.
+# If we are local, we just see the executable's output.
+# If we are remote (and the configuration supports it), we see the
+# target responses encapsulated by gdb's annotation.
+if [target_info exists use_gdb_stub] {
+    set op_pattern "@\"H\"\r\n@\"e\"\r\n@\"l\"\r\n@\"l\"\r\n@\"o\"\r\n@\" \"\r\n@\"\\\\\\\\\"\r\n@\"\\\\\"\"\r\n@\"!\"\r\n@\"\\\\r\"\r\n@\"\\\\n\"\r\n"
+} else {
+    set op_pattern "Hello \\\\\"!\[\r\n\]+"
+}
+
 mi_gdb_test "220-exec-next" \
 	    "220\\^running(\r\n\\*running,thread-id=\"all\")?" \
 	    "Testing console output" \
-	    "Hello \\\\\"!\[\r\n\]+"
+	    $op_pattern
 
 mi_expect_stop "end-stepping-range" "main" "" ".*mi-console.c" "14" "" \
     "finished step over hello"
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 3d55609..898a230 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -764,7 +764,21 @@ proc mi_gdb_test { args } {
     # If the GDB output matched, compare the inferior output.
     if { $result == 0 } {
 	if [ info exists ipattern ] {
-	    if { ![target_info exists gdb,noinferiorio] } {
+	   if { [target_info exists use_gdb_stub] } {
+	       if { [target_info exists gdb,noinferiorio] } {
+		   unsupported "$message inferior output"
+	       } else {
+		   gdb_expect {
+		       -re "$ipattern" {
+			   pass "$message inferior output"
+		       }
+		       timeout {
+			   fail "$message inferior output (timeout)"
+			   set result 1
+		       }
+		   }
+	       }
+	   } else {
 		global mi_inferior_spawn_id
 		expect {
 		    -i $mi_inferior_spawn_id -re "$ipattern" {
@@ -775,8 +789,6 @@ proc mi_gdb_test { args } {
 			set result 1
 		    }
 		}
-	    } else {
-		unsupported "$message inferior output"
 	    }
         }
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]