blob: bfe8316cf6bed4738aaa01db83d613cc9281ce60 [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
Misha Brukman1d83e112004-03-01 18:21:04 +000029<p><b>Written by John T. Criswell</b></p>
John Criswell020cbd82003-10-10 18:42:49 +000030
Misha Brukman1d83e112004-03-01 18:21:04 +000031<!--===============================================================-->
32<div class="doc_section"><a name="overview">Overview</a></div>
33<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000034
Misha Brukman1d83e112004-03-01 18:21:04 +000035<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +000036
Misha Brukman1d83e112004-03-01 18:21:04 +000037<p>This document is the reference manual for the LLVM test suite. It documents
38the structure of the LLVM test suite, the tools needed to use it, and how to add
39and run tests.</p>
John Criswell020cbd82003-10-10 18:42:49 +000040
Misha Brukman1d83e112004-03-01 18:21:04 +000041</div>
John Criswell020cbd82003-10-10 18:42:49 +000042
Misha Brukman1d83e112004-03-01 18:21:04 +000043<!--===============================================================-->
44<div class="doc_section"><a name="Requirements">Requirements</a></div>
45<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000046
Misha Brukman1d83e112004-03-01 18:21:04 +000047<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +000048
Misha Brukman1d83e112004-03-01 18:21:04 +000049<p>In order to use the LLVM test suite, you will need all of the software
50required to build LLVM, plus the following:</p>
John Criswell020cbd82003-10-10 18:42:49 +000051
Misha Brukman1d83e112004-03-01 18:21:04 +000052<dl>
53 <dt><a href="http://www.qmtest.com">QMTest</A></dt>
54 <dd>The LLVM test suite uses QMTest to organize and run tests.</dd>
John Criswell020cbd82003-10-10 18:42:49 +000055
Misha Brukman1d83e112004-03-01 18:21:04 +000056 <dt><a href="http://www.python.org">Python</A></dt>
57 <dd>You will need a Python interpreter that works with QMTest. Python will
58 need zlib and SAX support enabled.</dd>
59</dl>
John Criswell020cbd82003-10-10 18:42:49 +000060
Misha Brukman1d83e112004-03-01 18:21:04 +000061</div>
John Criswell020cbd82003-10-10 18:42:49 +000062
Misha Brukman1d83e112004-03-01 18:21:04 +000063<!--===============================================================-->
64<div class="doc_section"><a name="quick">Quick Start</a></div>
65<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +000066
Misha Brukman1d83e112004-03-01 18:21:04 +000067<div class="doc_text">
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000068
Misha Brukman1d83e112004-03-01 18:21:04 +000069<p> The tests are located in the LLVM source tree under the directory
70<tt>llvm/test</tt>. To run all of the tests in LLVM, use the Master Makefile in
71that directory:</p>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +000072
Misha Brukman1d83e112004-03-01 18:21:04 +000073<pre>
74 % gmake -C llvm/test
75</pre>
John Criswell020cbd82003-10-10 18:42:49 +000076
Misha Brukman1d83e112004-03-01 18:21:04 +000077<p>To run only the code fragment tests (i.e. those that do basic testing of
78LLVM), run the tests organized by QMTest:</p>
John Criswell020cbd82003-10-10 18:42:49 +000079
Misha Brukman1d83e112004-03-01 18:21:04 +000080<pre>
81 % gmake -C llvm/test qmtest
82</pre>
John Criswell020cbd82003-10-10 18:42:49 +000083
Misha Brukman1d83e112004-03-01 18:21:04 +000084<p>To run only the tests that compile and execute whole programs, run the
85Programs tests:</p>
John Criswell020cbd82003-10-10 18:42:49 +000086
Misha Brukman1d83e112004-03-01 18:21:04 +000087<pre>
88 % gmake -C llvm/test/Programs
89</pre>
90
91</div>
92
93<!--===============================================================-->
94<div class="doc_section"><a name="org">LLVM Test Suite Organization</a></div>
95<!--===============================================================-->
96
97<div class="doc_text">
98
99<p>The LLVM test suite contains two major categories of tests: code
100fragments and whole programs.</p>
101
102</div>
103
104<div class="doc_subsection"><a name="codefragments">Code Fragments</a>
105</div>
106
107<div class="doc_text">
108
109<p>Code fragments are small pieces of code that test a specific feature of LLVM
110or trigger a specific bug in LLVM. They are usually written in LLVM assembly
111language, but can be written in other languages if the test targets a particular
112language front end.</p>
113
114<p>Code fragments are not complete programs, and they are never executed to
115determine correct behavior.</p>
116
117<p>The tests in the Features and Regression directories contain code
118fragments.</p>
119
120</div>
121
122<div class="doc_subsection"><a name="wholeprograms">Whole Programs</a></div>
123
124<div class="doc_text">
125
126<p>Whole Programs are pieces of code which can be compiled and linked into a
127stand-alone program that can be executed. These programs are generally written
128in high level languages such as C or C++, but sometimes they are written
129straight in LLVM assembly.</p>
130
131<p>These programs are compiled and then executed using several different
132methods (native compiler, LLVM C backend, LLVM JIT, LLVM native code generation,
133etc). The output of these programs is compared to ensure that LLVM is compiling
134the program correctly.</p>
135
136<p>In addition to compiling and executing programs, whole program tests serve as
137a way of benchmarking LLVM performance, both in terms of the efficiency of the
138programs generated as well as the speed with which LLVM compiles, optimizes, and
139generates code.</p>
140
141<p>The Programs directory contains all tests which compile and benchmark whole
142programs.</p>
143
144</div>
145
146<!--===============================================================-->
147<div class="doc_section"><a name="tree">LLVM Test Suite Tree</a></div>
148<!--===============================================================-->
149
150<div class="doc_text">
151
152<p>Each type of test in the LLVM test suite has its own directory. The major
153subtrees of the test suite directory tree are as follows:</p>
154
155<ul>
156 <li>Features
157 <p>This directory contains sample codes that test various features of the
158 LLVM language. These pieces of sample code are run through various
159 assembler, disassembler, and optimizer passes.</p>
160
161 <li>Regression
162 <p>This directory contains regression tests for LLVM. When a bug is found
163 in LLVM, a regression test containing just enough code to reproduce the
164 problem should be written and placed somewhere underneath this directory.
165 In most cases, this will be a small piece of LLVM assembly language code,
166 often distilled from an actual application or benchmark.</p>
167
168 <li>Programs
169 <p>The Programs directory contains programs that can be compiled with LLVM
170 and executed. These programs are compiled using the native compiler and
171 various LLVM backends. The output from the program compiled with the native
172 compiler is assumed correct; the results from the other programs are
173 compared to the native program output and pass if they match. </p>
174
175 <p> In addition for testing correctness, the Programs directory also
176 performs timing tests of various LLVM optimizations. It also records
177 compilation times for the compilers and the JIT. This information can be
178 used to compare the effectiveness of LLVM's optimizations and code
179 generation.</p>
180
181 <p>The Programs directory is subdivided into several smaller subdirectories:
182 </p>
183
184 <ul>
185 <li>Programs/SingleSource
186 <p>The SingleSource directory contains test programs that are only a
187 single source file in size. These are usually small benchmark programs
188 or small programs that calculate a particular value. Several such
189 programs are grouped together in each directory.</p></li>
190
191 <li>Programs/MultiSource
192 <p>The MultiSource directory contains subdirectories which contain
193 entire programs with multiple source files. Large benchmarks and whole
194 applications go here.</p></li>
195
196 <li>Programs/External
197 <p>The External directory contains Makefiles for building code that is
198 external to (i.e. not distributed with) LLVM. The most prominent member
199 of this directory is the SPEC 2000 benchmark suite. The presence and
200 location of these external programs is configured by the LLVM
201 <tt>configure</tt> script.</p></li>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000202
Misha Brukman1d83e112004-03-01 18:21:04 +0000203 </ul></li>
John Criswell020cbd82003-10-10 18:42:49 +0000204
Misha Brukman1d83e112004-03-01 18:21:04 +0000205 <li>QMTest
206 <p>This directory contains the QMTest information files. Inside this
207 directory are QMTest administration files and the Python code that
208 implements the LLVM test and database classes.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000209
Misha Brukman1d83e112004-03-01 18:21:04 +0000210</ul>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000211
Misha Brukman1d83e112004-03-01 18:21:04 +0000212</div>
John Criswell020cbd82003-10-10 18:42:49 +0000213
Misha Brukman1d83e112004-03-01 18:21:04 +0000214<!--===============================================================-->
215<div class="doc_section"><a name="qmstructure">QMTest Structure</a></div>
216<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +0000217
Misha Brukman1d83e112004-03-01 18:21:04 +0000218<div class="doc_text">
John Criswell020cbd82003-10-10 18:42:49 +0000219
Misha Brukman1d83e112004-03-01 18:21:04 +0000220<p>The LLVM test suite is partially driven by QMTest and partially
221driven by GNU Make. Specifically, the Features and Regression tests
222are all driven by QMTest. The Programs directory is currently
223driven by a set of Makefiles.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000224
Misha Brukman1d83e112004-03-01 18:21:04 +0000225<p>The QMTest system needs to have several pieces of information
226available; these pieces of configuration information are known
227collectively as the "context" in QMTest parlance. Since the context
228for LLVM is relatively large, the master Makefile in llvm/test
229sets it for you.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000230
Misha Brukman1d83e112004-03-01 18:21:04 +0000231<p>The LLVM database class makes the subdirectories of llvm/test a
232QMTest test database. For each directory that contains tests driven by
233QMTest, it knows what type of test the source file is and how to run it.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000234
Misha Brukman1d83e112004-03-01 18:21:04 +0000235<p>Hence, the QMTest namespace is essentially what you see in the
236Feature and Regression directories, but there is some magic that
237the database class performs (as described below).</p>
John Criswell020cbd82003-10-10 18:42:49 +0000238
Misha Brukman1d83e112004-03-01 18:21:04 +0000239<p>The QMTest namespace is currently composed of the following tests and test
240suites:</p>
John Criswell020cbd82003-10-10 18:42:49 +0000241
Misha Brukman1d83e112004-03-01 18:21:04 +0000242<ul>
243 <li>Feature
244 <p>
245 These are the feature tests found in the Feature directory.
246 They are broken up into the following categories:
247 </p>
248 <ul>
249 <li>ad
250 <p>Assembler/Disassembler tests. These tests verify that a piece of LLVM
251 assembly language can be assembled into bytecode and then disassembled
252 into the original assembly language code. It does this several times to
253 ensure that assembled output can be disassembled and disassembler output
254 can be assembled. It also verifies that the give assembly language file
255 can be assembled correctly.</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000256
Misha Brukman1d83e112004-03-01 18:21:04 +0000257 <li>opt
258 <p>Optimizer tests. These tests verify that two of the optimizer passes
259 completely optimize a program (i.e. after a single pass, they cannot
260 optimize a program any further).</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000261
Misha Brukman1d83e112004-03-01 18:21:04 +0000262 <li>mc
263 <p> Machine code tests. These tests verify that the LLVM assembly
264 language file can be translated into native assembly code.</p></li>
John Criswell020cbd82003-10-10 18:42:49 +0000265
Misha Brukman1d83e112004-03-01 18:21:04 +0000266 <li>cc
267 <p>C code tests. These tests verify that the specified LLVM assembly
268 code can be converted into C source code using the C backend.</p></li>
269 </ul>
John Criswell020cbd82003-10-10 18:42:49 +0000270
Misha Brukman1d83e112004-03-01 18:21:04 +0000271 <p>The LLVM database class looks at every file in the Feature directory and
272 creates a fake test hierarchy containing
273 <tt>Feature.&lt;testtype&gt;.&lt;testname&gt;</tt>. So, if you add an LLVM
274 assembly language file to the Feature directory, it actually creates 5 new
275 tests: assembler/disassembler, assembler, optimizer, machine code, and C code.
276 </p>
John Criswell020cbd82003-10-10 18:42:49 +0000277
Misha Brukman1d83e112004-03-01 18:21:04 +0000278 <li>Regression
279 <p>These are the regression tests. There is one suite for each
280 subdirectory of the Regression directory. If you add a new subdirectory
281 there, you will need to modify, at least, the <tt>RegressionMap</tt>
282 variable in <tt>QMTest/llvmdb.py</tt> so that QMTest knows how to run the
283 tests in the new subdirectory.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000284
Misha Brukman1d83e112004-03-01 18:21:04 +0000285</ul>
286
287</div>
John Criswell020cbd82003-10-10 18:42:49 +0000288
Misha Brukman1d83e112004-03-01 18:21:04 +0000289<!--===============================================================-->
290<div class="doc_section"><a name="progstructure">Programs Structure</a></div>
291<!--===============================================================-->
John Criswell020cbd82003-10-10 18:42:49 +0000292
Misha Brukman1d83e112004-03-01 18:21:04 +0000293<div class="doc_text">
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000294
Misha Brukman1d83e112004-03-01 18:21:04 +0000295<p>As mentioned previously, the Programs tree in llvm/test provides three types
296of tests: MultiSource, SingleSource, and External. Each tree is then subdivided
297into several categories, including applications, benchmarks, regression tests,
298code that is strange grammatically, etc. These organizations should be
299relatively self explanatory.</p>
John Criswell020cbd82003-10-10 18:42:49 +0000300
Misha Brukman1d83e112004-03-01 18:21:04 +0000301<p>In addition to the regular Programs tests, the Programs tree also provides a
302mechanism for compiling the programs in different ways. If the variable TEST is
303defined on the gmake command line, the test system will include a Makefile named
304<tt>TEST.&lt;value of TEST variable&gt;.Makefile</tt>. This Makefile can modify
305build rules to yield different results.</p>
306
307<p>For example, the LLVM nightly tester uses <tt>TEST.nightly.Makefile</tt> to
308create the nightly test reports. To run the nightly tests, run <tt>gmake
309TEST=nightly</tt>.</p>
310
311<p>There are several TEST Makefiles available in the tree. Some of them are
312designed for internal LLVM research and will not work outside of the LLVM
313research group. They may still be valuable, however, as a guide to writing your
314own TEST Makefile for any optimization or analysis passes that you develop with
315LLVM.</p>
316
317</div>
318
319<!--===============================================================-->
320<div class="doc_section"><a name="run">Running the LLVM Tests</a></div>
321<!--===============================================================-->
322
323<div class="doc_text">
324
325<p>First, all tests are executed within the LLVM object directory tree. They
326<i>are not</i> executed inside of the LLVM source tree. This is because the
327test suite creates temporary files during execution. </p>
328
329<p>The master Makefile in llvm/test is capable of running both the QMTest driven
330tests and the Programs tests. By default, it will run all of the tests.</p>
331
332<p>To run only the QMTest driven tests, run <tt>gmake qmtest</tt> at the
333command line in llvm/tests. To run a specific qmtest, suffix the test name with
334".t" when running gmake.</p>
335
336<p>For example, to run the Regression.LLC tests, type <tt>gmake
337Regression.LLC.t</tt> in llvm/tests.</p>
338
339<p>Note that the Makefiles in llvm/test/Features and llvm/test/Regression are
340gone. You must now use QMTest from the llvm/test directory to run them.</p>
341
342<p>To run the Programs test, cd into the llvm/test/Programs directory and type
343<tt>gmake</tt>. Alternatively, you can type <tt>gmake TEST=&lt;type&gt;
344test</tt> to run one of the specialized tests in
345llvm/test/Programs/TEST.&lt;type&gt;.Makefile. For example, you could run the
346nightly tester tests using the following commands:</p>
347
348<pre>
349 % cd llvm/test/Programs
350 % gmake TEST=nightly test
351</pre>
352
353<p>Regardless of which test you're running, the results are printed on standard
354output and standard error. You can redirect these results to a file if you
355choose.</p>
356
357<p>Some tests are known to fail. Some are bugs that we have not fixed yet;
358others are features that we haven't added yet (or may never add). In QMTest,
359the result for such tests will be XFAIL (eXpected FAILure). In this way, you
360can tell the difference between an expected and unexpected failure.</p>
361
362<p>The Programs tests have no such feature as of this time. If the test passes,
363only warnings and other miscellaneous output will be generated. If a test
364fails, a large &lt;program&gt; FAILED message will be displayed. This will help
365you separate benign warnings from actual test failures.</p>
366
367</div>
John Criswell020cbd82003-10-10 18:42:49 +0000368
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000369<!-- *********************************************************************** -->
John Criswell020cbd82003-10-10 18:42:49 +0000370
Misha Brukman1d83e112004-03-01 18:21:04 +0000371<hr>
372<address>
373 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
374 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
375 <a href="http://validator.w3.org/check/referer"><img
376 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000377
Misha Brukman1d83e112004-03-01 18:21:04 +0000378 John T. Criswell<br>
379 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
380 Last modified: $Date$
381</address>
Brian Gaekeaf19f2e2003-10-23 18:10:28 +0000382</body>
John Criswell020cbd82003-10-10 18:42:49 +0000383</html>