atf_check() equivalent to test individual shell functions?

Fabian Keil freebsd-listen at
Sat Jul 26 11:30:27 UTC 2014

Here's another zogftw-related problem.

Putting something like this in a test case works as expected:

| atf_check -s exit:0 -o empty -e empty $ZOGFTW cmd zogftw_string_ends_with "abc" "c"

It would be preferably to source zogftw once at the beginning
and call the shell function zogftw_string_ends_with() directly
afterwards to reduce the overhead, though.

The following sort of does this, but the stdout and stderr
output isn't verified, it's tedious to write and if nothing
fails, the "kyua debug" output isn't particular useful:

| . $ZOGFTW source || atf_fail "Failed to source zogftw"
| if ! zogftw_string_ends_with "abc" "c"; then
|     atf_fail "Failed to find 'c' at the end of 'abc'"
| fi

The following also sort of works, but in case of errors the output
isn't helpful (because atf_check_equal() doesn't see the actual
function) and the stderr output isn't verified either:

| . $ZOGFTW source || atf_fail "Failed to source zogftw"
| atf_check_equal $(zogftw_string_ends_with "abc" "c"; echo $?) "0"

What I'm looking for is something like this:

| atf_check_shell_function -s return:0 -o empty -e empty zogftw_string_ends_with "abc" "c"

atf-sh-api(3) doesn't seem to mention anything like it,
so I'm wondering how other people are testing individual
shell functions?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <>

More information about the freebsd-testing mailing list