ATF-CHECK(1)

πŸ“¦
version 0.23 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ atf-check β€” the girl who runs ur command and judges it πŸ’…

okay so bestie, welcome to atf-check(1) from the General Commands Manual β€” yes we're doing manpage lore today, and this one is literally the vibe-checker of the Unix world. she runs a command, then reads the receipts: exit code, stdout, stderr, all of it. πŸ‘‘


πŸ¦‹ NAME πŸ¦‹

atf-check β€” executes a command and analyzes its results


🌸 SYNOPSIS 🌸

atf-check [-s qual:value] [-o action:arg ...] [-e action:arg ...] [-x]
          command

πŸ’– DESCRIPTION πŸ’–

atf-check runs a command for you and then analyzes what happened β€” like the exit code, the stdout, and the stderr. she's nosy in the best way fr fr.

test cases must use atf-sh(3)'s atf_check builtin function instead of calling this utility directly. like, don't come for her directly, use the builtin, iykyk.

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). so like, everyone has to agree. no dissent. periodt.

In the second synopsis form, atf-check will print information about all supported options and their purpose. ✨

The following options are available:

  • -s qual:value β€” Analyzes termination status. Must be one of:
    • exit:<value> β€” checks that the program exited cleanly and that its exit status is equal to value. The exit code can be omitted altogether, in which case any clean exit is accepted. πŸŽ€
    • ignore β€” ignores the exit check. not me caring... anyway.
    • signal:<value> β€” checks that the program exited due to a signal and that the signal that terminated it is value. The signal can be specified both as a number or as a name, or it can also be omitted altogether, in which case any signal is accepted. πŸ’€

Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. πŸ”„

  • -o action:arg β€” Analyzes standard output. Must be one of:
    • empty β€” checks that stdout is empty
    • ignore β€” ignores stdout
    • file:<path> β€” compares stdout with given file
    • inline:<value> β€” compares stdout with inline value
    • match:<regexp> β€” looks for a regular expression in stdout
    • save:<path> β€” saves stdout to given file

Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. πŸ”„

  • -e action:arg β€” Analyzes standard error (syntax identical to above) 🫢
  • -x β€” Executes command as a shell command line, executing it with the system shell defined by ATF_SHELL. You should avoid using this flag if at all possible to prevent shell quoting issues. ⚠️ like genuinely, avoid it, quoting hell is not the moment.
  • -r timeout[:interval] β€” Repeats failed checks until the timeout (in seconds) expires. If unspecified, the default interval (in milliseconds) is 50 ms. This can be used to wait for an expected update to the contents of a file. ⏰ she's patient, she'll wait for you to show up.

🌈 ENVIRONMENT 🌈

  • ATF_SHELL β€” Path to the system shell to be used when the -x is given to run commands.

πŸ’œ EXIT STATUS πŸ’œ

atf-check exits 0 on success, and other (unspecified) value on failure. slay when it works, mystery number when it doesn't. πŸ€·β™€οΈ


⭐ EXAMPLES ⭐

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

πŸŽ€ SEE ALSO πŸŽ€


okay that's the whole page bestie, you ate it, you read it, you understood it πŸ’…βœ¨ this was the Debian edition, dated February 6, 2021, and it's giving iconic. go forth and check ur commands responsibly, ily 🫢🌸

πŸ“¦ where this page comes from