3 .\" The DragonFly Project. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in
13 .\" the documentation and/or other materials provided with the
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\" contributors may be used to endorse or promote products derived
17 .\" from this software without specific, prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 .Nd an automation test driver and framework
40 .Op Fl o Ar output_plist
41 .Op Fl t Ar testcase_dir
42 .Op Fl p Ar prepost_dir
48 is a regression test framework and automation driver.
49 It executes a series of testcases as specified in the
51 and collects the results.
53 The path to the testcase collection is specified via the
56 If this argument is not specified, the default is assumed to be the
57 same directory as that of the runlist.
58 For example if the used runlist is
59 .Pa /usr/src/test/testcases/sample.run
60 the default testcase directory, unless otherwise specified, will be
61 .Pa /usr/src/test/testcases .
63 Similarly the path to the pre- and post commands is
68 only needs to be specified if the runlist contains custom pre or
71 The output is saved in plist format to the
73 file, or if none is specified, to a file with the same base name as
74 the runlist, but in the current working directory and with a
77 For example if the used runlist is
78 .Pa /usr/src/test/testcases/sample.run
79 the default output, unless otherwise specified, will be
81 Other tools, known as frontends, can parse the plist output into
82 an easier to read form.
84 The following is a summary of the optional parameters:
85 .Bl -tag -width indent
86 .It Fl o Ar output_plist
87 Specifies the file to which to write the results.
90 will be in plist format.
91 .It Fl t Ar testcase_dir
92 Specifies the directory in which to find the testcases specified in the runlist.
93 .It Fl p Ar prepost_dir
94 Specifies the directory in which to find the pre- and post commands used
96 This argument is only required when the runlist uses custom pre- or post
99 Prints a short synopsis.
102 Testcases are specified one testcase per line, with whitespace separated
104 Empty lines and lines beginning with a
108 Runlist lines are of the following format:
109 .Bd -literal -offset indent
110 .Ic testcase type options Cm arguments ...
115 part needs to be a relative path from the testcase base directory specified
118 argument to the resulting (after building the testcase) testcase executable.
119 The testcase will be executed with the
121 passed as command line arguments to it.
128 .Bl -tag -width indent -offset indent
130 A userland testcase is a normal userland executable that returns a non-zero
131 exit value on test failure.
133 A kernel testcase is run with the kernel test bridge inside the kernel.
135 A buildonly test passes when the build for the given testcase succeeds.
151 .Bl -tag -width indent -offset indent
153 This option does nothing.
154 All default options are applied.
155 .It Ic interpreter Ar command
158 for running the test case instead of calling it directly.
159 This is useful when you have tests that you want to call with a specific shell
162 and there is no shebang in the testcase file, there are no
163 execution permissions and you don't want or cannot modify the testcase.
164 .It Ic make Ar make_command
169 to build the testcase.
171 Sets the return code that will be considered successful.
172 By default 0 is considered success.
173 .It Ic timeout Ar timeout
174 Sets the timeout for the testcase after which the testcase will be aborted to
178 If this option is set, the build stage and cleanup stage of the test case
181 Runs the testcase as the user identified by the given
184 Executes the testcase command with the argument
186 during the pre-run command stage.
188 Executes the testcase command with the argument
190 during the post-run command stage.
192 Executes the command specified by
194 during the pre-run command stage.
195 .It Ic pre Ar postcmd
196 Executes the command specified by
198 during the post-run command stage.
200 .Sh TESTCASE EXECUTION
201 .Bl -enum -width 3n -offset indent
204 to the testcase directory.
205 If it fails, the result will be set to
209 buffer will provide further details.
212 the testcase using the command specified by the
214 option or, if not specified,
218 option was specified.
219 If there is an internal driver error, the result will be set to
221 the next step to be performed will be
225 buffer will provide further details.
226 If no internal error occurs, the
228 will contain the build log.
230 .Tn "RUN PRE COMMAND"
236 If there is an internal driver error, the result will be set to
238 the next step to be performed will be
242 buffer will provide further details.
243 If the pre command has a non-zero exit value, the result will be set to
246 next step to be performed will be
248 In this case and in the case where the command succeeds, the
250 will contain the execution log.
254 .Bl -tag -width 2n -compact
256 testcases will get their result set to
258 at this point, since the build must have succeeded already.
260 testcases will get executed in a separate child process, possibly as a
261 different user, depending on whether the
263 option was specified.
264 The result will be set to
266 if the timeout is reached before the testcase finishes,
268 if the testcase dies because of an unhandled signal (often due to crashing),
270 if the testcase could not be executed,
272 if the testcase completes but returns failure or
274 if the testcase completes and returns success.
276 testcases will be executed in kernel space by loading a given module and
277 running the testcase entry point function.
278 The result will be set to
280 if the testcase could not be executed.
281 Otherwise the result will be set according to the kernel test case to
288 The output will be logged separately for stdout and stderr to the
297 will contain more information.
299 .Tn "RUN POST COMMAND"
305 If there is an internal driver error, the result will be set to
306 .Dv RESULT_POSTFAIL ,
307 the next step to be performed will be
311 buffer will provide further details.
312 If the post command has a non-zero exit value, the result will be set to
315 next step to be performed will be
317 In this case and in the case where the command succeeds, the
319 will contain the execution log.
322 the testcase execution using the command specified by the
324 option or, if not specified,
330 option was specified.
331 If there is an internal driver error the
333 buffer will contain more information.
334 If no internal error occurs, the
336 will contain the cleanup log.
341 is in the Apple plist serialized object format.
342 This format can be easily parsed by using
345 Ruby and Python also have parsers for the plist format.
349 parses the intermediate output plist into a more easily readable format
350 such as plain text or websites.
357 .Sh HOW TO WRITE A TESTCASE
358 A userland testcase is a simple program that prints some relevant
359 information to stdout and stderr, both of which are captured by the test
360 driver, and returns an exit value of 0 if the test passed, or any other
361 non-zero exit value to signal a failure.
362 The exact exit value is recorded by
364 All signals/exceptions not explicitly caught by the testcase will abort
365 the execution of the testcase and the result will be set appropriately and
366 the signal number will be recorded.
368 A kernel testcase is a simple kernel module that defines two methods:
371 method as well as an optional
376 method will be run from a separate kernel thread.
377 The testcase will need to call
379 functions to record output and to notify of testcase completion.
382 manual page for more details.
384 For all testcase types the build stage is common.
385 Every testcase should either have the
387 option set, or have a Makefile or similar in its directory.
390 assumes it is a standard
393 If that is not the case, the
395 option needs to be adjusted accordingly.
396 .Sh GENERAL ADVICE ON WRITING TESTCASES
397 Test only one thing at a time, it is not good practice to test multiple
398 things in the same testcase as it makes it less obvious what's going on.
400 Keep it short, simple and well documented on what the requirements are,
401 what the preconditions need to be, what exactly is being tested, ideally
402 with a reference to a particular bug if that exists, and most importantly
403 what the expected outcomes are.
405 Make sure your testcase doesn't depend on any other being run previously
406 as well as that it won't hinder any other testcase from running.
407 This effectively means that your testcase should make no assumptions as
408 to what has been run previously unless it has a registered pre-command
409 and that the system should be left as found before your testcase.
411 An example runlist can be found under
412 .Pa test/testcases/sample.run .
414 Several example testcases for both userland and kernel are under
415 .Pa test/testcases/sample .