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, testsuite] Adjust gdb.base/maint.exp for Windows hosts


Hi,

Last year changes to gdb.base/maint.exp seem to have caused a few failures for Windows testing.

The first issue is the output of "maint set per-command". On Linux hosts, it looks like this:

(top-gdb) maint set per-command off
Command execution time: 0.000000 (cpu), 0.000070 (wall)
Space used: 10321920 (+0 for this command)
#symtabs: 492 (+0), #primary symtabs: 3 (+0), #blocks: 253 (+0)

On Windows hosts, it looks like this:

(gdb) maint set per-command off
Command execution time: 0.000000 (cpu), 0.000000 (wall)
#symtabs: 0 (+0), #primary symtabs: 0 (+0), #blocks: 0 (+0)

The space summary isn't displayed because Windows hosts don't have HAVE_SBRK defined. Other systems that don't define the same constant will also run into pattern matching problems here.

That pattern needs to be optional then.

The second problem is the attempt to use GDB's 'shell' command to invoke various tools that may not be available on Windows hosts, like 'grep', 'ls' and 'rm'.

Skipping those file-checking tests seems to be a reasonable solution, since those tests are likely not run on Windows anyway.

The following patch accomplishes both of the above solutions. Most of it is identation changes, so i attached a -w version of the patch as well.

With the patch applied, i have full passes on both Windows (less tests) and Linux.

Thoughts? Does it look OK?

Luis
2014-06-10  Luis Machado  <lgustavo@codesourcery.com>

	gdb/testsuite
	* gdb.base/maint.exp: Prevent testing operations that involve
	linux tools on targets that do not support them.
	Make used space pattern optional.

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 64753b7..b588c69 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -46,6 +46,13 @@
 #
 
 
+# Some targets do not support 'ls', 'grep' and 'rm', like Windows.
+# Set the flag here so we don't attempt to test things using those tools
+# later on.
+set linux_tools_supported 1
+if { [ishost *-*-*mingw*] } {
+  set linux_tools_supported 0
+}
 
 standard_testfile break.c break1.c
 
@@ -132,8 +139,11 @@ gdb_test_no_output "maint check-symtabs"
 
 gdb_test_no_output "maint set per-command on"
 
+# Information about space used is not available on some targets, like
+# Windows. Therefore that pattern is optional in the following regular
+# expression.
 gdb_test "maint set per-command off" \
-    "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
+    "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+(Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+)?#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
 
 gdb_test "maint demangle" \
     "\"maintenance demangle\" takes an argument to demangle\\."
@@ -218,7 +228,7 @@ gdb_test "maint print psymbols" \
     "print-psymbols takes an output file name and optional symbol file name" \
     "maint print psymbols w/o args"
 
