public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Add proc require in lib/gdb.exp
@ 2021-10-11 10:21 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-10-11 10:21 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4f69f0a21ef0a22e5e7d82ba271d6a7330469fb1

commit 4f69f0a21ef0a22e5e7d82ba271d6a7330469fb1
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Oct 11 12:21:00 2021 +0200

    [gdb/testsuite] Add proc require in lib/gdb.exp
    
    Add a new proc require in lib/gdb.exp, and use it to shorten:
    ...
    if { [gdb_skip_xml_test] } {
        # Valgrind gdbserver requires gdb with xml support.
        untested "missing xml support"
        return 0
    }
    ...
    into:
    ...
    require gdb_skip_xml_test 0
    ...
    
    Tested on x86_64-linux, both with and without a trigger patch that forces
    gdb_skip_xml_test to return 1.

Diff:
---
 gdb/testsuite/gdb.base/valgrind-bt.exp        |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-disp-step.exp |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-infcall-2.exp |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-infcall.exp   |  7 ++-----
 gdb/testsuite/lib/gdb.exp                     | 30 +++++++++++++++++++++++++++
 5 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp
index 440c6e403e9..546701498b2 100644
--- a/gdb/testsuite/gdb.base/valgrind-bt.exp
+++ b/gdb/testsuite/gdb.base/valgrind-bt.exp
@@ -13,11 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.exp b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
index 88ac848ae2d..c1ed5a3e69b 100644
--- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp
+++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
@@ -18,11 +18,8 @@
 # really tests is that GDB falls back to in-line stepping
 # automatically instead of getting stuck or crashing.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
index a368717c1e8..064cf719712 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
@@ -29,11 +29,8 @@
 # terminate called after throwing an instance of 'gdb_exception_error'
 # Aborted (core dumped)
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp
index 9f49a320f52..68bc1b8e4e7 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp
@@ -13,11 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 5642db4334d..6a5cdc06485 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8215,5 +8215,35 @@ gdb_caching_proc have_avx {
     return $status
 }
 
+# Called as either:
+# - require EXPR VAL
+# - require EXPR OP VAL
+# In the first case, OP is ==.
+#
+# Require EXPR OP VAL, where EXPR is evaluated in caller context.  If not,
+# return in the caller's context.
+
+proc require { fn arg1 {arg2 ""} } {
+    if { $arg2 == "" } {
+	set op ==
+	set val $arg1
+    } else {
+	set op $arg1
+	set val $arg2
+    }
+    set res [uplevel 1 $fn]
+    if { [expr $res $op $val] } {
+	return
+    }
+
+    switch "$fn $op $val" {
+	"gdb_skip_xml_test == 0" { set msg "missing xml support" }
+	default { set msg "$fn != $val" }
+    }
+
+    untested $msg
+    return -code return 0
+}
+
 # Always load compatibility stuff.
 load_lib future.exp


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-11 10:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 10:21 [binutils-gdb] [gdb/testsuite] Add proc require in lib/gdb.exp Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).