You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
8.8KB

  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>compat Testing (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="compat Testing (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="compat Testing (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="Torture-Tests.html#Torture-Tests" rel="next" title="Torture Tests">
  31. <link href="profopt-Testing.html#profopt-Testing" rel="prev" title="profopt Testing">
  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="compat-Testing"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Torture-Tests.html#Torture-Tests" accesskey="n" rel="next">Torture Tests</a>, Previous: <a href="profopt-Testing.html#profopt-Testing" accesskey="p" rel="prev">profopt Testing</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="Support-for-testing-binary-compatibility"></a>
  68. <h3 class="section">7.8 Support for testing binary compatibility</h3>
  69. <p>The file <samp>compat.exp</samp> provides language-independent support for
  70. binary compatibility testing. It supports testing interoperability of
  71. two compilers that follow the same ABI, or of multiple sets of
  72. compiler options that should not affect binary compatibility. It is
  73. intended to be used for testsuites that complement ABI testsuites.
  74. </p>
  75. <p>A test supported by this framework has three parts, each in a
  76. separate source file: a main program and two pieces that interact
  77. with each other to split up the functionality being tested.
  78. </p>
  79. <dl compact="compact">
  80. <dt><samp><var>testname</var>_main.<var>suffix</var></samp></dt>
  81. <dd><p>Contains the main program, which calls a function in file
  82. <samp><var>testname</var>_x.<var>suffix</var></samp>.
  83. </p>
  84. </dd>
  85. <dt><samp><var>testname</var>_x.<var>suffix</var></samp></dt>
  86. <dd><p>Contains at least one call to a function in
  87. <samp><var>testname</var>_y.<var>suffix</var></samp>.
  88. </p>
  89. </dd>
  90. <dt><samp><var>testname</var>_y.<var>suffix</var></samp></dt>
  91. <dd><p>Shares data with, or gets arguments from,
  92. <samp><var>testname</var>_x.<var>suffix</var></samp>.
  93. </p></dd>
  94. </dl>
  95. <p>Within each test, the main program and one functional piece are
  96. compiled by the GCC under test. The other piece can be compiled by
  97. an alternate compiler. If no alternate compiler is specified,
  98. then all three source files are all compiled by the GCC under test.
  99. You can specify pairs of sets of compiler options. The first element
  100. of such a pair specifies options used with the GCC under test, and the
  101. second element of the pair specifies options used with the alternate
  102. compiler. Each test is compiled with each pair of options.
  103. </p>
  104. <p><samp>compat.exp</samp> defines default pairs of compiler options.
  105. These can be overridden by defining the environment variable
  106. <code>COMPAT_OPTIONS</code> as:
  107. </p>
  108. <div class="smallexample">
  109. <pre class="smallexample">COMPAT_OPTIONS=&quot;[list [list {<var>tst1</var>} {<var>alt1</var>}]
  110. &hellip;[list {<var>tstn</var>} {<var>altn</var>}]]&quot;
  111. </pre></div>
  112. <p>where <var>tsti</var> and <var>alti</var> are lists of options, with <var>tsti</var>
  113. used by the compiler under test and <var>alti</var> used by the alternate
  114. compiler. For example, with
  115. <code>[list [list {-g -O0} {-O3}] [list {-fpic} {-fPIC -O2}]]</code>,
  116. the test is first built with <samp>-g -O0</samp> by the compiler under
  117. test and with <samp>-O3</samp> by the alternate compiler. The test is
  118. built a second time using <samp>-fpic</samp> by the compiler under test
  119. and <samp>-fPIC -O2</samp> by the alternate compiler.
  120. </p>
  121. <p>An alternate compiler is specified by defining an environment
  122. variable to be the full pathname of an installed compiler; for C
  123. define <code>ALT_CC_UNDER_TEST</code>, and for C++ define
  124. <code>ALT_CXX_UNDER_TEST</code>. These will be written to the
  125. <samp>site.exp</samp> file used by DejaGnu. The default is to build each
  126. test with the compiler under test using the first of each pair of
  127. compiler options from <code>COMPAT_OPTIONS</code>. When
  128. <code>ALT_CC_UNDER_TEST</code> or
  129. <code>ALT_CXX_UNDER_TEST</code> is <code>same</code>, each test is built using
  130. the compiler under test but with combinations of the options from
  131. <code>COMPAT_OPTIONS</code>.
  132. </p>
  133. <p>To run only the C++ compatibility suite using the compiler under test
  134. and another version of GCC using specific compiler options, do the
  135. following from <samp><var>objdir</var>/gcc</samp>:
  136. </p>
  137. <div class="smallexample">
  138. <pre class="smallexample">rm site.exp
  139. make -k \
  140. ALT_CXX_UNDER_TEST=${alt_prefix}/bin/g++ \
  141. COMPAT_OPTIONS=&quot;<var>lists as shown above</var>&quot; \
  142. check-c++ \
  143. RUNTESTFLAGS=&quot;compat.exp&quot;
  144. </pre></div>
  145. <p>A test that fails when the source files are compiled with different
  146. compilers, but passes when the files are compiled with the same
  147. compiler, demonstrates incompatibility of the generated code or
  148. runtime support. A test that fails for the alternate compiler but
  149. passes for the compiler under test probably tests for a bug that was
  150. fixed in the compiler under test but is present in the alternate
  151. compiler.
  152. </p>
  153. <p>The binary compatibility tests support a small number of test framework
  154. commands that appear within comments in a test file.
  155. </p>
  156. <dl compact="compact">
  157. <dt><code>dg-require-*</code></dt>
  158. <dd><p>These commands can be used in <samp><var>testname</var>_main.<var>suffix</var></samp>
  159. to skip the test if specific support is not available on the target.
  160. </p>
  161. </dd>
  162. <dt><code>dg-options</code></dt>
  163. <dd><p>The specified options are used for compiling this particular source
  164. file, appended to the options from <code>COMPAT_OPTIONS</code>. When this
  165. command appears in <samp><var>testname</var>_main.<var>suffix</var></samp> the options
  166. are also used to link the test program.
  167. </p>
  168. </dd>
  169. <dt><code>dg-xfail-if</code></dt>
  170. <dd><p>This command can be used in a secondary source file to specify that
  171. compilation is expected to fail for particular options on particular
  172. targets.
  173. </p></dd>
  174. </dl>
  175. <hr>
  176. <div class="header">
  177. <p>
  178. Next: <a href="Torture-Tests.html#Torture-Tests" accesskey="n" rel="next">Torture Tests</a>, Previous: <a href="profopt-Testing.html#profopt-Testing" accesskey="p" rel="prev">profopt Testing</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>
  179. </div>
  180. </body>
  181. </html>