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