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]

[commit/testsuite] Improve reliability of charset.exp


This test matches ", (\[^ \t\n\r,.\]*)" repeatedly to extract elements
from a list.  But this has a partial matching problem; it can equally
well match ", ISO" as ", ISO-8859-1".  It's important to anchor
regular expressions that end in a wildcard.

In practice, this problem never seems to turn up on a local Linux
host.  I hit it frequently when testing over SSH to Cygwin, though,
and finally got annoyed enough to debug it.

Instead, match the whole output at once, and then parse it.  Tested on
arm-none-eabi and x86_64-linux; committed to trunk.

-- 
Daniel Jacobowitz
CodeSourcery

2010-02-16  Daniel Jacobowitz  <dan@codesourcery.com>

	gdb/testsuite/
	* gdb.base/charset.exp: Use a single regular expression to match
	show host-charset and show target-charset output.

diff -urp gdb-merged-orig/gdb/testsuite/gdb.base/charset.exp gdb-merged/gdb/testsuite/gdb.base/charset.exp
--- gdb-merged-orig/gdb/testsuite/gdb.base/charset.exp	2010-02-10 14:53:22.000000000 -0800
+++ gdb-merged/gdb/testsuite/gdb.base/charset.exp	2010-02-13 12:23:38.000000000 -0800
@@ -138,28 +138,19 @@ proc valid_target_charset {charset} {
 
 send_gdb "set host-charset\n"
 gdb_expect {
-    -re "Requires an argument. Valid arguments are (\[^ \t\n\r,.\]*)" {
-	#set host_charset_list $expect_out(1,string)
-	set charsets($expect_out(1,string)) 1
-	exp_continue
-	#pass "capture valid host charsets"
-    }
-
-    -re ", (\[^ \t\n\r,.\]*)" {
-	#set host_charset_list $expect_out(1,string)
-	set charsets($expect_out(1,string)) 1
-	exp_continue
-	#pass "capture valid host charsets"
-    }
-
-    -re "\\.\r\n$gdb_prompt $" {
-	#set host_charset_list $expect_out(1,string)
+    -re "Requires an argument. Valid arguments are (.*)\\.\r\n$gdb_prompt $" {
+	set host_charset_list $expect_out(1,string)
+	set host_charset_list [regsub -all {, } $host_charset_list {,}]
+	foreach host_charset [split $host_charset_list ","] {
+	    set charsets($host_charset) 1
+	}
 	pass "capture valid host charsets"
     }
 
     -re ".*$gdb_prompt $" {
 	fail "capture valid host charsets"
     }
+
     timeout {
 	fail "(timeout) capture valid host charsets"
     }
@@ -175,25 +166,15 @@ if {[llength [array names charsets]] < 3
 
 send_gdb "set target-charset\n"
 gdb_expect {
-    -re "Requires an argument. Valid arguments are (\[^ \t\n\r,.\]*)" {
-	set target_charset $expect_out(1,string)
-	if {! [info exists charsets($target_charset)]} {
-	    set charsets($target_charset) 0
-	}
-	exp_continue
-    }
-
-    -re ", (\[^ \t\n\r,.\]*)" {
-	set target_charset $expect_out(1,string)
-	if {! [info exists charsets($target_charset)]} {
-	    set charsets($target_charset) 0
+    -re "Requires an argument. Valid arguments are (.*)\\.\r\n$gdb_prompt $" {
+	set target_charset_list $expect_out(1,string)
+	set target_charset_list [regsub -all {, } $target_charset_list {,}]
+	foreach target_charset [split $target_charset_list ","] {
+	    if {! [info exists charsets($target_charset)]} {
+		set charsets($target_charset) 0
+	    }
 	}
-	exp_continue
-    }
-
-    -re "\\.\r\n$gdb_prompt $" {
 	pass "capture valid target charsets"
-
     }
 
     -re ".*$gdb_prompt $" {


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