Test directives appear within comments in a test source file and begin
with dg-
. Some of these are defined within DejaGnu and others
are local to the GCC testsuite.
The order in which test directives appear in a test can be important: directives local to GCC sometimes override information used by the DejaGnu directives, which know nothing about the GCC directives, so the DejaGnu directives must precede GCC directives.
Several test directives include selectors which are usually preceded by
the keyword target
or xfail
. A selector is: one or more
target triplets, possibly including wildcard characters; a single
effective-target keyword; or a logical expression. Depending on the
context, the selector specifies whether a test is skipped and reported
as unsupported or is expected to fail. Use *-*-* to match any
target.
Effective-target keywords are defined in target-supports.exp in
the GCC testsuite.
A selector expression appears within curly braces and uses a single logical operator: one of !, &&, or ||. An operand is another selector expression, an effective-target keyword, a single target triplet, or a list of target triplets within quotes or curly braces. For example:
{ target { ! "hppa*-*-* ia64*-*-*" } } { target { powerpc*-*-* && lp64 } } { xfail { lp64 || vect_no_align } }
{ dg-do
do-what-keyword [{ target/xfail
selector }] }
preprocess
compile
assemble
link
run
The default is compile
. That can be overridden for a set of
tests by redefining dg-do-what-default
within the .exp
file for those tests.
If the directive includes the optional { target selector } then the test is skipped unless the target system is included in the list of target triplets or matches the effective-target keyword.
If do-what-keyword is run
and the directive includes
the optional { xfail selector } and the selector is met
then the test is expected to fail. The xfail
clause is ignored
for other values of do-what-keyword; those tests can use
directive dg-xfail-if
.
{ dg-options
options [{ target
selector }] }
{ dg-add-options
feature ... }
dg-options
directives.
The supported values of feature are:
c99_runtime
mips16_attribute
mips16
function attributes. Only MIPS targets support this feature,
and only then in certain modes.
{ dg-skip-if
comment {
selector } {
include-opts } {
exclude-opts } }
Use "*" for an empty include-opts list and "" for
an empty exclude-opts list.
{ dg-xfail-if
comment {
selector } {
include-opts } {
exclude-opts } }
dg-skip-if
) are met.
{ dg-require-
support args }
dg-do
directive in the test
and before any dg-additional-sources
directive.
They require at least one argument, which can be an empty string if the
specific procedure does not examine the argument.
{ dg-require-effective-target
keyword }
dg-do
directive in the test
and before any dg-additional-sources
directive.
{ dg-shouldfail
comment {
selector } {
include-opts } {
exclude-opts } }
dg-skip-if
) are met.
{ dg-error
regexp [
comment [{ target/xfail
selector } [
line] }]] }
FAIL
message. The check does
not look for the string "error" unless it is part of regexp.
{ dg-warning
regexp [
comment [{ target/xfail
selector } [
line] }]] }
FAIL
message. The check does
not look for the string "warning" unless it is part of regexp.
{ dg-message
regexp [
comment [{ target/xfail
selector } [
line] }]] }
FAIL
message.
{ dg-bogus
regexp [
comment [{ target/xfail
selector } [
line] }]] }
{ dg-excess-errors
comment [{ target/xfail
selector }] }
{ dg-output
regexp [{ target/xfail
selector }] }
{ dg-prune-output
regexp }
{ dg-additional-files "
filelist" }
{ dg-additional-sources "
filelist" }
{ dg-final {
local-directive } }
The GCC testsuite defines the following directives to be used within
dg-final
.
cleanup-coverage-files
cleanup-repo-files
cleanup-rtl-dump
suffixcleanup-tree-dump
suffixcleanup-saved-temps
scan-file
filename regexp [{ target/xfail
selector }]
scan-file-not
filename regexp [{ target/xfail
selector }]
scan-hidden
symbol [{ target/xfail
selector }]
scan-not-hidden
symbol [{ target/xfail
selector }]
scan-assembler-times
regex num [{ target/xfail
selector }]
scan-assembler
regex [{ target/xfail
selector }]
scan-assembler-not
regex [{ target/xfail
selector }]
scan-assembler-dem
regex [{ target/xfail
selector }]
scan-assembler-dem-not
regex [{ target/xfail
selector }]
scan-tree-dump-times
regex num suffix [{ target/xfail
selector }]
scan-tree-dump
regex suffix [{ target/xfail
selector }]
scan-tree-dump-not
regex suffix [{ target/xfail
selector }]
scan-tree-dump-dem
regex suffix [{ target/xfail
selector }]
scan-tree-dump-dem-not
regex suffix [{ target/xfail
selector }]
output-exists [{ target/xfail
selector }]
output-exists-not [{ target/xfail
selector }]
run-gcov
sourcefilerun-gcov [branches] [calls] {
opts sourcefile }