This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[testsuite patch] support checking existence of compiler output


This patch adds, tests, and documents testsuite support for checking
that compilation of a test did or did not produce an output file.
It extends Bernhard Fischer's version of the new directives to handle
target and xfail lists.

Tested by running the new tests in gcc.test-framework (I'm probably the
only person who enables those) and with "make info", "make html", and
"make dvi"; I assume the documentation changes are simple enough that
they don't need approval by a doc maintainer.  Checked into mainline;
they'll be in 4.2 and 4.1 in a day or two.

gcc/

2006-11-06  Janis Johnson  <janis187@us.ibm.com>

	* gcc/doc/sourcebuild.texi (Test Directives): Add output-exists
	and output-exists-not.

gcc/testsuite/

2006-11-06  Janis Johnson  <janis187@us.ibm.com
	    Bernhard Fischer  <aldot@gcc.gnu.org>

	* lib/gcc-dg.exp (output-exists): New proc.
	(output-exists-not): New proc.
	* gcc.test-framework/test-framework.awk: Support new directives.
	* gcc.test-framework/dg-outexistsnot-exp-F.c: New test.
	* gcc.test-framework/dg-outexistsnot-exp-P.c: New test.
	* gcc.test-framework/dg-outexists-exp-F.c: New test.
	* gcc.test-framework/dg-outexists-exp-XP.c: New test.
	* gcc.test-framework/dg-outexistsnot-exp-XF.c: New test.
	* gcc.test-framework/dg-outexists-exp-P.c: New test.

Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi	(revision 118518)
+++ gcc/doc/sourcebuild.texi	(working copy)
@@ -1130,6 +1130,12 @@
 Passes if @var{regex} does not match demangled text in the dump file with
 suffix @var{suffix}.
 
+@item output-exists [@{ target/xfail @var{selector} @}]
+Passes if compiler output file exists.
+
+@item output-exists-not [@{ target/xfail @var{selector} @}]
+Passes if compiler output file does not exist.
+
 @item run-gcov @var{sourcefile}
 Check line counts in @command{gcov} tests.
 
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	(revision 118518)
+++ gcc/testsuite/lib/gcc-dg.exp	(working copy)
@@ -446,6 +446,52 @@
     }
 }
 
+# Verify that the compiler output file exists, invoked via dg-final.
+proc output-exists { args } {
+    # Process an optional target or xfail list.
+    if { [llength $args] >= 1 } {
+	switch [dg-process-target [lindex $args 0]] {
+	    "S" { }
+	    "N" { return }
+	    "F" { setup_xfail "*-*-*" }
+	    "P" { }
+	}
+    }
+
+    # Access variables from gcc-dg-test-1.
+    upvar 2 name testcase
+    upvar 2 output_file output_file
+
+    if [file exists $output_file] {
+	pass "$testcase output-exists $output_file"
+    } else {
+	fail "$testcase output-exists $output_file"
+    }
+}
+
+# Verify that the compiler output file does not exist, invoked via dg-final.
+proc output-exists-not { args } {
+    # Process an optional target or xfail list.
+    if { [llength $args] >= 1 } {
+	switch [dg-process-target [lindex $args 0]] {
+	    "S" { }
+	    "N" { return }
+	    "F" { setup_xfail "*-*-*" }
+	    "P" { }
+	}
+    }
+
+    # Access variables from gcc-dg-test-1.
+    upvar 2 name testcase
+    upvar 2 output_file output_file
+
+    if [file exists $output_file] {
+	fail "$testcase output-exists-not $output_file"
+    } else {
+	pass "$testcase output-exists-not $output_file"
+    }
+}
+
 # We need to make sure that additional_* are cleared out after every
 # test.  It is not enough to clear them out *before* the next test run
 # because gcc-target-compile gets run directly from some .exp files
Index: gcc/testsuite/gcc.test-framework/test-framework.awk
===================================================================
--- gcc/testsuite/gcc.test-framework/test-framework.awk	(revision 118518)
+++ gcc/testsuite/gcc.test-framework/test-framework.awk	(working copy)
@@ -40,17 +40,20 @@
 /^PASS.*-2.c/		{ ignore(); next }
 # dg-xfail-if applies to the compile step; these should be XPASS for the
 # compile step on dox tests, which are run tests.
-/^XPASS.*dox.*xiff.*-1.c.*(test for excess errors)/ { ignore(); next }
+/^XPASS.*dox.*xiff.*-1.c.*\(test for excess errors\)/ { ignore(); next }
 # xfail for scan-assembler-not tests doesn't apply to the compile step.
-/^PASS.*sa.*-1.c.*(test for excess errors)/ { ignore(); next }
+/^PASS.*sa.*-1.c.*\(test for excess errors\)/ { ignore(); next }
+# ignore compile step, tests for warnings for output-exists[-not] tests.
+/dg-outexists.*\(test for excess errors)/ { ignore(); next }
+/dg-outexists.*\(test for warnings/ { ignore(); next }
 # The other dox tests pass the compile step; ignore that message.
-/^PASS.*dox.*(test for excess errors)/ { ignore(); next }
+/^PASS.*dox.*\(test for excess errors\)/ { ignore(); next }
 # The sf tests pass the compile step; ignore that message.
-/^PASS.*sf.*(test for excess errors)/ { ignore(); next }
+/^PASS.*sf.*\(test for excess errors\)/ { ignore(); next }
 # Ignore lines that begin with comma.
 /^,/			{ ignore(); next }
 # For tests of dg-output, ignore successful compilation.
-/^PASS.*dg-output.*(test for excess error)/	{ ignore(); next }
+/^PASS.*dg-output.*\(test for excess errors\)/	{ ignore(); next }
 # For tests of dg-output, ignore successful execution.
 /^PASS.*dg-output.*execution test/	{ ignore(); next }
 /^PASS/			{ if (match ($0, "exp-P")) { pass(); next } }
Index: gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-F.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-F.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-F.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do link } */
+
+int main (void) { return 0; }
+
+/* { dg-final { output-exists-not { target bogus-bogus-bogus } } } */
Index: gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-P.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-P.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-P.c	(revision 0)
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-W -Werror" } */
+
+int main (void) { 0; }   /* { dg-warning "no effect" } */
+
+/* { dg-warning "warnings being treated as errors" "" { target *-*-* } 0 } */
+/* { dg-final { output-exists-not { target *-*-* } } } */
Index: gcc/testsuite/gcc.test-framework/dg-outexists-exp-F.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexists-exp-F.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexists-exp-F.c	(revision 0)
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-W -Werror" } */
+
+int main (void) { 0; }   /* { dg-warning "no effect" } */
+
+/* { dg-warning "warnings being treated as errors" "" { target *-*-* } 0 } */
+/* { dg-final { output-exists { target *-*-* } } } */
Index: gcc/testsuite/gcc.test-framework/dg-outexists-exp-XP.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexists-exp-XP.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexists-exp-XP.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do assemble } */
+
+int main (void) { return 0; }
+
+/* { dg-final { output-exists { xfail *-*-* } } } */
Index: gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-XF.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-XF.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexistsnot-exp-XF.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do link } */
+
+int main (void) { return 0; }
+
+/* { dg-final { output-exists-not { xfail *-*-* } } } */
Index: gcc/testsuite/gcc.test-framework/dg-outexists-exp-P.c
===================================================================
--- gcc/testsuite/gcc.test-framework/dg-outexists-exp-P.c	(revision 0)
+++ gcc/testsuite/gcc.test-framework/dg-outexists-exp-P.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+int main (void) { return 0; }
+
+/* { dg-final { output-exists } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]