1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 2 "http://www.w3.org/TR/html4/strict.dtd"> 3 <html> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 6 <title>LLVM test-suite Makefile Guide</title> 7 <link rel="stylesheet" href="llvm.css" type="text/css"> 8 </head> 9 <body> 10 11 <h1> 12 LLVM test-suite Makefile Guide 13 </h1> 14 15 <ol> 16 <li><a href="#overview">Overview</a></li> 17 <li><a href="#testsuitestructure">Test suite structure</a></li> 18 <li><a href="#testsuiterun">Running the test suite</a> 19 <ul> 20 <li><a href="#testsuiteexternal">Configuring External Tests</a></li> 21 <li><a href="#testsuitetests">Running different tests</a></li> 22 <li><a href="#testsuiteoutput">Generating test output</a></li> 23 <li><a href="#testsuitecustom">Writing custom tests for test-suite</a></li> 24 </ul> 25 </li> 26 </ol> 27 28 <div class="doc_author"> 29 <p>Written by John T. Criswell, Daniel Dunbar, Reid Spencer, and Tanya Lattner</p> 30 </div> 31 32 <!--=========================================================================--> 33 <h2><a name="overview">Overview</a></h2> 34 <!--=========================================================================--> 35 36 <div> 37 38 <p>This document describes the features of the Makefile-based LLVM 39 test-suite. This way of interacting with the test-suite is deprecated in favor 40 of running the test-suite using LNT, but may continue to prove useful for some 41 users. See the Testing 42 Guide's <a href="TestingGuide.html#testsuitequickstart">test-suite 43 Quickstart</a> section for more information.</p> 44 45 </div> 46 47 <!--=========================================================================--> 48 <h2><a name="testsuitestructure">Test suite Structure</a></h2> 49 <!--=========================================================================--> 50 51 <div> 52 53 <p>The <tt>test-suite</tt> module contains a number of programs that can be compiled 54 with LLVM and executed. These programs are compiled using the native compiler 55 and various LLVM backends. The output from the program compiled with the 56 native compiler is assumed correct; the results from the other programs are 57 compared to the native program output and pass if they match.</p> 58 59 <p>When executing tests, it is usually a good idea to start out with a subset of 60 the available tests or programs. This makes test run times smaller at first and 61 later on this is useful to investigate individual test failures. To run some 62 test only on a subset of programs, simply change directory to the programs you 63 want tested and run <tt>gmake</tt> there. Alternatively, you can run a different 64 test using the <tt>TEST</tt> variable to change what tests or run on the 65 selected programs (see below for more info).</p> 66 67 <p>In addition for testing correctness, the <tt>test-suite</tt> directory also 68 performs timing tests of various LLVM optimizations. It also records 69 compilation times for the compilers and the JIT. This information can be 70 used to compare the effectiveness of LLVM's optimizations and code 71 generation.</p> 72 73 <p><tt>test-suite</tt> tests are divided into three types of tests: MultiSource, 74 SingleSource, and External.</p> 75 76 <ul> 77 <li><tt>test-suite/SingleSource</tt> 78 <p>The SingleSource directory contains test programs that are only a single 79 source file in size. These are usually small benchmark programs or small 80 programs that calculate a particular value. Several such programs are grouped 81 together in each directory.</p></li> 82 83 <li><tt>test-suite/MultiSource</tt> 84 <p>The MultiSource directory contains subdirectories which contain entire 85 programs with multiple source files. Large benchmarks and whole applications 86 go here.</p></li> 87 88 <li><tt>test-suite/External</tt> 89 <p>The External directory contains Makefiles for building code that is external 90 to (i.e., not distributed with) LLVM. The most prominent members of this 91 directory are the SPEC 95 and SPEC 2000 benchmark suites. The <tt>External</tt> 92 directory does not contain these actual tests, but only the Makefiles that know 93 how to properly compile these programs from somewhere else. The presence and 94 location of these external programs is configured by the test-suite 95 <tt>configure</tt> script.</p></li> 96 </ul> 97 98 <p>Each tree is then subdivided into several categories, including applications, 99 benchmarks, regression tests, code that is strange grammatically, etc. These 100 organizations should be relatively self explanatory.</p> 101 102 <p>Some tests are known to fail. Some are bugs that we have not fixed yet; 103 others are features that we haven't added yet (or may never add). In the 104 regression tests, the result for such tests will be XFAIL (eXpected FAILure). 105 In this way, you can tell the difference between an expected and unexpected 106 failure.</p> 107 108 <p>The tests in the test suite have no such feature at this time. If the 109 test passes, only warnings and other miscellaneous output will be generated. If 110 a test fails, a large <program> FAILED message will be displayed. This 111 will help you separate benign warnings from actual test failures.</p> 112 113 </div> 114 115 <!--=========================================================================--> 116 <h2><a name="testsuiterun">Running the test suite</a></h2> 117 <!--=========================================================================--> 118 119 <div> 120 121 <p>First, all tests are executed within the LLVM object directory tree. They 122 <i>are not</i> executed inside of the LLVM source tree. This is because the 123 test suite creates temporary files during execution.</p> 124 125 <p>To run the test suite, you need to use the following steps:</p> 126 127 <ol> 128 <li><tt>cd</tt> into the <tt>llvm/projects</tt> directory in your source tree. 129 </li> 130 131 <li><p>Check out the <tt>test-suite</tt> module with:</p> 132 133 <div class="doc_code"> 134 <pre> 135 % svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite 136 </pre> 137 </div> 138 <p>This will get the test suite into <tt>llvm/projects/test-suite</tt>.</p> 139 </li> 140 <li><p>Configure and build <tt>llvm</tt>.</p></li> 141 <li><p>Configure and build <tt>llvm-gcc</tt>.</p></li> 142 <li><p>Install <tt>llvm-gcc</tt> somewhere.</p></li> 143 <li><p><em>Re-configure</em> <tt>llvm</tt> from the top level of 144 each build tree (LLVM object directory tree) in which you want 145 to run the test suite, just as you do before building LLVM.</p> 146 <p>During the <em>re-configuration</em>, you must either: (1) 147 have <tt>llvm-gcc</tt> you just built in your path, or (2) 148 specify the directory where your just-built <tt>llvm-gcc</tt> is 149 installed using <tt>--with-llvmgccdir=$LLVM_GCC_DIR</tt>.</p> 150 <p>You must also tell the configure machinery that the test suite 151 is available so it can be configured for your build tree:</p> 152 <div class="doc_code"> 153 <pre> 154 % cd $LLVM_OBJ_ROOT ; $LLVM_SRC_ROOT/configure [--with-llvmgccdir=$LLVM_GCC_DIR] 155 </pre> 156 </div> 157 <p>[Remember that <tt>$LLVM_GCC_DIR</tt> is the directory where you 158 <em>installed</em> llvm-gcc, not its src or obj directory.]</p> 159 </li> 160 161 <li><p>You can now run the test suite from your build tree as follows:</p> 162 <div class="doc_code"> 163 <pre> 164 % cd $LLVM_OBJ_ROOT/projects/test-suite 165 % make 166 </pre> 167 </div> 168 </li> 169 </ol> 170 <p>Note that the second and third steps only need to be done once. After you 171 have the suite checked out and configured, you don't need to do it again (unless 172 the test code or configure script changes).</p> 173 174 <!-- _______________________________________________________________________ --> 175 <h3> 176 <a name="testsuiteexternal">Configuring External Tests</a> 177 </h3> 178 <!-- _______________________________________________________________________ --> 179 180 <div> 181 <p>In order to run the External tests in the <tt>test-suite</tt> 182 module, you must specify <i>--with-externals</i>. This 183 must be done during the <em>re-configuration</em> step (see above), 184 and the <tt>llvm</tt> re-configuration must recognize the 185 previously-built <tt>llvm-gcc</tt>. If any of these is missing or 186 neglected, the External tests won't work.</p> 187 <dl> 188 <dt><i>--with-externals</i></dt> 189 <dt><i>--with-externals=<<tt>directory</tt>></i></dt> 190 </dl> 191 This tells LLVM where to find any external tests. They are expected to be 192 in specifically named subdirectories of <<tt>directory</tt>>. 193 If <tt>directory</tt> is left unspecified, 194 <tt>configure</tt> uses the default value 195 <tt>/home/vadve/shared/benchmarks/speccpu2000/benchspec</tt>. 196 Subdirectory names known to LLVM include: 197 <dl> 198 <dt>spec95</dt> 199 <dt>speccpu2000</dt> 200 <dt>speccpu2006</dt> 201 <dt>povray31</dt> 202 </dl> 203 Others are added from time to time, and can be determined from 204 <tt>configure</tt>. 205 </div> 206 207 <!-- _______________________________________________________________________ --> 208 <h3> 209 <a name="testsuitetests">Running different tests</a> 210 </h3> 211 <!-- _______________________________________________________________________ --> 212 <div> 213 <p>In addition to the regular "whole program" tests, the <tt>test-suite</tt> 214 module also provides a mechanism for compiling the programs in different ways. 215 If the variable TEST is defined on the <tt>gmake</tt> command line, the test system will 216 include a Makefile named <tt>TEST.<value of TEST variable>.Makefile</tt>. 217 This Makefile can modify build rules to yield different results.</p> 218 219 <p>For example, the LLVM nightly tester uses <tt>TEST.nightly.Makefile</tt> to 220 create the nightly test reports. To run the nightly tests, run <tt>gmake 221 TEST=nightly</tt>.</p> 222 223 <p>There are several TEST Makefiles available in the tree. Some of them are 224 designed for internal LLVM research and will not work outside of the LLVM 225 research group. They may still be valuable, however, as a guide to writing your 226 own TEST Makefile for any optimization or analysis passes that you develop with 227 LLVM.</p> 228 229 </div> 230 231 <!-- _______________________________________________________________________ --> 232 <h3> 233 <a name="testsuiteoutput">Generating test output</a> 234 </h3> 235 <!-- _______________________________________________________________________ --> 236 <div> 237 <p>There are a number of ways to run the tests and generate output. The most 238 simple one is simply running <tt>gmake</tt> with no arguments. This will 239 compile and run all programs in the tree using a number of different methods 240 and compare results. Any failures are reported in the output, but are likely 241 drowned in the other output. Passes are not reported explicitely.</p> 242 243 <p>Somewhat better is running <tt>gmake TEST=sometest test</tt>, which runs 244 the specified test and usually adds per-program summaries to the output 245 (depending on which sometest you use). For example, the <tt>nightly</tt> test 246 explicitely outputs TEST-PASS or TEST-FAIL for every test after each program. 247 Though these lines are still drowned in the output, it's easy to grep the 248 output logs in the Output directories.</p> 249 250 <p>Even better are the <tt>report</tt> and <tt>report.format</tt> targets 251 (where <tt>format</tt> is one of <tt>html</tt>, <tt>csv</tt>, <tt>text</tt> or 252 <tt>graphs</tt>). The exact contents of the report are dependent on which 253 <tt>TEST</tt> you are running, but the text results are always shown at the 254 end of the run and the results are always stored in the 255 <tt>report.<type>.format</tt> file (when running with 256 <tt>TEST=<type></tt>). 257 258 The <tt>report</tt> also generate a file called 259 <tt>report.<type>.raw.out</tt> containing the output of the entire test 260 run. 261 </div> 262 263 <!-- _______________________________________________________________________ --> 264 <h3> 265 <a name="testsuitecustom">Writing custom tests for the test suite</a> 266 </h3> 267 <!-- _______________________________________________________________________ --> 268 269 <div> 270 271 <p>Assuming you can run the test suite, (e.g. "<tt>gmake TEST=nightly report</tt>" 272 should work), it is really easy to run optimizations or code generator 273 components against every program in the tree, collecting statistics or running 274 custom checks for correctness. At base, this is how the nightly tester works, 275 it's just one example of a general framework.</p> 276 277 <p>Lets say that you have an LLVM optimization pass, and you want to see how 278 many times it triggers. First thing you should do is add an LLVM 279 <a href="ProgrammersManual.html#Statistic">statistic</a> to your pass, which 280 will tally counts of things you care about.</p> 281 282 <p>Following this, you can set up a test and a report that collects these and 283 formats them for easy viewing. This consists of two files, a 284 "<tt>test-suite/TEST.XXX.Makefile</tt>" fragment (where XXX is the name of your 285 test) and a "<tt>test-suite/TEST.XXX.report</tt>" file that indicates how to 286 format the output into a table. There are many example reports of various 287 levels of sophistication included with the test suite, and the framework is very 288 general.</p> 289 290 <p>If you are interested in testing an optimization pass, check out the 291 "libcalls" test as an example. It can be run like this:<p> 292 293 <div class="doc_code"> 294 <pre> 295 % cd llvm/projects/test-suite/MultiSource/Benchmarks # or some other level 296 % make TEST=libcalls report 297 </pre> 298 </div> 299 300 <p>This will do a bunch of stuff, then eventually print a table like this:</p> 301 302 <div class="doc_code"> 303 <pre> 304 Name | total | #exit | 305 ... 306 FreeBench/analyzer/analyzer | 51 | 6 | 307 FreeBench/fourinarow/fourinarow | 1 | 1 | 308 FreeBench/neural/neural | 19 | 9 | 309 FreeBench/pifft/pifft | 5 | 3 | 310 MallocBench/cfrac/cfrac | 1 | * | 311 MallocBench/espresso/espresso | 52 | 12 | 312 MallocBench/gs/gs | 4 | * | 313 Prolangs-C/TimberWolfMC/timberwolfmc | 302 | * | 314 Prolangs-C/agrep/agrep | 33 | 12 | 315 Prolangs-C/allroots/allroots | * | * | 316 Prolangs-C/assembler/assembler | 47 | * | 317 Prolangs-C/bison/mybison | 74 | * | 318 ... 319 </pre> 320 </div> 321 322 <p>This basically is grepping the -stats output and displaying it in a table. 323 You can also use the "TEST=libcalls report.html" target to get the table in HTML 324 form, similarly for report.csv and report.tex.</p> 325 326 <p>The source for this is in test-suite/TEST.libcalls.*. The format is pretty 327 simple: the Makefile indicates how to run the test (in this case, 328 "<tt>opt -simplify-libcalls -stats</tt>"), and the report contains one line for 329 each column of the output. The first value is the header for the column and the 330 second is the regex to grep the output of the command for. There are lots of 331 example reports that can do fancy stuff.</p> 332 333 </div> 334 335 </div> 336 337 <!-- *********************************************************************** --> 338 339 <hr> 340 <address> 341 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img 342 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> 343 <a href="http://validator.w3.org/check/referer"><img 344 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> 345 346 John T. Criswell, Daniel Dunbar, Reid Spencer, and Tanya Lattner<br> 347 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br> 348 Last modified: $Date$ 349 </address> 350 </body> 351 </html> 352