RFA testsuite: make option strings optional for dg-skip-if and friends
Janis Johnson
janis187@us.ibm.com
Wed Mar 3 22:18:00 GMT 2010
On Mon, 2010-03-01 at 16:36 -0800, Janis Johnson wrote:
> Rainer Orth recently noticed some tests that should have been skipped
> but weren't due to missing arguments for dg-skip-if. Over fifty other
> tests are missing arguments to dg-skip-if and related directives.
> Rather than fix the tests I'd prefer to fix the directives to match
> what people expect them to do.
>
> This patch makes optional the include-opts and exclude-opts arguments
> to dg-skip-if, dg-xfail-if, and dg-xfail-run-if (they are already
> optional for dg-shouldfail). If there are no options to match, we now
> skip the call to DejaGnu's matching procedure.
>
> Tested by running the entire testsuite on powerpc64-linux with -m32/-m64
> and comparing results, and lots of ad hoc testing. Documentation
> changes tested with make html/dvi/info and by looking at the new html
> files.
>
> Are there any objections to changing these test directives at this
> point in the release cycle? If they go into trunk I plan to also
> backport them for the 4.4 and 4.3 branches.
I've checked this in on trunk and will add it to the 4.4 branch in a
couple of days. Backporting to 4.3 would require more changes so I'm
not planning to do that.
> 2010-03-01 Janis Johnson <janis187@us.ibm.com>
>
> * doc/sourcebuild.texi (Test directives): Document that arguments
> include-opts and exclude-opts are now optional for dg-skip-if,
> dg-xfail-if, dg-xfail-run-if, and dg-shouldfail.
>
> * lib/target-supports-dg.exp (check-flags): Provide defaults for
> include-opts and exclude-opts; skip checking the flags if arguments
> are the same as the defaults.
> (dg-xfail-if): Verify the number of arguments, supply defaults
> for unspecified optional arguments.
> (dg-skip-if, dg-xfail-run-if): Verify the number of arguments.
>
> Index: gcc/doc/sourcebuild.texi
> ===================================================================
> --- gcc/doc/sourcebuild.texi (revision 157154)
> +++ gcc/doc/sourcebuild.texi (working copy)
> @@ -1020,7 +1020,7 @@ the test
> @item 300
> @end itemize
>
> -@item @{ dg-skip-if @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
> +@item @{ dg-skip-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
> Arguments @var{include-opts} and @var{exclude-opts} are lists in which
> each element is a string of zero or more GCC options.
> Skip the test if all of the following conditions are met:
> @@ -1030,11 +1030,13 @@ Skip the test if all of the following co
> @item for at least one of the option strings in @var{include-opts},
> every option from that string is in the set of options with which
> the test would be compiled; use @samp{"*"} for an @var{include-opts} list
> -that matches any options
> +that matches any options; that is the default if @var{include-opts} is
> +not specified
>
> @item for each of the option strings in @var{exclude-opts}, at least one
> option from that string is not in the set of options with which the test
> -would be compiled; use @samp{""} for an empty @var{exclude-opts} list
> +would be compiled; use @samp{""} for an empty @var{exclude-opts} list;
> +that is the default if @var{exclude-opts} is not specified
> @end itemize
>
> For example, to skip a test if option @code{-Os} is present:
> @@ -1068,11 +1070,11 @@ but not if @code{-fpic} is also present:
> /* @{ dg-skip-if "" @{ *-*-* @} @{ "-O2 -g" "-O3 -g" @} @{ "-fpic" @} @} */
> @end smallexample
>
> -@item @{ dg-xfail-if @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
> +@item @{ dg-xfail-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
> Expect the test to fail if the conditions (which are the same as for
> @code{dg-skip-if}) are met. This does not affect the execute step.
>
> -@item @{ dg-xfail-run-if @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
> +@item @{ dg-xfail-run-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
> Expect the execute step of a test to fail if the conditions (which are
> the same as for @code{dg-skip-if}) and @code{dg-xfail-if}) are met.
>
> @@ -1090,7 +1092,7 @@ is not covered by the effective-target k
> This directive must appear after any @code{dg-do} directive in the test
> and before any @code{dg-additional-sources} directive.
>
> -@item @{ dg-shouldfail @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
> +@item @{ dg-shouldfail @var{comment} [@{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]]] @}
> Expect the test executable to return a nonzero exit status if the
> conditions (which are the same as for @code{dg-skip-if}) are met.
>
> Index: gcc/testsuite/lib/target-supports-dg.exp
> ===================================================================
> --- gcc/testsuite/lib/target-supports-dg.exp (revision 157154)
> +++ gcc/testsuite/lib/target-supports-dg.exp (working copy)
> @@ -235,9 +235,26 @@ proc check-flags { args } {
> append compiler_flags "[board_info $dest multilib_flags] "
> }
>
> - # 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 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 "*-*-*"]]
> + }
>
> # Any value in this variable was left over from an earlier test.
> set compiler_flags ""
> @@ -256,14 +273,18 @@ proc check-flags { args } {
> # group of tests or flags specified with a previous dg-options command.
>
> proc dg-skip-if { args } {
> + # Verify the number of arguments. The last two are optional.
> + set args [lreplace $args 0 0]
> + if { [llength $args] < 2 || [llength $args] > 4 } {
> + error "dg-skip-if 2: need 2, 3, or 4 arguments"
> + }
> +
> # Don't bother if we're already skipping the test.
> upvar dg-do-what dg-do-what
> if { [lindex ${dg-do-what} 1] == "N" } {
> return
> }
>
> - set args [lreplace $args 0 0]
> -
> set selector [list target [lindex $args 1]]
> if { [dg-process-target $selector] == "S" } {
> if [check-flags $args] {
> @@ -276,31 +297,53 @@ proc dg-skip-if { args } {
> # Like check_conditional_xfail, but callable from a dg test.
>
> proc dg-xfail-if { args } {
> + # Verify the number of arguments. The last three are optional.
> + set args [lreplace $args 0 0]
> + if { [llength $args] < 2 || [llength $args] > 4 } {
> + error "dg-xfail-if: need 2, 3, or 4 arguments"
> + }
> +
> # Don't change anything if we're already skipping the test.
> upvar dg-do-what dg-do-what
> if { [lindex ${dg-do-what} 1] == "N" } {
> return
> }
>
> - set args [lreplace $args 0 0]
> set selector [list target [lindex $args 1]]
> if { [dg-process-target $selector] == "S" } {
> global compiler_conditional_xfail_data
> - set compiler_conditional_xfail_data [lreplace $args 1 1 "*-*-*"]
> +
> + # The target list might be an effective-target keyword. Replace
> + # the original list with "*-*-*", since we already know it matches.
> + set args [lreplace $args 1 1 "*-*-*"]
> +
> + # Supply default values for unspecified optional arguments.
> + if { [llength $args] == 2 } {
> + lappend $args [list "*"]
> + }
> + if { [llength $args] == 3 } {
> + lappend $args [list ""]
> + }
> +
> + set compiler_conditional_xfail_data $args
> }
> }
>
> # Like dg-xfail-if but for the execute step.
>
> proc dg-xfail-run-if { args } {
> + # Verify the number of arguments. The last two are optional.
> + set args [lreplace $args 0 0]
> + if { [llength $args] < 2 || [llength $args] > 4 } {
> + error "dg-xfail-run-if: need 2, 3, or 4 arguments"
> + }
> +
> # Don't bother if we're already skipping the test.
> upvar dg-do-what dg-do-what
> if { [lindex ${dg-do-what} 1] == "N" } {
> return
> }
>
> - set args [lreplace $args 0 0]
> -
> set selector [list target [lindex $args 1]]
> if { [dg-process-target $selector] == "S" } {
> if [check-flags $args] {
>
>
More information about the Gcc-patches
mailing list