Next: Selectors, Up: Test Directives
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.
测试指令出现在测试源文件的注释中,并且起始于dg-。
其中一些是在DejaGnu中定义的,其它的是局限于GCC测试包自己的。
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. 测试中测试指令出现的顺序很重要: 局限于GCC的指令有时会覆盖DejaGnu的指令使用的信息, 并且其对GCC指令一无所知,所以DejaGnu指令必须在GCC指令之前。
Several test directives include selectors (参见Selectors)
which are usually preceded by the keyword target or xfail.
个别测试指令包含了选择器,
其通常由关键字target或xfail打头。
一个选择器为:一个或多个目标三元组,可能包含通配符;
单个的有效目标关键字;或者一个逻辑表达式。
取决于上下文,选择器指定了是否测试被跳过并报告为不支持,
或者预期为失败。使用‘*-*-*’来匹配任何目标。
有效目标关键字在GCC测试包的target-supports.exp中定义。
选择器表达式出现在大括号中, 并且使用单个的逻辑操作符:‘!’,‘&&’, 或‘||’。 操作数为另一个选择器表达式,一个有效目标关键字, 单个的目标三元组,或者一个双引号或大括号包裹的目标三元组列表。 例如:
{ dg-do do-what-keyword [{ target/xfail selector }] }preprocesscompileassemblelinkrun缺省情况为compile。
可以通过在那些测试的.exp文件中重定义
dg-do-what-default来覆盖这个值。
如果指令包含了可选的‘{ target selector } ’, 则除非目标系统被包含在目标三元组列表中,或者匹配有效目标关键字, 否则测试将被跳过。
如果运行了‘do-what-keyword’并且指令包含了可选的
‘{ xfail selector }’并且选择器匹配,则测试期望为失败。
对于‘do-what-keyword’的其它值,xfail子句会被忽略;
那些测试可以使用指令dg-xfail-if。
{ dg-options options [{ target selector }] }{ dg-add-options feature ... }dg-options指令之后。
支持的feature为:
通常的时间限制,以秒为单位,按照下列顺序来查找:
dg-timeout指令定义
{ 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.
参见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.
参见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.