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 103tests as a group. 104Rather than running before and after each test, 105these scripts are run only once each at the start and end of the test group. 106.Ss Test Execution 107The specified tests run serially, and are typically assigned results according 108to exit values. 109Tests that exit zero and non-zero are marked 110.Sy PASS 111and 112.Sy FAIL , 113respectively. 114When a pre script fails for a test group, only the post script is executed, 115and the remaining tests are marked 116.Sy SKIPPED . 117Any test that exceeds 118its 119.Ar timeout 120is terminated, and marked 121.Sy KILLED . 122.Pp 123By default, tests are executed with the credentials of the 124.Nm 125script. 126Executing tests with other credentials is done via 127.Xr sudo 1m , 128which must 129be configured to allow execution without prompting for a password. 130Environment variables from the calling shell are available to individual tests. 131During test execution, the working directory is changed to 132.Ar outputdir . 133. 134.Ss Output Logging 135By default, 136.Nm 137will print one line on standard output at the conclusion 138of each test indicating the test name, result and elapsed time. 139Additionally, for each invocation of 140.Nm , 141a directory is created using the ISO 8601 date format. 142Within this directory is a file named 143.Sy log 144containing all the 145test output with timestamps, and a directory for each test. 146Within the test directories, there is one file each for standard output, 147standard error and merged output. 148The default location for the 149.Ar outputdir 150is 151.Pa /var/tmp/test_results . 152.Ss "Runfiles" 153The 154.Ar runfile 155is an INI-style configuration file that describes a test run. 156The file has one section named 157.Sy DEFAULT , 158which contains configuration option 159names and their values in 160.Sy name No = Ar value 161format. 162The values in this section apply to all the subsequent sections, 163unless they are also specified there, in which case the default is overridden. 164The remaining section names are the absolute pathnames of files and directories, 165describing tests and test groups respectively. 166The legal option names are: 167.Bl -tag -width "tests = ['filename', …]" 168.It Sy outputdir No = Ar pathname 169The name of the directory that holds test logs. 170.It Sy pre No = Ar script 171Run 172.Ar script 173prior to the test or test group. 174.It Sy pre_user No = Ar username 175Execute the pre script as 176.Ar username . 177.It Sy post No = Ar script 178Run 179.Ar script 180after the test or test group. 181.It Sy post_user No = Ar username 182Execute the post script as 183.Ar username . 184.It Sy quiet No = Sy True Ns | Ns Sy False 185If 186.Sy True , 187only the results summary is printed to standard out. 188.It Sy tests No = [ Ns Ar 'filename' , No … ] 189Specify a list of 190.Ar filenames 191for this test group. 192Only the basename of the absolute path is required. 193This option is only valid for test groups, and each 194.Ar filename 195must be single quoted. 196.It Sy timeout No = Ar n 197A timeout value of 198.Ar n 199seconds. 200.It Sy user No = Ar username 201Execute the test or test group as 202.Ar username . 203.El 204. 205.Sh OPTIONS 206.Bl -tag -width "-o outputdir" 207.It Fl c Ar runfile 208Specify a 209.Ar runfile 210to be consumed by the run command. 211.It Fl d 212Dry run mode. 213Execute no tests, but print a description of each test that would have been run. 214.It Fl m 215Enable kmemleak reporting (Linux only) 216.It Fl g 217Create test groups from any directories found while searching for tests. 218.It Fl o Ar outputdir 219Specify the directory in which to write test results. 220.It Fl p Ar script 221Run 222.Ar script 223prior to any test or test group. 224.It Fl P Ar script 225Run 226.Ar script 227after any test or test group. 228.It Fl q 229Print only the results summary to the standard output. 230.It Fl s Ar script 231Run 232.Ar script 233as a failsafe after any test is killed. 234.It Fl S Ar username 235Execute the failsafe script as 236.Ar username . 237.It Fl t Ar n 238Specify a timeout value of 239.Ar n 240seconds per test. 241.It Fl u Ar username 242Execute tests or test groups as 243.Ar username . 244.It Fl w Ar runfile 245Specify the name of the 246.Ar runfile 247to create. 248.It Fl x Ar username 249Execute the pre script as 250.Ar username . 251.It Fl X Ar username 252Execute the post script as 253.Ar username . 254.El 255. 256.Sh EXAMPLES 257.Bl -tag -width "-h" 258.It Sy Example 1 : No Running ad-hoc tests . 259This example demonstrates the simplest invocation of 260.Nm . 261.Bd -literal 262.No % Nm run Ar my-tests 263Test: /home/jkennedy/my-tests/test-01 [00:02] [PASS] 264Test: /home/jkennedy/my-tests/test-02 [00:04] [PASS] 265Test: /home/jkennedy/my-tests/test-03 [00:01] [PASS] 266 267Results Summary 268PASS 3 269 270Running Time: 00:00:07 271Percent passed: 100.0% 272Log directory: /var/tmp/test_results/20120923T180654 273.Ed 274.It Sy Example 2 : No Creating a Ar runfile No for future use . 275This example demonstrates creating a 276.Ar runfile 277with non-default options. 278.Bd -literal 279.No % Nm run Fl p Ar setup Fl x Ar root Fl g Fl w Ar new-tests.run Ar new-tests 280.No % Nm cat Pa new-tests.run 281[DEFAULT] 282pre = setup 283post_user = 284quiet = False 285user = 286timeout = 60 287post = 288pre_user = root 289outputdir = /var/tmp/test_results 290 291[/home/jkennedy/new-tests] 292tests = ['test-01', 'test-02', 'test-03'] 293.Ed 294.El 295. 296.Sh SEE ALSO 297.Xr sudo 1m 298