1ATF-CHECK(1) BSD General Commands Manual ATF-CHECK(1)
2
4 atf-check — executes a command and analyzes its results
5
7 atf-check [-s qual:value] [-o action:arg ...] [-e action:arg ...] [-x]
8 command
9
11 atf-check executes a given command and analyzes its results, including
12 exit code, stdout and stderr.
13
14 Test cases must use atf-sh(3)'s atf_check builtin function instead of
15 calling this utility directly.
16
17 In the first synopsis form, atf-check will execute the provided command
18 and apply checks specified by arguments. By default it will act as if it
19 was run with -s exit:0 -o empty -e empty. Multiple checks for the same
20 output channel are allowed and, if specified, their results will be com‐
21 bined as a logical and (meaning that the output must match all the pro‐
22 vided checks).
23
24 In the second synopsis form, atf-check will print information about all
25 supported options and their purpose.
26
27 The following options are available:
28
29 -s qual:value Analyzes termination status. Must be one of:
30 exit:<value> checks that the program exited cleanly and
31 that its exit status is equal to value.
32 The exit code can be omitted altogether,
33 in which case any clean exit is accepted.
34 ignore ignores the exit check.
35 signal:<value> checks that the program exited due to a
36 signal and that the signal that terminated
37 it is value. The signal can be specified
38 both as a number or as a name, or it can
39 also be omitted altogether, in which case
40 any signal is accepted.
41
42 Most of these checkers can be prefixed by the ‘not-’
43 string, which effectively reverses the check.
44
45 -o action:arg Analyzes standard output. Must be one of:
46 empty checks that stdout is empty
47 ignore ignores stdout
48 file:<path> compares stdout with given file
49 inline:<value> compares stdout with inline value
50 match:<regexp> looks for a regular expression in stdout
51 save:<path> saves stdout to given file
52
53 Most of these checkers can be prefixed by the ‘not-’
54 string, which effectively reverses the check.
55
56 -e action:arg Analyzes standard error (syntax identical to above)
57
58 -x Executes command as a shell command line, executing it
59 with the system shell defined by ATF_SHELL. You should
60 avoid using this flag if at all possible to prevent shell
61 quoting issues.
62
64 atf-check exits 0 on success, and other (unspecified) value on failure.
65
67 ATF_SHELL Path to the system shell to be used when the -x is given to
68 run commands.
69
71 The following are sample invocations from within a test case. Note that
72 we use the atf_check function provided by atf-sh(3) instead of executing
73 atf-check directly:
74
75 # Exit code 0, nothing on stdout/stderr
76 atf_check 'true'
77
78 # Typical usage if failure is expected
79 atf_check -s not-exit:0 'false'
80
81 # Checking stdout/stderr
82 echo foobar >expout
83 atf_check -o file:expout -e inline:"xx\tyy\n" \
84 'echo foobar ; printf "xx\tyy\n" >&2'
85
86 # Checking for a crash
87 atf_check -s signal:sigsegv my_program
88
89 # Combined checks
90 atf_check -o match:foo -o not-match:bar echo foo baz
91
93 atf-sh(1)
94
95BSD October 5, 2014 BSD