Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

164 Zeilen
7.4KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Test Idioms (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Test Idioms (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Test Idioms (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  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="Testsuites.html#Testsuites" rel="up" title="Testsuites">
  30. <link href="Test-Directives.html#Test-Directives" rel="next" title="Test Directives">
  31. <link href="Testsuites.html#Testsuites" rel="prev" title="Testsuites">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Test-Idioms"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Test-Directives.html#Test-Directives" accesskey="n" rel="next">Test Directives</a>, Up: <a href="Testsuites.html#Testsuites" accesskey="u" rel="up">Testsuites</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>
  65. </div>
  66. <hr>
  67. <a name="Idioms-Used-in-Testsuite-Code"></a>
  68. <h3 class="section">7.1 Idioms Used in Testsuite Code</h3>
  69. <p>In general, C testcases have a trailing <samp>-<var>n</var>.c</samp>, starting
  70. with <samp>-1.c</samp>, in case other testcases with similar names are added
  71. later. If the test is a test of some well-defined feature, it should
  72. have a name referring to that feature such as
  73. <samp><var>feature</var>-1.c</samp>. If it does not test a well-defined feature
  74. but just happens to exercise a bug somewhere in the compiler, and a
  75. bug report has been filed for this bug in the GCC bug database,
  76. <samp>pr<var>bug-number</var>-1.c</samp> is the appropriate form of name.
  77. Otherwise (for miscellaneous bugs not filed in the GCC bug database),
  78. and previously more generally, test cases are named after the date on
  79. which they were added. This allows people to tell at a glance whether
  80. a test failure is because of a recently found bug that has not yet
  81. been fixed, or whether it may be a regression, but does not give any
  82. other information about the bug or where discussion of it may be
  83. found. Some other language testsuites follow similar conventions.
  84. </p>
  85. <p>In the <samp>gcc.dg</samp> testsuite, it is often necessary to test that an
  86. error is indeed a hard error and not just a warning&mdash;for example,
  87. where it is a constraint violation in the C standard, which must
  88. become an error with <samp>-pedantic-errors</samp>. The following idiom,
  89. where the first line shown is line <var>line</var> of the file and the line
  90. that generates the error, is used for this:
  91. </p>
  92. <div class="smallexample">
  93. <pre class="smallexample">/* { dg-bogus &quot;warning&quot; &quot;warning in place of error&quot; } */
  94. /* { dg-error &quot;<var>regexp</var>&quot; &quot;<var>message</var>&quot; { target *-*-* } <var>line</var> } */
  95. </pre></div>
  96. <p>It may be necessary to check that an expression is an integer constant
  97. expression and has a certain value. To check that <code><var>E</var></code> has
  98. value <code><var>V</var></code>, an idiom similar to the following is used:
  99. </p>
  100. <div class="smallexample">
  101. <pre class="smallexample">char x[((E) == (V) ? 1 : -1)];
  102. </pre></div>
  103. <p>In <samp>gcc.dg</samp> tests, <code>__typeof__</code> is sometimes used to make
  104. assertions about the types of expressions. See, for example,
  105. <samp>gcc.dg/c99-condexpr-1.c</samp>. The more subtle uses depend on the
  106. exact rules for the types of conditional expressions in the C
  107. standard; see, for example, <samp>gcc.dg/c99-intconst-1.c</samp>.
  108. </p>
  109. <p>It is useful to be able to test that optimizations are being made
  110. properly. This cannot be done in all cases, but it can be done where
  111. the optimization will lead to code being optimized away (for example,
  112. where flow analysis or alias analysis should show that certain code
  113. cannot be called) or to functions not being called because they have
  114. been expanded as built-in functions. Such tests go in
  115. <samp>gcc.c-torture/execute</samp>. Where code should be optimized away, a
  116. call to a nonexistent function such as <code>link_failure ()</code> may be
  117. inserted; a definition
  118. </p>
  119. <div class="smallexample">
  120. <pre class="smallexample">#ifndef __OPTIMIZE__
  121. void
  122. link_failure (void)
  123. {
  124. abort ();
  125. }
  126. #endif
  127. </pre></div>
  128. <p>will also be needed so that linking still succeeds when the test is
  129. run without optimization. When all calls to a built-in function
  130. should have been optimized and no calls to the non-built-in version of
  131. the function should remain, that function may be defined as
  132. <code>static</code> to call <code>abort ()</code> (although redeclaring a function
  133. as static may not work on all targets).
  134. </p>
  135. <p>All testcases must be portable. Target-specific testcases must have
  136. appropriate code to avoid causing failures on unsupported systems;
  137. unfortunately, the mechanisms for this differ by directory.
  138. </p>
  139. <p>FIXME: discuss non-C testsuites here.
  140. </p>
  141. <hr>
  142. <div class="header">
  143. <p>
  144. Next: <a href="Test-Directives.html#Test-Directives" accesskey="n" rel="next">Test Directives</a>, Up: <a href="Testsuites.html#Testsuites" accesskey="u" rel="up">Testsuites</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>
  145. </div>
  146. </body>
  147. </html>