| ATF-CHECK(1) | General Commands Manual | ATF-CHECK(1) |
atf-check —
executes a command and analyzes its results
atf-check |
[-s qual:value]
[-o action:arg ...]
[-e action:arg ...]
[-x] command |
atf-check executes a given command and
analyzes its results, including exit code, stdout and stderr.
atf_check builtin function instead of calling this
utility directly.In the first synopsis form, atf-check will
execute the provided command and apply checks specified by arguments. By
default it will act as if it was run with -s
exit:0 -o
empty -e
empty. Multiple checks for the same output channel are
allowed and, if specified, their results will be combined as a logical and
(meaning that the output must match all the provided checks).
In the second synopsis form, atf-check
will print information about all supported options and their purpose.
The following options are available:
-s
qual:valueMost of these checkers can be prefixed by the ‘not-’ string, which effectively reverses the check.
-o
action:argMost of these checkers can be prefixed by the ‘not-’ string, which effectively reverses the check.
-e
action:arg-x-r
timeout[:interval]-x is
given to run commands.atf-check exits 0 on success, and other
(unspecified) value on failure.
The following are sample invocations from within a test case. Note
that we use the atf_check function provided by
atf-sh(3) instead of executing
atf-check directly:
# Exit code 0, nothing on stdout/stderr
atf_check true
# Typical usage if failure is expected
atf_check -s not-exit:0 false
# Checking stdout/stderr
echo foobar >expout
atf_check -o file:expout -e inline:"xx\tyy\n" \
-x 'echo foobar ; printf "xx\tyy\n" >&2'
# Checking for a crash
atf_check -s signal:sigsegv my_program
# Combined checks
atf_check -o match:foo -o not-match:bar echo foo baz
# Wait 5 seconds for a line to show up in a file
( sleep 2 ; echo "testing 123" > $test_path ) &
atf-check -o ignore -e ignore -s exit:0 -r 5 \
grep "testing 123" $test_path
| February 6, 2021 | Debian |