diff mbox

[testsuite] Adjust gdb.base/maint.exp for Windows hosts

Message ID 5396F67D.9080203@codesourcery.com
State New
Headers show

Commit Message

Luis Machado June 10, 2014, 12:13 p.m. UTC
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

Comments

Pedro Alves June 23, 2014, 2:17 p.m. UTC | #1
On 06/10/2014 01:13 PM, Luis Machado wrote:
> 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.

So that bit of code should be ported to Windows then IMO, IMO.
The test failure is exactly serving as reminder.  I believe
VirtualQuery/VirtualQueryEx would be what to use.


> Other systems that don't define the same constant 
> will also run into pattern matching problems here.

Well, we can make the code do whatever is necessary for such
systems as we find them -- and the test is what helps us find them.

> 
> 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
> +}

These tools really aren't "Linux"-specific.

In any case, it seems to me that the test should instead be tweaked
to use tcl/dejagnu commands instead of (ab)using GDB's "shell".
Eli Zaretskii June 23, 2014, 3:14 p.m. UTC | #2
> Date: Mon, 23 Jun 2014 15:17:52 +0100
> From: Pedro Alves <palves@redhat.com>
> 
> > 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.
> 
> So that bit of code should be ported to Windows then IMO, IMO.
> The test failure is exactly serving as reminder.  I believe
> VirtualQuery/VirtualQueryEx would be what to use.

GetProcessMemoryInfo sounds like a better candidate for this.  You
want the PrivateUsage member of the structure it returns, I believe.

Btw, isn't 'sbrk(0)' not too meaningful on modern systems, since their
malloc implementation uses mmap?
diff mbox

Patch

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 {