From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 02/46] Change 'require' to accept a list of predicates
Date: Fri, 16 Dec 2022 17:07:34 -0700 [thread overview]
Message-ID: <20221217000818.3729389-3-tom@tromey.com> (raw)
In-Reply-To: <20221217000818.3729389-1-tom@tromey.com>
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.
---
gdb/testsuite/gdb.base/valgrind-bt.exp | 2 +-
gdb/testsuite/gdb.base/valgrind-disp-step.exp | 2 +-
gdb/testsuite/gdb.base/valgrind-infcall-2.exp | 2 +-
gdb/testsuite/gdb.base/valgrind-infcall.exp | 2 +-
gdb/testsuite/gdb.dwarf2/dw2-lines.exp | 2 +-
.../gdb.dwarf2/dw2-symtab-includes-lookup.exp | 2 +-
.../frame-inlined-in-outer-frame.exp | 2 +-
gdb/testsuite/gdb.mi/mi-async.exp | 2 +-
gdb/testsuite/gdb.reverse/insn-reverse.exp | 2 +-
gdb/testsuite/gdb.tui/tui-missing-src.exp | 2 +-
gdb/testsuite/lib/gdb.exp | 51 ++++++++-----------
11 files changed, 30 insertions(+), 41 deletions(-)
diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp
index 5dba34e2348..e3399dfc767 100644
--- a/gdb/testsuite/gdb.base/valgrind-bt.exp
+++ b/gdb/testsuite/gdb.base/valgrind-bt.exp
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
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 ee0ed660565..896ea2875b9 100644
--- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp
+++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
@@ -19,7 +19,7 @@
# automatically instead of getting stuck or crashing.
# Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
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 a001561aed3..b59d8b14c01 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
@@ -30,7 +30,7 @@
# Aborted (core dumped)
# Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
load_lib valgrind.exp
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp
index 87d7c6b8a50..389cdaa9bc0 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Valgrind gdbserver requires gdb with xml support.
-require gdb_skip_xml_test 0
+require !gdb_skip_xml_test
load_lib valgrind.exp
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
index b24eec0c8d2..b3e0aff446e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
@@ -18,7 +18,7 @@
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support 1
+require dwarf2_support
standard_testfile .c
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
index 0390d36f74e..c8df4b46477 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
@@ -40,7 +40,7 @@
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
-require dwarf2_support 1
+require dwarf2_support
standard_testfile main.c .S
diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
index 02f9d13af77..cb208c430db 100644
--- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
+++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
@@ -26,7 +26,7 @@
# directives.
# Check if starti command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
load_lib dwarf.exp
diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp
index 756ca112820..5687c9ac335 100644
--- a/gdb/testsuite/gdb.mi/mi-async.exp
+++ b/gdb/testsuite/gdb.mi/mi-async.exp
@@ -26,7 +26,7 @@ if {!([isnative] && [istarget *-linux*])} {
}
# Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
# The plan is for async mode to become the default but toggle for now.
set saved_gdbflags $GDBFLAGS
diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb.reverse/insn-reverse.exp
index 82ae39f9cd9..e16866e1433 100644
--- a/gdb/testsuite/gdb.reverse/insn-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/insn-reverse.exp
@@ -18,7 +18,7 @@ if ![supports_reverse] {
}
# Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
standard_testfile
diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp
index d1fac0b5811..1cb1bb1fbad 100644
--- a/gdb/testsuite/gdb.tui/tui-missing-src.exp
+++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp
@@ -26,7 +26,7 @@
# 7. Going back to main() shall result in no contents again.
# Check if start command is supported.
-require use_gdb_stub 0
+require !use_gdb_stub
tuiterm_env
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 132d538957c..62e519a3cb7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9022,41 +9022,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.
--
2.38.1
next prev parent reply other threads:[~2022-12-17 0:08 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-17 0:07 [PATCH 00/46] Rewrite "require" test procedure and use it more often Tom Tromey
2022-12-17 0:07 ` [PATCH 01/46] Don't use ensure_gdb_index with require Tom Tromey
2022-12-17 0:07 ` Tom Tromey [this message]
2022-12-17 0:07 ` [PATCH 03/46] Use unsupported in 'require' Tom Tromey
2022-12-23 12:39 ` Aktemur, Tankut Baris
2023-01-06 1:14 ` Tom Tromey
2022-12-17 0:07 ` [PATCH 04/46] Use require supports_reverse Tom Tromey
2022-12-17 0:07 ` [PATCH 05/46] Use require supports_process_record Tom Tromey
2022-12-17 0:07 ` [PATCH 06/46] Use require dwarf2_support Tom Tromey
2022-12-17 0:07 ` [PATCH 07/46] Use require is_x86_like_target Tom Tromey
2022-12-17 0:07 ` [PATCH 08/46] Use require skip_cplus_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 09/46] Use require skip_shlib_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 10/46] Use require skip_dlmopen_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 11/46] Use require skip_stl_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 12/46] Use require skip_rust_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 13/46] Use require skip_fortran_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 14/46] Use require skip_ada_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 15/46] Use require skip_go_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 16/46] Use require skip_d_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 17/46] Use require skip_ctf_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 18/46] Use require skip_hw_watchpoint_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 19/46] Use require skip_ifunc_tests Tom Tromey
2022-12-17 0:07 ` [PATCH 20/46] Use require skip_aarch64_sve_tests Tom Tromey
2022-12-19 10:50 ` Luis Machado
2022-12-17 0:07 ` [PATCH 21/46] Use require skip_btrace_tests Tom Tromey
2022-12-17 1:15 ` Enze Li
2022-12-18 0:48 ` Tom Tromey
2022-12-19 5:13 ` Enze Li
2022-12-19 14:44 ` Tom Tromey
2022-12-17 0:07 ` [PATCH 22/46] " Tom Tromey
2022-12-17 9:22 ` Metzger, Markus T
2022-12-18 17:46 ` Tom Tromey
2022-12-17 0:07 ` [PATCH 23/46] Use require skip_avx_* Tom Tromey
2022-12-17 0:07 ` [PATCH 24/46] Use require support_displaced_stepping Tom Tromey
2022-12-17 0:07 ` [PATCH 25/46] Use require is_aarch64_target Tom Tromey
2022-12-19 10:46 ` Luis Machado
2022-12-17 0:07 ` [PATCH 26/46] Use require is_aarch32_target Tom Tromey
2022-12-19 10:46 ` Luis Machado
2022-12-17 0:07 ` [PATCH 27/46] Use require is_amd64_regs_target Tom Tromey
2022-12-17 0:08 ` [PATCH 28/46] Use require is_elf_target Tom Tromey
2022-12-17 0:08 ` [PATCH 29/46] Use require can_single_step_to_signal_handler Tom Tromey
2022-12-17 0:08 ` [PATCH 30/46] Use require supports_get_siginfo_type Tom Tromey
2022-12-17 0:08 ` [PATCH 31/46] Use require support_go_compile Tom Tromey
2022-12-17 0:08 ` [PATCH 32/46] Use require use_gdb_stub Tom Tromey
2022-12-17 0:08 ` [PATCH 33/46] Use require can_spawn_for_attach Tom Tromey
2022-12-17 0:08 ` [PATCH 34/46] Use require isnative Tom Tromey
2022-12-17 0:08 ` [PATCH 35/46] Use require skip_gdbserver_tests Tom Tromey
2022-12-17 0:08 ` [PATCH 36/46] Use require skip_shlib_tests Tom Tromey
2022-12-17 0:08 ` [PATCH 37/46] Use require is_c_compiler_gcc Tom Tromey
2022-12-17 0:08 ` [PATCH 38/46] Use require gdb_debug_enabled Tom Tromey
2022-12-17 0:08 ` [PATCH 39/46] Use require gdb_skip_xml_test Tom Tromey
2022-12-17 0:08 ` [PATCH 40/46] Use require gdb_trace_common_supports_arch Tom Tromey
2022-12-17 0:08 ` [PATCH 41/46] Use require skip_perf_tests Tom Tromey
2022-12-17 0:08 ` [PATCH 42/46] Use require skip_opencl_tests Tom Tromey
2022-12-17 0:08 ` [PATCH 43/46] Use require target_can_use_run_cmd Tom Tromey
2022-12-17 0:08 ` [PATCH 44/46] Use require using_fission Tom Tromey
2022-12-17 0:08 ` [PATCH 45/46] Use require skip_debuginfod_tests Tom Tromey
2022-12-17 0:08 ` [PATCH 46/46] Use require gnat_runtime_has_debug_info Tom Tromey
2022-12-19 10:49 ` [PATCH 00/46] Rewrite "require" test procedure and use it more often Luis Machado
2023-01-06 2:45 ` Tom Tromey
2023-01-05 1:29 ` Kevin Buettner
2023-01-06 2:47 ` Tom Tromey
2023-01-07 0:07 ` Kevin Buettner
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=20221217000818.3729389-3-tom@tromey.com \
--to=tom@tromey.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).