blob: ab96ea6b28fc62549f06125e2e9bccd567457d37 [file] [log] [blame]
Misha Brukman1d83e112004-03-01 18:21:04 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
John Criswell020cbd82003-10-10 18:42:49 +00003<html>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +00004<head>
Misha Brukman1d83e112004-03-01 18:21:04 +00005 <title>LLVM Test Suite Guide</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
Brian Gaekeaf19f2e2003-10-23 18:10:28 +00007</head>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +00008<body>
9
10<div class="doc_title">
11 LLVM Test Suite Guide
12</div>
John Criswell020cbd82003-10-10 18:42:49 +000013
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000014<ol>
15<li><a href="#overview">Overview</a></li>
16<li><a href="#Requirements">Requirements</a></li>
17<li><a href="#quick">Quick Start</a></li>
Misha Brukman1d83e112004-03-01 18:21:04 +000018<li><a href="#org">LLVM Test Suite Organization</a>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000019<ul>
20 <li><a href="#codefragments">Code Fragments</a></li>
21 <li><a href="#wholeprograms">Whole Programs</a></li>
Misha Brukman1d83e112004-03-01 18:21:04 +000022</ul></li>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000023<li><a href="#tree">LLVM Test Suite Tree</a></li>
24<li><a href="#qmstructure">QMTest Structure</a></li>
25<li><a href="#progstructure">Programs Structure</a></li>
26<li><a href="#run">Running the LLVM Tests</a></li>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000027</ol>
John Criswell020cbd82003-10-10 18:42:49 +000028
Chris Lattner7911ce22004-05-23 21:07:27 +000029<div class="doc_author">
30 <p>Written by John T. Criswell</p>
31</div>
John Criswell020cbd82003-10-10 18:42:49 +000032
Misha Brukman1d83e112004-03-01 18:21:04 +000033<!--===============================================================-->
34<div class="doc_section"><a name="overview">Overview</a></div>
35<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000036
Misha Brukman1d83e112004-03-01 18:21:04 +000037<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +000038
Misha Brukman1d83e112004-03-01 18:21:04 +000039<p>This document is the reference manual for the LLVM test suite. It documents
40the structure of the LLVM test suite, the tools needed to use it, and how to add
41and run tests.</p>
John Criswell020cbd82003-10-10 18:42:49 +000042
Misha Brukman1d83e112004-03-01 18:21:04 +000043</div>
John Criswell020cbd82003-10-10 18:42:49 +000044
Misha Brukman1d83e112004-03-01 18:21:04 +000045<!--===============================================================-->
46<div class="doc_section"><a name="Requirements">Requirements</a></div>
47<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000048
Misha Brukman1d83e112004-03-01 18:21:04 +000049<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +000050
Misha Brukman1d83e112004-03-01 18:21:04 +000051<p>In order to use the LLVM test suite, you will need all of the software
52required to build LLVM, plus the following:</p>
John Criswell020cbd82003-10-10 18:42:49 +000053
Misha Brukman1d83e112004-03-01 18:21:04 +000054<dl>
55 <dt><a href="http://www.qmtest.com">QMTest</A></dt>
56 <dd>The LLVM test suite uses QMTest to organize and run tests.</dd>
John Criswell020cbd82003-10-10 18:42:49 +000057
Misha Brukman1d83e112004-03-01 18:21:04 +000058 <dt><a href="http://www.python.org">Python</A></dt>
59 <dd>You will need a Python interpreter that works with QMTest. Python will
60 need zlib and SAX support enabled.</dd>
61</dl>
John Criswell020cbd82003-10-10 18:42:49 +000062
Misha Brukman1d83e112004-03-01 18:21:04 +000063</div>
John Criswell020cbd82003-10-10 18:42:49 +000064
Misha Brukman1d83e112004-03-01 18:21:04 +000065<!--===============================================================-->
66<div class="doc_section"><a name="quick">Quick Start</a></div>
67<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000068
Misha Brukman1d83e112004-03-01 18:21:04 +000069<div class="doc_text">
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000070
Misha Brukman1d83e112004-03-01 18:21:04 +000071<p> The tests are located in the LLVM source tree under the directory
72<tt>llvm/test</tt>. To run all of the tests in LLVM, use the Master Makefile in
73that directory:</p>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000074
Misha Brukman1d83e112004-03-01 18:21:04 +000075<pre>
76 % gmake -C llvm/test
77</pre>
John Criswell020cbd82003-10-10 18:42:49 +000078
Misha Brukman1d83e112004-03-01 18:21:04 +000079<p>To run only the code fragment tests (i.e. those that do basic testing of
80LLVM), run the tests organized by QMTest:</p>
John Criswell020cbd82003-10-10 18:42:49 +000081
Misha Brukman1d83e112004-03-01 18:21:04 +000082<pre>
83 % gmake -C llvm/test qmtest
84</pre>
John Criswell020cbd82003-10-10 18:42:49 +000085
Misha Brukman1d83e112004-03-01 18:21:04 +000086<p>To run only the tests that compile and execute whole programs, run the
87Programs tests:</p>
John Criswell020cbd82003-10-10 18:42:49 +000088
Misha Brukman1d83e112004-03-01 18:21:04 +000089<pre>
90 % gmake -C llvm/test/Programs
91</pre>
92
93</div>
94
95<!--===============================================================-->
96<div class="doc_section"><a name="org">LLVM Test Suite Organization</a></div>
97<!--===============================================================-->
98
99<div class="doc_text">
100
101<p>The LLVM test suite contains two major categories of tests: code
102fragments and whole programs.</p>
103
104</div>
105
106<div class="doc_subsection"><a name="codefragments">Code Fragments</a>
107</div>
108
109<div class="doc_text">
110
111<p>Code fragments are small pieces of code that test a specific feature of LLVM
112or trigger a specific bug in LLVM. They are usually written in LLVM assembly
113language, but can be written in other languages if the test targets a particular
114language front end.</p>
115
116<p>Code fragments are not complete programs, and they are never executed to
117determine correct behavior.</p>
118
119<p>The tests in the Features and Regression directories contain code
120fragments.</p>
121
122</div>
123
124<div class="doc_subsection"><a name="wholeprograms">Whole Programs</a></div>
125
126<div class="doc_text">
127
128<p>Whole Programs are pieces of code which can be compiled and linked into a
129stand-alone program that can be executed. These programs are generally written
130in high level languages such as C or C++, but sometimes they are written
131straight in LLVM assembly.</p>
132
133<p>These programs are compiled and then executed using several different
134methods (native compiler, LLVM C backend, LLVM JIT, LLVM native code generation,
135etc). The output of these programs is compared to ensure that LLVM is compiling
136the program correctly.</p>
137
138<p>In addition to compiling and executing programs, whole program tests serve as
139a way of benchmarking LLVM performance, both in terms of the efficiency of the
140programs generated as well as the speed with which LLVM compiles, optimizes, and
141generates code.</p>
142
143<p>The Programs directory contains all tests which compile and benchmark whole
144programs.</p>
145
146</div>
147
148<!--===============================================================-->
149<div class="doc_section"><a name="tree">LLVM Test Suite Tree</a></div>
150<!--===============================================================-->
151
152<div class="doc_text">
153
154<p>Each type of test in the LLVM test suite has its own directory. The major
155subtrees of the test suite directory tree are as follows:</p>
156
157<ul>
158 <li>Features
159 <p>This directory contains sample codes that test various features of the
160 LLVM language. These pieces of sample code are run through various
161 assembler, disassembler, and optimizer passes.</p>
162
163 <li>Regression
164 <p>This directory contains regression tests for LLVM. When a bug is found
165 in LLVM, a regression test containing just enough code to reproduce the
166 problem should be written and placed somewhere underneath this directory.
167 In most cases, this will be a small piece of LLVM assembly language code,
168 often distilled from an actual application or benchmark.</p>
169
170 <li>Programs
171 <p>The Programs directory contains programs that can be compiled with LLVM
172 and executed. These programs are compiled using the native compiler and
173 various LLVM backends. The output from the program compiled with the native
174 compiler is assumed correct; the results from the other programs are
175 compared to the native program output and pass if they match. </p>
176
177 <p> In addition for testing correctness, the Programs directory also
178 performs timing tests of various LLVM optimizations. It also records
179 compilation times for the compilers and the JIT. This information can be
180 used to compare the effectiveness of LLVM's optimizations and code
181 generation.</p>
182
183 <p>The Programs directory is subdivided into several smaller subdirectories:
184 </p>
185
186 <ul>
187 <li>Programs/SingleSource
188 <p>The SingleSource directory contains test programs that are only a
189 single source file in size. These are usually small benchmark programs
190 or small programs that calculate a particular value. Several such
191 programs are grouped together in each directory.</p></li>
192
193 <li>Programs/MultiSource
194 <p>The MultiSource directory contains subdirectories which contain
195 entire programs with multiple source files. Large benchmarks and whole
196 applications go here.</p></li>
197
198 <li>Programs/External
199 <p>The External directory contains Makefiles for building code that is
200 external to (i.e. not distributed with) LLVM. The most prominent member
201 of this directory is the SPEC 2000 benchmark suite. The presence and
202 location of these external programs is configured by the LLVM
203 <tt>configure</tt> script.</p></li>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000204
Misha Brukman1d83e112004-03-01 18:21:04 +0000205 </ul></li>
John Criswell020cbd82003-10-10 18:42:49 +0000206
Misha Brukman1d83e112004-03-01 18:21:04 +0000207 <li>QMTest
208 <p>This directory contains the QMTest information files. Inside this
209 directory are QMTest administration files and the Python code that
210 implements the LLVM test and database classes.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000211
Misha Brukman1d83e112004-03-01 18:21:04 +0000212</ul>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000213
Misha Brukman1d83e112004-03-01 18:21:04 +0000214</div>
John Criswell020cbd82003-10-10 18:42:49 +0000215
Misha Brukman1d83e112004-03-01 18:21:04 +0000216<!--===============================================================-->
217<div class="doc_section"><a name="qmstructure">QMTest Structure</a></div>
218<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +0000219
Misha Brukman1d83e112004-03-01 18:21:04 +0000220<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +0000221
Misha Brukman1d83e112004-03-01 18:21:04 +0000222<p>The LLVM test suite is partially driven by QMTest and partially
223driven by GNU Make. Specifically, the Features and Regression tests
224are all driven by QMTest. The Programs directory is currently
225driven by a set of Makefiles.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000226
Misha Brukman1d83e112004-03-01 18:21:04 +0000227<p>The QMTest system needs to have several pieces of information
228available; these pieces of configuration information are known
229collectively as the "context" in QMTest parlance. Since the context
230for LLVM is relatively large, the master Makefile in llvm/test
231sets it for you.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000232
Misha Brukman1d83e112004-03-01 18:21:04 +0000233<p>The LLVM database class makes the subdirectories of llvm/test a
234QMTest test database. For each directory that contains tests driven by
235QMTest, it knows what type of test the source file is and how to run it.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000236
Misha Brukman1d83e112004-03-01 18:21:04 +0000237<p>Hence, the QMTest namespace is essentially what you see in the
238Feature and Regression directories, but there is some magic that
239the database class performs (as described below).</p>
John Criswell020cbd82003-10-10 18:42:49 +0000240
Misha Brukman1d83e112004-03-01 18:21:04 +0000241<p>The QMTest namespace is currently composed of the following tests and test
242suites:</p>
John Criswell020cbd82003-10-10 18:42:49 +0000243
Misha Brukman1d83e112004-03-01 18:21:04 +0000244<ul>
245 <li>Feature
246 <p>
247 These are the feature tests found in the Feature directory.
248 They are broken up into the following categories:
249 </p>
250 <ul>
251 <li>ad
252 <p>Assembler/Disassembler tests. These tests verify that a piece of LLVM
253 assembly language can be assembled into bytecode and then disassembled
254 into the original assembly language code. It does this several times to
255 ensure that assembled output can be disassembled and disassembler output
256 can be assembled. It also verifies that the give assembly language file
257 can be assembled correctly.</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000258
Misha Brukman1d83e112004-03-01 18:21:04 +0000259 <li>opt
260 <p>Optimizer tests. These tests verify that two of the optimizer passes
261 completely optimize a program (i.e. after a single pass, they cannot
262 optimize a program any further).</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000263
Misha Brukman1d83e112004-03-01 18:21:04 +0000264 <li>mc
265 <p> Machine code tests. These tests verify that the LLVM assembly
266 language file can be translated into native assembly code.</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000267
Misha Brukman1d83e112004-03-01 18:21:04 +0000268 <li>cc
269 <p>C code tests. These tests verify that the specified LLVM assembly
270 code can be converted into C source code using the C backend.</p></li>
271 </ul>
John Criswell020cbd82003-10-10 18:42:49 +0000272
Misha Brukman1d83e112004-03-01 18:21:04 +0000273 <p>The LLVM database class looks at every file in the Feature directory and
274 creates a fake test hierarchy containing
275 <tt>Feature.&lt;testtype&gt;.&lt;testname&gt;</tt>. So, if you add an LLVM
276 assembly language file to the Feature directory, it actually creates 5 new
277 tests: assembler/disassembler, assembler, optimizer, machine code, and C code.
278 </p>
John Criswell020cbd82003-10-10 18:42:49 +0000279
Misha Brukman1d83e112004-03-01 18:21:04 +0000280 <li>Regression
281 <p>These are the regression tests. There is one suite for each
282 subdirectory of the Regression directory. If you add a new subdirectory
283 there, you will need to modify, at least, the <tt>RegressionMap</tt>
284 variable in <tt>QMTest/llvmdb.py</tt> so that QMTest knows how to run the
285 tests in the new subdirectory.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000286
Misha Brukman1d83e112004-03-01 18:21:04 +0000287</ul>
288
289</div>
John Criswell020cbd82003-10-10 18:42:49 +0000290
Misha Brukman1d83e112004-03-01 18:21:04 +0000291<!--===============================================================-->
292<div class="doc_section"><a name="progstructure">Programs Structure</a></div>
293<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +0000294
Misha Brukman1d83e112004-03-01 18:21:04 +0000295<div class="doc_text">
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000296
Misha Brukman1d83e112004-03-01 18:21:04 +0000297<p>As mentioned previously, the Programs tree in llvm/test provides three types
298of tests: MultiSource, SingleSource, and External. Each tree is then subdivided
299into several categories, including applications, benchmarks, regression tests,
300code that is strange grammatically, etc. These organizations should be
301relatively self explanatory.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000302
Misha Brukman1d83e112004-03-01 18:21:04 +0000303<p>In addition to the regular Programs tests, the Programs tree also provides a
304mechanism for compiling the programs in different ways. If the variable TEST is
305defined on the gmake command line, the test system will include a Makefile named
306<tt>TEST.&lt;value of TEST variable&gt;.Makefile</tt>. This Makefile can modify
307build rules to yield different results.</p>
308
309<p>For example, the LLVM nightly tester uses <tt>TEST.nightly.Makefile</tt> to
310create the nightly test reports. To run the nightly tests, run <tt>gmake
311TEST=nightly</tt>.</p>
312
313<p>There are several TEST Makefiles available in the tree. Some of them are
314designed for internal LLVM research and will not work outside of the LLVM
315research group. They may still be valuable, however, as a guide to writing your
316own TEST Makefile for any optimization or analysis passes that you develop with
317LLVM.</p>
318
319</div>
320
321<!--===============================================================-->
322<div class="doc_section"><a name="run">Running the LLVM Tests</a></div>
323<!--===============================================================-->
324
325<div class="doc_text">
326
327<p>First, all tests are executed within the LLVM object directory tree. They
328<i>are not</i> executed inside of the LLVM source tree. This is because the
329test suite creates temporary files during execution. </p>
330
331<p>The master Makefile in llvm/test is capable of running both the QMTest driven
332tests and the Programs tests. By default, it will run all of the tests.</p>
333
334<p>To run only the QMTest driven tests, run <tt>gmake qmtest</tt> at the
335command line in llvm/tests. To run a specific qmtest, suffix the test name with
336".t" when running gmake.</p>
337
338<p>For example, to run the Regression.LLC tests, type <tt>gmake
339Regression.LLC.t</tt> in llvm/tests.</p>
340
341<p>Note that the Makefiles in llvm/test/Features and llvm/test/Regression are
342gone. You must now use QMTest from the llvm/test directory to run them.</p>
343
344<p>To run the Programs test, cd into the llvm/test/Programs directory and type
345<tt>gmake</tt>. Alternatively, you can type <tt>gmake TEST=&lt;type&gt;
346test</tt> to run one of the specialized tests in
347llvm/test/Programs/TEST.&lt;type&gt;.Makefile. For example, you could run the
348nightly tester tests using the following commands:</p>
349
350<pre>
351 % cd llvm/test/Programs
352 % gmake TEST=nightly test
353</pre>
354
355<p>Regardless of which test you're running, the results are printed on standard
356output and standard error. You can redirect these results to a file if you
357choose.</p>
358
359<p>Some tests are known to fail. Some are bugs that we have not fixed yet;
360others are features that we haven't added yet (or may never add). In QMTest,
361the result for such tests will be XFAIL (eXpected FAILure). In this way, you
362can tell the difference between an expected and unexpected failure.</p>
363
364<p>The Programs tests have no such feature as of this time. If the test passes,
365only warnings and other miscellaneous output will be generated. If a test
366fails, a large &lt;program&gt; FAILED message will be displayed. This will help
367you separate benign warnings from actual test failures.</p>
368
369</div>
John Criswell020cbd82003-10-10 18:42:49 +0000370
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000371<!-- *********************************************************************** -->
John Criswell020cbd82003-10-10 18:42:49 +0000372
Misha Brukman1d83e112004-03-01 18:21:04 +0000373<hr>
374<address>
375 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
376 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
377 <a href="http://validator.w3.org/check/referer"><img
378 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000379
Misha Brukman1d83e112004-03-01 18:21:04 +0000380 John T. Criswell<br>
381 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
382 Last modified: $Date$
383</address>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000384</body>
John Criswell020cbd82003-10-10 18:42:49 +0000385</html>