[testsuite] new test directive dg-xfail-run-if

Janis Johnson janis187@us.ibm.com
Wed May 21 18:36:00 GMT 2008


This patch adds a new test directive, dg-xfail-run-if, to XFAIL the
execution step of a test for a particular target and flags.  It is
comparable to dg-xfail-if, which does the same thing for the
compilation step.  The patch includes documentation in the Test
Directives section of the GCC Internals Manual and some new tests in
gcc.test-framework, which is probably only ever run by me.

Tested on powerpc64-linux with -m32/-m64 by running the test framework
tests and make html/info/dvi, checked into trunk.

2008-05-21  Janis Johnson  <janis187@us.ibm.com>

gcc/
	* doc/sourcebuild.texi (Test Directives): Add dg-xfail-run-if.

gcc/testsuite/

	* lib/target-supports-dg.exp (dg-xfail-run-if): New.
	* gcc.test-framework/dg-do-run-xrif-exp-F.c: New test.
	* gcc.test-framework/dg-do-run-xrif-exp-P.c: New test.
	* gcc.test-framework/dg-do-run-xrif-exp-XF.c: New test.
	* gcc.test-framework/dg-do-run-xrif-exp-XP.c: New test.
	* gcc.test-framework/dg-dot-run-xrif-exp-F.c: New test.
	* gcc.test-framework/dg-dot-run-xrif-exp-P.c: New test.
	* gcc.test-framework/dg-dot-run-xrif-exp-XF.c: New test.
	* gcc.test-framework/dg-dot-run-xrif-exp-XP.c: New test.
	* gcc.test-framework/test-framework.awk: Handle new tests.

Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi	(revision 135726)
+++ gcc/doc/sourcebuild.texi	(working copy)
@@ -1004,7 +1004,11 @@ an empty @var{exclude-opts} list.
 
 @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.
+@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} @} @}
+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.
 
 @item @{ dg-require-@var{support} args @}
 Skip the test if the target does not provide the required support;
Index: gcc/testsuite/lib/target-supports-dg.exp
===================================================================
--- gcc/testsuite/lib/target-supports-dg.exp	(revision 135726)
+++ gcc/testsuite/lib/target-supports-dg.exp	(working copy)
@@ -294,6 +294,30 @@ proc dg-xfail-if { args } {
     }
 }
 
+# Like dg-xfail-if but for the execute step.
+
+proc dg-xfail-run-if { args } {
+    # 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" } {
+	# These are defined in DejaGnu's dg-test, needed by check-flags.
+	upvar dg-extra-tool-flags dg-extra-tool-flags
+	upvar tool_flags tool_flags
+
+	if [check-flags $args] {
+	    upvar dg-do-what dg-do-what
+            set dg-do-what [list [lindex ${dg-do-what} 0] "S" "F"]
+	}
+    }
+}
+
 # Record whether the program is expected to return a nonzero status.
 
 set shouldfail 0
Index: gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-F.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-F.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-F.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-xfail-run-if "" { empty-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    abort ();	/* This results in a failure.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-P.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-P.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-P.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-xfail-run-if "" { empty-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    return 0;	/* This results in a pass.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XF.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XF.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XF.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-xfail-run-if "" { *-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    abort ();	/* This results in an expected failure.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XP.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XP.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-do-run-xrif-exp-XP.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-xfail-run-if "" { *-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    return 0;	/* This results in unexpected pass.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-F.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-F.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-F.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run { xfail *-empty-* } } */
+/* { dg-xfail-run-if "" { empty-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    abort ();	/* Neither xfail list matched, so fail.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-P.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-P.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-P.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run { xfail *-empty-* } } */
+/* { dg-xfail-run-if "" { empty-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    return 0;	/* Neither xfail list matched, so pass.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XF.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XF.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XF.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run { xfail *-*-* } } */
+/* { dg-xfail-run-if "" { empty-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    abort ();	/* A failed match doesn't override an existing XFAIL.  */
+}
Index: gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XP.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XP.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-dot-run-xrif-exp-XP.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run { xfail empty-*-* } } */
+/* { dg-xfail-run-if "" { *-*-* } { "*" } { "" } } */
+
+extern void abort (void);
+
+int
+main ()
+{
+    return 0;	/* First xfail list didn't match but second did, so XPASS.  */
+}
Index: gcc/testsuite/gcc.test-framework/test-framework.awk
===================================================================
--- gcc/testsuite/gcc.test-framework/test-framework.awk	(revision 135726)
+++ gcc/testsuite/gcc.test-framework/test-framework.awk	(working copy)
@@ -3,7 +3,7 @@
 # of passing tests.
 #
 #
-# Copyright (c) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (c) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,6 +47,8 @@ BEGIN			{ skip = 1; passes = 0; fails = 
 /dg-outexists.*\(test for excess errors)/ { ignore(); next }
 /dg-outexists.*\(test for warnings/ { ignore(); next }
 /dg-outexists.*\(test for errors/ { ignore(); next }
+# ignore compile step for dg-xfail-run-if tests.
+/run-xrif.*\(test for excess errors)/ { ignore(); next }
 # The other dox tests pass the compile step; ignore that message.
 /^PASS.*dox.*\(test for excess errors\)/ { ignore(); next }
 # The sf tests pass the compile step; ignore that message.





More information about the Gcc-patches mailing list