1*5277e1dbSop.\" $OpenBSD: bsd.regress.mk.5,v 1.26 2023/11/13 10:11:41 op Exp $ 2db0c11e5Savsm.\" 3db0c11e5Savsm.\" Copyright (c) 2002 Anil Madhavapeddy 4db0c11e5Savsm.\" Copyright (c) 2000 Marc Espie 5db0c11e5Savsm.\" 6db0c11e5Savsm.\" All rights reserved. 7db0c11e5Savsm.\" 8db0c11e5Savsm.\" Redistribution and use in source and binary forms, with or without 9db0c11e5Savsm.\" modification, are permitted provided that the following conditions 10db0c11e5Savsm.\" are met: 11db0c11e5Savsm.\" 1. Redistributions of source code must retain the above copyright 12db0c11e5Savsm.\" notice, this list of conditions and the following disclaimer. 13db0c11e5Savsm.\" 2. Redistributions in binary form must reproduce the above copyright 14db0c11e5Savsm.\" notice, this list of conditions and the following disclaimer in the 15db0c11e5Savsm.\" documentation and/or other materials provided with the distribution. 16db0c11e5Savsm.\" 17db0c11e5Savsm.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 18db0c11e5Savsm.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19db0c11e5Savsm.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20db0c11e5Savsm.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 21db0c11e5Savsm.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22db0c11e5Savsm.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23db0c11e5Savsm.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24db0c11e5Savsm.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25db0c11e5Savsm.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26db0c11e5Savsm.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27db0c11e5Savsm.\" 28*5277e1dbSop.Dd $Mdocdate: November 13 2023 $ 29db0c11e5Savsm.Dt BSD.REGRESS.MK 5 30db0c11e5Savsm.Os 31db0c11e5Savsm.Sh NAME 32db0c11e5Savsm.Nm bsd.regress.mk 33db0c11e5Savsm.Nd regression test master Makefile fragment 34db0c11e5Savsm.Sh SYNOPSIS 35db0c11e5Savsm.Fd .include <bsd.regress.mk> 36db0c11e5Savsm.Sh DESCRIPTION 37db0c11e5Savsm.Nm 38db0c11e5Savsmholds the standard routines used by the source regression tests. 39db0c11e5SavsmSome variables and targets are for its internal use only. 40db0c11e5SavsmThe rest are documented here. 41db0c11e5Savsm.Pp 42db0c11e5SavsmSince this file also includes 43db0c11e5Savsm.Nm bsd.prog.mk , 44db0c11e5Savsmall of the usual 45db0c11e5Savsm.Ox 46db0c11e5SavsmMakefile variables may be used to build the regression 47db0c11e5Savsmtest programs. 48db0c11e5Savsm.Sh TARGETS 49db0c11e5Savsm.Bl -tag -width regress 50919882e8Sschwarze.It Cm depend 51db0c11e5SavsmBuild any dependencies required to carry out the current set 52db0c11e5Savsmof regression tests. 53919882e8Sschwarze.It Cm regress 54*5277e1dbSopExecutes the regression targets defined in the Makefile. 55*5277e1dbSopIf a tests fails, the line 5604bb0bceSbluhm.Qq FAILED 5704bb0bceSbluhmis printed to the standard output. 58*5277e1dbSopBy default, execution stops after the first test failure and 5904bb0bceSbluhm.Sy make Cm regress 60*5277e1dbSopexits with a non-zero status. 61919882e8Sschwarze.It Cm run-regress-* 6224f769bfSmpechRuns an individual regression test. 6324f769bfSmpechIf the exit status of the program indicates an error or timeout, 6424f769bfSmpechthen a failure is logged, otherwise the test is marked as a success. 6524f769bfSmpech.El 66db0c11e5Savsm.Sh VARIABLES 67919882e8Sschwarze.Bl -tag -width Ds 685b0ae2d5Sbluhm.It Ev REGRESS_CLEANUP 695b0ae2d5SbluhmIf this variable is set, it contains a target that is executed 705b0ae2d5Sbluhmafter all regress targets. 71e8e70738Sespie.It Ev REGRESS_EXPECTED_FAILURES 72e8e70738SespieTargets which are expected to fail. 73e8e70738SespieSpecifically: sometimes tests are added for features that should be 74e8e70738Sespiesupported eventually, but are somewhat complicated to fix right away. 75f4045754Shalex.It Ev REGRESS_FAIL_EARLY 76f4045754ShalexIf this variable is set to anything but 77f4045754Shalex.Dq no , 78f4045754Shalexthe 79919882e8Sschwarze.Cm regress 80f4045754Shalextarget will abort as soon as a test fails. 81b67a3bf3SclaudioDefaults to 82b67a3bf3Sclaudio.Dq yes 83b67a3bf3Sclaudiounless 84b67a3bf3Sclaudio.Ev REGRESS_LOG 85b67a3bf3Sclaudiois set. 86e4219786Savsm.It Ev REGRESS_LOG 87db0c11e5SavsmPoints to the fully-qualified path of a file to which regression 8824f769bfSmpechresults are appended. 8924f769bfSmpechDefaults to 9024f769bfSmpech.Pa /dev/null . 91b67a3bf3SclaudioIf set to any other path, 92b67a3bf3Sclaudio.Ev REGRESS_FAIL_EARLY 93b67a3bf3Sclaudiodefaults to 94b67a3bf3Sclaudio.Dq no . 95e4219786Savsm.It Ev REGRESS_ROOT_TARGETS 9624f769bfSmpechTargets for which root access is required to run the test. 9724f769bfSmpechThe 98db0c11e5Savsm.Ev SUDO 99c01fff2cSespievariable should be used in the test parts that require root. 10024f769bfSmpechSee also 101db0c11e5Savsm.Ev SUDO . 1025b0ae2d5Sbluhm.It Ev REGRESS_SETUP 1035b0ae2d5SbluhmIf this variable is set, it contains a target that is executed 10422231771Sbluhmbefore each regress target. 10522231771SbluhmRegress targets depend on this one to enforce setup. 10622231771Sbluhm.It Ev REGRESS_SETUP_ONCE 10722231771SbluhmIf this variable is set, it contains a target that is executed 10822231771Sbluhmonce before all regress targets. 10922231771SbluhmRegress targets depend on a stamp file generated during setup. 110e4219786Savsm.It Ev REGRESS_SKIP_SLOW 111e4219786SavsmIf this variable is not empty, skip over all the regression 112e4219786Savsmtests which have been marked as being 'slow' using the 113e4219786Savsm.Ev REGRESS_SLOW_TARGETS 114db0c11e5Savsmvariable. 11587d30890Santon.It Ev REGRESS_SKIP_TARGETS 11687d30890SantonTargets which are unconditionally skipped. 117e4219786Savsm.It Ev REGRESS_SLOW_TARGETS 11824f769bfSmpechTargets which are defined as 'slow'. 11924f769bfSmpechAll of these tests can be skipped by setting the 120e4219786Savsm.Ev REGRESS_SKIP_SLOW 121db0c11e5Savsmvariable. 122e4219786Savsm.It Ev REGRESS_TARGETS 123db0c11e5SavsmTargets which are invoked to run the set of regression tests 12424f769bfSmpechfor this Makefile. 12524f769bfSmpechDefaults to 126919882e8Sschwarze.Cm run-regress-${PROG} . 127db0c11e5Savsm.It Ev SUDO 128a674281fSjmcLocation of a command used to switch to root for certain 129db0c11e5Savsmtest targets which require it. 130a674281fSjmcSee 131a674281fSjmc.Xr doas 1 . 13224f769bfSmpech.El 133d0d2010aSbluhm.Pp 134d0d2010aSbluhmSome variables are intended to be set at runtime in the environment 135d0d2010aSbluhmor in 136d0d2010aSbluhm.Xr mk.conf 5 , 137d0d2010aSbluhmbut not in the regress Makefile itself. 13804bb0bceSbluhm.Sh GUIDELINES 139455f06dbSjmcIf an individual test passes, 14004bb0bceSbluhm.Sy make Ar testname 14104bb0bceSbluhmshould return with an exit status of 0. 14204bb0bceSbluhmIf it fails, it should return with a non-zero exit status. 14304bb0bceSbluhm.Pp 14404bb0bceSbluhmIf a test cannot be executed because a package is not installed or 14504bb0bceSbluhmsome environment variable is not set, 14604bb0bceSbluhm.Sy make Ar testname 14704bb0bceSbluhmshould print 14804bb0bceSbluhm.Qq SKIPPED 14904bb0bceSbluhmto stdout and exit with status 0. 15004bb0bceSbluhmTo skip everything, implement the 15104bb0bceSbluhm.Cm regress 15204bb0bceSbluhmtarget with a command that prints 15304bb0bceSbluhm.Qq SKIPPED . 15404bb0bceSbluhm.Pp 155d0d2010aSbluhmSome tests may require a special setup on the test machine that has 156d0d2010aSbluhmto be done manually before testing. 157d0d2010aSbluhmThis requirement has to be documented in the Makefile or in a 158d0d2010aSbluhm.Pa README 159d0d2010aSbluhmfile. 160d0d2010aSbluhmThe test should find out whether the setup exists before running 161d0d2010aSbluhmand print 162d0d2010aSbluhm.Qq SKIPPED 163d0d2010aSbluhmand exit if it is missing. 164d0d2010aSbluhm.Pp 16504bb0bceSbluhmTests should not fail because an intended feature has not been 16604bb0bceSbluhmimplemented yet. 16704bb0bceSbluhmTo avoid such false failures, a test should show the reason, print 16804bb0bceSbluhm.Qq DISABLED 16904bb0bceSbluhmto stdout and exit with status 0. 17004bb0bceSbluhm.Pp 17104bb0bceSbluhmTests must be able to run with an 17204bb0bceSbluhm.Pa obj 17304bb0bceSbluhmdirectory. 17404bb0bceSbluhmIn case the test is not linked to the build or the tester forgot 17504bb0bceSbluhmto run 17604bb0bceSbluhm.Sy make Cm obj 17704bb0bceSbluhmbefore, this directory or symlink may not exist. 17804bb0bceSbluhmThen the test should run anyway. 17904bb0bceSbluhm.Pp 1807d096061SrobTests are executed with 18104bb0bceSbluhm.Sy make Cm regress , 18204bb0bceSbluhmbut running 18304bb0bceSbluhm.Sy make Cm all 18404bb0bceSbluhmor 18504bb0bceSbluhm.Sy make 18604bb0bceSbluhmshould have the same effect. 187d0d2010aSbluhmTests must be runnable by root, and may also succeed when run as a 188d0d2010aSbluhmregular user. 1899a83a2a7SjmcTests must not assume they have a controlling tty, 1909a83a2a7Sjmcto allow them to be run by 1919a83a2a7Sjmc.Xr cron 8 . 192d0d2010aSbluhmAn individual regress test may create a pseudo tty if it needs one. 19304bb0bceSbluhm.Pp 19404bb0bceSbluhmTests should use the binaries installed and the kernel running on 19504bb0bceSbluhmthe local system. 19604bb0bceSbluhmThey may use environment variables to test alternative binaries or 19704bb0bceSbluhmremote kernels running on other machines. 19804bb0bceSbluhmIn some cases a test may need binaries or libraries or object files 19904bb0bceSbluhmto be present in 20004bb0bceSbluhm.Pa /usr/obj/ 20104bb0bceSbluhmthat exist only after 20204bb0bceSbluhm.Sy make Cm build 20304bb0bceSbluhmwas run in 20404bb0bceSbluhm.Pa /usr/src/ . 20504bb0bceSbluhmThe test must not assume that they have already been built, but 20604bb0bceSbluhmshould run 20704bb0bceSbluhm.Sy make 20804bb0bceSbluhmin the appropriate source directory as a dependency. 2091e1db3e5SbluhmFor missing generated source or header files a target called 2101e1db3e5Sbluhm.Sy make Cm generated 2111e1db3e5Sbluhmis common. 21204bb0bceSbluhmThe 21304bb0bceSbluhm.Pa /usr/src/ 21404bb0bceSbluhmtree can be found with a relative path or with the 21504bb0bceSbluhm.Ev BSDSRCDIR 21604bb0bceSbluhmvariable. 217f45a9042Sjasper.Pp 218f45a9042SjasperTests should generally not set or modify 219f45a9042Sjasper.Ev MALLOC_OPTIONS 220f45a9042Sjasperunless it is testing specific behaviour that depends on a particular 221f45a9042Sjasperflag or combination of flags. 22241ce3b17SnaddyWhen running tests, the appropriate sysctl 223f45a9042Sjasper.Pq vm.malloc_conf 224f45a9042Sjaspercould be used instead. 2253b1d4ce7Sjmc.Sh SEE ALSO 2263b1d4ce7Sjmc.Xr bsd.port.mk 5 227db0c11e5Savsm.Sh HISTORY 228db0c11e5SavsmThe regression system originally came from 229db0c11e5Savsm.Nx , 230db0c11e5Savsmwith many tests added by 231db0c11e5Savsm.Ox 232db0c11e5Savsmsince. 233db0c11e5SavsmThe current Makefile framework was written by Artur Grabowski 234db0c11e5Savsmand Marc Espie for 235db0c11e5Savsm.Ox 3.1 . 236