aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.test-framework
diff options
context:
space:
mode:
authorJanis Johnson <janis187@us.ibm.com>2005-02-03 00:41:35 +0000
committerJanis Johnson <janis@gcc.gnu.org>2005-02-03 00:41:35 +0000
commit1f732f61ea2ac643e30b8068ee3f6737f07de271 (patch)
treecfe606a8586c46cc8160cfeae8a3fc4e6d10d2bf /gcc/testsuite/gcc.test-framework
parentd47fc2487f21739ef36ed6bbfc078ab2ae3b98e5 (diff)
downloadgcc-1f732f61ea2ac643e30b8068ee3f6737f07de271.zip
gcc-1f732f61ea2ac643e30b8068ee3f6737f07de271.tar.gz
gcc-1f732f61ea2ac643e30b8068ee3f6737f07de271.tar.bz2
gen_directive_tests: Generate tests for selector expressions.
* gcc.test-framework/gen_directive_tests: Generate tests for selector expressions. From-SVN: r94642
Diffstat (limited to 'gcc/testsuite/gcc.test-framework')
-rwxr-xr-xgcc/testsuite/gcc.test-framework/gen_directive_tests123
1 files changed, 123 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.test-framework/gen_directive_tests b/gcc/testsuite/gcc.test-framework/gen_directive_tests
index 3198d9e..ac817dd 100755
--- a/gcc/testsuite/gcc.test-framework/gen_directive_tests
+++ b/gcc/testsuite/gcc.test-framework/gen_directive_tests
@@ -36,8 +36,10 @@ 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.
@@ -441,6 +443,127 @@ three_all() {
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