xref: /netbsd-src/share/man/man7/tests.atf.7 (revision 7a91345762ac9492ff9468a4a2e37d1e8925abe0)
1.\"	$NetBSD: tests.atf.7,v 1.8 2023/08/27 15:17:50 rillig Exp $
2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
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 the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
16.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
20.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd July 29, 2015
29.Dt TESTS 7
30.Os
31.Sh NAME
32.Nm tests
33.Nd introduction to the NetBSD test suite
34.Sh DESCRIPTION
35The
36.Nx
37test suite provides a collection of automated tests for two major purposes.
38On the one hand, the test suite aids
39.Em developers
40in catching bugs and regressions in the code
41when they are performing modifications to the source tree.
42On the other hand, the test suite allows
43.Em end users
44(and, in particular, system administrators) to verify that fresh installations
45of the
46.Nx
47operating system behave correctly in their hardware platform and also to ensure
48that the system does not suffer from regressions during regular system
49operation and maintenance.
50.Pp
51The
52.Nx
53tests are implemented using the
54.Em Automated Testing Framework (ATF) ,
55a third-party package shipped with
56.Nx ;
57see
58.Xr atf 7
59for details.
60The
61.Nx
62test suite is distributed as a separate installation set, named
63.Pa tests.tgz ,
64and the test programs are all installed under the
65.Pa /usr/tests
66hierarchy.
67.Pp
68This manual page describes how to execute the test suite and how to configure
69some of its optional features.
70.Ss When to run the tests?
71Before diving into the details of how to run the test suite, here are some
72scenarios in which you should be running them:
73.Bl -bullet -offset indent
74.It
75After a fresh installation of
76.Nx
77to ensure that the system works correctly on your hardware platform.
78.It
79After an upgrade of
80.Nx
81to a different version to ensure that the new code works well on your
82hardware platform and that the upgrade did not introduce regressions in your
83configuration.
84.It
85After performing changes to the source tree to catch any bugs and/or regressions
86introduced by the modifications.
87.It
88Periodically, maybe from a
89.Xr cron 8
90job, to ensure that any changes to the system (such as the installation of
91third-party packages or manual modifications to configuration files) do not
92introduce unexpected failures.
93.El
94.Ss Installing the tests
95If you chose to install the
96.Pa tests.tgz
97distribution set while setting up your
98.Nx
99system, the tests are already available in
100.Pa /usr/tests .
101Otherwise, install the set now by running:
102.Bd -literal -offset indent
103# cd /
104# tar xzpf /path/to/tests.tgz
105.Ed
106.Ss Running the tests
107Use the following commands to run the whole test suite:
108.Bd -literal -offset indent
109$ cd /usr/tests
110$ atf-run | atf-report
111.Ed
112.Pp
113The above will go through all test programs in
114.Pa /usr/tests
115recursively, execute them, and, at the very end, show a report of
116the results of the test suite.
117These results include the count of tests that succeeded (passed), the names of
118the tests that failed, and the count of the tests that were not executed
119(skipped) because the system configuration did not meet their requirements.
120.Pp
121If you are interested in saving the whole output of the test suite execution so
122that you can later investigate failures, use the following idiom instead:
123.Bd -literal -offset indent
124$ cd /usr/tests
125$ atf-run | tee ~/tests.log | atf-report
126.Ed
127.Pp
128The above command will save the raw output of the test suite in
129.Pa ~/tests.log ,
130which you can later inspect manually to look for failures.
131Note that the file contains a copy of the
132.Sq stdout
133and
134.Sq stderr
135of each test case, which becomes valuable during debugging.
136.Pp
137It is also possible to restrict which tests to execute so that only a small
138subsystem is tested; see
139.Xr atf-run 1
140for details.
141Additionally, it is also possible to run the test programs themselves by hand;
142see
143.Xr atf-test-program 1
144for more details, but be aware that you should only be doing this if you are
145debugging failing tests.
146.Ss Test environment considerations
147Tests can be invoked as an unprivileged user, in which case tests that
148require privileges will be skipped.
149If run as root, an unprivileged user will be used for tests that
150do not require privileges.
151For maximal coverage, the standard approach is to invoke tests as root.
152.Pp
153Ideally, tests are self-contained and do not either depend on or
154perturb the host environment, aside from skipping tests when optional
155facilities are not available.
156In reality, tests load and unload modules, and do other things that
157might cause problems.
158While it is not entirely safe to run tests on a multi-user system,
159permanent problems or crashes from doing so are viewed as bugs and
160should be reported.
161.Ss Configuring the tests
162Some test cases in the
163.Nx
164test suite require the administrator to manually set up some configuration
165properties before they can run.
166Unless these properties are defined, the tests that require them will be marked
167as skipped and thus they will not be really executed.
168.Pp
169Each test suite is configured through a separate file that lives under
170.Pa /etc/atf/
171and that carries the name of the test suite.
172Henceforth, to configure the properties that affect the execution of the
173.Nx
174test suite, you need to edit
175.Pa /etc/atf/NetBSD.conf .
176The suite-specific configuration file implicitly depends on
177.Pa /etc/atf/common.conf ,
178which contains properties shared among all test suites.
179These files conform to the configuration file format described in
180.Xr atf-formats 5 .
181.Pp
182The following configuration variables are available in the
183.Nx
184test suite:
185.Bl -tag -width "unprivileged-user"
186.It fstype
187When set to a filesystem type, restrict tests programs from the
188.Pa /usr/tests/fs/vfs/
189tree to only run test cases for the given type.
190.It unprivileged-user
191This variable allows setting an unprivileged user login name to be used by
192tests.
193Defaults to
194.Sq _tests .
195.El
196.Ss What to do if something fails?
197If there is
198.Em any failure
199during the execution of the test suite, please considering reporting it to the
200.Nx
201developers so that the failure can be analyzed and fixed.
202To do so, either send a message to the appropriate mailing list or file a
203problem report.
204For more details please refer to:
205.Bl -bullet -offset indent -compact
206.It
207.Lk https://www.netbsd.org/mailinglists/ "NetBSD mailing lists"
208.It
209.Lk https://www.netbsd.org/support/send-pr.html "NetBSD Problem Reports"
210.El
211.Sh FILES
212.Bl -tag -compact -width etcXatfXNetBSDXconfXX
213.It Pa /etc/atf/NetBSD.conf
214Configuration file for the
215.Nx
216test suite.
217.It Pa /etc/atf/common.conf
218Configuration file for all test suites.
219.It Pa /usr/tests/
220Location of the test suites.
221.El
222.Sh SEE ALSO
223.Xr atf 7
224.Sh HISTORY
225The
226.Nm
227manual page first appeared in
228.Nx 6.0 .
229.Pp
230The ATF testing framework was first distributed with
231.Nx 5.0
232and the collection of test programs in
233.Pa /usr/tests
234has been growing since then.
235.Sh AUTHORS
236.An Julio Merino Aq Mt jmmv@NetBSD.org
237