1.\" 2.\" Automated Testing Framework (atf) 3.\" 4.\" Copyright (c) 2008 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28.\" 29.Dd March 2, 2014 30.Dt ATF-CHECK 1 31.Os 32.Sh NAME 33.Nm atf-check 34.Nd executes a command and analyzes its results 35.Sh SYNOPSIS 36.Nm 37.Op Fl s Ar qual:value 38.Op Fl o Ar action:arg ... 39.Op Fl e Ar action:arg ... 40.Op Fl x 41.Ar command 42.Nm 43.Fl h 44.Sh DESCRIPTION 45.Nm 46executes a given command and analyzes its results, including 47exit code, stdout and stderr. 48.Pp 49In the first synopsis form, 50.Nm 51will execute the provided command and apply checks specified 52by arguments. 53By default it will act as if it was run with 54.Fl s 55.Ar exit:0 56.Fl o 57.Ar empty 58.Fl e 59.Ar empty . 60Multiple checks for the same output channel are allowed and, if specified, 61their results will be combined as a logical and (meaning that the output must 62match all the provided checks). 63.Pp 64In the second synopsis form, 65.Nm 66will print information about all supported options and their purpose. 67.Pp 68The following options are available: 69.Bl -tag -width XqualXvalueXX 70.It Fl h 71Shows a short summary of all available options and their purpose. 72.It Fl s Ar qual:value 73Analyzes termination status. 74Must be one of: 75.Bl -tag -width signal:<value> -compact 76.It Ar exit:<value> 77checks that the program exited cleanly and that its exit status is equal to 78.Va value . 79The exit code can be omitted altogether, in which case any clean exit is 80accepted. 81.It Ar ignore 82ignores the exit check. 83.It Ar signal:<value> 84checks that the program exited due to a signal and that the signal that 85terminated it is 86.Va value . 87The signal can be specified both as a number or as a name, or it can also 88be omitted altogether, in which case any signal is accepted. 89.El 90.Pp 91Most of these checkers can be prefixed by the 92.Sq not- 93string, which effectively reverses the check. 94.It Fl o Ar action:arg 95Analyzes standard output. 96Must be one of: 97.Bl -tag -width inline:<value> -compact 98.It Ar empty 99checks that stdout is empty 100.It Ar ignore 101ignores stdout 102.It Ar file:<path> 103compares stdout with given file 104.It Ar inline:<value> 105compares stdout with inline value 106.It Ar match:<regexp> 107looks for a regular expression in stdout 108.It Ar save:<path> 109saves stdout to given file 110.El 111.Pp 112Most of these checkers can be prefixed by the 113.Sq not- 114string, which effectively reverses the check. 115.It Fl e Ar action:arg 116Analyzes standard error (syntax identical to above) 117.It Fl x 118Executes 119.Ar command 120as a shell command line, executing it with the system shell defined by 121.Va ATF_SHELL . 122You should avoid using this flag if at all possible to prevent shell quoting 123issues. 124.El 125.Sh EXIT STATUS 126.Nm 127exits 0 on success, and other (unspecified) value on failure. 128.Sh ENVIRONMENT 129.Bl -tag -width ATFXSHELLXX -compact 130.It Va ATF_SHELL 131Path to the system shell to be used when the 132.Fl x 133is given to run commands. 134.El 135.Sh EXAMPLES 136.Bd -literal -offset indent 137# Exit code 0, nothing on stdout/stderr 138atf-check 'true' 139 140# Typical usage if failure is expected 141atf-check -s not-exit:0 'false' 142 143# Checking stdout/stderr 144echo foobar >expout 145atf-check -o file:expout -e inline:"xx\etyy\en" \e 146 'echo foobar ; printf "xx\etyy\en" >&2' 147 148# Checking for a crash 149atf-check -s signal:sigsegv my_program 150 151# Combined checks 152atf-check -o match:foo -o not-match:bar echo foo baz 153.Ed 154