1.\" $OpenBSD: bsd.regress.mk.5,v 1.22 2021/09/02 07:14:15 jasper Exp $ 2.\" 3.\" Copyright (c) 2002 Anil Madhavapeddy 4.\" Copyright (c) 2000 Marc Espie 5.\" 6.\" All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27.\" 28.Dd $Mdocdate: September 2 2021 $ 29.Dt BSD.REGRESS.MK 5 30.Os 31.Sh NAME 32.Nm bsd.regress.mk 33.Nd regression test master Makefile fragment 34.Sh SYNOPSIS 35.Fd .include <bsd.regress.mk> 36.Sh DESCRIPTION 37.Nm 38holds the standard routines used by the source regression tests. 39Some variables and targets are for its internal use only. 40The rest are documented here. 41.Pp 42Since this file also includes 43.Nm bsd.prog.mk , 44all of the usual 45.Ox 46Makefile variables may be used to build the regression 47test programs. 48.Sh TARGETS 49.Bl -tag -width regress 50.It Cm depend 51Build any dependencies required to carry out the current set 52of regression tests. 53.It Cm regress 54Executes all of the regression targets defined in the Makefile. 55If one of the tests fails, the line 56.Qq FAILED 57is printed to the standard output. 58By default, execution continues with the next test and, after running 59all the tests, 60.Sy make Cm regress 61exits with an exit status of 0 even if some of the tests failed. 62.It Cm run-regress-* 63Runs an individual regression test. 64If the exit status of the program indicates an error or timeout, 65then a failure is logged, otherwise the test is marked as a success. 66.El 67.Sh VARIABLES 68.Bl -tag -width Ds 69.It Ev REGRESS_CLEANUP 70If this variable is set, it contains a target that is executed 71after all regress targets. 72.It Ev REGRESS_EXPECTED_FAILURES 73Targets which are expected to fail. 74Specifically: sometimes tests are added for features that should be 75supported eventually, but are somewhat complicated to fix right away. 76.It Ev REGRESS_FAIL_EARLY 77If this variable is set to anything but 78.Dq no , 79the 80.Cm regress 81target will abort as soon as a test fails. 82.It Ev REGRESS_LOG 83Points to the fully-qualified path of a file to which regression 84results are appended. 85Defaults to 86.Pa /dev/null . 87.It Ev REGRESS_ROOT_TARGETS 88Targets for which root access is required to run the test. 89The 90.Ev SUDO 91variable should be used in the test parts that require root. 92See also 93.Ev SUDO . 94.It Ev REGRESS_SETUP 95If this variable is set, it contains a target that is executed 96before each regress target. 97Regress targets depend on this one to enforce setup. 98.It Ev REGRESS_SETUP_ONCE 99If this variable is set, it contains a target that is executed 100once before all regress targets. 101Regress targets depend on a stamp file generated during setup. 102.It Ev REGRESS_SKIP_SLOW 103If this variable is not empty, skip over all the regression 104tests which have been marked as being 'slow' using the 105.Ev REGRESS_SLOW_TARGETS 106variable. 107.It Ev REGRESS_SKIP_TARGETS 108Targets which are unconditionally skipped. 109.It Ev REGRESS_SLOW_TARGETS 110Targets which are defined as 'slow'. 111All of these tests can be skipped by setting the 112.Ev REGRESS_SKIP_SLOW 113variable. 114.It Ev REGRESS_TARGETS 115Targets which are invoked to run the set of regression tests 116for this Makefile. 117Defaults to 118.Cm run-regress-${PROG} . 119.It Ev SUDO 120Location of a command used to switch to root for certain 121test targets which require it. 122See 123.Xr doas 1 . 124.El 125.Pp 126Some variables are intended to be set at runtime in the environment 127or in 128.Xr mk.conf 5 , 129but not in the regress Makefile itself. 130.Sh GUIDELINES 131If an individual test passes, 132.Sy make Ar testname 133should return with an exit status of 0. 134If it fails, it should return with a non-zero exit status. 135.Pp 136If a test cannot be executed because a package is not installed or 137some environment variable is not set, 138.Sy make Ar testname 139should print 140.Qq SKIPPED 141to stdout and exit with status 0. 142To skip everything, implement the 143.Cm regress 144target with a command that prints 145.Qq SKIPPED . 146.Pp 147Some tests may require a special setup on the test machine that has 148to be done manually before testing. 149This requirement has to be documented in the Makefile or in a 150.Pa README 151file. 152The test should find out whether the setup exists before running 153and print 154.Qq SKIPPED 155and exit if it is missing. 156.Pp 157Tests should not fail because an intended feature has not been 158implemented yet. 159To avoid such false failures, a test should show the reason, print 160.Qq DISABLED 161to stdout and exit with status 0. 162.Pp 163Tests must be able to run with an 164.Pa obj 165directory. 166In case the test is not linked to the build or the tester forgot 167to run 168.Sy make Cm obj 169before, this directory or symlink may not exist. 170Then the test should run anyway. 171.Pp 172Tests are executed with 173.Sy make Cm regress , 174but running 175.Sy make Cm all 176or 177.Sy make 178should have the same effect. 179Tests must be runnable by root, and may also succeed when run as a 180regular user. 181Tests must not assume they have a controlling tty, 182to allow them to be run by 183.Xr cron 8 . 184An individual regress test may create a pseudo tty if it needs one. 185.Pp 186Tests should use the binaries installed and the kernel running on 187the local system. 188They may use environment variables to test alternative binaries or 189remote kernels running on other machines. 190In some cases a test may need binaries or libraries or object files 191to be present in 192.Pa /usr/obj/ 193that exist only after 194.Sy make Cm build 195was run in 196.Pa /usr/src/ . 197The test must not assume that they have already been built, but 198should run 199.Sy make 200in the appropriate source directory as a dependency. 201For missing generated source or header files a target called 202.Sy make Cm generated 203is common. 204The 205.Pa /usr/src/ 206tree can be found with a relative path or with the 207.Ev BSDSRCDIR 208variable. 209.Pp 210Tests should generally not set or modify 211.Ev MALLOC_OPTIONS 212unless it is testing specific behaviour that depends on a particular 213flag or combination of flags. 214When running tests the approciate sysctl 215.Pq vm.malloc_conf 216could be used instead. 217.Sh SEE ALSO 218.Xr bsd.port.mk 5 219.Sh HISTORY 220The regression system originally came from 221.Nx , 222with many tests added by 223.Ox 224since. 225The current Makefile framework was written by Artur Grabowski 226and Marc Espie for 227.Ox 3.1 . 228