aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-12-13 15:00:07 -0700
committerTom Tromey <tom@tromey.com>2023-01-13 13:18:54 -0700
commit793862d2f427bdc7b80da5bb917acccb06c4ba61 (patch)
tree615d1059ec9703698e76b4ca3127e21539130946 /gdb/testsuite/lib
parent15bdcf4ca1514b89c242eccd3a74599bdd00e3e0 (diff)
downloadfsf-binutils-gdb-793862d2f427bdc7b80da5bb917acccb06c4ba61.zip
fsf-binutils-gdb-793862d2f427bdc7b80da5bb917acccb06c4ba61.tar.gz
fsf-binutils-gdb-793862d2f427bdc7b80da5bb917acccb06c4ba61.tar.bz2
Change 'require' to accept a list of predicates
This changes 'require' to accept a list of simple predicates. For now, each predicate is just the name of a proc, optionally prefixed with "!" to indicate that the result should be inverted. It's possible to make this fancier, but so far I haven't done so. One idea I had is to allow a predicate to have associated text to display on failure. Another is to convert the predicates that need a running gdb (e.g., skip_python_tests) to start their own gdb, and then 'require' could enforce the rule that gdb not be running when it is called.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp51
1 files changed, 20 insertions, 31 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 39dfa67..88dfdaf 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9061,41 +9061,30 @@ 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
- }
+# Called as
+# - require ARG...
+#
+# ARG can either be a name, or of the form !NAME.
+#
+# Each name is a proc to evaluate in the caller's context. It returns
+# a boolean, and a "!" means to invert the result. If this is
+# nonzero, all is well. If it is zero, an "untested" is emitted and
+# this proc causes the caller to return.
- switch "$fn $op $val" {
- "gdb_skip_xml_test == 0" { set msg "missing xml support" }
- "ensure_gdb_index $binfile != -1" -
- "ensure_gdb_index $binfile -dwarf-5 != -1" {
- set msg "Couldn't ensure index in binfile"
+proc require { args } {
+ foreach arg $args {
+ if {[string index $arg 0] == "!"} {
+ set ok 0
+ set fn [string range $arg 1 end]
+ } else {
+ set ok 1
+ set fn $arg
}
- "use_gdb_stub == 0" {
- set msg "Remote stub used"
+ if {$ok != !![uplevel 1 $fn]} {
+ untested "require failed: $arg"
+ return -code return 0
}
- default { set msg "$fn != $val" }
}
-
- untested $msg
- return -code return 0
}
# Wait up to ::TIMEOUT seconds for file PATH to exist on the target system.