[PATCH] Harden gdb.base/coredump-filter.exp

Luis Gustavo
2015-04-09T19:36:23Z

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

This testcase seems to assume the target is running Linux, so bare
metal, simulators and other debugging stubs running different OS' will
have a hard time executing some of the commands the testcase issues.

Even restricting the testcase to Linux systems (which the patch below
does), there are still problems with, say, QEMU not providing PID
information when "info inferior" is issued. As a consequence, the
subsequent tests will either fail or will not make much sense.

The attached patch checks if PID information is available. If not, it
just bails out and avoids running into a number of failures.

No regressions on x86-64. For QEMU, i see only a couple PASSes before it
is done with the testcase.

OK?

[-- Attachment #2: coredump_filter.diff --]
[-- Type: text/x-patch, Size: 1164 bytes --]

2015-04-09 Luis Machado <lgustavo@codesourcery.com>

gdb/testsuite/
* gdb.base/coredump-filter.exp: Restrict test to Linux systems only.
Handle the case of targets that do not provide PID information.

diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp
index f3203be..4c6c6ed 100644
--- a/gdb/testsuite/gdb.base/coredump-filter.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter.exp
@@ -15,6 +15,12 @@

standard_testfile

+# This test is Linux-only.
+if ![istarget *-*-linux*] then {
+ unsupported "coredump-filter.exp"
+ return -1
+}
+
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
untested "could not compile test program"
return -1
@@ -146,6 +152,11 @@ gdb_test_multiple "info inferiors" "getting inferior pid" {
-re "process \($decimal\).*\r\n$gdb_prompt $" {
set infpid $expect_out(1,string)
}
+ -re "Remote target.*$gdb_prompt $" {
+ # If the target does not provide PID information (like QEMU), just bail
+ # out as the rest of the test may rely on it, giving spurious failures.
+ return -1
+ }
}

# Get the main function's address.