Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp
Date: Thu, 24 Jun 2021 17:34:50 +0200	[thread overview]
Message-ID: <20210624153449.GA30047@delia> (raw)

Hi,

At the moment some check-read1 timeouts are handled like this in
gdb.base/info-macros.exp:
...
gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
  -re "$r1$r2$r3" {
     pass $testname
  }
  -re ".*#define TWO.*\r\n$gdb_prompt" {
     fail $testname
  }
  -re ".*#define THREE.*\r\n$gdb_prompt" {
     fail $testname
  }
  -re ".*#define FOUR.*\r\n$gdb_prompt" {
     fail $testname
  }
}
...
which is not ideal.

We could use gdb_test_lines, but it currently doesn't support verifying
the absence of regexps, which is currently implemented using the clauses above
calling fail.

Fix this by using gdb_test_lines and adding a -re-not syntax to
gdb_test_lines, such that we can do:
...
gdb_test_lines $test $testname $r1.*$r2 \
    -re-not "#define TWO" \
    -re-not "#define THREE" \
    -re-not "#define FOUR"
...

Only removing one use of gdb_test_multiple_with_read1_timeout_factor in the
test-case for now.

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

Any comments?

Thanks,
- Tom

[gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp

gdb/testsuite/ChangeLog:

2021-06-24  Tom de Vries  <tdevries@suse.de>

	* gdb.base/info-macros.exp: Replace
	gdb_test_multiple_with_read1_timeout_factor with gdb_test_lines.
	* lib/gdb.exp (gdb_test_lines): Add handling or -re-not <regexp>.

---
 gdb/testsuite/gdb.base/info-macros.exp | 24 +++++++-----------------
 gdb/testsuite/lib/gdb.exp              | 31 ++++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp
index 19f16814374..6af34ff77cb 100644
--- a/gdb/testsuite/gdb.base/info-macros.exp
+++ b/gdb/testsuite/gdb.base/info-macros.exp
@@ -125,24 +125,14 @@ proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
 }
 
 set test "info macros"
-set r1 ".*#define FOO \"hello\""
-set r2 ".*#define ONE"
-set r3 ".*\r\n$gdb_prompt"
+set r1 "#define FOO \"hello\""
+set r2 "#define ONE"
 set testname "$test 2"
-gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
-  -re "$r1$r2$r3" {
-     pass $testname
-  }
-  -re ".*#define TWO.*\r\n$gdb_prompt" {
-     fail $testname
-  }
-  -re ".*#define THREE.*\r\n$gdb_prompt" {
-     fail $testname
-  }
-  -re ".*#define FOUR.*\r\n$gdb_prompt" {
-     fail $testname
-  }
-}
+gdb_test_lines $test $testname $r1.*$r2 \
+    -re-not "#define TWO" \
+    -re-not "#define THREE" \
+    -re-not "#define FOUR"
+
 gdb_test "next" ".*" ""
 
 set r1 ".*#define FOO \" \""
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 02b65617ea4..543a7dc6b06 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1443,13 +1443,34 @@ proc gdb_test_sequence { args } {
 #  '<line1>^M
 #   <line2>^M
 #  '
+#
+# Optionally, additional -re-not <regexp> arguments can be specified, to
+# ensure that a regexp is not match by the COMMAND output.
+# Such an additional argument generates an additional PASS/FAIL of the form:
+#   PASS: test-case.exp: $message: pattern not matched: <regexp>
+
+proc gdb_test_lines { command message re args } {
+    set re_not [list]
+
+    for {set i 0} {$i < [llength $args]} {incr i} {
+	set arg [lindex $args $i]
+	if { $arg == "-re-not" } {
+	    incr i
+	    if { [llength $args] == $i } {
+		error "Missing argument for -re-not"
+		break
+	    }
+	    set arg [lindex $args $i]
+	    lappend re_not $arg
+	} else {
+	    error "Unhandled argument: $arg"
+	}
+    }
 
-proc gdb_test_lines { command message re } {
-    set found 0
-    set idx 0
     if { $message == ""} {
 	set message $command
     }
+
     set lines ""
     gdb_test_multiple $command $message {
 	-re "\r\n(\[^\r\n\]*)(?=\r\n)" {
@@ -1467,6 +1488,10 @@ proc gdb_test_lines { command message re } {
     }
 
     gdb_assert { [regexp $re $lines] } $message
+
+    foreach re $re_not {
+	gdb_assert { ![regexp $re $lines] } "$message: pattern not matched: $re"
+    }
 }
 
 # Test that a command gives an error.  For pass or fail, return

             reply	other threads:[~2021-06-24 15:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 15:34 Tom de Vries [this message]
2021-06-25 14:46 ` Simon Marchi via Gdb-patches
2021-07-06 10:06   ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624153449.GA30047@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox