diff mbox

[gdb/testsuite] Fix corefile-buildid.exp with check-read1

Message ID 20200219174014.GA28126@delia
State New
Headers show

Commit Message

Tom de Vries Feb. 19, 2020, 5:40 p.m. UTC
Hi,

When running gdb.base/corefile-buildid.exp using check-read1, I run into:
...
FAIL: gdb.base/corefile-buildid.exp: shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: shared sepdebug: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared sepdebug: info files \
  (timeout)
...

This is caused by attempting to match the output of an "info files" command
using a single gdb_test in check_exec_file.

Fix this by doing line-by-line matching in check_exec_file.

Tested on x86_64-linux, using make targets check and check-read1.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Fix corefile-buildid.exp with check-read1

gdb/testsuite/ChangeLog:

2020-02-19  Tom de Vries  <tdevries@suse.de>

	* gdb.base/corefile-buildid.exp (check_exec_file): Match info files
	output line-by-line.

---
 gdb/testsuite/gdb.base/corefile-buildid.exp | 49 ++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

Comments

Pedro Alves Feb. 19, 2020, 8:09 p.m. UTC | #1
On 2/19/20 5:40 PM, Tom de Vries wrote:
> Hi,
> 
> When running gdb.base/corefile-buildid.exp using check-read1, I run into:
> ...
> FAIL: gdb.base/corefile-buildid.exp: shared: info files (timeout)
> FAIL: gdb.base/corefile-buildid.exp: symlink shared: info files (timeout)
> FAIL: gdb.base/corefile-buildid.exp: shared sepdebug: info files (timeout)
> FAIL: gdb.base/corefile-buildid.exp: symlink shared sepdebug: info files \
>   (timeout)
> ...
> 
> This is caused by attempting to match the output of an "info files" command
> using a single gdb_test in check_exec_file.
> 
> Fix this by doing line-by-line matching in check_exec_file.
> 
> Tested on x86_64-linux, using make targets check and check-read1.
> 
> OK for trunk?

OK.

If this pattern appears in more places it may be worth it to
think about some abstraction to make it easier to write.
Like e.g., a new "-lbl" (line-by-line) option switch to
gdb_test_multiple that auto-appends the "match one line" regexp.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/corefile-buildid.exp b/gdb/testsuite/gdb.base/corefile-buildid.exp
index 158cbb6dc6..b9844ee354 100644
--- a/gdb/testsuite/gdb.base/corefile-buildid.exp
+++ b/gdb/testsuite/gdb.base/corefile-buildid.exp
@@ -108,8 +108,55 @@  proc append_debug_dir {debugdir} {
 # FILE.
 
 proc check_exec_file {file} {
+    global gdb_prompt
     send_log "expecting exec file \"$file\"\n"
-    gdb_test "info files" "Local exec file:\[\r\n\t\ \]+`[string_to_regexp $file]'.*"
+
+    # Get line with "Local exec file:".
+    set ok 0
+    gdb_test_multiple "info files" "" {
+	-re "^Local exec file:\r\n" {
+	    set test_name $gdb_test_name
+	    set ok 1
+	}
+	-re "^$gdb_prompt $" {
+	    fail $gdb_test_name
+	}
+	-re "^\[^\r\n\]*\r\n" {
+	    exp_continue
+	}
+    }
+
+    if { $ok == 0 } {
+	return
+    }
+
+    # Get subsequent line with $file.
+    set ok 0
+    gdb_test_multiple "" $test_name {
+	-re "^\[\t\ \]+`[string_to_regexp $file]'\[^\r\n\]*\r\n" {
+	    set ok 1
+	}
+	-re "^$gdb_prompt $" {
+	    fail $gdb_test_name
+	}
+	-re "^\[^\r\n\]*\r\n" {
+	    exp_continue
+	}
+    }
+
+    if { $ok == 0 } {
+	return
+    }
+
+    # Skip till prompt.
+    gdb_test_multiple "" $test_name {
+	-re "^$gdb_prompt $" {
+	    pass $gdb_test_name
+	}
+	-re "^\[^\r\n\]*\r\n" {
+	    exp_continue
+	}
+    }
 }
 
 # Test whether gdb can find an exec file from a core file's build-id.