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 (see Selectors)
which are usually preceded by the keyword target
or xfail
.
{ 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 matches the selector.
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.
For supported values of feature see Add Options.
{ dg-additional-options
options [{ target
selector }] }
The normal timeout limit, in seconds, is found by searching the following in order:
dg-timeout
directive in
the test
{ dg-timeout
n [{target
selector }] }
{ dg-timeout-factor
x [{ target
selector }] }
{ dg-skip-if
comment {
selector } [{
include-opts } [{
exclude-opts }]] }
For example, to skip a test if option -Os
is present:
/* { dg-skip-if "" { *-*-* } { "-Os" } { "" } } */
To skip a test if both options -O2
and -g
are present:
/* { dg-skip-if "" { *-*-* } { "-O2 -g" } { "" } } */
To skip a test if either -O2
or -O3
is present:
/* { dg-skip-if "" { *-*-* } { "-O2" "-O3" } { "" } } */
To skip a test unless option -Os
is present:
/* { dg-skip-if "" { *-*-* } { "*" } { "-Os" } } */
To skip a test if either -O2
or -O3
is used with -g
but not if -fpic
is also present:
/* { dg-skip-if "" { *-*-* } { "-O2 -g" "-O3 -g" } { "-fpic" } } */
{ dg-require-effective-target
keyword [{
selector }] }
dg-do
directive in the test
and before any dg-additional-sources
directive.
See Effective-Target Keywords.
{ 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.
See Require Support, for a complete list of these directives.
{ dg-xfail-if
comment {
selector } [{
include-opts } [{
exclude-opts }]] }
dg-skip-if
) are met. This does not affect the execute step.
{ dg-xfail-run-if
comment {
selector } [{
include-opts } [{
exclude-opts }]] }
dg-skip-if
) are met.
{ 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-prune-output
regexp }
{ dg-output
regexp [{ target/xfail
selector }] }
{ dg-additional-files "
filelist" }
{ dg-additional-sources "
filelist" }
{ dg-final {
local-directive } }
dg-final
.