-if { ! $have_gdb_index } {
+if { ! $have_gdb_index && $linux_tools_supported } {
     set psymbols_output [standard_output_file psymbols_output]
     send_gdb "maint print psymbols $psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
     gdb_expect  {
@@ -259,74 +269,76 @@ gdb_test "maint print msymbols" \
     "maint print msymbols w/o args"
 
 
-set msymbols_output [standard_output_file msymbols_output]
-send_gdb "maint print msymbols $msymbols_output ${binfile}\n"
-gdb_expect  {
-    -re "^maint print msymbols $msymbols_output \[^\n\]*\r\n$gdb_prompt $" {
-	send_gdb "shell ls $msymbols_output\n"
-	gdb_expect {
-	    -re "$msymbols_output\r\n$gdb_prompt $" {
-		send_gdb "shell grep factorial $msymbols_output\n"
-		gdb_expect {
-		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
-			pass "maint print msymbols"
+if { $linux_tools_supported } {
+    set msymbols_output [standard_output_file msymbols_output]
+    send_gdb "maint print msymbols $msymbols_output ${binfile}\n"
+    gdb_expect  {
+	-re "^maint print msymbols $msymbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	    send_gdb "shell ls $msymbols_output\n"
+	    gdb_expect {
+		-re "$msymbols_output\r\n$gdb_prompt $" {
+		    send_gdb "shell grep factorial $msymbols_output\n"
+		    gdb_expect {
+			-re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
+			    pass "maint print msymbols"
+			}
+			-re ".*$gdb_prompt $"     { fail "maint print msymbols" }
+			timeout         { fail "(timeout) maint print msymbols" }
 		    }
-		    -re ".*$gdb_prompt $"     { fail "maint print msymbols" }
-		    timeout         { fail "(timeout) maint print msymbols" }
+		    gdb_test "shell rm -f $msymbols_output" ".*" \
+			"shell rm -f msymbols_output"
 		}
-		gdb_test "shell rm -f $msymbols_output" ".*" \
-		    "shell rm -f msymbols_output"
+		-re ".*$gdb_prompt $"     { fail "maint print msymbols" }
+		timeout         { fail "(timeout) maint print msymbols" }
 	    }
-	    -re ".*$gdb_prompt $"     { fail "maint print msymbols" }
-	    timeout         { fail "(timeout) maint print msymbols" }
 	}
+	-re ".*$gdb_prompt $"     { fail "maint print msymbols" }
+	timeout         { fail "(timeout) maint print msymbols" }
     }
-    -re ".*$gdb_prompt $"     { fail "maint print msymbols" }
-    timeout         { fail "(timeout) maint print msymbols" }
-}
 
-# Check that maint print msymbols allows relative pathnames
-set mydir [pwd]
-gdb_test "cd [standard_output_file {}]" \
-    "Working directory .*\..*" \
-    "cd to objdir"
-
-gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
-    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
-    	gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
-	    -re "msymbols_output2\r\n$gdb_prompt $" {
-	    	gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
-		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
-		    	pass "maint print msymbols"
-		    }
-		    -re ".*$gdb_prompt $" {
-		        fail "maint print msymbols"
-		    }
-		    timeout {
-		        fail "(timeout) maint print msymbols"
+    # Check that maint print msymbols allows relative pathnames
+    set mydir [pwd]
+    gdb_test "cd [standard_output_file {}]" \
+	"Working directory .*\..*" \
+	"cd to objdir"
+
+    gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
+	-re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
+	    gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
+		-re "msymbols_output2\r\n$gdb_prompt $" {
+		    gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
+			-re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
+			    pass "maint print msymbols"
+			}
+			-re ".*$gdb_prompt $" {
+			    fail "maint print msymbols"
+			}
+			timeout {
+			    fail "(timeout) maint print msymbols"
+			}
 		    }
+		    gdb_test "shell rm -f msymbols_output2" ".*" \
+			"shell rm -f msymbols_output2"
+		}
+		-re ".*$gdb_prompt $" {
+		    fail "maint print msymbols"
+		}
+		timeout {
+		    fail "(timeout) maint print msymbols"
 		}
-		gdb_test "shell rm -f msymbols_output2" ".*" \
-		    "shell rm -f msymbols_output2"
-	    }
-	    -re ".*$gdb_prompt $" {
-		fail "maint print msymbols"
-	    }
-	    timeout {
-	    	fail "(timeout) maint print msymbols"
 	    }
 	}
+	-re ".*$gdb_prompt $" {
+	    fail "maint print msymbols"
+	}
+	timeout {
+	    fail "(timeout) maint print msymbols"
+	}
     }
-    -re ".*$gdb_prompt $" {
-	fail "maint print msymbols"
-    }
-    timeout {
-	fail "(timeout) maint print msymbols"
-    }
+    gdb_test "cd ${mydir}" \
+	"Working directory [string_to_regexp ${mydir}]\..*" \
+	"cd to mydir"
 }
-gdb_test "cd ${mydir}" \
-    "Working directory [string_to_regexp ${mydir}]\..*" \
-    "cd to mydir"
 
 gdb_test "maint print symbols" \
     "Arguments missing: an output file name and an optional symbol file name" \
@@ -337,31 +349,33 @@ gdb_test "maint print symbols" \
 # dump the symbol information for the entire C library - over 500MB nowadays
 # for GNU libc.
 
-set symbols_output [standard_output_file symbols_output]
-send_gdb "maint print symbols $symbols_output ${srcdir}/${subdir}/${srcfile}\n"
-gdb_expect  {
-    -re "^maint print symbols $symbols_output \[^\n\]*\r\n$gdb_prompt $" {
-	send_gdb "shell ls $symbols_output\n"
-	gdb_expect {
-	    -re "$symbols_output\r\n$gdb_prompt $" {
-		# See comments for `maint print psymbols'.
-		send_gdb "shell grep 'main(.*block' $symbols_output\n"
-		gdb_expect {
-		    -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" {
-			pass "maint print symbols"
+if { $linux_tools_supported } {
+    set symbols_output [standard_output_file symbols_output]
+    send_gdb "maint print symbols $symbols_output ${srcdir}/${subdir}/${srcfile}\n"
+    gdb_expect  {
+	-re "^maint print symbols $symbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	    send_gdb "shell ls $symbols_output\n"
+	    gdb_expect {
+		-re "$symbols_output\r\n$gdb_prompt $" {
+		    # See comments for `maint print psymbols'.
+		    send_gdb "shell grep 'main(.*block' $symbols_output\n"
+		    gdb_expect {
+			-re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" {
+			    pass "maint print symbols"
+			}
+			-re ".*$gdb_prompt $"     { fail "maint print symbols" }
+			timeout         { fail "(timeout) maint print symbols" }
 		    }
-		    -re ".*$gdb_prompt $"     { fail "maint print symbols" }
-		    timeout         { fail "(timeout) maint print symbols" }
+		    gdb_test "shell rm -f $symbols_output" ".*" \
+			"shell rm -f symbols_output"
 		}
-		gdb_test "shell rm -f $symbols_output" ".*" \
-		    "shell rm -f symbols_output"
+		-re ".*$gdb_prompt $"     { fail "maint print symbols" }
+		timeout         { fail "(timeout) maint print symbols" }
 	    }
-	    -re ".*$gdb_prompt $"     { fail "maint print symbols" }
-	    timeout         { fail "(timeout) maint print symbols" }
 	}
+	-re ".*$gdb_prompt $"     { fail "maint print symbols" }
+	timeout         { fail "(timeout) maint print symbols" }
     }
-    -re ".*$gdb_prompt $"     { fail "maint print symbols" }
-    timeout         { fail "(timeout) maint print symbols" }
 }
 
 set msg "maint print type"
2014-06-10  Luis Machado  <lgustavo@codesourcery.com>

	gdb/testsuite
	* gdb.base/maint.exp: Prevent testing operations that involve
	linux tools on targets that do not support them.
	Make used space pattern optional.

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 64753b7..b588c69 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -46,6 +46,13 @@
 #
 
 
+# Some targets do not support 'ls', 'grep' and 'rm', like Windows.
+# Set the flag here so we don't attempt to test things using those tools
+# later on.
+set linux_tools_supported 1
+if { [ishost *-*-*mingw*] } {
+  set linux_tools_supported 0
+}
 
 standard_testfile break.c break1.c
 
@@ -132,8 +139,11 @@ gdb_test_no_output "maint check-symtabs"
 
 gdb_test_no_output "maint set per-command on"
 
+# Information about space used is not available on some targets, like
+# Windows. Therefore that pattern is optional in the following regular
+# expression.
 gdb_test "maint set per-command off" \
-    "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
+    "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+(Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+)?#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
 
 gdb_test "maint demangle" \
     "\"maintenance demangle\" takes an argument to demangle\\."
@@ -218,7 +228,7 @@ gdb_test "maint print psymbols" \
     "print-psymbols takes an output file name and optional symbol file name" \
     "maint print psymbols w/o args"
 
-if { ! $have_gdb_index } {
+if { ! $have_gdb_index && $linux_tools_supported } {
     set psymbols_output [standard_output_file psymbols_output]
     send_gdb "maint print psymbols $psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
     gdb_expect  {
@@ -259,6 +269,7 @@ gdb_test "maint print msymbols" \
     "maint print msymbols w/o args"
 
 
+if { $linux_tools_supported } {
     set msymbols_output [standard_output_file msymbols_output]
     send_gdb "maint print msymbols $msymbols_output ${binfile}\n"
     gdb_expect  {
@@ -327,6 +338,7 @@ gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint pri
     gdb_test "cd ${mydir}" \
 	"Working directory [string_to_regexp ${mydir}]\..*" \
 	"cd to mydir"
+}
 
 gdb_test "maint print symbols" \
     "Arguments missing: an output file name and an optional symbol file name" \
@@ -337,6 +349,7 @@ gdb_test "maint print symbols" \
 # dump the symbol information for the entire C library - over 500MB nowadays
 # for GNU libc.
 
+if { $linux_tools_supported } {
     set symbols_output [standard_output_file symbols_output]
     send_gdb "maint print symbols $symbols_output ${srcdir}/${subdir}/${srcfile}\n"
     gdb_expect  {
@@ -363,6 +376,7 @@ gdb_expect  {
 	-re ".*$gdb_prompt $"     { fail "maint print symbols" }
 	timeout         { fail "(timeout) maint print symbols" }
     }
+}
 
 set msg "maint print type"
 gdb_test_multiple "maint print type argc" $msg {

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