From: Janis Johnson Date: Tue, 20 Dec 2005 20:58:42 +0000 (+0000) Subject: backport: dg-dot-run-sif-exp-P.c: New test. X-Git-Tag: releases/gcc-3.4.6~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7758cafda9e2504b59ff0c1da647be6d726f6f28;p=thirdparty%2Fgcc.git backport: dg-dot-run-sif-exp-P.c: New test. Backport: 2005-12-06 Janis Johnson * gcc.test-framework/dg-dot-run-sif-exp-P.c: New test. * gcc.test-framework/dg-dot-run-sif-exp-U.c: New test. * gcc.test-framework/dg-dot-run-xif-exp-P.c: New test. * gcc.test-framework/dg-dot-run-xif-exp-XP.c: New test. Backport: 2005-02-01 Janis Johnson * gcc.test-framework/dg-bogus-exp-P.c: New test. * gcc.test-framework/dg-bogus-exp-XF.c: New test. * gcc.test-framework/dg-do-assemble-exp-P.c: New test. * gcc.test-framework/dg-do-compile-exp-P.c: New test. * gcc.test-framework/dg-do-link-exp-P.c: New test. * gcc.test-framework/dg-do-run-exp-P.c: New test. * gcc.test-framework/dg-dot-run-exp-P.c: New test. * gcc.test-framework/dg-dot-run-exp-U.c: New test. * gcc.test-framework/dg-dox-run-exp-XF.c: New test. * gcc.test-framework/dg-error-exp-P.c: New test. * gcc.test-framework/dg-error-exp-XP.c: New test. * gcc.test-framework/dg-excess-errors-exp-XF.c: New test. * gcc.test-framework/dg-excess-errors-exp-XP.c: New test. * gcc.test-framework/dg-output-exp-P.c: New test. * gcc.test-framework/dg-output-exp-XF.c: New test. * gcc.test-framework/dg-warning-exp-P.c: New test. * gcc.misc-tests/dg-1.c, gcc.misc-tests/dg-2.c, gcc.misc-tests/dg-3.c, gcc.misc-tests/dg-4.c, gcc.misc-tests/dg-5.c, gcc.misc-tests/dg-6.c, gcc.misc-tests/dg-7.c, gcc.misc-tests/dg-8.c, gcc.misc-tests/dg-9.c, gcc.misc-tests/dg-10.c, gcc.misc-tests/dg-11.c, gcc.misc-tests/dg-12.c, gcc.misc-tests/dg-test.exp: Remove. Backport: 2005-02-01 Janis Johnson * gcc.test-framwork: New directory. * gcc.test-framework/README: New. * gcc.test-framework/test-framework.exp * gcc.test-framework/gen_directive_tests * gcc.test-framework/test-framework.awk From-SVN: r108867 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50caf633484d..0b4b80ccca6b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,44 @@ 2005-12-20 Janis Johnson + Backport: + 2005-12-06 Janis Johnson + * gcc.test-framework/dg-dot-run-sif-exp-P.c: New test. + * gcc.test-framework/dg-dot-run-sif-exp-U.c: New test. + * gcc.test-framework/dg-dot-run-xif-exp-P.c: New test. + * gcc.test-framework/dg-dot-run-xif-exp-XP.c: New test. + + Backport: + 2005-02-01 Janis Johnson + * gcc.test-framework/dg-bogus-exp-P.c: New test. + * gcc.test-framework/dg-bogus-exp-XF.c: New test. + * gcc.test-framework/dg-do-assemble-exp-P.c: New test. + * gcc.test-framework/dg-do-compile-exp-P.c: New test. + * gcc.test-framework/dg-do-link-exp-P.c: New test. + * gcc.test-framework/dg-do-run-exp-P.c: New test. + * gcc.test-framework/dg-dot-run-exp-P.c: New test. + * gcc.test-framework/dg-dot-run-exp-U.c: New test. + * gcc.test-framework/dg-dox-run-exp-XF.c: New test. + * gcc.test-framework/dg-error-exp-P.c: New test. + * gcc.test-framework/dg-error-exp-XP.c: New test. + * gcc.test-framework/dg-excess-errors-exp-XF.c: New test. + * gcc.test-framework/dg-excess-errors-exp-XP.c: New test. + * gcc.test-framework/dg-output-exp-P.c: New test. + * gcc.test-framework/dg-output-exp-XF.c: New test. + * gcc.test-framework/dg-warning-exp-P.c: New test. + * gcc.misc-tests/dg-1.c, gcc.misc-tests/dg-2.c, gcc.misc-tests/dg-3.c, + gcc.misc-tests/dg-4.c, gcc.misc-tests/dg-5.c, gcc.misc-tests/dg-6.c, + gcc.misc-tests/dg-7.c, gcc.misc-tests/dg-8.c, gcc.misc-tests/dg-9.c, + gcc.misc-tests/dg-10.c, gcc.misc-tests/dg-11.c, gcc.misc-tests/dg-12.c, + gcc.misc-tests/dg-test.exp: Remove. + + Backport: + 2005-02-01 Janis Johnson + * gcc.test-framwork: New directory. + * gcc.test-framework/README: New. + * gcc.test-framework/test-framework.exp + * gcc.test-framework/gen_directive_tests + * gcc.test-framework/test-framework.awk + Backport: 2005-01-24 Janis Johnson * lib/gcc-dg.exp: Clear xfail data in dg-test diff --git a/gcc/testsuite/gcc.misc-tests/dg-1.c b/gcc/testsuite/gcc.misc-tests/dg-1.c deleted file mode 100644 index 319f8a20a7b8..000000000000 --- a/gcc/testsuite/gcc.misc-tests/dg-1.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Test the tester. */ -/* { dg-prms-id 42 } */ -/* { dg-do compile } */ - -main () { return 0; } - -/* { dg-final { if ![file exists dg-1.s] { fail "dg-1.c (compile)"; return; } } } */ - -/* { dg-final { set tmp [grep dg-1.s main line] } } */ -/* { dg-final { if ![string match "" $tmp] \{ } } */ -/* { dg-final { pass "dg-1.c (main function present)" } } */ -/* { dg-final { \} else \{ } } */ -/* { dg-final { fail "dg-1.c (main function not present)" } } */ -/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-10.c b/gcc/testsuite/gcc.misc-tests/dg-10.c deleted file mode 100644 index 6d7b3441623b..000000000000 --- a/gcc/testsuite/gcc.misc-tests/dg-10.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Test the tester. */ -/* { dg-prms-id 42 } */ -/* { dg-options "-Wall" } */ - -/* FIXME: we want to test dg-lose here. Anyone know of a good way to - crash the compiler? */ - -int -main (int argc, char *argv[]) -{ - return 0; -} diff --git a/gcc/testsuite/gcc.misc-tests/dg-2.c b/gcc/testsuite/gcc.misc-tests/dg-2.c deleted file mode 100644 index bb40387e632c..000000000000 --- a/gcc/testsuite/gcc.misc-tests/dg-2.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Test the tester. */ -/* { dg-prms-id 42 } */ -/* { dg-do assemble } */ - -main () { return 0; } - -/* { dg-final { if [file exists dg-2.o] \{ } } */ -/* { dg-final { pass "dg-2.c (assemble: produce .o test)" } } */ -/* { dg-final { \} else \{ } } */ -/* { dg-final { fail "dg-2.c (assemble: produce .o test)" } } */ -/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-3.c b/gcc/testsuite/gcc.misc-tests/dg-3.c deleted file mode 100644 index 017ab279f8ea..000000000000 --- a/gcc/testsuite/gcc.misc-tests/dg-3.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Test the tester. */ -/* { dg-prms-id 42 } */ -/* { dg-do link } */ - -main () { return 0; } - -/* { dg-final { if [file exists a.out] \{ } } */ -/* { dg-final { pass "dg-2.c (link: produce a.out test)" } } */ -/* { dg-final { \} else \{ } } */ -/* { dg-final { fail "dg-2.c (link: produce a.out test)" } } */ -/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-test.exp b/gcc/testsuite/gcc.misc-tests/dg-test.exp deleted file mode 100644 index 820e28de4716..000000000000 --- a/gcc/testsuite/gcc.misc-tests/dg-test.exp +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 1997 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# Test the dg.exp driver. -# This is a testsuite tester tester. As such we *want* to test things like -# expected failure handling. But expected failures must continually be -# monitored and so in the normal case we create unnecessary work. So only -# run these tests if DG_TEST is defined to "yes". - -global DG_TEST -if { ![info exists DG_TEST] || "$DG_TEST" != "yes" } { - return -} - -# Load support procs. -load_lib gcc-dg.exp - -# Initialize harness. -dg-init - -# Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dg-*.c]] "" "" - -# All done. -dg-finish diff --git a/gcc/testsuite/gcc.test-framework/README b/gcc/testsuite/gcc.test-framework/README new file mode 100644 index 000000000000..3a9d4f086afd --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/README @@ -0,0 +1,25 @@ +Check the test directives used in GCC's testsuite by generating and +running tests that use combinations of those commands or that stress +the selector expressions that can be used in those directives. Also +run a few tests of specific functionality from the source directory. + +Each generated test has two parts: a file ending in "-1.c" whose +expected result is encoded in the filename after "-exp-", and a file +ending in "-2.c" which is always expected to pass. + +This test directory is normally skipped and is not meant to be run at +the same time as other parts of the testsuite; it's only of interest to +people who are modifying the test directives or their support in GCC's +.exp files. + +To run these tests: + + CHECK_TEST_FRAMEWORK=1 make -k check RUNTESTFLAGS="test-framework.exp" + +To check the results: + + TF=${SRC}/gcc/testsuite/gcc.test-framework + awk -f ${TF}/test-framework.awk gcc/testsuite/gcc.sum + +The awk script prints unexpected results followed by the number of tests +that passed and failed. diff --git a/gcc/testsuite/gcc.test-framework/dg-bogus-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-bogus-exp-P.c new file mode 100644 index 000000000000..003264a72df4 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-bogus-exp-P.c @@ -0,0 +1,8 @@ +/* Test the tester; previously part of gcc.misc-tests/dg-9.c. */ +/* { dg-prms-id 42 } */ +/* { dg-options "-Wall" } */ + +int main (int argc, char *argv[]) +{ + return 0; /* { dg-bogus "foobar" "bogus fail test" } */ +} diff --git a/gcc/testsuite/gcc.test-framework/dg-bogus-exp-XF.c b/gcc/testsuite/gcc.test-framework/dg-bogus-exp-XF.c new file mode 100644 index 000000000000..60c9147af6ee --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-bogus-exp-XF.c @@ -0,0 +1,9 @@ +/* Test the tester; previously part of gcc.misc-tests/dg-9.c. */ +/* { dg-prms-id 42 } */ +/* { dg-options "-Wall" } */ + +main (int argc, char *argv[]) +{ /* { dg-bogus "return type" "bogus pass test" { xfail *-*-* } } */ +} + +/* { dg-excess-errors "bogus pass test" { xfail *-*-* } } */ diff --git a/gcc/testsuite/gcc.test-framework/dg-do-assemble-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-do-assemble-exp-P.c new file mode 100644 index 000000000000..316572092a65 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-do-assemble-exp-P.c @@ -0,0 +1,11 @@ +/* Test the tester; previously gcc.misc-tests/dg-2.c. */ +/* { dg-prms-id 42 } */ +/* { dg-do assemble } */ + +main () { return 0; } + +/* { dg-final { if [file exists dg-do-assemble-exp-P.o] \{ } } */ +/* { dg-final { pass "dg-do-assemble-exp-P.c (assemble: produce .o test)" } } */ +/* { dg-final { \} else \{ } } */ +/* { dg-final { fail "dg-do-assemble-exp-P.c (assemble: produce .o test)" } } */ +/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.test-framework/dg-do-compile-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-do-compile-exp-P.c new file mode 100644 index 000000000000..93857465a162 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-do-compile-exp-P.c @@ -0,0 +1,14 @@ +/* Test the tester; previously gcc.misc-tests/dg-1.c. */ +/* { dg-prms-id 42 } */ +/* { dg-do compile } */ + +main () { return 0; } + +/* { dg-final { if ![file exists dg-do-compile-exp-P.s] { fail "dg-do-compile-exp-P.c (compile)"; return; } } } */ + +/* { dg-final { set tmp [grep dg-do-compile-exp-P.s main line] } } */ +/* { dg-final { if ![string match "" $tmp] \{ } } */ +/* { dg-final { pass "dg-do-compile-exp-P.c (main function present)" } } */ +/* { dg-final { \} else \{ } } */ +/* { dg-final { fail "dg-do-compile-exp-P.c (main function not present)" } } */ +/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.test-framework/dg-do-link-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-do-link-exp-P.c new file mode 100644 index 000000000000..254109e65264 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-do-link-exp-P.c @@ -0,0 +1,11 @@ +/* Test the tester; previously gcc.misc-tests/dg-3.c. */ +/* { dg-prms-id 42 } */ +/* { dg-do link } */ + +main () { return 0; } + +/* { dg-final { if [file exists dg-do-link-exp-P.exe] \{ } } */ +/* { dg-final { pass "dg-do-link-exp-P.c (link: produce a.out test)" } } */ +/* { dg-final { \} else \{ } } */ +/* { dg-final { fail "dg-do-link-exp-P.c (link: produce a.out test)" } } */ +/* { dg-final { \} } } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-4.c b/gcc/testsuite/gcc.test-framework/dg-do-run-exp-P.c similarity index 53% rename from gcc/testsuite/gcc.misc-tests/dg-4.c rename to gcc/testsuite/gcc.test-framework/dg-do-run-exp-P.c index 806bdfbf91ae..a7f3ffa680ab 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-4.c +++ b/gcc/testsuite/gcc.test-framework/dg-do-run-exp-P.c @@ -1,4 +1,4 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-4.c. */ /* { dg-prms-id 42 } */ /* { dg-do run } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-11.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-exp-P.c similarity index 68% rename from gcc/testsuite/gcc.misc-tests/dg-11.c rename to gcc/testsuite/gcc.test-framework/dg-dot-run-exp-P.c index bfbba4d12167..3bbc4e1bd405 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-11.c +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-exp-P.c @@ -1,6 +1,6 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-11.c. */ /* { dg-prms-id 42 } */ -/* { dg-do run { target sparc-sun-solaris2* } } */ +/* { dg-do run { target *-*-* } } */ /* The \n is left out of the pattern because tcl's exec will remove it. */ /* { dg-output {Hello world[.]} } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-12.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-exp-U.c similarity index 80% rename from gcc/testsuite/gcc.misc-tests/dg-12.c rename to gcc/testsuite/gcc.test-framework/dg-dot-run-exp-U.c index c6adbf53d95b..9d79604b2268 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-12.c +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-exp-U.c @@ -1,4 +1,4 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-12.c. */ /* { dg-prms-id 42 } */ /* { dg-do run { target foo-bar-eh } } */ /* The \n is left out of the pattern because tcl's exec will remove it. */ diff --git a/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-P.c new file mode 100644 index 000000000000..bf473616abb7 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-P.c @@ -0,0 +1,8 @@ +/* { dg-do run { target { *-*-* && yes } } } */ +/* { dg-skip-if "comment" { no && yes } { "*" } { "" } } */ + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-U.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-U.c new file mode 100644 index 000000000000..65008c8ab288 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-sif-exp-U.c @@ -0,0 +1,8 @@ +/* { dg-do run { target { *-*-* || no } } } */ +/* { dg-skip-if "comment" { *-*-* && yes } { "*" } { "" } } */ + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-P.c new file mode 100644 index 000000000000..eb2af26081f0 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-P.c @@ -0,0 +1,8 @@ +/* { dg-do run { target { *-*-* && yes } } } */ +/* { dg-xfail-if "comment" { empty-*-* && yes } { "*" } { "" } } */ + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-XP.c b/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-XP.c new file mode 100644 index 000000000000..59cb76894018 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-dot-run-xif-exp-XP.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { *-*-* empty-*-* } } } */ +/* { dg-xfail-if "comment" { *-*-* && yes } { "*" } { "" } } */ + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.misc-tests/dg-7.c b/gcc/testsuite/gcc.test-framework/dg-dox-run-exp-XF.c similarity index 67% rename from gcc/testsuite/gcc.misc-tests/dg-7.c rename to gcc/testsuite/gcc.test-framework/dg-dox-run-exp-XF.c index adde4cb60d2d..69cff8bb8e31 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-7.c +++ b/gcc/testsuite/gcc.test-framework/dg-dox-run-exp-XF.c @@ -1,4 +1,4 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-7.c. */ /* { dg-prms-id 42 } */ /* { dg-do run { xfail *-*-* } } */ extern void abort (void); diff --git a/gcc/testsuite/gcc.test-framework/dg-error-exp-P.c b/gcc/testsuite/gcc.test-framework/dg-error-exp-P.c new file mode 100644 index 000000000000..cb28e34ce954 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-error-exp-P.c @@ -0,0 +1,9 @@ +/* Test the tester; previously part of gcc.misc-tests/dg-9.c. */ +/* { dg-prms-id 42 } */ +/* { dg-options "-Wall" } */ + +int main (int argc, char *argv[]) +{ + +; /* { dg-error "syntax error" "error test" } */ + return 0; +} diff --git a/gcc/testsuite/gcc.test-framework/dg-error-exp-XP.c b/gcc/testsuite/gcc.test-framework/dg-error-exp-XP.c new file mode 100644 index 000000000000..856b7270b255 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-error-exp-XP.c @@ -0,0 +1,11 @@ +/* Test the tester; previously part of gcc.misc-tests/dg-9.c. */ +/* { dg-prms-id 42 } */ +/* { dg-options "-Wall" } */ + +int main (int argc, char *argv[]) +{ + +; + /* { dg-error "syntax error" "error test" { xfail *-*-* } 7 } */ + return 0; +} +/* { dg-excess-errors "expect failure" { xfail *-*-* } } */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-8.c b/gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XF.c similarity index 69% rename from gcc/testsuite/gcc.misc-tests/dg-8.c rename to gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XF.c index 63a5b0e73fa0..496c6a60d50d 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-8.c +++ b/gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XF.c @@ -1,7 +1,7 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-8.c. */ /* { dg-prms-id 42 } */ /* { dg-options "-Wall" } */ -/* { dg-do run } */ +/* { dg-do compile } */ /* { dg-excess-errors "excess errors" } */ /* should get warning about defaulting return type - excess error */ diff --git a/gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XP.c b/gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XP.c new file mode 100644 index 000000000000..4aecca3ba340 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/dg-excess-errors-exp-XP.c @@ -0,0 +1,9 @@ +/* Test the tester. */ +/* { dg-prms-id 42 } */ +/* { dg-options "-Wall" } */ +/* { dg-do compile } */ +/* { dg-excess-errors "excess errors" } */ + +/* No messages, so unexpected pass. */ + +int main () { return 0; } diff --git a/gcc/testsuite/gcc.misc-tests/dg-5.c b/gcc/testsuite/gcc.test-framework/dg-output-exp-P.c similarity index 79% rename from gcc/testsuite/gcc.misc-tests/dg-5.c rename to gcc/testsuite/gcc.test-framework/dg-output-exp-P.c index 178fcb85a4d7..4cec76f982c5 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-5.c +++ b/gcc/testsuite/gcc.test-framework/dg-output-exp-P.c @@ -1,4 +1,4 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-5.c. */ /* { dg-prms-id 42 } */ /* { dg-do run } */ /* The \n is left out of the pattern because tcl's exec will remove it. */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-6.c b/gcc/testsuite/gcc.test-framework/dg-output-exp-XF.c similarity index 82% rename from gcc/testsuite/gcc.misc-tests/dg-6.c rename to gcc/testsuite/gcc.test-framework/dg-output-exp-XF.c index 8323792c9188..6606e5c932aa 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-6.c +++ b/gcc/testsuite/gcc.test-framework/dg-output-exp-XF.c @@ -1,4 +1,4 @@ -/* Test the tester. */ +/* Test the tester; previously gcc.misc-tests/dg-6.c. */ /* { dg-prms-id 42 } */ /* { dg-do run { target *-*-* } } */ /* The \n is left out of the pattern because tcl's exec will remove it. */ diff --git a/gcc/testsuite/gcc.misc-tests/dg-9.c b/gcc/testsuite/gcc.test-framework/dg-warning-exp-P.c similarity index 59% rename from gcc/testsuite/gcc.misc-tests/dg-9.c rename to gcc/testsuite/gcc.test-framework/dg-warning-exp-P.c index b228fff7437f..cb9883ac4e82 100644 --- a/gcc/testsuite/gcc.misc-tests/dg-9.c +++ b/gcc/testsuite/gcc.test-framework/dg-warning-exp-P.c @@ -1,15 +1,15 @@ -/* Test the tester. */ +/* Test the tester; previously part of gcc.misc-tests/dg-9.c. */ /* { dg-prms-id 42 } */ /* { dg-options "-Wall" } */ +int i; + f () { /* { dg-warning "return type" "warning test" } */ + i = 1; } /* { dg-warning "control reaches end" "warning test" } */ main (int argc, char *argv[]) { /* { dg-warning "return type" "warning test" } */ - +; /* { dg-error "parse" "error test" } */ - /* { dg-bogus "foobar" "bogus fail test" } */ - - return a; /* { dg-bogus "undeclared|identifier|appears" "bogus pass test" { xfail *-*-* } } */ + i = 1; } /* { dg-warning "control reaches end" "warning test" } */ diff --git a/gcc/testsuite/gcc.test-framework/gen_directive_tests b/gcc/testsuite/gcc.test-framework/gen_directive_tests new file mode 100644 index 000000000000..42e63826b316 --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/gen_directive_tests @@ -0,0 +1,693 @@ +#! /bin/bash + +######################################################################## +# +# File: generate_framework_tests +# Author: Janis Johnson +# Date: 2004/11/02 +# +# Generate tests of GCC's test framework. Each test has encoded in +# its name the dg commands that are used in the test and the expected +# result of the test, *-1.c. Each test is followed by a test ending +# in *-2.c that is expected to pass. +# +# This script has evolved and could be rewritten to be more compact. +# +# +# Copyright (c) 2004, 2005 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License, write the the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +######################################################################## + +cd $1 + +GOOD0='*-*-*' +GOOD1="yes" +GOOD2='empty-*-* *-*-empty *-*-*' +BAD0='empty-empty-empty' +BAD1="no" +BAD2='empty-*-* *-empty-* *-*-empty' + +# Programs used in the tests: good compile and run, bad compile, and +# bad run. +GOOD_PROG="int main () { return 0; }" +BADC_PROG="int missing_body () }" +BADR_PROG="extern void abort (void); int main () { abort (); }" + +# dg-do commands with a target list. +DOT_S0="{ dg-do compile { target ${GOOD0} } }" +DOT_S1="{ dg-do compile { target ${GOOD1} } }" +DOT_N0="{ dg-do compile { target ${BAD0} } }" +DOT_N1="{ dg-do compile { target ${BAD1} } }" + +# dg-do commands with an xfail list; the xfail list is ignored for +# everything but "run". +DOX_P0="{ dg-do run { xfail ${BAD0} } }" +DOX_P1="{ dg-do run { xfail ${BAD1} } }" +DOX_F0="{ dg-do run { xfail ${GOOD0} } }" +DOX_F1="{ dg-do run { xfail ${GOOD1} } }" + +# dg-xfail-if commands. +XIF_P0="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DY2\" } }" +XIF_P1="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DN\" } }" +XIF_P2="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DN\" } { \"-DY1\" } }" +XIF_P3="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DN1\" } { \"-DN2\" } }" +XIF_P4="{ dg-xfail-if \"exclude option matched\" { ${GOOD0} } { \"-DY1\" } { \"-DY2\" } }" +XIF_P5="{ dg-xfail-if \"include option not matched\" { ${GOOD0} } { \"-DN\" } { \"-DY1\" } }" +XIF_P6="{ dg-xfail-if \"include option not matched\" { ${GOOD0} } { \"-DN1\" } { \"-DN2\" } }" +XIF_F0="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"-DN\" } }" +XIF_F1="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"-DN\" } }" +XIF_F2="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"\" } }" +XIF_F3="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"\" } }" + +XIF_P7="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DY2\" } }" +XIF_P8="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DN\" } }" +XIF_P9="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DN\" } { \"-DY1\" } }" +XIF_P10="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DN1\" } { \"-DN2\" } }" +XIF_P11="{ dg-xfail-if \"exclude option matched\" { ${GOOD1} } { \"-DY1\" } { \"-DY2\" } }" +XIF_P12="{ dg-xfail-if \"include option not matched\" { ${GOOD1} } { \"-DN\" } { \"-DY1\" } }" +XIF_P13="{ dg-xfail-if \"include option not matched\" { ${GOOD1} } { \"-DN1\" } { \"-DN2\" } }" +XIF_F4="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"-DN\" } }" +XIF_F5="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"-DN\" } }" +XIF_F6="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"\" } }" +XIF_F7="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"\" } }" + + +# dg-skip-if commands. +SIF_S0="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DY2\" } }" +SIF_S1="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DN\" } }" +SIF_S2="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DN\" } { \"-DY1\" } }" +SIF_S3="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DN1\" } { \"-DN2\" } }" +SIF_S4="{ dg-skip-if \"exclude option matched\" { ${GOOD0} } { \"-DY1\" } { \"-DY2\" } }" +SIF_S5="{ dg-skip-if \"include option not matched\" { ${GOOD0} } { \"-DN\" } { \"-DY1\" } }" +SIF_S6="{ dg-skip-if \"include option not matched\" { ${GOOD0} } { \"-DN1\" } { \"-DN2\" } }" +SIF_N0="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"-DN\" } }" +SIF_N1="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"-DN\" } }" +SIF_N2="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"\" } }" +SIF_N3="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"\" } }" +SIF_S7="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DY2\" } }" +SIF_S8="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DN\" } }" +SIF_S9="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DN\" } { \"-DY1\" } }" +SIF_S10="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DN1\" } { \"-DN2\" } }" +SIF_S11="{ dg-skip-if \"exclude option matched\" { ${GOOD1} } { \"-DY1\" } { \"-DY2\" } }" +SIF_S12="{ dg-skip-if \"include option not matched\" { ${GOOD1} } { \"-DN\" } { \"-DY1\" } }" +SIF_S13="{ dg-skip-if \"include option not matched\" { ${GOOD1} } { \"-DN1\" } { \"-DN2\" } }" +SIF_N4="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"-DN\" } }" +SIF_N5="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"-DN\" } }" +SIF_N6="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"\" } }" +SIF_N7="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"\" } }" + +# dg-require-* commands, using procedures defined for this set of tests. +REQ_S0="{ dg-require-true \"\" }" # do not skip the test +REQ_N0="{ dg-require-false \"\" }" # skip the test + +# scan-assembler-not, which is hoped to be representative of commands +# used with dg-final, with a target list. +SAT_N0="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${BAD0} } } }" +SAT_N1="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${BAD1} } } }" +SAT_S0="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${GOOD0} } } }" +SAT_S1="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${GOOD1} } } }" + +# scan-assembler-not, which is hoped to be representative of commands +# used with dg-final, with an xfail list. +SAX_P0="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${BAD0} } } }" +SAX_P1="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${BAD1} } } }" +SAX_F0="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${GOOD0} } } }" +SAX_F1="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${GOOD1} } } }" + +KIND_LIST="" + +# Expected result of the *-1.c test, encoded into the file name. +EXP_PASS="exp-P" +EXP_XPASS="exp-XP" +EXP_SKIP="exp-U" +EXP_FAIL="exp-F" +EXP_XFAIL="exp-XF" + +get_list() { + KIND=$1 + case $KIND in + "dots") KIND_LIST="dots0 dots1";; + "dotn") KIND_LIST="dotn0 dotn1";; + "doxp") KIND_LIST="doxp0 doxp1";; + "doxf") KIND_LIST="doxf0 doxf1";; + "sifs") KIND_LIST="sifs0 sifs1 sifs2 sifs3 sifs4 sifs5 sifs6 sifs7 sifs8 sifs9 sifs10 sifs11 sifs12 sifs13";; + "sifn") KIND_LIST="sifn0 sifn1 sifn2 sifn3 sifn4 sifn5 sifn6 sifn7";; + "xifp") KIND_LIST="xifp0 xifp1 xifp2 xifp3 xifp4 xifp5 xifp6 xifp7 xifp8 xifp9 xifp10 xifp11 xifp12 xifp13";; + "xiff") KIND_LIST="xiff0 xiff1 xiff2 xiff3 xiff4 xiff5 xiff6 xiff7";; + "sats") KIND_LIST="sats0 sats1";; + "satn") KIND_LIST="satn0 satn1";; + "saxp") KIND_LIST="saxp0 saxp1";; + "saxf") KIND_LIST="saxf0 saxf1";; + "reqs") KIND_LIST="reqs0";; + "reqn") KIND_LIST="reqn0";; + *) echo "oops: $KIND"; exit 1;; + esac +} + +cmd() { + KIND=$1 + FILE=$2 + + case $KIND in + "dots") echo '/*' "${DOT_S0}" '*/' >> $FILE;; + "dots0") echo '/*' "${DOT_S0}" '*/' >> $FILE;; + "dots1") echo '/*' "${DOT_S1}" '*/' >> $FILE;; + "dots2") echo '/*' "${DOT_S2}" '*/' >> $FILE;; + "dots3") echo '/*' "${DOT_S3}" '*/' >> $FILE;; + "dots4") echo '/*' "${DOT_S4}" '*/' >> $FILE;; + "dotn") echo '/*' "${DOT_N0}" '*/' >> $FILE;; + "dotn0") echo '/*' "${DOT_N0}" '*/' >> $FILE;; + "dotn1") echo '/*' "${DOT_N1}" '*/' >> $FILE;; + "dotn2") echo '/*' "${DOT_N2}" '*/' >> $FILE;; + "dotn3") echo '/*' "${DOT_N3}" '*/' >> $FILE;; + "dotn4") echo '/*' "${DOT_N4}" '*/' >> $FILE;; + "doxp") echo '/*' "${DOX_P0}" '*/' >> $FILE;; + "doxp0") echo '/*' "${DOX_P0}" '*/' >> $FILE;; + "doxp1") echo '/*' "${DOX_P1}" '*/' >> $FILE;; + "doxp2") echo '/*' "${DOX_P2}" '*/' >> $FILE;; + "doxp3") echo '/*' "${DOX_P3}" '*/' >> $FILE;; + "doxp4") echo '/*' "${DOX_P4}" '*/' >> $FILE;; + "doxf") echo '/*' "${DOX_F0}" '*/' >> $FILE;; + "doxf0") echo '/*' "${DOX_F0}" '*/' >> $FILE;; + "doxf1") echo '/*' "${DOX_F1}" '*/' >> $FILE;; + "doxf2") echo '/*' "${DOX_F2}" '*/' >> $FILE;; + "doxf3") echo '/*' "${DOX_F3}" '*/' >> $FILE;; + "doxf4") echo '/*' "${DOX_F4}" '*/' >> $FILE;; + "sifs") echo '/*' "${SIF_S0}" '*/' >> $FILE;; + "sifs0") echo '/*' "${SIF_S0}" '*/' >> $FILE;; + "sifs1") echo '/*' "${SIF_S1}" '*/' >> $FILE;; + "sifs2") echo '/*' "${SIF_S2}" '*/' >> $FILE;; + "sifs3") echo '/*' "${SIF_S3}" '*/' >> $FILE;; + "sifs4") echo '/*' "${SIF_S4}" '*/' >> $FILE;; + "sifs5") echo '/*' "${SIF_S5}" '*/' >> $FILE;; + "sifs6") echo '/*' "${SIF_S6}" '*/' >> $FILE;; + "sifs7") echo '/*' "${SIF_S7}" '*/' >> $FILE;; + "sifs8") echo '/*' "${SIF_S8}" '*/' >> $FILE;; + "sifs9") echo '/*' "${SIF_S9}" '*/' >> $FILE;; + "sifs10") echo '/*' "${SIF_S10}" '*/' >> $FILE;; + "sifs11") echo '/*' "${SIF_S11}" '*/' >> $FILE;; + "sifs12") echo '/*' "${SIF_S12}" '*/' >> $FILE;; + "sifs13") echo '/*' "${SIF_S13}" '*/' >> $FILE;; + "sifn") echo '/*' "${SIF_N0}" '*/' >> $FILE;; + "sifn0") echo '/*' "${SIF_N0}" '*/' >> $FILE;; + "sifn1") echo '/*' "${SIF_N1}" '*/' >> $FILE;; + "sifn2") echo '/*' "${SIF_N2}" '*/' >> $FILE;; + "sifn3") echo '/*' "${SIF_N3}" '*/' >> $FILE;; + "sifn4") echo '/*' "${SIF_N4}" '*/' >> $FILE;; + "sifn5") echo '/*' "${SIF_N5}" '*/' >> $FILE;; + "sifn6") echo '/*' "${SIF_N6}" '*/' >> $FILE;; + "sifn7") echo '/*' "${SIF_N7}" '*/' >> $FILE;; + "xifp") echo '/*' "${XIF_P0}" '*/' >> $FILE;; + "xifp0") echo '/*' "${XIF_P0}" '*/' >> $FILE;; + "xifp1") echo '/*' "${XIF_P1}" '*/' >> $FILE;; + "xifp2") echo '/*' "${XIF_P2}" '*/' >> $FILE;; + "xifp3") echo '/*' "${XIF_P3}" '*/' >> $FILE;; + "xifp4") echo '/*' "${XIF_P4}" '*/' >> $FILE;; + "xifp5") echo '/*' "${XIF_P5}" '*/' >> $FILE;; + "xifp6") echo '/*' "${XIF_P6}" '*/' >> $FILE;; + "xifp7") echo '/*' "${XIF_P7}" '*/' >> $FILE;; + "xifp8") echo '/*' "${XIF_P8}" '*/' >> $FILE;; + "xifp9") echo '/*' "${XIF_P9}" '*/' >> $FILE;; + "xifp10") echo '/*' "${XIF_P10}" '*/' >> $FILE;; + "xifp11") echo '/*' "${XIF_P11}" '*/' >> $FILE;; + "xifp12") echo '/*' "${XIF_P12}" '*/' >> $FILE;; + "xifp13") echo '/*' "${XIF_P13}" '*/' >> $FILE;; + "xiff") echo '/*' "${XIF_F0}" '*/' >> $FILE;; + "xiff0") echo '/*' "${XIF_F0}" '*/' >> $FILE;; + "xiff1") echo '/*' "${XIF_F1}" '*/' >> $FILE;; + "xiff2") echo '/*' "${XIF_F2}" '*/' >> $FILE;; + "xiff3") echo '/*' "${XIF_F3}" '*/' >> $FILE;; + "xiff4") echo '/*' "${XIF_F4}" '*/' >> $FILE;; + "xiff5") echo '/*' "${XIF_F5}" '*/' >> $FILE;; + "xiff6") echo '/*' "${XIF_F6}" '*/' >> $FILE;; + "xiff7") echo '/*' "${XIF_F7}" '*/' >> $FILE;; + "satn") echo '/*' "${SAT_N0}" '*/' >> $FILE;; + "satn0") echo '/*' "${SAT_N0}" '*/' >> $FILE;; + "satn1") echo '/*' "${SAT_N1}" '*/' >> $FILE;; + "satn2") echo '/*' "${SAT_N2}" '*/' >> $FILE;; + "satn3") echo '/*' "${SAT_N3}" '*/' >> $FILE;; + "satn4") echo '/*' "${SAT_N4}" '*/' >> $FILE;; + "sats") echo '/*' "${SAT_S0}" '*/' >> $FILE;; + "sats0") echo '/*' "${SAT_S0}" '*/' >> $FILE;; + "sats1") echo '/*' "${SAT_S1}" '*/' >> $FILE;; + "sats2") echo '/*' "${SAT_S2}" '*/' >> $FILE;; + "sats3") echo '/*' "${SAT_S3}" '*/' >> $FILE;; + "sats4") echo '/*' "${SAT_S4}" '*/' >> $FILE;; + "saxp") echo '/*' "${SAX_P0}" '*/' >> $FILE;; + "saxp0") echo '/*' "${SAX_P0}" '*/' >> $FILE;; + "saxp1") echo '/*' "${SAX_P1}" '*/' >> $FILE;; + "saxp2") echo '/*' "${SAX_P2}" '*/' >> $FILE;; + "saxp3") echo '/*' "${SAX_P3}" '*/' >> $FILE;; + "saxp4") echo '/*' "${SAX_P4}" '*/' >> $FILE;; + "saxf") echo '/*' "${SAX_F0}" '*/' >> $FILE;; + "saxf0") echo '/*' "${SAX_F0}" '*/' >> $FILE;; + "saxf1") echo '/*' "${SAX_F1}" '*/' >> $FILE;; + "saxf2") echo '/*' "${SAX_F2}" '*/' >> $FILE;; + "saxf3") echo '/*' "${SAX_F3}" '*/' >> $FILE;; + "saxf4") echo '/*' "${SAX_F4}" '*/' >> $FILE;; + "reqs") echo '/*' "${REQ_S0}" '*/' >> $FILE;; + "reqs0") echo '/*' "${REQ_S0}" '*/' >> $FILE;; + "reqn") echo '/*' "${REQ_N0}" '*/' >> $FILE;; + "reqn0") echo '/*' "${REQ_N0}" '*/' >> $FILE;; + *) echo "oops: $KIND"; exit 1;; + esac +} + +# Generate a test using a single dg- command. If requested, generate a +# second version that will fail. +one() { + KIND=$1 + EXP=$2 + FAIL_VERSION=$3 + + NAME=${KIND}-${EXP} + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + cmd $KIND $FILE1 + echo "${GOOD_PROG}" >> $FILE1 + echo "${GOOD_PROG}" > $FILE2 + + if [ "${FAIL_VERSION}" == "yes" ]; then + if [ "${EXP}" == "${EXP_PASS}" ]; then + NAME=${KIND}-${EXP_FAIL} + else + NAME=${KIND}-${EXP_XFAIL} + fi + + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + cmd $KIND $FILE1 + case $KIND in + dox*) echo "${BADR_PROG}" >> $FILE1;; + *) echo "${BADC_PROG}" >> $FILE1;; + esac + echo "${GOOD_PROG}" > $FILE2 + fi +} + +# Generate a test using two dg- commands. If requested, generate a +# second version that will fail. +two() { + KIND1=$1 + KIND2=$2 + EXP=$3 + FAIL_VERSION=$4 + + NAME=${KIND1}-${KIND2}-${EXP} + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + + rm -f $FILE1 + touch $FILE1 + cmd $KIND1 $FILE1 + cmd $KIND2 $FILE1 + echo "${GOOD_PROG}" >> $FILE1 + echo "${GOOD_PROG}" > $FILE2 + + if [ "${FAIL_VERSION}" == "yes" ]; then + if [ "${EXP}" == "${EXP_PASS}" ]; then + NAME=${KIND1}-${KIND2}-${EXP_FAIL} + else + NAME=${KIND1}-${KIND2}-${EXP_XFAIL} + fi + + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + cmd $KIND1 $FILE1 + cmd $KIND2 $FILE1 + # dg-do with an xfail list is only used as the first command. + case $KIND1 in + dox*) echo "${BADR_PROG}" >> $FILE1;; + *) echo "${BADC_PROG}" >> $FILE1;; + esac + echo "${GOOD_PROG}" > $FILE2 + fi +} + +# Generate a test using three dg- commands. If requested generate a +# second version that will fail. +three() { + KIND1=$1 + KIND2=$2 + KIND3=$3 + EXP=$4 + FAIL_VERSION=$5 + + NAME=${KIND1}-${KIND2}-${KIND3}-${EXP} + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + cmd $KIND1 $FILE1 + cmd $KIND2 $FILE1 + cmd $KIND3 $FILE1 + echo "${GOOD_PROG}" >> $FILE1 + echo "${GOOD_PROG}" > $FILE2 + + if [ "${FAIL_VERSION}" == "${yes}" ]; then + if [ "${EXP}" == "${EXP_PASS}" ]; then + NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_FAIL} + else + NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_XFAIL} + fi + + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + cmd $KIND1 $FILE1 + cmd $KIND2 $FILE1 + cmd $KIND3 $FILE1 + # dg-do with an xfail list is only used as the first command. + case $KIND1 in + dox*) echo "${BADR_PROG}" >> $FILE1;; + *) echo "${BADC_PROG}" >> $FILE1;; + esac + echo "${GOOD_PROG}" > $FILE2 + fi +} + +# Generate tests using one dg- command. Generate a test for each variant +# of KIND. +one_all() { + KIND=$1 + EXP=$2 + FAIL_VERSION=$3 + + get_list $KIND + for k in $KIND_LIST; do + one $k $EXP $FAIL_VERSION + done +} + +# Generate tests using two dg- commands. For each KIND, generate +# a test for each of its variants. +two_all() { + KIND1=$1 + KIND2=$2 + EXP=$3 + FAIL_VERSION=$4 + + get_list $KIND1 + KIND_LIST1="$KIND_LIST" + get_list $KIND2 + KIND_LIST2="$KIND_LIST" + for k1 in $KIND_LIST1; do + for k2 in $KIND_LIST2; do + two $k1 $k2 $EXP $FAIL_VERSION + done + done +} + +# Generate tests using three dg- commands. For each KIND, generate +# a test for each of its variants. +three_all() { + KIND1=$1 + KIND2=$2 + KIND3=$3 + EXP=$4 + FAIL_VERSION=$5 + + get_list $KIND1 + KIND_LIST1="$KIND_LIST" + get_list $KIND2 + KIND_LIST2="$KIND_LIST" + get_list $KIND3 + KIND_LIST3="$KIND_LIST" + for k1 in $KIND_LIST1; do + for k2 in $KIND_LIST2; do + for k3 in $KIND_LIST3; do + three $k1 $k2 $k3 $EXP $FAIL_VERSION + done + done + done +} + +# Generate a test that uses a dg-do directive with a selector expression. +dgdo_progs() { + WHAT=$1 + KIND=$2 + PROG="$3" + NAME="$4" + XPR="$5" + + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + echo '/* { dg-do' $WHAT '{' $KIND "$XPR" '} } */' >> $FILE1 + echo "${PROG}" >> $FILE1 + echo "${GOOD_PROG}" > $FILE2 +} + +# Use various selector-expressions that evaluate to TRUE in dg-do directives. +selector_good() { + NUM=101 + for xpr in \ + "$GOOD0" \ + "$GOOD1" \ + "$GOOD2" \ + "{ ! $BAD0 }" \ + "{ ! $BAD1 }" \ + "{ ! { $BAD2 } }" \ + "{ ! \"${BAD2}\" }" \ + "{ $GOOD1 || $GOOD0 }" \ + "{ $BAD1 || $GOOD0 }" \ + "{ $GOOD0 && $GOOD1 }" \ + "{ $BAD1 || { \"${GOOD2}\" && $GOOD1 } }" \ + "{ { $BAD0 || $GOOD0 } && $GOOD0 }" \ + "{ $GOOD1 && { \"${GOOD2}\" || $BAD1 } }" \ + "{ \"${GOOD2}\" && { $GOOD1 || $BAD1 } }" + do + dgdo_progs compile target "$GOOD_PROG" "dots${NUM}-exp-P" "$xpr" + dgdo_progs compile target "$BADC_PROG" "dots${NUM}-exp-F" "$xpr" + dgdo_progs run xfail "$GOOD_PROG" "doxf${NUM}-exp-XP" "$xpr" + dgdo_progs run xfail "$BADR_PROG" "doxf${NUM}-exp-XF" "$xpr" + let NUM=NUM+1 + done +} + +# Use various selector-expressions that evaluate to FALSE in dg-do directives. +selector_bad() { + NUM=101 + for xpr in \ + "$BAD0" \ + "$BAD1" \ + "$BAD2" \ + "{ ! $GOOD0 }" \ + "{ ! $GOOD1 }" \ + "{ ! { $GOOD2 } }" \ + "{ ! \"${GOOD2}\" }" \ + "{ $BAD1 || $BAD0 }" \ + "{ $BAD0 && $GOOD1 }" \ + "{ $GOOD1 && $BAD0 }" \ + "{ $BAD1 || { $GOOD1 && $BAD0 } }" \ + "{ { $GOOD1 || $BAD1 } && $BAD0 }" \ + "{ $BAD1 || { \"${BAD2}\" && $GOOD1 } }" \ + "{ \"${BAD2}\" && { $GOOD1 || $BAD1 } }" + do + dgdo_progs compile target "$GOOD_PROG" "dotn${NUM}-exp-U" "$xpr" + dgdo_progs run xfail "$GOOD_PROG" "doxp${NUM}-exp-P" "$xpr" + dgdo_progs run xfail "$BADR_PROG" "doxp${NUM}-exp-F" "$xpr" + let NUM=NUM+1 + done +} + +# Write a test whose directive is too long and messy to do as one string. +deep_progs() { + PROG="$1" + NAME=$2 + CMD1="$3" + CMD2="$4" + CMD3="$5" + + FILE1=${NAME}-1.c + FILE2=${NAME}-2.c + rm -f $FILE1 + touch $FILE1 + echo "$CMD1" "$CMD2" "$CMD3" > $FILE1 + echo "$PROG" >> $FILE1 + echo "$GOOD_PROG" > $FILE2 +} + +# Use nested expressions in various test directives. +selector_deep() { + GOODXPR="{ \"${GOOD2}\" && { ! { $BAD0 || $BAD1 } } }" + BADXPR="{ ! { \"${GOOD2}\" || { $GOOD1 && $BAD1 } } }" + NUM=100 + dgdo_progs compile target "$GOOD_PROG" "dots${NUM}-exp-P" "$GOODXPR" + dgdo_progs compile target "$GOOD_PROG" "dotn${NUM}-exp-U" "$BADXPR" + + deep_progs "$BADC_PROG" "xiff-100-exp-XF" \ + '/* { dg-xfail-if "match" { ' "{ $GOODXPR }" ' } { "*" } { "" } } */' + deep_progs "$GOOD_PROG" "xifp-100-exp-P" \ + '/* { dg-xfail-if "no match" { ' "{ $BADXPR }" ' } { "*" } { "" } } */' + deep_progs "$BADC_PROG" "xifn-100-exp-U" \ + '/* { dg-skip-if "match" { ' "{ $GOODXPR }" ' } { "*" } { "" } } */' + deep_progs "$GOOD_PROG" "xifs-100-exp-P" \ + '/* { dg-skip-if "match" { ' "{ $BADXPR }" ' } { "*" } { "" } } */' + deep_progs "$GOOD_PROG" "satn-100-exp-P" \ + '/* { dg-final { scan-assembler-not "unexpected garbage" { target ' \ + "$GOODXPR" ' } } } */' + deep_progs "$GOOD_PROG" "satn-100-exp-U" \ + '/* { dg-final { scan-assembler-not "unexpected garbage" { target ' \ + "$BADXPR" ' } } } */' + deep_progs "$GOOD_PROG" "satf-100-exp-XP" \ + '/* { dg-final { scan-assembler-not "unexpected garbage" { xfail ' \ + "$GOODXPR" ' } } } */' + deep_progs "$GOOD_PROG" "satp-100-exp-P" \ + '/* { dg-final { scan-assembler-not "unexpected garbage" { xfail ' \ + "$BADXPR" ' } } } */' +} + +selector_good +selector_bad +selector_deep + +one_all saxp $EXP_PASS no +one_all saxf $EXP_XPASS no +one_all sats $EXP_PASS no +one_all satn $EXP_SKIP no +one_all dots $EXP_PASS yes +one_all dotn $EXP_SKIP no +one_all doxp $EXP_PASS yes +one_all doxf $EXP_XPASS yes +one_all sifs $EXP_PASS yes +one_all sifn $EXP_SKIP no +one_all xifp $EXP_PASS yes +one_all xiff $EXP_XPASS yes +one_all reqs $EXP_PASS yes +one_all reqn $EXP_SKIP no + +two_all dots xifp $EXP_PASS yes +two_all dots xiff $EXP_XPASS yes +two_all dots sifs $EXP_PASS yes +two_all dots sifn $EXP_SKIP no +two_all dotn xifp $EXP_SKIP no +two_all dotn sifs $EXP_SKIP no +two_all dotn sifn $EXP_SKIP no +two_all dotn xiff $EXP_SKIP no +two_all dots reqs $EXP_PASS yes +two_all dots reqn $EXP_SKIP no +two_all dotn reqs $EXP_SKIP no +two_all dotn reqn $EXP_SKIP no + +two_all doxp xifp $EXP_PASS yes +two_all doxp xiff $EXP_PASS yes # dg-xfail-if applies to compile, not run +two_all doxp sifs $EXP_PASS yes +two_all doxp sifn $EXP_SKIP no +two_all doxf xifp $EXP_XPASS yes +two_all doxf xiff $EXP_XPASS yes +two_all doxf sifs $EXP_XPASS yes +two_all doxf sifn $EXP_SKIP no + +two_all doxp reqs $EXP_PASS yes +two_all doxp reqn $EXP_SKIP no +two_all doxf reqs $EXP_XPASS yes +two_all doxf reqn $EXP_SKIP no + +two_all reqs xifp $EXP_PASS yes +two_all reqs xiff $EXP_XPASS yes +two_all reqs sifs $EXP_PASS yes +two_all reqs sifn $EXP_SKIP no +two_all reqn xifp $EXP_SKIP no +two_all reqn xiff $EXP_SKIP no +two_all reqn sifs $EXP_SKIP no +two_all reqn sifn $EXP_SKIP no + +two_all xifp reqs $EXP_PASS yes +two_all xiff reqs $EXP_XPASS yes +two_all sifs reqs $EXP_PASS yes +two_all sifn reqs $EXP_SKIP no +two_all xifp reqn $EXP_SKIP no +two_all xiff reqn $EXP_SKIP no +two_all sifs reqn $EXP_SKIP no +two_all sifn reqn $EXP_SKIP no + +three_all dots reqs xifp $EXP_PASS yes +three_all dots reqs xiff $EXP_XPASS yes +three_all dots reqs sifs $EXP_PASS yes +three_all dots reqs sifn $EXP_SKIP no +three_all dots reqn xifp $EXP_SKIP no +three_all dots reqn xiff $EXP_SKIP no +three_all dots reqn sifs $EXP_SKIP no +three_all dots reqn sifn $EXP_SKIP no +three_all dotn reqs xifp $EXP_SKIP no +three_all dotn reqs xiff $EXP_SKIP no +three_all dotn reqs sifs $EXP_SKIP no +three_all dotn reqs sifn $EXP_SKIP no +three_all dotn reqn xifp $EXP_SKIP no +three_all dotn reqn xiff $EXP_SKIP no +three_all dotn reqn sifs $EXP_SKIP no +three_all dotn reqn sifn $EXP_SKIP no +# +three_all dots xifp reqs $EXP_PASS yes +three_all dots xiff reqs $EXP_XPASS yes +three_all dots sifs reqs $EXP_PASS yes +three_all dots sifn reqs $EXP_SKIP no +three_all dots xifp reqn $EXP_SKIP no +three_all dots xiff reqn $EXP_SKIP no +three_all dots sifs reqn $EXP_SKIP no +three_all dots sifn reqn $EXP_SKIP no +three_all dotn xifp reqs $EXP_SKIP no +three_all dotn xiff reqs $EXP_SKIP no +three_all dotn sifs reqs $EXP_SKIP no +three_all dotn sifn reqs $EXP_SKIP no +three_all dotn xifp reqn $EXP_SKIP no +three_all dotn xiff reqn $EXP_SKIP no +three_all dotn sifs reqn $EXP_SKIP no +three_all dotn sifn reqn $EXP_SKIP no + +three_all doxp reqs xifp $EXP_PASS yes +three_all doxp reqs xiff $EXP_PASS yes # dg-xfail-if applies to compile, not run +three_all doxp reqs sifs $EXP_PASS yes +three_all doxp reqs sifn $EXP_SKIP no +three_all doxp reqn xifp $EXP_SKIP no +three_all doxp reqn xiff $EXP_SKIP no +three_all doxp reqn sifs $EXP_SKIP no +three_all doxp reqn sifn $EXP_SKIP no +three_all doxf reqs xifp $EXP_XPASS yes +three_all doxf reqs xiff $EXP_XPASS yes +three_all doxf reqs sifs $EXP_XPASS yes +three_all doxf reqs sifn $EXP_SKIP no +three_all doxf reqn xifp $EXP_SKIP no +three_all doxf reqn xiff $EXP_SKIP no +three_all doxf reqn sifs $EXP_SKIP no +three_all doxf reqn sifn $EXP_SKIP no + +three_all doxp xifp reqs $EXP_PASS yes +three_all doxp xiff reqs $EXP_PASS yes # dg-xfail-if applies to compile, not run +three_all doxp sifs reqs $EXP_PASS yes +three_all doxp sifn reqs $EXP_SKIP no +three_all doxp xifp reqn $EXP_SKIP no +three_all doxp xiff reqn $EXP_SKIP no +three_all doxp sifs reqn $EXP_SKIP no +three_all doxp sifn reqn $EXP_SKIP no +three_all doxf xifp reqs $EXP_XPASS yes +three_all doxf xiff reqs $EXP_XPASS yes +three_all doxf sifs reqs $EXP_XPASS yes +three_all doxf sifn reqs $EXP_SKIP no +three_all doxf xifp reqn $EXP_SKIP no +three_all doxf xiff reqn $EXP_SKIP no +three_all doxf sifs reqn $EXP_SKIP no +three_all doxf sifn reqn $EXP_SKIP no diff --git a/gcc/testsuite/gcc.test-framework/test-framework.awk b/gcc/testsuite/gcc.test-framework/test-framework.awk new file mode 100644 index 000000000000..30ff13d6e2de --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/test-framework.awk @@ -0,0 +1,65 @@ +# Process the gcc.sum file for a run through gcc.test-framework. +# Print result lines that show potential problems. Report the number +# of passing tests. +# +# +# Copyright (c) 2004, 2005 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License, write the the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +function pass(msg) { + passes++; + # printf("pass %s\n", $0); + } +function fail(msg) { + fails++; + printf("fail %s\n", $0); + } +function ignore(msg) { + # printf("ignore %s\n", $0); + } + +BEGIN { skip = 1; passes = 0; fails = 0; } +/Running.*test-frame/ { skip = 0; next } +/gcc Summary/ { skip = 1; next } + { if (skip) next } +/^$/ { next } +# The post tests are always expected to pass. +/^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 } +# xfail for scan-assembler-not tests doesn't apply to the compile step. +/^PASS.*sa.*-1.c.*(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 } +# 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 } +# For tests of dg-output, ignore successful execution. +/^PASS.*dg-output.*execution test/ { ignore(); next } +/^PASS/ { if (match ($0, "exp-P")) { pass(); next } } +/^FAIL/ { if (match ($0, "exp-F")) { pass(); next } } +/^XPASS/ { if (match ($0, "exp-XP")) { pass(); next } } +/^XFAIL/ { if (match ($0, "exp-XF")) { pass(); next } } +/^UNSUPPORTED/ { if (match ($0, "exp-U")) { pass(); next } } + { fail() } +END { + printf("\n\t\t=== Test Framework Summary ===\n\n"); + printf("# of expected passes\t\t%d\n", passes); + if (fails != 0) + printf("# of unexpected failures\t%d\n", fails); + } diff --git a/gcc/testsuite/gcc.test-framework/test-framework.exp b/gcc/testsuite/gcc.test-framework/test-framework.exp new file mode 100644 index 000000000000..495ffe2cb99b --- /dev/null +++ b/gcc/testsuite/gcc.test-framework/test-framework.exp @@ -0,0 +1,75 @@ +# Copyright (c) 2002, 2003, 2004, 2005 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a copy of the GNU General Public License, write the the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Based on gcc/testsuite/gcc.dg/dg.exp. + +# Don't run these tests unless an environment variable is defined. +if { ![info exists env(CHECK_TEST_FRAMEWORK)] } { + verbose "skipping test framework tests, CHECK_TEST_FRAMEWORK is not defined" 0 + return +} + +load_lib gcc-dg.exp + +proc dg-require-true { args } { + verbose "dg-require-true" 2 +} + +proc dg-require-false { args } { + verbose "dg-require-false" 2 + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] +} + +proc check_effective_target_yes { args } { + return 1 +} + +proc check_effective_target_no { args } { + return 0 +} + +global dg-do-what-default +set save-dg-do-what-default ${dg-do-what-default} +set dg-do-what-default compile + +dg-init + +# Run tests from the source directory. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dg-*.c]] "" "" + +# Skip generated tests unless CHECK_TEST_FRAMEWORK is 1. +if { $env(CHECK_TEST_FRAMEWORK) != 1 } { + verbose "skipping generated test framework tests, CHECK_TEST_FRAMEWORK is not 1" 0 + return +} + +# Generate additional tests. +set tstobjdir "$tmpdir/gcc.test-framework" +set generator "$srcdir/$subdir/gen_directive_tests" +file delete -force $tstobjdir +file mkdir $tstobjdir +set status [remote_exec host "$generator $tstobjdir"] +set status [lindex $status 0] +if { $status == 0 } { + # Run the generated tests. + dg-runtest [lsort [find $tstobjdir *.c]] "" "-DY1 -DY2" +} else { + warning "Could not generate test framework tests" +} + +dg-finish +set dg-do-what-default ${save-dg-do-what-default}