xref: /freebsd/sys/contrib/openzfs/man/man1/test-runner.1 (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\" Copyright (c) 2012 by Delphix. All rights reserved.
12.\"
13.Dd May 26, 2021
14.Dt RUN 1
15.Os
16.
17.Sh NAME
18.Nm run
19.Nd find, execute, and log the results of tests
20.Sh SYNOPSIS
21.Nm
22.Op Fl dgq
23.Op Fl o Ar outputdir
24.Op Fl pP Ar script
25.Op Fl t seconds
26.Op Fl uxX Ar username
27.Ar pathname Ns No …
28.Pp
29.Nm
30.Fl w Ar runfile
31.Op Fl gq
32.Op Fl o Ar outputdir
33.Op Fl pP Ar script
34.Op Fl t seconds
35.Op Fl uxX Ar username
36.Ar pathname Ns No …
37.Pp
38.Nm
39.Fl c Ar runfile
40.Op Fl dq
41.Pp
42.Nm
43.Op Fl h
44.
45.Sh DESCRIPTION
46.Nm
47command has three basic modes of operation.
48With neither
49.Fl c
50nor
51.Fl w ,
52.Nm
53processes the arguments provided on
54the command line, adding them to the list for this run.
55If a specified
56.Ar pathname
57is an executable file, it is added as a test.
58If a specified
59.Ar pathname
60is a directory, the behavior depends upon the presence of
61.Fl g .
62If
63.Fl g
64is specified, the directory is treated as a test group.
65See the section on
66.Sy Test Groups
67below.
68Without
69.Fl g ,
70.Nm
71simply descends into the directory looking for executable files.
72The tests are then executed, and the results are logged.
73.Pp
74With
75.Fl w ,
76.Nm
77finds tests in the manner described above.
78Rather than executing the tests and logging the results, the test configuration
79is stored in a
80.Ar runfile ,
81which can be used in future invocations, or edited
82to modify which tests are executed and which options are applied.
83Options included on the command line with
84.Fl w
85become defaults in the
86.Ar runfile .
87.Pp
88With
89.Fl c ,
90.Nm
91parses a
92.Ar runfile ,
93which can specify a series of tests and test groups to be executed.
94The tests are then executed, and the results are logged.
95.
96.Ss Test Groups
97A test group is comprised of a set of executable files, all of which exist in
98one directory.
99The options specified on the command line or in a
100.Ar runfile
101apply to individual tests in the group.
102The exception is options pertaining to pre and post scripts, which act on all tests as a group.
103Rather than running before and after each test,
104these scripts are run only once each at the start and end of the test group.
105.Ss Test Execution
106The specified tests run serially, and are typically assigned results according
107to exit values.
108Tests that exit zero and non-zero are marked
109.Sy PASS
110and
111.Sy FAIL ,
112respectively.
113When a pre script fails for a test group, only the post script is executed,
114and the remaining tests are marked
115.Sy SKIPPED .
116Any test that exceeds
117its
118.Ar timeout
119is terminated, and marked
120.Sy KILLED .
121.Pp
122By default, tests are executed with the credentials of the
123.Nm
124script.
125Executing tests with other credentials is done via
126.Xr sudo 1m ,
127which must
128be configured to allow execution without prompting for a password.
129Environment variables from the calling shell are available to individual tests.
130During test execution, the working directory is changed to
131.Ar outputdir .
132.
133.Ss Output Logging
134By default,
135.Nm
136will print one line on standard output at the conclusion
137of each test indicating the test name, result and elapsed time.
138Additionally, for each invocation of
139.Nm ,
140a directory is created using the ISO 8601 date format.
141Within this directory is a file named
142.Sy log
143containing all the
144test output with timestamps, and a directory for each test.
145Within the test directories, there is one file each for standard output,
146standard error and merged output.
147The default location for the
148.Ar outputdir
149is
150.Pa /var/tmp/test_results .
151.Ss "Runfiles"
152The
153.Ar runfile
154is an INI-style configuration file that describes a test run.
155The file has one section named
156.Sy DEFAULT ,
157which contains configuration option
158names and their values in
159.Sy name No = Ar value
160format.
161The values in this section apply to all the subsequent sections,
162unless they are also specified there, in which case the default is overridden.
163The remaining section names are the absolute pathnames of files and directories,
164describing tests and test groups respectively.
165The legal option names are:
166.Bl -tag -width "tests = ['filename', …]"
167.It Sy outputdir No = Ar pathname
168The name of the directory that holds test logs.
169.It Sy pre No = Ar script
170Run
171.Ar script
172prior to the test or test group.
173.It Sy pre_user No = Ar username
174Execute the pre script as
175.Ar username .
176.It Sy post No = Ar script
177Run
178.Ar script
179after the test or test group.
180.It Sy post_user No = Ar username
181Execute the post script as
182.Ar username .
183.It Sy quiet No = Sy True Ns | Ns Sy False
184If
185.Sy True ,
186only the results summary is printed to standard out.
187.It Sy tests No = [ Ns Ar 'filename' , No … ]
188Specify a list of
189.Ar filenames
190for this test group.
191Only the basename of the absolute path is required.
192This option is only valid for test groups, and each
193.Ar filename
194must be single quoted.
195.It Sy timeout No = Ar n
196A timeout value of
197.Ar n
198seconds.
199.It Sy user No = Ar username
200Execute the test or test group as
201.Ar username .
202.El
203.
204.Sh OPTIONS
205.Bl -tag -width "-o outputdir"
206.It Fl c Ar runfile
207Specify a
208.Ar runfile
209to be consumed by the run command.
210.It Fl d
211Dry run mode.
212Execute no tests, but print a description of each test that would have been run.
213.It Fl m
214Enable kmemleak reporting (Linux only)
215.It Fl g
216Create test groups from any directories found while searching for tests.
217.It Fl o Ar outputdir
218Specify the directory in which to write test results.
219.It Fl p Ar script
220Run
221.Ar script
222prior to any test or test group.
223.It Fl P Ar script
224Run
225.Ar script
226after any test or test group.
227.It Fl q
228Print only the results summary to the standard output.
229.It Fl s Ar script
230Run
231.Ar script
232as a failsafe after any test is killed.
233.It Fl S Ar username
234Execute the failsafe script as
235.Ar username .
236.It Fl t Ar n
237Specify a timeout value of
238.Ar n
239seconds per test.
240.It Fl u Ar username
241Execute tests or test groups as
242.Ar username .
243.It Fl w Ar runfile
244Specify the name of the
245.Ar runfile
246to create.
247.It Fl x Ar username
248Execute the pre script as
249.Ar username .
250.It Fl X Ar username
251Execute the post script as
252.Ar username .
253.El
254.
255.Sh EXAMPLES
256.Bl -tag -width "-h"
257.It Sy Example 1 : No Running ad-hoc tests.
258This example demonstrates the simplest invocation of
259.Nm .
260.Bd -literal
261.No % Nm run Ar my-tests
262Test: /home/jkennedy/my-tests/test-01                    [00:02] [PASS]
263Test: /home/jkennedy/my-tests/test-02                    [00:04] [PASS]
264Test: /home/jkennedy/my-tests/test-03                    [00:01] [PASS]
265
266Results Summary
267PASS       3
268
269Running Time:   00:00:07
270Percent passed: 100.0%
271Log directory:  /var/tmp/test_results/20120923T180654
272.Ed
273.It Sy Example 2 : No Creating a Ar runfile No for future use.
274This example demonstrates creating a
275.Ar runfile
276with non-default options.
277.Bd -literal
278.No % Nm run Fl p Ar setup Fl x Ar root Fl g Fl w Ar new-tests.run Ar new-tests
279.No % Nm cat Pa new-tests.run
280[DEFAULT]
281pre = setup
282post_user =
283quiet = False
284user =
285timeout = 60
286post =
287pre_user = root
288outputdir = /var/tmp/test_results
289
290[/home/jkennedy/new-tests]
291tests = ['test-01', 'test-02', 'test-03']
292.Ed
293.El
294.
295.Sh SEE ALSO
296.Xr sudo 1m
297