1.\" $NetBSD: tests.kyua.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 53test suite is distributed as a separate installation set, named 54.Pa tests.tgz , 55and the test programs are all installed under the 56.Pa /usr/tests 57hierarchy. 58.Pp 59This manual page describes how to execute the test suite and how to configure 60some of its optional features. 61.Ss When to run the tests? 62Before diving into the details of how to run the test suite, here are some 63scenarios in which you should be running them: 64.Bl -bullet -offset indent 65.It 66After a fresh installation of 67.Nx 68to ensure that the system works correctly on your hardware platform. 69.It 70After an upgrade of 71.Nx 72to a different version to ensure that the new code works well on your 73hardware platform and that the upgrade did not introduce regressions in your 74configuration. 75.It 76After performing changes to the source tree to catch any bugs and/or regressions 77introduced by the modifications. 78.It 79Periodically, maybe from a 80.Xr cron 8 81job, to ensure that any changes to the system (such as the installation of 82third-party packages or manual modifications to configuration files) do not 83introduce unexpected failures. 84.El 85.Ss Installing the tests 86If you chose to install the 87.Pa tests.tgz 88distribution set while setting up your 89.Nx 90system, the tests are already available in 91.Pa /usr/tests . 92Otherwise, install the set now by running: 93.Bd -literal -offset indent 94# cd / 95# tar xzpf /path/to/tests.tgz 96.Ed 97.Ss Running the tests 98Use the following command to run the whole test suite: 99.Bd -literal -offset indent 100$ kyua test -k /usr/tests/Kyuafile 101.Ed 102.Pp 103The above will go through all test programs in 104.Pa /usr/tests 105recursively, execute them, store their results and debugging data in Kyua 106database (by default in 107.Pa ~/.kyua/store.db ) , 108and print a summary of the results. 109This summary includes a brief count of all total tests run and how many of 110them failed. 111.Pp 112It is possible to restrict which tests to run by providing their names in 113the command line. 114For example, this would execute the tests for the 115.Xr cp 1 116and 117.Xr cut 1 118utilities: 119.Bd -literal -offset indent 120$ kyua test -k /usr/tests/Kyuafile bin/cp usr.bin/cut 121.Ed 122.Ss Obtaining reports of the tests execution 123Additional information of the results of the execution can be later extracted 124from the database by using the various reporting commands of Kyua. 125For example, the following would extract a plain-text report of the executed 126tests and show which ones failed: 127.Bd -literal -offset indent 128$ kyua report 129.Ed 130.Pp 131This other example would generate an HTML report ready to be published on a 132web server, possibly the built-in 133.Xr httpd 8 : 134.Bd -literal -offset indent 135$ kyua report-html --output ~/public_html/tests 136.Ed 137.Pp 138For further details on the command-line interface of Kyua, please refer 139to its manual page 140.Xr kyua 1 . 141.Ss Test environment considerations 142Tests can be invoked as an unprivileged user, in which case tests that 143require privileges will be skipped. 144If run as root, an unprivileged user will be used for tests that 145do not require privileges. 146For maximal coverage, the standard approach is to invoke tests as root. 147.Pp 148Ideally, tests are self-contained and do not either depend on or 149perturb the host environment, aside from skipping tests when optional 150facilities are not available. 151In reality, tests load and unload modules, and do other things that 152might cause problems. 153While it is not entirely safe to run tests on a multi-user system, 154permanent problems or crashes from doing so are viewed as bugs and 155should be reported. 156.Ss Configuring the tests 157Some test cases in the 158.Nx 159test suite require the administrator to manually set up some configuration 160properties before they can run. 161Unless these properties are defined, the tests that require them will be marked 162as skipped and thus they will not be really executed. 163.Pp 164Test suites are configured by defining the values to their configuration 165variables in 166.Pa /etc/kyua/kyua.conf . 167The format of this file is detailed in 168.Xr kyua.conf 5 . 169.Pp 170The following configuration variables are available in the 171.Nx 172test suite: 173.Bl -tag -width "fstype" 174.It fstype 175When set to a filesystem type, restrict tests programs from the 176.Pa /usr/tests/fs/vfs/ . 177.El 178.Ss What to do if something fails? 179If there is 180.Em any failure 181during the execution of the test suite, please considering reporting it to the 182.Nx 183developers so that the failure can be analyzed and fixed. 184To do so, either send a message to the appropriate mailing list or file a 185problem report. 186For more details please refer to: 187.Bl -bullet -offset indent -compact 188.It 189.Lk https://www.netbsd.org/mailinglists/ "NetBSD mailing lists" 190.It 191.Lk https://www.netbsd.org/support/send-pr.html "NetBSD Problem Reports" 192.El 193.Sh FILES 194.Bl -tag -compact -width etcXatfXNetBSDXconfXX 195.It Pa /etc/kyua/kyua.conf 196System-wide configuration file for 197.Xr kyua 1 . 198.It Pa ~/.kyua/kyua.conf 199User-specific configuration file for 200.Xr kyua 1 ; 201overrides the system file. 202.It Pa ~/.kyua/store.db 203Default database used by Kyua to maintain the data of the executed tests. 204.It Pa /usr/tests/ 205Location of the 206.Nx 207test suite. 208.It Pa /usr/tests/Kyuafile 209Top-level test suite definition file. 210.El 211.Sh SEE ALSO 212.Xr kyua 1 , 213.Xr kyua-report 1 , 214.Xr kyua-test 1 215.Sh HISTORY 216The collection of test programs in 217.Pa /usr/tests 218first appeared in 219.Nx 5.0 220and has been growing since then. 221.Pp 222The 223.Nm 224manual page first appeared in 225.Nx 6.0 226and was updated in 227.Nx 7.0 228to describe the execution of the tests with Kyua rather than with ATF. 229.Pp 230The ATF testing framework was first distributed with 231.Nx 5.0 232and the runtime tools of this framework are being phased out in 233.Nx 7.0 . 234Note that the 235.Em libraries 236that ship with ATF are still in active use and are not deprecated. 237.Pp 238The Kyua testing toolkit was first distributed with 239.Nx 7.0 . 240The 241.Xr atf-run 1 242and 243.Xr atf-report 1 244tools were replaced as part of this import to be backwards-compatibility 245wrappers around 246.Xr kyua 1 . 247.Sh AUTHORS 248.An Julio Merino Aq Mt jmmv@NetBSD.org 249