regression.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4. <title>Boost Internal Regression Test Suite</title>
  5. </head>
  6. <body bgcolor="#FFFFFF" text="#000000">
  7. <table border="1" bgcolor="#007F7F" cellpadding="2">
  8. <tr>
  9. <td bgcolor="#FFFFFF"><img src="../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
  10. <td><a href="../index.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>Home</big></font></a></td>
  11. <td><a href="../libs/libraries.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>Libraries</big></font></a></td>
  12. <td><a href="../people/people.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>People</big></font></a></td>
  13. <td><a href="../more/faq.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>FAQ</big></font></a></td>
  14. <td><a href="../more/index.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>More</big></font></a></td>
  15. </tr>
  16. </table>
  17. <h1>Boost Internal Regression Test Suite</h1>
  18. Boost's internal regression test suite produces the
  19. <a href="../status/compiler_status.html">compiler status tables</a>.
  20. <p>Although not ordinarily run by Boost library users, it is documented here for
  21. the benefit of Boost developers, and for Boost users porting to a new platform.</p>
  22. <p>Boost is transitioning to a new version of the regression tests.&nbsp; During
  23. the transition, both versions are available.</p>
  24. <blockquote>
  25. <p><a href="#Version Three">Documentation for version 3</a><br>
  26. <a href="#Version Two">Documentation for version 2</a></p>
  27. </blockquote>
  28. <h2>Requirements</h2>
  29. The test suite has been designed to meet to the following requirements.
  30. <ul>
  31. <li>Pure ISO C++, no tools required except a C++ compiler.
  32. <li>Support for tests which expect an error
  33. <li>Flexible configuration, independent of the target platform or compiler.
  34. <li>HTML output
  35. </ul>
  36. These requirements rule out any script-based approach such as dejagnu
  37. (requires Tcl and expect) or even shell scripts.
  38. <h1>Regression Tests - <a name="Version Two">Version Two</a></h1>
  39. The implementation is provided in a single source file named
  40. <a href="../status/regression.cpp">regression.cpp</a>.
  41. <p>
  42. You should be able to compile and link this file using whatever C++
  43. compiler is at your disposition. However, you may need to configure
  44. both the compiler and the standard library to use "strict" ISO
  45. compliance mode. Also, you need to extend the search path for include
  46. files with the main boost directory so that the header file
  47. <a href="../boost/config.hpp">boost/config.hpp</a>
  48. can be found. This header file is required to work around compiler
  49. deficiencies.
  50. <p>
  51. You can then start the resulting executable to run regression tests.
  52. By default, the regression test program reads the file "compiler.cfg"
  53. in the current directory to determine the list of compilers and their
  54. invocation syntax. After that, it reads the file "regression.cfg" in
  55. the current directory to determine the regression tests to run. The
  56. results of the regression tests are written in an HTML formatted text
  57. file. This file is by default named "cs-OS.html" in the current
  58. directory, where "OS" is a placeholder for the name of the operating
  59. system (e.g., "linux" or "win32").
  60. <p>
  61. To generate the
  62. <a href="../status/compiler_status.html">compiler status tables</a>,
  63. boost uses the files
  64. <a href="../status/compiler.cfg">status/compiler.cfg</a>
  65. and
  66. <a href="../status/regression.cfg">status/regression.cfg</a>.
  67. <p>
  68. The regression test program accepts some command-line options to alter
  69. its behavior.
  70. <p>
  71. <table border="1">
  72. <tr>
  73. <td>-h <em>or</em> --help</td>
  74. <td>prints a help message
  75. </tr>
  76. <tr>
  77. <td>--config <em>file</em></td>
  78. <td>Use <em>file</em> instead of "compiler.cfg" as the compiler
  79. configuration file. This allows for private compiler setups.</td>
  80. </tr>
  81. <tr>
  82. <td>--tests <em>file</em></td>
  83. <td>Use <em>file</em> instead of "regression.cfg" as the tests
  84. configuration file. This allows individual libraries to specify
  85. additional tests not to be published in the main
  86. <a href="../status/compiler_status.html">compiler status tables</a>.
  87. </td>
  88. </tr>
  89. <tr>
  90. <td>--boost <em>path</em></td>
  91. <td>Use <em>path</em> as the filesystem path to the main boost
  92. directory. The default is "..", i.e. the parent directory.</td>
  93. </tr>
  94. <tr>
  95. <td>--output <em>file</em><br>-o <em>file</em></td>
  96. <td>Write the HTML output to <em>file</em> instead of the default
  97. "cs-OS.html".</td>
  98. </tr>
  99. <tr>
  100. <td>--compiler <em>name</em></td>
  101. <td>Run the tests only with compiler <em>name</em>. The <em>name</em>
  102. must be defined in the second line of an applicable compiler
  103. configuration (see below). The default is to run the tests with all
  104. compilers suitable for the platform.</td>
  105. </tr>
  106. <tr>
  107. <td>--diff</td>
  108. <td>Read the HTML output file before writing it. In the HTML output,
  109. highlight differences in test outcomes compared to the previous
  110. run.</td>
  111. </tr>
  112. <tr>
  113. <td><em>test</em></td>
  114. <td>Run only the named test. The syntax is the same as in the
  115. configuration file (see below).</td>
  116. </tr>
  117. </table>
  118. <p>
  119. When running only a selected test, you must also provide an alternate
  120. HTML output filename with "--output" so that the full test output is
  121. not accidentally overwritten.
  122. <p>
  123. You should redirect the output (<code>std::cout</code>) and error
  124. (<code>std::cerr</code>) channels to a suitable log file for later
  125. inspection.
  126. <h2>Configuration Files</h2>
  127. In both configuration files, single-line comments starting with "//"
  128. at the leftmost column are ignored.
  129. <h3>Compiler Configuration</h3>
  130. The compiler configuration file can contain descriptions for an
  131. arbitrary number of compilers. Each compiler is configured by a block
  132. of six consecutive text lines.
  133. <ol>
  134. <li>Name of the operating system for which the entry is applicable
  135. (e.g., "linux" or "win32").
  136. <li>Name of the compiler; should be unique within one operating
  137. system. The name of the compiler should not contain the version
  138. number, because it is expected that regression tests are always run
  139. with the most recent compiler version available.
  140. <li>Name and version number of the compiler. This is printed on
  141. <code>std::cout</code> prior to running a test with that compiler.
  142. <li>Command-line invocation of the compiler to compile a single source
  143. file to an object file.
  144. <li>Command-line invocation of the compiler to compile a single source
  145. file to an executable.
  146. <li>Identification of the compiler for inclusion in the HTML output;
  147. may contain HTML tags such as &lt;br>.
  148. </ol>
  149. The two command-lines are subject to the following substitutions:
  150. <ul>
  151. <li>Any string starting with a dollar symbol "$", then containing an
  152. arbitrary number of underscores, digits, or uppercase letters, is
  153. replaced by the value of the associated environment variable.
  154. <li>%include is replaced by the path given by the "--boost" command
  155. line option (".." by default). This should be used to extend the
  156. search path of your compiler so that the boost header files are found.
  157. <li>%source is the name of the source file to be compiled, qualified
  158. with the path given by the "--boost" command-line option (".." by
  159. default).
  160. </ul>
  161. <h3>Test Configuration</h3>
  162. The test configuration file can contain descriptions for an arbitrary
  163. number of tests. Each test is described by a single line. The first
  164. word (up to the first space) is the type of the test, the next word
  165. gives the filename of the test relative the directory to be given by the
  166. "--boost" command-line option. Optionally, additional words are
  167. passed on as command-line arguments when the test is executed (only
  168. for types "run" and "run-fail"). In these arguments, "%boost" is
  169. replaced by the path given by the "--boost" command-line option (".."
  170. by default).
  171. <p>
  172. The following test types are available:
  173. <ul>
  174. <li>compile: The given test file should compile successfully.
  175. Otherwise, the test fails.
  176. <li>compile-fail: The given test file should not compile successfully,
  177. but instead the compiler should give an error message. If the test
  178. does compile successfully, the test fails.
  179. <li>link: The given test file should compile and link successfully.
  180. Otherwise, the test fails. In particular, a <code>main</code>
  181. function must be present in the test file.
  182. <li>link-fail: The given test file should not compile and link
  183. successfully. It is not specified whether the compile or the link
  184. should not succeed. If the test does compile and link successfully,
  185. the test fails.
  186. <li>run: The given test file should compile and link successfully.
  187. After that, the resulting executable is invoked and should return a
  188. zero exit code. If any of these steps fail, the test fails.
  189. <li>run-fail: The given test file is compiled, linked, and, if an
  190. executable was successfully generated, it is invoked. Either
  191. compiling or linking should fail or the resulting executable should
  192. return a non-zero exit code. If compiling and linking succeeds and
  193. the resulting executable returns a zero exit code, the test fails.
  194. </ul>
  195. <h2>Adapting for a New Platform</h2>
  196. In order to adapt the regression test suite for a new platform, a few
  197. changes to the <a href="../status/regression.cpp">regression.cpp</a>
  198. are required.
  199. <ul>
  200. <li>Add an appropriate check for your platform in
  201. <code>get_host()</code> and return a unique string identifying the
  202. platform (this string is used to filter the compile configuration
  203. file).
  204. <li>Verify that <code>get_system_configuration()</code> is
  205. appropriately defined for your platform. For a Unix platform, it most
  206. likely is. The function may return a verbose HTML string describing
  207. the platform.
  208. </ul>
  209. You also need to configure the compilers available on your platform in
  210. "compiler.cfg" as described above.
  211. <p>You may need to add an entry for the compiler to <a href="../boost/config.hpp">boost/config.hpp</a>,
  212. but only if entries for the compiler is not already present, and the compiler
  213. doesn't fully conform to the ISO C++ Standard.</p>
  214. <h1>Regression Tests - <a name="Version Three">Version Three</a></h1>
  215. <p>Version 3 of the Boost regression testing framework is based on
  216. <a href="../tools/build/index.html">Boost.Build</a>, and uses <i>bjam</i> to
  217. actually run the tests. Because Boost.Build does dependency analysis, only tests
  218. for which some dependency has change are rerun.</p>
  219. <p>The reporting of test results as HTML files is accomplished by separate C++
  220. programs which process the residue and log files from the <i>bjam</i> run.</p>
  221. <h2>Preparation</h2>
  222. <p>Install the following programs on your system, in some location suitable for
  223. program executables. Normally that location will be a directory which is part of
  224. your search path for executables.</p>
  225. <ul>
  226. <li><i>bjam</i> - Executables and sources are available; see
  227. <a href="../tools/build/index.html#Jam">Boost.Build docs</a>.&nbsp; Before
  228. worrying about regression tests, you might want to verify your <i>bjam</i>
  229. installation works by <a href="../tools/build/index.html#Building">building
  230. the boost-root/status/Jamfile libraries</a>.<br>
  231. &nbsp;</li>
  232. <li><i>process_jam_log</i> and <i>compiler_status</i> - Sources available in
  233. the <a href="mailing_lists.htm#sandbox">Boost Sandbox</a>. These two post-bjam
  234. processing programs are currently only available in the sandbox <i>libs/filesystem/example</i>
  235. directory, since they depend on the Filesystem Library, which is not scheduled
  236. for Boost formal review until late September, 2002.&nbsp; Once the Filesystem
  237. Library has been accepted, they will become part of the regular Boost
  238. distribution. There is a Jamfile in the <i>libs/filesystem/example</i>
  239. directory to automate building these programs.</li>
  240. </ul>
  241. <h2>Execution</h2>
  242. <p>These examples assume several environment variables have been set:</p>
  243. <ul>
  244. <li>BOOST_ROOT is set to the directory where the unzipped Boost distribution
  245. or CVS working copy resides.&nbsp; For example:<br>
  246. <br>
  247. set BOOST_ROOT=/boost_1_29_0<br>
  248. &nbsp;</li>
  249. <li>TOOLS is set to the <a href="../tools/build/index.html#Tools">compiler
  250. toolsets</a> you wish to use. For example:<br>
  251. <br>
  252. set TOOLS=borland gcc intel-win32 metrowerks vc7<br>
  253. &nbsp;</li>
  254. <li>Any environment variables required for particular compilers.&nbsp; You
  255. might wish to test first with one compiler at a time to make sure each toolset
  256. is fully operational.</li>
  257. </ul>
  258. <p>A full set of tests and status tables can then be run thusly on a Window 2000
  259. system:</p>
  260. <blockquote>
  261. <pre>cd %BOOST_ROOT%\status
  262. md bin 2&gt;nul
  263. bjam test &gt;bin\regr.log 2&gt;&amp;1
  264. start notepad bin\regr.log
  265. process_jam_log &lt;bin\regr.log
  266. compiler_status %BOOST_ROOT% cs-win32.html
  267. rem Specify links file, even though it will be overwritten, so report html includes links
  268. rem This works because the generated bookmark names are the same regardless of other settings
  269. compiler_status --ignore-pass --no-warn %BOOST_ROOT% cs-win32-fail.html cs-win32-links.html
  270. compiler_status --ignore-pass %BOOST_ROOT% cs-win32-warn-or-fail.html cs-win32-links.html
  271. compiler_status %BOOST_ROOT% cs-win32-full.html cs-win32-links.html</pre>
  272. </blockquote>
  273. <p>Modulo syntax adjustments, the same procedure should work on other operating
  274. systems.&nbsp; Rename the cs-win-xxx output files as appropriate.</p>
  275. <p>If you execute <i>compiler_status</i> without arguments, you can see the
  276. available options and tailor your own favorite report.</p>
  277. <p>If you want to run just a single test, specify it as the <i>bjam</i> target
  278. rather than &quot;test&quot;.&nbsp; For example, to debug configurations, it might be
  279. useful to just run the <i>config_info</i> test, with a switch to force even
  280. up-to-date programs be rebuilt:</p>
  281. <blockquote>
  282. <pre>bjam -a config_info</pre>
  283. </blockquote>
  284. <h2>Adding a new test</h2>
  285. <h3>Overall Boost regression tests</h3>
  286. <p>Adding tests is as simple as adding a single line to the
  287. <a href="../status/Jamfile">boost-root/status/Jamfile</a>:</p>
  288. <blockquote>
  289. <pre>run libs/mylib/test/mytest.cpp ;</pre>
  290. </blockquote>
  291. <p>Don't forget that Jam is white-space sensitive; delete the space before the
  292. semi-colon in the example above, and you will get an introduction to Jam error
  293. messages.</p>
  294. <p>For creating more complex tests and test-suites, look at examples in the
  295. <a href="../status/Jamfile">Jamfile</a>.&nbsp; The <i>bind</i> and <i>config</i>
  296. test-suites are simple examples, while the <i>regex</i> and <i>threads</i> test
  297. suites show more of the power of Jam based testing.</p>
  298. <h3>Private tests for a specific library</h3>
  299. <p>A library can have its own private set of tests by creating a Jamfile in one
  300. of the library's own sub-directories.&nbsp; For an example of this, see
  301. <a href="../libs/test/test/Jamfile">boost-root/libs/test/test/Jamfile</a>.</p>
  302. <h2>History</h2>
  303. <p>The version 3 testing.jam and status/Jamfile foundation was contributed by
  304. Dave Abrahams. The post-bjam processing programs were contributed by Beman
  305. Dawes.</p>
  306. <p>The version 2 regression.cpp test program was contributed
  307. by Jens Maurer, generalizing and improving an earlier version 1 program by Beman Dawes.</p>
  308. <hr>
  309. 2001-01-30<br>
  310. <a href="../people/jens_maurer.htm">Jens Maurer</a>
  311. </body>
  312. </html>
粤ICP备19079148号