From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] testsuite: Allow general skips/requires in PCH tests
Date: Thu, 26 Oct 2023 13:34:03 +0100 [thread overview]
Message-ID: <mpty1fpimv8.fsf@arm.com> (raw)
dg-pch.exp handled dg-require-effective-target pch_supported_debug
as a special case, by grepping the source code. This patch tries
to generalise it to other dg-require-effective-targets, and to
dg-skip-if.
There also seemed to be some errors in check-flags. It used:
lappend $args [list <elt>]
which treats the contents of args as a variable name. I think
it was supposed to be "lappend args" instead. From the later
code, the element was supposed to be <elt> itself, rather than
a singleton list containing <elt>.
We can also save some time by doing the common early-exit first.
Doing this removes the need to specify the dg-require-effective-target
in both files. Tested by faking unsupported debug and checking that
the tests were still correctly skipped.
Tested on aarch64-linux-gnu. OK to install?
Richard
gcc/testsuite/
* lib/target-supports-dg.exp (check-flags): Move default argument
handling further up. Fix a couple of issues in the lappends.
Avoid frobbing the compiler flags if the return value is already
known to be 1.
* lib/dg-pch.exp (dg-flags-pch): Process the dg-skip-if and
dg-require-effective-target directives to see whether the
assembly test should be skipped.
* gcc.dg/pch/valid-1.c: Remove dg-require-effective-target.
* gcc.dg/pch/valid-1b.c: Likewise.
---
gcc/testsuite/gcc.dg/pch/valid-1.c | 1 -
gcc/testsuite/gcc.dg/pch/valid-1b.c | 1 -
gcc/testsuite/lib/dg-pch.exp | 24 ++++++++++++--
gcc/testsuite/lib/target-supports-dg.exp | 40 ++++++++++++------------
4 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/pch/valid-1.c b/gcc/testsuite/gcc.dg/pch/valid-1.c
index 6e9abdaef3a..b950d0d4c64 100644
--- a/gcc/testsuite/gcc.dg/pch/valid-1.c
+++ b/gcc/testsuite/gcc.dg/pch/valid-1.c
@@ -1,4 +1,3 @@
-/* { dg-require-effective-target pch_supported_debug } */
/* { dg-options "-I. -Winvalid-pch -g" } */
#include "valid-1.h"/* { dg-warning "created with .none. debug info, but used with" } */
diff --git a/gcc/testsuite/gcc.dg/pch/valid-1b.c b/gcc/testsuite/gcc.dg/pch/valid-1b.c
index 3113d0f744d..a2709967c07 100644
--- a/gcc/testsuite/gcc.dg/pch/valid-1b.c
+++ b/gcc/testsuite/gcc.dg/pch/valid-1b.c
@@ -1,4 +1,3 @@
-/* { dg-require-effective-target pch_supported_debug } */
/* { dg-options "-I. -Winvalid-pch -g0" } */
#include "valid-1b.h"
diff --git a/gcc/testsuite/lib/dg-pch.exp b/gcc/testsuite/lib/dg-pch.exp
index 6b09e8c0478..b6fefaa0286 100644
--- a/gcc/testsuite/lib/dg-pch.exp
+++ b/gcc/testsuite/lib/dg-pch.exp
@@ -100,6 +100,27 @@ proc dg-flags-pch { subdir test otherflags options suffix } {
# For the rest, the default is to compile to .s.
set dg-do-what-default compile
+ # Process the target selectors to see whether the remaining
+ # part of the test should be skipped.
+ #
+ # ??? This doesn't currently handle flag-specific skips,
+ # based on dg-options.
+ set dg-do-what [list compile "" P]
+ set dg-extra-tool-flags ""
+ foreach op [dg-get-options "./$bname$suffix"] {
+ switch [lindex $op 0] {
+ dg-require-effective-target -
+ dg-skip-if {
+ if { [catch "$op" msg] } {
+ perror "$bname$suffix: $msg for \"$op\""
+ }
+ }
+ }
+ }
+ if { [lindex ${dg-do-what} 1] == "N" } {
+ continue
+ }
+
set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[ \t\]\+.*\[ \t\]\+}"]]
if { [ file_on_host exists "$bname$suffix.gch" ] } {
@@ -134,8 +155,7 @@ proc dg-flags-pch { subdir test otherflags options suffix } {
fail "$nshort $flags assembly comparison"
}
}
- } elseif { $pch_unsupported_debug == 0 \
- || [llength [grep $test "{\[ \t\]\+dg-require-effective-target\[ \t\]\+pch_supported_debug\[ \t\]\+.*\[ \t\]\+}"]] > 0 } {
+ } else {
verbose -log "pch file '$bname$suffix.gch' missing"
fail "$nshort $flags"
if { !$have_errs } {
diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
index a80970f1ac2..b5658c1c33e 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -334,6 +334,23 @@ proc check-flags { args } {
# The args are within another list; pull them out.
set args [lindex $args 0]
+ # The next two arguments are optional. If they were not specified,
+ # use the defaults.
+ if { [llength $args] == 2 } {
+ lappend args "*"
+ }
+ if { [llength $args] == 3 } {
+ lappend args ""
+ }
+
+ # If the option strings are the defaults, or the same as the
+ # defaults, there is no need to call check_conditional_xfail to
+ # compare them to the actual options.
+ if { [string compare [lindex $args 2] "*"] == 0
+ && [string compare [lindex $args 3] "" ] == 0 } {
+ return 1
+ }
+
# Start the list with a dummy tool name so the list will match "*"
# if there are no flags.
set compiler_flags " toolname "
@@ -350,26 +367,9 @@ proc check-flags { args } {
append compiler_flags "[board_info $dest multilib_flags] "
}
- # The next two arguments are optional. If they were not specified,
- # use the defaults.
- if { [llength $args] == 2 } {
- lappend $args [list "*"]
- }
- if { [llength $args] == 3 } {
- lappend $args [list ""]
- }
-
- # If the option strings are the defaults, or the same as the
- # defaults, there is no need to call check_conditional_xfail to
- # compare them to the actual options.
- if { [string compare [lindex $args 2] "*"] == 0
- && [string compare [lindex $args 3] "" ] == 0 } {
- set result 1
- } else {
- # The target list might be an effective-target keyword, so replace
- # the original list with "*-*-*", since we already know it matches.
- set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
- }
+ # The target list might be an effective-target keyword, so replace
+ # the original list with "*-*-*", since we already know it matches.
+ set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
# Any value in this variable was left over from an earlier test.
set compiler_flags ""
--
2.25.1
next reply other threads:[~2023-10-26 12:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 12:34 Richard Sandiford [this message]
2023-10-26 15:30 ` Mike Stump
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=mpty1fpimv8.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.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).