blob: a25d604ab091c235ba5cb28b1a5167244dd6b795 [file] [log] [blame]
nstraz7638a532000-10-09 20:35:46 +00001#LyX 1.1 created this file. For more info see http://www.lyx.org/
2\lyxformat 2.16
3\textclass docbook
4\begin_preamble
5<!entity header system "header.sgml">
6\end_preamble
7\language default
8\inputencoding default
9\fontscheme default
10\graphics default
11\paperfontsize default
12\spacing single
13\papersize Default
14\paperpackage a4
15\use_geometry 0
16\use_amsmath 0
17\paperorientation portrait
18\secnumdepth 3
19\tocdepth 3
20\paragraph_separation indent
21\defskip medskip
22\quotes_language english
23\quotes_times 2
24\papercolumns 1
25\papersides 1
26\paperpagestyle default
27
28\layout Title
29\added_space_top vfill \added_space_bottom vfill
30Linux Test Project HOWTO
31\layout Date
32
nstraz562c7372000-10-10 21:57:51 +00003310 October 2000
nstraz7638a532000-10-09 20:35:46 +000034\layout Author
35
36Nate Straz
37\layout Abstract
38
39This document explains some of the more in depth topics of the Linux Test
40 Project and related testing issues.
41 It does not cover basic installation procedures.
42 See the INSTALL and README files in the tarball for that information.
43\layout Section
44
45Preface
46\layout Standard
47
48This document was written to help bring the community up to speed on the
49 ins and outs of the Linux Test Project.
50\layout Subsection
51
52Copyright
53\layout Standard
54
55Copyright (c) 2000 by SGI, Inc.
56
57\layout Standard
58
59Please freely copy and distribute (sell or give away) this document in any
60 format.
61 It's requested that corrections and/or comments be fowarded to the document
62 maintainer.
63 You may create a derivative work and distribute it provided that you:
64\layout Itemize
65
66Send your derivative work (in the most suitable format such as sgml) to
67 the LDP (Linux Documentation Project) or the like for posting on the Internet.
68 If not the LDP, then let the LDP know where it is available.
69
70\layout Itemize
71
72License the derivative work with this same license or use GPL.
73 Include a copyright notice and at least a pointer to the license used.
74
75\layout Itemize
76
77Give due credit to previous authors and major contributors.
78
79\layout Standard
80
81If you're considering making a derived work other than a translation, it's
82 requested that you discuss your plans with the current maintainer.
83
84\layout Subsection
85
86Disclaimer
87\layout Standard
88
89Use the information in this document at your own risk.
90 I disavow any potential liability for the contents of this document.
91 Use of the concepts, examples, and/or other content of this document is
92 entirely at your own risk.
93
94\layout Standard
95
96All copyrights are owned by their owners, unless specifically noted otherwise.
97 Use of a term in this document should not be regarded as affecting the
98 validity of any trademark or service mark.
99
100\layout Standard
101
102Naming of particular products or brands should not be seen as endorsements.
103
104\layout Standard
105
106You are strongly recommended to take a backup of your system before major
107 installation and backups at regular intervals.
108
109\layout Section
110
111Introduction
112\layout Subsection
113
114What is the Linux Test Project?
115\layout Standard
116
117The Linux Test Project (LTP) is an effort to create a set of tools and tests
118 to verify the functionality and stability of the Linux kernel.
119 We hope this will support Linux development by making unit testing more
120 complete and minimizing user impact by building a barrier to keep bugs
121 from making it to the user.
122
123\layout Subsection
124
125What is wrong with the current testing model?
126\layout Standard
127
128The Linux development community utilizes two important (some out argue most
129 important) testing techniques in its normal operations: Design and Code
130 Inspections.
131 The intent of LTP is to support this by giving developers an ever growing
132 set of tools to help identify any operational problems in their code that
133 may be missed by human review.
134 One of the toughest categories of problems to catch with inspection is
135 that of interaction of features.
136 With a continuously improving set of tests and tools, developers can get
137 an indication of whether their changes may have broken some other functionality.
138
139\layout Standard
140
141There is no such thing as a perfect test base.
142 It is only useful it if keeps up with new and changing functionality,
143 and if it actually gets used.
144
145\layout Subsection
146
147Are you doing benchmarking?
148\layout Standard
149
150Not at this time.
151 We are more interested in functional, regression, and stress testing the
152 Linux kernel.
153 Benchmarking may be workable to compare the performance among kernel versions.
154
155\layout Subsection
156
157Are you doing standards testing?
158\layout Standard
159
160No, we are leaving that to the Linux Standards Base (LSB).
161 See the Linux Standards Base
162\begin_inset LatexCommand \htmlurl[web site]{http://www.linuxbase.org/}
163
164\end_inset
165
166 for more information.
167
168\layout Section
169
170Structure
171\layout Standard
172
173The basic building block of the test project is a
174\series bold
175test case
176\series default
177 that consists of a single action and a verification that the action worked.
178 The result of the test case is usually restricted to PASS/FAIL.
179
180\layout Standard
181
182A
183\series bold
184test program
185\series default
186 is a runnable program that contains one or more test cases.
187 Test programs often understand command line options which alter their behavior.
188 The options could determine the amount of memory tested, the location of
189 temporary files, the type of network packet used, or any other useful parameter.
190\layout Standard
191
192
193\series bold
194Test tags
195\series default
196 are used to pair a unique identifier with a test program and a set of command
197 line options.
198 Test tags are the basis for test suites.
199\layout Section
200
201Writing Tests
202\layout Standard
203
204Writing a test case is a lot easier than most people think.
205 Any code that you write to examine how a part of the kernel works can
206 be adapted into a test case.
207 All that is needed is a way to report the result of the action to the
208 rest of the world.
209 There are several ways of doing this, some more involved than others.
210
211\layout Subsection
212
213Exit Style Tests
214\layout Standard
215
216Probably the simplest way of reporting the results of a test case is the
217 exit status of your program.
218 If your test program encounters unexpected or incorrect results, exit
219 the test program with a non-zero exit status, i.e.
220
221\family typewriter
222exit(1)
223\family default
224.
225 Conversely, if your program completes as expected, return a zero exit status,
226 i.e.
227
228\family typewriter
229exit(0)
230\family default
231.
232 Any test driver should be able to handle this type of error reporting.
233 If a test program has multiple test cases you won't know which test case
234 failed, but you will know the program that failed.
235
236\layout Subsection
237
238Formatted Output Tests
239\layout Standard
240
241The next easiest way of reporting the results is to write the results of
242 each test case to standard output.
243 This allows for the testing results to be more understandable to both the
244 tester and the analysis tools.
245 When the results are written in a standard way, tools can be used to analyze
246 the results.
247
248\layout Section
249
250Testing Tools
251\layout Standard
252
253The Linux Test Project has not yet decided on a "final" test harness.
254 We have provided a simple solution with
255\family typewriter
256pan
257\family default
258 to make due until a complete solution has been found/created that compliments
259 the Linux kernel development process.
260 Several people have said we should use such and such a test harness.
261 Until we find we need a large complex test harness, we will apply the KISS
262 concept.
263
264\layout Subsection
265
nstraz562c7372000-10-10 21:57:51 +0000266Pan
nstraz7638a532000-10-09 20:35:46 +0000267\layout Standard
268
269
270\family typewriter
271pan
272\family default
nstraz03d32f42000-10-11 22:46:16 +0000273 is a simple test driver with the ability to keep track of orphaned processes
274 and capture test output.
275 It works by reading a list of test tags and command lines and runs them.
276 By default pan will select a command randomly from the list of test tags,
277 wait for it to finish.
278 Through command line options you can run through the entire list sequentially,
279 run n tests, keep n test running at all times, and buffer test output.
280 Pan can be nested to create very complex test environments.
nstraz7638a532000-10-09 20:35:46 +0000281\layout Standard
282
nstraz03d32f42000-10-11 22:46:16 +0000283Pan uses an
284\emph on
285active file
286\emph default
287, also called a
288\emph on
289zoo file
290\emph default
291 to keep track of which tests are currently running.
292 This file holds the pid, tag, and a portion of the command line.
293 When you start pan it becomes a test tag in itself, thus it requires a
294 name for itself.
295 Pan updates the active file to show which test tags are currently running.
296 When a test tag exits, pan will overwrite the first character with a '#'.
297 The active file can be shared between multiple instances of pan so you
298 know which tests were running when the system crashes by looking at one
299 file.
300
301\layout Standard
302
303A
304\emph on
305pan file
306\emph default
307 contains a list of test tags for pan to run.
nstraz562c7372000-10-10 21:57:51 +0000308 The format of a pan file is as follows:
309\layout Code
310
311testtag testprogram -o one -p two other command line options
312\layout Code
313
314# This is a comment.
315 It is a good idea to describe the test
316\layout Code
317
318# tags in your pan file.
319 Tests programs can have different
320\layout Code
321
322# behaviors depending on the command line options so it is
323\layout Code
324
nstraz03d32f42000-10-11 22:46:16 +0000325# helpful to describe what each test tag is meant to verify or # provoke.
nstraz562c7372000-10-10 21:57:51 +0000326\layout Code
327
328# Some more test cases
329\layout Code
330
331mm01 mmap001 -m 10000
332\layout Code
333
334# 40 Mb mmap() test.
335\layout Code
336
337# Creates a 10000 page mmap, touches all of the map, sync's
338\layout Code
339
340# it, and munmap()s it.
341\layout Code
342
343mm03 mmap001 -i 0 -I 1 -m 100
344\layout Code
345
346# repetitive mmapping test.
347\layout Code
348
349# Creates a one page map repetitively for one minute.
350\layout Code
351
352dup02 dup02
353\layout Code
354
355# Negative test for dup(2) with bad fd
356\layout Code
357
358kill09 kill09
359\layout Code
360
361# Basic test for kill(2)
362\layout Code
363
364fs-suite01 pan -e -a fs-suite01.zoo -n fs-suite01 -f runtest/fs
365\layout Code
366
367# run the entire set of file system tests
368\layout Standard
369
nstraz03d32f42000-10-11 22:46:16 +0000370The test tags are simple identifiers, no spaces are allowed.
371 The test of the line is the program to run, which is done using execvp(3).
372 Lines starting with '#' are comments and ignored by pan.
373 It is a good practice to include descriptions with your test tags so you
374 can have a reminder what a certain obscure test tag tries to do.
375\layout Subsubsection
376
377Examples
nstraz830a65b2000-10-12 16:39:25 +0000378\layout Itemize
nstraz03d32f42000-10-11 22:46:16 +0000379
nstraz830a65b2000-10-12 16:39:25 +0000380Using pan to run one test program (command line arg)
381\layout Itemize
382
383Using a pan file to run multiple tests
384\layout Itemize
385
386Running tests in parallel with output buffering
387\layout Itemize
388
389Nesting pan
nstraz03d32f42000-10-11 22:46:16 +0000390\layout Standard
391
nstraz562c7372000-10-10 21:57:51 +0000392For more information on pan see the man page
393\family typewriter
394doc/man1/pan.1
395\family default
396.
397\layout Subsection
398
399Scanner
400\layout Standard
401
nstraz7638a532000-10-09 20:35:46 +0000402
403\family typewriter
404scanner
405\family default
406 is a results analysis tool that understands the
407\emph on
408rts
409\emph default
410 style output which
411\family typewriter
412pan
413\family default
414 generates by default.
415 It will produce a table summarizing which tests passed and which failed.
416
nstraz7638a532000-10-09 20:35:46 +0000417\layout Subsection
418
nstraz562c7372000-10-10 21:57:51 +0000419The Quick-hitter Package
nstraz7638a532000-10-09 20:35:46 +0000420\layout Standard
421
nstraz562c7372000-10-10 21:57:51 +0000422Many of the tests released use the Quick-hitter test package to perform
423 tasks like create and move to a temporary directory, handle some common
424 command line parameters, loop, run in parallel, handle signals, and clean
425 up.
nstraz7638a532000-10-09 20:35:46 +0000426
nstraz562c7372000-10-10 21:57:51 +0000427\layout Standard
428
429There is an example test case,
430\family typewriter
431doc/examples/quickhit.c
432\family default
433, which shows how the quick-hitter package can be used.
434 The file is meant to be a supplement to the documentation, not a working
435 test case.
436 Use any of the tests in
437\family typewriter
438tests/
439\family default
440 as a template.
nstraz7638a532000-10-09 20:35:46 +0000441\layout Section
442
443To Do
444\layout Standard
445
nstraz562c7372000-10-10 21:57:51 +0000446There are a lot of things that still need to be done to make this a complete
nstraz7638a532000-10-09 20:35:46 +0000447 kernel testing system.
448 The following sections will discuss some of the to do items in detail.
449
450\layout Subsection
451
452Configuration Analysis
453\layout Standard
454
455While the number of configuration options for the Linux kernel is seen as
456 a strength to developers and users alike, it is a curse to testers.
457 To create a powerful automated testing system, we need to be able to determine
458 what the configuration on the booted box is and then determine which tests
459 should be run on that box.
460
461\layout Standard
462
463The Linux kernel has hundreds of configuration options that can be set to
464 compile the kernel.
465 There are more options that can be set when you boot the kernel and while
466 it is running.
467 There are also many patches that can be applied to the kernel to add functiona
468lity or change behavior.
469
470\layout Subsection
471
472Result Comparison
473\layout Standard
474
475A lot of testing will be done in the life of the Linux Test Project.
476 Keeping track of the results from all the testing will require some infrastruct
477ure.
478 It would be nice to take that output from a test machine, feed it to a
479 program and receive a list of items that broke since the last run on that
480 machine, or were fixed, or work on another test machine but not on this
481 one.
482
483\layout Section
484
485Contact information and updates
486\layout Literal
487
488URL: http://oss.sgi.com/projects/ltp/
489\layout Literal
490
491email: owners-ltp@oss.sgi.com
492\layout Literal
493
494mailing list: ltp@oss.sgi.com
495\layout Literal
496
497list archive: http://oss.sgi.com/projects/ltp/mail-threaded/
498\layout Standard
499
500Questions and comments should be sent to the LTP mailing list at ltp@oss.sgi.com.
501 To subscribe, send mail to majordomo@oss.sgi.com with "subscribe ltp" in
502 the body of the message.
503
504\layout Standard
505
506The source is also available via CVS.
507 See the web site for a web interface and check out instructions.
508
509\layout Section
510
511Glossary
512\layout Description
513
514Test IEEE/ANSI
515\begin_float footnote
516\layout Standard
517
518Kit, Edward, Software Testing in the Real World: Improving the Process.
519 P.
520 82.
521 ACM Press, 1995.
522\end_float
523:
524\shape italic
525
526\newline
527
528\shape default
529
530\shape italic
531(i)
532\shape default
533 An activity in which a system or component is executed under specified
534 conditions, the results are observed or record, and an evaluation is made
535 of some aspect of the system or component.
536
537\shape italic
538
539\newline
540
541\shape default
542
543\shape italic
544(ii)
545\shape default
546 A set of one or more test cases.
547
548\layout Description
549
550Test\SpecialChar ~
551Case A test assertion with a single result that is being verified.
552 This allows designations such as PASS or FAIL to be applied to a single
553 bit of functionality.
554 A single test case may be one of many test cases for testing the complete
555 functionality of a system.
556
557\newline
558IEEE/ANSI:
559\shape italic
560
561\newline
562(i)
563\shape default
564A set of test inputs, execution conditions, and expected results developed
565 for a particular objective.
566
567\shape italic
568
569\newline
570(ii)
571\shape default
572 The smallest entity that is always executed as a unit, from beginning to
573 end.
574
575\layout Description
576
577Test\SpecialChar ~
578Driver A program that handles the execution of test programs.
579 It is responsible for starting the test programs, capturing their output,
580 and recording their results.
581 Pan is an example of a test driver.
582\layout Description
583
584Test\SpecialChar ~
nstraz562c7372000-10-10 21:57:51 +0000585Framework A mechanism for organizing a group of tests.
nstraz7638a532000-10-09 20:35:46 +0000586 Frameworks may have complex or very simple API's, drivers and result logging
587 mechanisms.
588 Examples of frameworks are TETware and DejaGnu.
589
590\layout Description
591
592Test\SpecialChar ~
593Harness A Test harness is the mechanism that connects a test program
594 to a test framework.
595 It may be a specification of exit codes, or a set of libraries for formatting
596 messages and determining exit codes.
597 In TETware, the tet_result() API is the test harness.
598
599\layout Description
600
601Test\SpecialChar ~
602Program A single invokable program.
603 A test program can contain one or more test cases.
604 The test harness's API allows for reporting/analysis of the individual
605 test cases.
606
607\layout Description
608
609Test\SpecialChar ~
610Suite A collection of tests programs, assertions, cases grouped together
611 under a framework.
612
613\layout Description
614
615Test\SpecialChar ~
616Tag An identifier that corresponds to a command line which runs a test.
617 The tag is a single word that matches a test program with a set of command
618 line arguments.
619
620\the_end