Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

152 lines
7.1KB

  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>gcov Testing (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="gcov Testing (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="gcov 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="profopt-Testing.html#profopt-Testing" rel="next" title="profopt Testing">
  31. <link href="LTO-Testing.html#LTO-Testing" rel="prev" title="LTO 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="gcov-Testing"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="profopt-Testing.html#profopt-Testing" accesskey="n" rel="next">profopt Testing</a>, Previous: <a href="LTO-Testing.html#LTO-Testing" accesskey="p" rel="prev">LTO 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-gcov"></a>
  68. <h3 class="section">7.6 Support for testing <code>gcov</code></h3>
  69. <p>Language-independent support for testing <code>gcov</code>, and for checking
  70. that branch profiling produces expected values, is provided by the
  71. expect file <samp>lib/gcov.exp</samp>. <code>gcov</code> tests also rely on procedures
  72. in <samp>lib/gcc-dg.exp</samp> to compile and run the test program. A typical
  73. <code>gcov</code> test contains the following DejaGnu commands within comments:
  74. </p>
  75. <div class="smallexample">
  76. <pre class="smallexample">{ dg-options &quot;--coverage&quot; }
  77. { dg-do run { target native } }
  78. { dg-final { run-gcov sourcefile } }
  79. </pre></div>
  80. <p>Checks of <code>gcov</code> output can include line counts, branch percentages,
  81. and call return percentages. All of these checks are requested via
  82. commands that appear in comments in the test&rsquo;s source file.
  83. Commands to check line counts are processed by default.
  84. Commands to check branch percentages and call return percentages are
  85. processed if the <code>run-gcov</code> command has arguments <code>branches</code>
  86. or <code>calls</code>, respectively. For example, the following specifies
  87. checking both, as well as passing <samp>-b</samp> to <code>gcov</code>:
  88. </p>
  89. <div class="smallexample">
  90. <pre class="smallexample">{ dg-final { run-gcov branches calls { -b sourcefile } } }
  91. </pre></div>
  92. <p>A line count command appears within a comment on the source line
  93. that is expected to get the specified count and has the form
  94. <code>count(<var>cnt</var>)</code>. A test should only check line counts for
  95. lines that will get the same count for any architecture.
  96. </p>
  97. <p>Commands to check branch percentages (<code>branch</code>) and call
  98. return percentages (<code>returns</code>) are very similar to each other.
  99. A beginning command appears on or before the first of a range of
  100. lines that will report the percentage, and the ending command
  101. follows that range of lines. The beginning command can include a
  102. list of percentages, all of which are expected to be found within
  103. the range. A range is terminated by the next command of the same
  104. kind. A command <code>branch(end)</code> or <code>returns(end)</code> marks
  105. the end of a range without starting a new one. For example:
  106. </p>
  107. <div class="smallexample">
  108. <pre class="smallexample">if (i &gt; 10 &amp;&amp; j &gt; i &amp;&amp; j &lt; 20) /* <span class="roman">branch(27 50 75)</span> */
  109. /* <span class="roman">branch(end)</span> */
  110. foo (i, j);
  111. </pre></div>
  112. <p>For a call return percentage, the value specified is the
  113. percentage of calls reported to return. For a branch percentage,
  114. the value is either the expected percentage or 100 minus that
  115. value, since the direction of a branch can differ depending on the
  116. target or the optimization level.
  117. </p>
  118. <p>Not all branches and calls need to be checked. A test should not
  119. check for branches that might be optimized away or replaced with
  120. predicated instructions. Don&rsquo;t check for calls inserted by the
  121. compiler or ones that might be inlined or optimized away.
  122. </p>
  123. <p>A single test can check for combinations of line counts, branch
  124. percentages, and call return percentages. The command to check a
  125. line count must appear on the line that will report that count, but
  126. commands to check branch percentages and call return percentages can
  127. bracket the lines that report them.
  128. </p>
  129. <hr>
  130. <div class="header">
  131. <p>
  132. Next: <a href="profopt-Testing.html#profopt-Testing" accesskey="n" rel="next">profopt Testing</a>, Previous: <a href="LTO-Testing.html#LTO-Testing" accesskey="p" rel="prev">LTO 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>
  133. </div>
  134. </body>
  135. </html>