Final-Actions.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Final Actions</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Final Actions">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Final Actions">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Test-Directives.html#Test-Directives" rel="up" title="Test Directives">
  30. <link href="Ada-Tests.html#Ada-Tests" rel="next" title="Ada Tests">
  31. <link href="Require-Support.html#Require-Support" rel="prev" title="Require Support">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Final-Actions"></a>
  63. <div class="header">
  64. <p>
  65. Previous: <a href="Require-Support.html#Require-Support" accesskey="p" rel="prev">Require Support</a>, Up: <a href="Test-Directives.html#Test-Directives" accesskey="u" rel="up">Test Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Commands-for-use-in-dg_002dfinal"></a>
  69. <h4 class="subsection">7.2.6 Commands for use in <code>dg-final</code></h4>
  70. <p>The GCC testsuite defines the following directives to be used within
  71. <code>dg-final</code>.
  72. </p>
  73. <a name="Scan-a-particular-file"></a>
  74. <h4 class="subsubsection">7.2.6.1 Scan a particular file</h4>
  75. <dl compact="compact">
  76. <dt><code>scan-file <var>filename</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  77. <dd><p>Passes if <var>regexp</var> matches text in <var>filename</var>.
  78. </p></dd>
  79. <dt><code>scan-file-not <var>filename</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  80. <dd><p>Passes if <var>regexp</var> does not match text in <var>filename</var>.
  81. </p></dd>
  82. <dt><code>scan-module <var>module</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  83. <dd><p>Passes if <var>regexp</var> matches in Fortran module <var>module</var>.
  84. </p></dd>
  85. </dl>
  86. <a name="Scan-the-assembly-output"></a>
  87. <h4 class="subsubsection">7.2.6.2 Scan the assembly output</h4>
  88. <dl compact="compact">
  89. <dt><code>scan-assembler <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  90. <dd><p>Passes if <var>regex</var> matches text in the test&rsquo;s assembler output.
  91. </p>
  92. </dd>
  93. <dt><code>scan-assembler-not <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  94. <dd><p>Passes if <var>regex</var> does not match text in the test&rsquo;s assembler output.
  95. </p>
  96. </dd>
  97. <dt><code>scan-assembler-times <var>regex</var> <var>num</var> [{ target/xfail <var>selector</var> }]</code></dt>
  98. <dd><p>Passes if <var>regex</var> is matched exactly <var>num</var> times in the test&rsquo;s
  99. assembler output.
  100. </p>
  101. </dd>
  102. <dt><code>scan-assembler-dem <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  103. <dd><p>Passes if <var>regex</var> matches text in the test&rsquo;s demangled assembler output.
  104. </p>
  105. </dd>
  106. <dt><code>scan-assembler-dem-not <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  107. <dd><p>Passes if <var>regex</var> does not match text in the test&rsquo;s demangled assembler
  108. output.
  109. </p>
  110. </dd>
  111. <dt><code>scan-hidden <var>symbol</var> [{ target/xfail <var>selector</var> }]</code></dt>
  112. <dd><p>Passes if <var>symbol</var> is defined as a hidden symbol in the test&rsquo;s
  113. assembly output.
  114. </p>
  115. </dd>
  116. <dt><code>scan-not-hidden <var>symbol</var> [{ target/xfail <var>selector</var> }]</code></dt>
  117. <dd><p>Passes if <var>symbol</var> is not defined as a hidden symbol in the test&rsquo;s
  118. assembly output.
  119. </p></dd>
  120. </dl>
  121. <a name="Scan-optimization-dump-files"></a>
  122. <h4 class="subsubsection">7.2.6.3 Scan optimization dump files</h4>
  123. <p>These commands are available for <var>kind</var> of <code>tree</code>, <code>rtl</code>,
  124. and <code>ipa</code>.
  125. </p>
  126. <dl compact="compact">
  127. <dt><code>scan-<var>kind</var>-dump <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  128. <dd><p>Passes if <var>regex</var> matches text in the dump file with suffix <var>suffix</var>.
  129. </p>
  130. </dd>
  131. <dt><code>scan-<var>kind</var>-dump-not <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  132. <dd><p>Passes if <var>regex</var> does not match text in the dump file with suffix
  133. <var>suffix</var>.
  134. </p>
  135. </dd>
  136. <dt><code>scan-<var>kind</var>-dump-times <var>regex</var> <var>num</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  137. <dd><p>Passes if <var>regex</var> is found exactly <var>num</var> times in the dump file
  138. with suffix <var>suffix</var>.
  139. </p>
  140. </dd>
  141. <dt><code>scan-<var>kind</var>-dump-dem <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  142. <dd><p>Passes if <var>regex</var> matches demangled text in the dump file with
  143. suffix <var>suffix</var>.
  144. </p>
  145. </dd>
  146. <dt><code>scan-<var>kind</var>-dump-dem-not <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  147. <dd><p>Passes if <var>regex</var> does not match demangled text in the dump file with
  148. suffix <var>suffix</var>.
  149. </p></dd>
  150. </dl>
  151. <a name="Verify-that-an-output-files-exists-or-not"></a>
  152. <h4 class="subsubsection">7.2.6.4 Verify that an output files exists or not</h4>
  153. <dl compact="compact">
  154. <dt><code>output-exists [{ target/xfail <var>selector</var> }]</code></dt>
  155. <dd><p>Passes if compiler output file exists.
  156. </p>
  157. </dd>
  158. <dt><code>output-exists-not [{ target/xfail <var>selector</var> }]</code></dt>
  159. <dd><p>Passes if compiler output file does not exist.
  160. </p></dd>
  161. </dl>
  162. <a name="Check-for-LTO-tests"></a>
  163. <h4 class="subsubsection">7.2.6.5 Check for LTO tests</h4>
  164. <dl compact="compact">
  165. <dt><code>scan-symbol <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  166. <dd><p>Passes if the pattern is present in the final executable.
  167. </p></dd>
  168. </dl>
  169. <a name="Checks-for-gcov-tests"></a>
  170. <h4 class="subsubsection">7.2.6.6 Checks for <code>gcov</code> tests</h4>
  171. <dl compact="compact">
  172. <dt><code>run-gcov <var>sourcefile</var></code></dt>
  173. <dd><p>Check line counts in <code>gcov</code> tests.
  174. </p>
  175. </dd>
  176. <dt><code>run-gcov [branches] [calls] { <var>opts</var> <var>sourcefile</var> }</code></dt>
  177. <dd><p>Check branch and/or call counts, in addition to line counts, in
  178. <code>gcov</code> tests.
  179. </p></dd>
  180. </dl>
  181. <a name="Clean-up-generated-test-files"></a>
  182. <h4 class="subsubsection">7.2.6.7 Clean up generated test files</h4>
  183. <p>Usually the test-framework removes files that were generated during
  184. testing. If a testcase, for example, uses any dumping mechanism to
  185. inspect a passes dump file, the testsuite recognized the dump option
  186. passed to the tool and schedules a final cleanup to remove these files.
  187. </p>
  188. <p>There are, however, following additional cleanup directives that can be
  189. used to annotate a testcase &quot;manually&quot;.
  190. </p><dl compact="compact">
  191. <dt><code>cleanup-coverage-files</code></dt>
  192. <dd><p>Removes coverage data files generated for this test.
  193. </p>
  194. </dd>
  195. <dt><code>cleanup-modules &quot;<var>list-of-extra-modules</var>&quot;</code></dt>
  196. <dd><p>Removes Fortran module files generated for this test, excluding the
  197. module names listed in keep-modules.
  198. Cleaning up module files is usually done automatically by the testsuite
  199. by looking at the source files and removing the modules after the test
  200. has been executed.
  201. </p><div class="smallexample">
  202. <pre class="smallexample">module MoD1
  203. end module MoD1
  204. module Mod2
  205. end module Mod2
  206. module moD3
  207. end module moD3
  208. module mod4
  209. end module mod4
  210. ! { dg-final { cleanup-modules &quot;mod1 mod2&quot; } } ! redundant
  211. ! { dg-final { keep-modules &quot;mod3 mod4&quot; } }
  212. </pre></div>
  213. </dd>
  214. <dt><code>keep-modules &quot;<var>list-of-modules-not-to-delete</var>&quot;</code></dt>
  215. <dd><p>Whitespace separated list of module names that should not be deleted by
  216. cleanup-modules.
  217. If the list of modules is empty, all modules defined in this file are kept.
  218. </p><div class="smallexample">
  219. <pre class="smallexample">module maybe_unneeded
  220. end module maybe_unneeded
  221. module keep1
  222. end module keep1
  223. module keep2
  224. end module keep2
  225. ! { dg-final { keep-modules &quot;keep1 keep2&quot; } } ! just keep these two
  226. ! { dg-final { keep-modules &quot;&quot; } } ! keep all
  227. </pre></div>
  228. </dd>
  229. <dt><code>dg-keep-saved-temps &quot;<var>list-of-suffixes-not-to-delete</var>&quot;</code></dt>
  230. <dd><p>Whitespace separated list of suffixes that should not be deleted
  231. automatically in a testcase that uses <samp>-save-temps</samp>.
  232. </p><div class="smallexample">
  233. <pre class="smallexample">// { dg-options &quot;-save-temps -fpch-preprocess -I.&quot; }
  234. int main() { return 0; }
  235. // { dg-keep-saved-temps &quot;.s&quot; } ! just keep assembler file
  236. // { dg-keep-saved-temps &quot;.s&quot; &quot;.i&quot; } ! ... and .i
  237. // { dg-keep-saved-temps &quot;.ii&quot; &quot;.o&quot; } ! or just .ii and .o
  238. </pre></div>
  239. </dd>
  240. <dt><code>cleanup-profile-file</code></dt>
  241. <dd><p>Removes profiling files generated for this test.
  242. </p>
  243. </dd>
  244. <dt><code>cleanup-repo-files</code></dt>
  245. <dd><p>Removes files generated for this test for <samp>-frepo</samp>.
  246. </p>
  247. </dd>
  248. </dl>
  249. <hr>
  250. <div class="header">
  251. <p>
  252. Previous: <a href="Require-Support.html#Require-Support" accesskey="p" rel="prev">Require Support</a>, Up: <a href="Test-Directives.html#Test-Directives" accesskey="u" rel="up">Test Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  253. </div>
  254. </body>
  255. </html>