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 May 10, 2023 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.Sh DESCRIPTION 43.Nm 44executes a given command and analyzes its results, including 45exit code, stdout and stderr. 46.Pp 47.Nm 48will execute the provided command and apply checks specified 49by arguments. 50By default it will act as if it was run with 51.Fl s 52.Ar exit:0 53.Fl o 54.Ar empty 55.Fl e 56.Ar empty . 57Multiple checks for the same output channel are allowed and, if specified, 58their results will be combined as a logical and (meaning that the output must 59match all the provided checks). 60.Pp 61The following options are available: 62.Bl -tag -width XqualXvalueXX 63.It Fl s Ar qual:value 64Analyzes termination status. 65Must be one of: 66.Bl -tag -width signal:<value> -compact 67.It Ar exit:<value> 68checks that the program exited cleanly and that its exit status is equal to 69.Va value . 70The exit code can be omitted altogether, in which case any clean exit is 71accepted. 72.It Ar ignore 73ignores the exit check. 74.It Ar signal:<value> 75checks that the program exited due to a signal and that the signal that 76terminated it is 77.Va value . 78The signal can be specified both as a number or as a name, or it can also 79be omitted altogether, in which case any signal is accepted. 80.El 81.Pp 82Most of these checkers can be prefixed by the 83.Sq not- 84string, which effectively reverses the check. 85.It Fl o Ar action:arg 86Analyzes standard output. 87Must be one of: 88.Bl -tag -width inline:<value> -compact 89.It Ar empty 90checks that stdout is empty 91.It Ar ignore 92ignores stdout 93.It Ar file:<path> 94compares stdout with given file 95.It Ar inline:<value> 96compares stdout with inline value 97.It Ar match:<regexp> 98looks for a regular expression in stdout 99.It Ar save:<path> 100saves stdout to given file 101.El 102.Pp 103Most of these checkers can be prefixed by the 104.Sq not- 105string, which effectively reverses the check. 106.It Fl e Ar action:arg 107Analyzes standard error (syntax identical to above) 108.It Fl x 109Executes 110.Ar command 111as a shell command line, executing it with the system shell defined by 112.Va ATF_SHELL 113in 114.Xr atf-config 1 . 115You should avoid using this flag if at all possible to prevent shell quoting 116issues. 117.El 118.Sh EXIT STATUS 119.Nm 120exits 0 on success, and other (unspecified) value on failure. 121.Sh EXAMPLES 122.Bd -literal -offset indent 123# Exit code 0, nothing on stdout/stderr 124atf-check 'true' 125 126# Typical usage if failure is expected 127atf-check -s not-exit:0 'false' 128 129# Checking stdout/stderr 130echo foobar >expout 131atf-check -o file:expout -e inline:"xx\etyy\en" \e 132 'echo foobar ; printf "xx\etyy\en" >&2' 133 134# Checking for a crash 135atf-check -s signal:sigsegv my_program 136 137# Combined checks 138atf-check -o match:foo -o not-match:bar echo foo baz 139.Ed 140.Sh SEE ALSO 141.Xr atf-config 1 , 142.Xr atf 7 143