xref: /freebsd/contrib/atf/atf-sh/atf-sh.3 (revision 71a1ae7cebd3791d4d18ac9620a7a4ce8cf15819)
10677dfd1SJulio Merino.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
20677dfd1SJulio Merino.\" All rights reserved.
30677dfd1SJulio Merino.\"
40677dfd1SJulio Merino.\" Redistribution and use in source and binary forms, with or without
50677dfd1SJulio Merino.\" modification, are permitted provided that the following conditions
60677dfd1SJulio Merino.\" are met:
70677dfd1SJulio Merino.\" 1. Redistributions of source code must retain the above copyright
80677dfd1SJulio Merino.\"    notice, this list of conditions and the following disclaimer.
90677dfd1SJulio Merino.\" 2. Redistributions in binary form must reproduce the above copyright
100677dfd1SJulio Merino.\"    notice, this list of conditions and the following disclaimer in the
110677dfd1SJulio Merino.\"    documentation and/or other materials provided with the distribution.
120677dfd1SJulio Merino.\"
130677dfd1SJulio Merino.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
140677dfd1SJulio Merino.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
150677dfd1SJulio Merino.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
160677dfd1SJulio Merino.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
170677dfd1SJulio Merino.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
180677dfd1SJulio Merino.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190677dfd1SJulio Merino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
200677dfd1SJulio Merino.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
210677dfd1SJulio Merino.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
220677dfd1SJulio Merino.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
230677dfd1SJulio Merino.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
240677dfd1SJulio Merino.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*71a1ae7cSAlan Somers.Dd January 27, 2021
260677dfd1SJulio Merino.Dt ATF-SH 3
270677dfd1SJulio Merino.Os
280677dfd1SJulio Merino.Sh NAME
290677dfd1SJulio Merino.Nm atf_add_test_case ,
300677dfd1SJulio Merino.Nm atf_check ,
310677dfd1SJulio Merino.Nm atf_check_equal ,
32c203bd70SAlex Richardson.Nm atf_check_not_equal ,
330677dfd1SJulio Merino.Nm atf_config_get ,
340677dfd1SJulio Merino.Nm atf_config_has ,
350677dfd1SJulio Merino.Nm atf_expect_death ,
360677dfd1SJulio Merino.Nm atf_expect_exit ,
370677dfd1SJulio Merino.Nm atf_expect_fail ,
380677dfd1SJulio Merino.Nm atf_expect_pass ,
390677dfd1SJulio Merino.Nm atf_expect_signal ,
400677dfd1SJulio Merino.Nm atf_expect_timeout ,
410677dfd1SJulio Merino.Nm atf_fail ,
420677dfd1SJulio Merino.Nm atf_get ,
430677dfd1SJulio Merino.Nm atf_get_srcdir ,
444fb696d6SEnji Cooper.Nm atf_init_test_cases ,
450677dfd1SJulio Merino.Nm atf_pass ,
460677dfd1SJulio Merino.Nm atf_require_prog ,
470677dfd1SJulio Merino.Nm atf_set ,
480677dfd1SJulio Merino.Nm atf_skip ,
490677dfd1SJulio Merino.Nm atf_test_case
500677dfd1SJulio Merino.Nd POSIX shell API to write ATF-based test programs
510677dfd1SJulio Merino.Sh SYNOPSIS
520677dfd1SJulio Merino.Nm atf_add_test_case
530677dfd1SJulio Merino.Qq name
540677dfd1SJulio Merino.Nm atf_check
550677dfd1SJulio Merino.Qq command
560677dfd1SJulio Merino.Nm atf_check_equal
570677dfd1SJulio Merino.Qq expected_expression
580677dfd1SJulio Merino.Qq actual_expression
59c203bd70SAlex Richardson.Nm atf_check_not_equal
60c203bd70SAlex Richardson.Qq expected_expression
61c203bd70SAlex Richardson.Qq actual_expression
620677dfd1SJulio Merino.Nm atf_config_get
630677dfd1SJulio Merino.Qq var_name
640677dfd1SJulio Merino.Nm atf_config_has
650677dfd1SJulio Merino.Qq var_name
660677dfd1SJulio Merino.Nm atf_expect_death
670677dfd1SJulio Merino.Qq reason
680677dfd1SJulio Merino.Qq ...
690677dfd1SJulio Merino.Nm atf_expect_exit
700677dfd1SJulio Merino.Qq exitcode
710677dfd1SJulio Merino.Qq reason
720677dfd1SJulio Merino.Qq ...
730677dfd1SJulio Merino.Nm atf_expect_fail
740677dfd1SJulio Merino.Qq reason
750677dfd1SJulio Merino.Qq ...
760677dfd1SJulio Merino.Nm atf_expect_pass
770677dfd1SJulio Merino.Qq
780677dfd1SJulio Merino.Nm atf_expect_signal
790677dfd1SJulio Merino.Qq signo
800677dfd1SJulio Merino.Qq reason
810677dfd1SJulio Merino.Qq ...
820677dfd1SJulio Merino.Nm atf_expect_timeout
830677dfd1SJulio Merino.Qq reason
840677dfd1SJulio Merino.Qq ...
850677dfd1SJulio Merino.Nm atf_fail
860677dfd1SJulio Merino.Qq reason
870677dfd1SJulio Merino.Nm atf_get
880677dfd1SJulio Merino.Qq var_name
890677dfd1SJulio Merino.Nm atf_get_srcdir
904fb696d6SEnji Cooper.Nm atf_init_test_cases
914fb696d6SEnji Cooper.Qq name
920677dfd1SJulio Merino.Nm atf_pass
930677dfd1SJulio Merino.Nm atf_require_prog
940677dfd1SJulio Merino.Qq prog_name
950677dfd1SJulio Merino.Nm atf_set
960677dfd1SJulio Merino.Qq var_name
970677dfd1SJulio Merino.Qq value
980677dfd1SJulio Merino.Nm atf_skip
990677dfd1SJulio Merino.Qq reason
1000677dfd1SJulio Merino.Nm atf_test_case
1010677dfd1SJulio Merino.Qq name
1020677dfd1SJulio Merino.Qq cleanup
1030677dfd1SJulio Merino.Sh DESCRIPTION
1040677dfd1SJulio MerinoATF
1050677dfd1SJulio Merinoprovides a simple but powerful interface to easily write test programs in
1060677dfd1SJulio Merinothe POSIX shell language.
1070677dfd1SJulio MerinoThese are extremely helpful given that they are trivial to write due to the
1080677dfd1SJulio Merinolanguage simplicity and the great deal of available external tools, so they
1090677dfd1SJulio Merinoare often ideal to test other applications at the user level.
1100677dfd1SJulio Merino.Pp
1110677dfd1SJulio MerinoTest programs written using this library must be run using the
1120677dfd1SJulio Merino.Xr atf-sh 1
1130677dfd1SJulio Merinointerpreter by putting the following on their very first line:
1140677dfd1SJulio Merino.Bd -literal -offset indent
1150677dfd1SJulio Merino#! /usr/bin/env atf-sh
1160677dfd1SJulio Merino.Ed
1170677dfd1SJulio Merino.Pp
1180677dfd1SJulio MerinoShell-based test programs always follow this template:
1190677dfd1SJulio Merino.Bd -literal -offset indent
1200677dfd1SJulio Merinoatf_test_case tc1
1210677dfd1SJulio Merinotc1_head() {
1220677dfd1SJulio Merino    ... first test case's header ...
1230677dfd1SJulio Merino}
1240677dfd1SJulio Merinotc1_body() {
1250677dfd1SJulio Merino    ... first test case's body ...
1260677dfd1SJulio Merino}
1270677dfd1SJulio Merino
1280677dfd1SJulio Merinoatf_test_case tc2 cleanup
1290677dfd1SJulio Merinotc2_head() {
1300677dfd1SJulio Merino    ... second test case's header ...
1310677dfd1SJulio Merino}
1320677dfd1SJulio Merinotc2_body() {
1330677dfd1SJulio Merino    ... second test case's body ...
1340677dfd1SJulio Merino}
1350677dfd1SJulio Merinotc2_cleanup() {
1360677dfd1SJulio Merino    ... second test case's cleanup ...
1370677dfd1SJulio Merino}
1380677dfd1SJulio Merino
139ba31e895SEnji Cooper\&... additional test cases ...
1400677dfd1SJulio Merino
1410677dfd1SJulio Merinoatf_init_test_cases() {
1420677dfd1SJulio Merino    atf_add_test_case tc1
1430677dfd1SJulio Merino    atf_add_test_case tc2
1440677dfd1SJulio Merino    ... add additional test cases ...
1450677dfd1SJulio Merino}
1460677dfd1SJulio Merino.Ed
1470677dfd1SJulio Merino.Ss Definition of test cases
1480677dfd1SJulio MerinoTest cases have an identifier and are composed of three different parts:
1490677dfd1SJulio Merinothe header, the body and an optional cleanup routine, all of which are
1500677dfd1SJulio Merinodescribed in
1510677dfd1SJulio Merino.Xr atf-test-case 4 .
1520677dfd1SJulio MerinoTo define test cases, one can use the
1530677dfd1SJulio Merino.Nm atf_test_case
154ba31e895SEnji Cooperfunction, which takes a first parameter specifying the test case's
1550677dfd1SJulio Merinoname and instructs the library to set things up to accept it as a valid
1560677dfd1SJulio Merinotest case.
1570677dfd1SJulio MerinoThe second parameter is optional and, if provided, must be
1580677dfd1SJulio Merino.Sq cleanup ;
1590677dfd1SJulio Merinoproviding this parameter allows defining a cleanup routine for the test
1600677dfd1SJulio Merinocase.
1610677dfd1SJulio MerinoIt is important to note that this function
1620677dfd1SJulio Merino.Em does not
1630677dfd1SJulio Merinoset the test case up for execution when the program is run.
1640677dfd1SJulio MerinoIn order to do so, a later registration is needed through the
1650677dfd1SJulio Merino.Nm atf_add_test_case
1660677dfd1SJulio Merinofunction detailed in
1670677dfd1SJulio Merino.Sx Program initialization .
1680677dfd1SJulio Merino.Pp
1690677dfd1SJulio MerinoLater on, one must define the three parts of the body by providing two
1700677dfd1SJulio Merinoor three functions (remember that the cleanup routine is optional).
1710677dfd1SJulio MerinoThese functions are named after the test case's identifier, and are
1720677dfd1SJulio Merino.Nm \*(Ltid\*(Gt_head ,
1730677dfd1SJulio Merino.Nm \*(Ltid\*(Gt_body
1740677dfd1SJulio Merinoand
1750677dfd1SJulio Merino.Nm \*(Ltid\*(Gt_cleanup .
1760677dfd1SJulio MerinoNone of these take parameters when executed.
1770677dfd1SJulio Merino.Ss Program initialization
1780677dfd1SJulio MerinoThe test program must define an
1790677dfd1SJulio Merino.Nm atf_init_test_cases
1800677dfd1SJulio Merinofunction, which is in charge of registering the test cases that will be
1810677dfd1SJulio Merinoexecuted at run time by using the
1820677dfd1SJulio Merino.Nm atf_add_test_case
1830677dfd1SJulio Merinofunction, which takes the name of a test case as its single parameter.
1840677dfd1SJulio MerinoThis main function should not do anything else, except maybe sourcing
1850677dfd1SJulio Merinoauxiliary source files that define extra variables and functions.
1860677dfd1SJulio Merino.Ss Configuration variables
1870677dfd1SJulio MerinoThe test case has read-only access to the current configuration variables
1880677dfd1SJulio Merinothrough the
1890677dfd1SJulio Merino.Nm atf_config_has
1900677dfd1SJulio Merinoand
1910677dfd1SJulio Merino.Nm atf_config_get
1920677dfd1SJulio Merinomethods.
1930677dfd1SJulio MerinoThe former takes a single parameter specifying a variable name and returns
1940677dfd1SJulio Merinoa boolean indicating whether the variable is defined or not.
1950677dfd1SJulio MerinoThe latter can take one or two parameters.
1960677dfd1SJulio MerinoIf it takes only one, it specifies the variable from which to get the
1970677dfd1SJulio Merinovalue, and this variable must be defined.
1980677dfd1SJulio MerinoIf it takes two, the second one specifies a default value to be returned
1990677dfd1SJulio Merinoif the variable is not available.
2000677dfd1SJulio Merino.Ss Access to the source directory
2010677dfd1SJulio MerinoIt is possible to get the path to the test case's source directory from
2020677dfd1SJulio Merinoanywhere in the test program by using the
2030677dfd1SJulio Merino.Nm atf_get_srcdir
2040677dfd1SJulio Merinofunction.
2050677dfd1SJulio MerinoIt is interesting to note that this can be used inside
2060677dfd1SJulio Merino.Nm atf_init_test_cases
2070677dfd1SJulio Merinoto silently include additional helper files from the source directory.
2080677dfd1SJulio Merino.Ss Requiring programs
2090677dfd1SJulio MerinoAside from the
2100677dfd1SJulio Merino.Va require.progs
2110677dfd1SJulio Merinometa-data variable available in the header only, one can also check for
2120677dfd1SJulio Merinoadditional programs in the test case's body by using the
2130677dfd1SJulio Merino.Nm atf_require_prog
2140677dfd1SJulio Merinofunction, which takes the base name or full path of a single binary.
2150677dfd1SJulio MerinoRelative paths are forbidden.
2160677dfd1SJulio MerinoIf it is not found, the test case will be automatically skipped.
2170677dfd1SJulio Merino.Ss Test case finalization
2180677dfd1SJulio MerinoThe test case finalizes either when the body reaches its end, at which
2190677dfd1SJulio Merinopoint the test is assumed to have
2200677dfd1SJulio Merino.Em passed ,
2210677dfd1SJulio Merinoor at any explicit call to
2220677dfd1SJulio Merino.Nm atf_pass ,
2230677dfd1SJulio Merino.Nm atf_fail
2240677dfd1SJulio Merinoor
2250677dfd1SJulio Merino.Nm atf_skip .
2260677dfd1SJulio MerinoThese three functions terminate the execution of the test case immediately.
2270677dfd1SJulio MerinoThe cleanup routine will be processed afterwards in a completely automated
2280677dfd1SJulio Merinoway, regardless of the test case's termination reason.
2290677dfd1SJulio Merino.Pp
2300677dfd1SJulio Merino.Nm atf_pass
2310677dfd1SJulio Merinodoes not take any parameters.
2320677dfd1SJulio Merino.Nm atf_fail
2330677dfd1SJulio Merinoand
2340677dfd1SJulio Merino.Nm atf_skip
2350677dfd1SJulio Merinotake a single string parameter that describes why the test case failed or
2360677dfd1SJulio Merinowas skipped, respectively.
2370677dfd1SJulio MerinoIt is very important to provide a clear error message in both cases so that
2380677dfd1SJulio Merinothe user can quickly know why the test did not pass.
2390677dfd1SJulio Merino.Ss Expectations
2400677dfd1SJulio MerinoEverything explained in the previous section changes when the test case
2410677dfd1SJulio Merinoexpectations are redefined by the programmer.
2420677dfd1SJulio Merino.Pp
2430677dfd1SJulio MerinoEach test case has an internal state called
2440677dfd1SJulio Merino.Sq expect
2450677dfd1SJulio Merinothat describes what the test case expectations are at any point in time.
2460677dfd1SJulio MerinoThe value of this property can change during execution by any of:
2470677dfd1SJulio Merino.Bl -tag -width indent
2480677dfd1SJulio Merino.It Nm atf_expect_death Qo reason Qc Qo ... Qc
2490677dfd1SJulio MerinoExpects the test case to exit prematurely regardless of the nature of the
2500677dfd1SJulio Merinoexit.
2510677dfd1SJulio Merino.It Nm atf_expect_exit Qo exitcode Qc Qo reason Qc Qo ... Qc
2520677dfd1SJulio MerinoExpects the test case to exit cleanly.
2530677dfd1SJulio MerinoIf
2540677dfd1SJulio Merino.Va exitcode
2550677dfd1SJulio Merinois not
2560677dfd1SJulio Merino.Sq -1 ,
2570677dfd1SJulio Merinothe runtime engine will validate that the exit code of the test case
2580677dfd1SJulio Merinomatches the one provided in this call.
2590677dfd1SJulio MerinoOtherwise, the exact value will be ignored.
2600677dfd1SJulio Merino.It Nm atf_expect_fail Qo reason Qc
2610677dfd1SJulio MerinoAny failure raised in this mode is recorded, but such failures do not report
2620677dfd1SJulio Merinothe test case as failed; instead, the test case finalizes cleanly and is
2630677dfd1SJulio Merinoreported as
2640677dfd1SJulio Merino.Sq expected failure ;
2650677dfd1SJulio Merinothis report includes the provided
2660677dfd1SJulio Merino.Fa reason
2670677dfd1SJulio Merinoas part of it.
2680677dfd1SJulio MerinoIf no error is raised while running in this mode, then the test case is
2690677dfd1SJulio Merinoreported as
2700677dfd1SJulio Merino.Sq failed .
2710677dfd1SJulio Merino.Pp
2720677dfd1SJulio MerinoThis mode is useful to reproduce actual known bugs in tests.
2730677dfd1SJulio MerinoWhenever the developer fixes the bug later on, the test case will start
2740677dfd1SJulio Merinoreporting a failure, signaling the developer that the test case must be
2750677dfd1SJulio Merinoadjusted to the new conditions.
2760677dfd1SJulio MerinoIn this situation, it is useful, for example, to set
2770677dfd1SJulio Merino.Fa reason
2780677dfd1SJulio Merinoas the bug number for tracking purposes.
2790677dfd1SJulio Merino.It Nm atf_expect_pass
2800677dfd1SJulio MerinoThis is the normal mode of execution.
2810677dfd1SJulio MerinoIn this mode, any failure is reported as such to the user and the test case
2820677dfd1SJulio Merinois marked as
2830677dfd1SJulio Merino.Sq failed .
2840677dfd1SJulio Merino.It Nm atf_expect_signal Qo signo Qc Qo reason Qc Qo ... Qc
2850677dfd1SJulio MerinoExpects the test case to terminate due to the reception of a signal.
2860677dfd1SJulio MerinoIf
2870677dfd1SJulio Merino.Va signo
2880677dfd1SJulio Merinois not
2890677dfd1SJulio Merino.Sq -1 ,
2900677dfd1SJulio Merinothe runtime engine will validate that the signal that terminated the test
2910677dfd1SJulio Merinocase matches the one provided in this call.
2920677dfd1SJulio MerinoOtherwise, the exact value will be ignored.
2930677dfd1SJulio Merino.It Nm atf_expect_timeout Qo reason Qc Qo ... Qc
2940677dfd1SJulio MerinoExpects the test case to execute for longer than its timeout.
2950677dfd1SJulio Merino.El
2960677dfd1SJulio Merino.Ss Helper functions for common checks
2970677dfd1SJulio Merino.Bl -tag -width indent
2980677dfd1SJulio Merino.It Nm atf_check Qo [options] Qc Qo command Qc Qo [args] Qc
2990677dfd1SJulio MerinoExecutes a command, performs checks on its exit code and its output, and
3000677dfd1SJulio Merinofails the test case if any of the checks is not successful.
3010677dfd1SJulio MerinoThis function is particularly useful in integration tests that verify the
3020677dfd1SJulio Merinocorrect functioning of a binary.
3030677dfd1SJulio Merino.Pp
3040677dfd1SJulio MerinoInternally, this function is just a wrapper over the
3050677dfd1SJulio Merino.Xr atf-check 1
3060677dfd1SJulio Merinotool (whose manual page provides all details on the calling syntax).
3070677dfd1SJulio MerinoYou should always use the
3080677dfd1SJulio Merino.Nm atf_check
3090677dfd1SJulio Merinofunction instead of the
3100677dfd1SJulio Merino.Xr atf-check 1
3110677dfd1SJulio Merinotool in your scripts; the latter is not even in the path.
3120677dfd1SJulio Merino.It Nm atf_check_equal Qo expected_expression Qc Qo actual_expression Qc
3130677dfd1SJulio MerinoThis function takes two expressions, evaluates them and, if their
3140677dfd1SJulio Merinoresults differ, aborts the test case with an appropriate failure message.
3150677dfd1SJulio MerinoThe common style is to put the expected value in the first parameter and the
3160677dfd1SJulio Merinoactual value in the second parameter.
317c203bd70SAlex Richardson.It Nm atf_check_not_equal Qo expected_expression Qc Qo actual_expression Qc
318c203bd70SAlex RichardsonThis function takes two expressions, evaluates them and, if their
319c203bd70SAlex Richardsonresults are equal, aborts the test case with an appropriate failure message.
320c203bd70SAlex RichardsonThe common style is to put the expected value in the first parameter and the
321c203bd70SAlex Richardsonactual value in the second parameter.
3220677dfd1SJulio Merino.El
3230677dfd1SJulio Merino.Sh EXAMPLES
3240677dfd1SJulio MerinoThe following shows a complete test program with a single test case that
3250677dfd1SJulio Merinovalidates the addition operator:
3260677dfd1SJulio Merino.Bd -literal -offset indent
3270677dfd1SJulio Merinoatf_test_case addition
3280677dfd1SJulio Merinoaddition_head() {
3290677dfd1SJulio Merino    atf_set "descr" "Sample tests for the addition operator"
3300677dfd1SJulio Merino}
3310677dfd1SJulio Merinoaddition_body() {
3320677dfd1SJulio Merino    atf_check_equal 0 $((0 + 0))
3330677dfd1SJulio Merino    atf_check_equal 1 $((0 + 1))
3340677dfd1SJulio Merino    atf_check_equal 1 $((1 + 0))
3350677dfd1SJulio Merino
3360677dfd1SJulio Merino    atf_check_equal 2 $((1 + 1))
3370677dfd1SJulio Merino
3380677dfd1SJulio Merino    atf_check_equal 300 $((100 + 200))
3390677dfd1SJulio Merino}
3400677dfd1SJulio Merino
3410677dfd1SJulio Merinoatf_init_test_cases() {
3420677dfd1SJulio Merino    atf_add_test_case addition
3430677dfd1SJulio Merino}
3440677dfd1SJulio Merino.Ed
3450677dfd1SJulio Merino.Pp
3460677dfd1SJulio MerinoThis other example shows how to include a file with extra helper functions
3470677dfd1SJulio Merinoin the test program:
3480677dfd1SJulio Merino.Bd -literal -offset indent
349ba31e895SEnji Cooper\&... definition of test cases ...
3500677dfd1SJulio Merino
3510677dfd1SJulio Merinoatf_init_test_cases() {
3520677dfd1SJulio Merino    . $(atf_get_srcdir)/helper_functions.sh
3530677dfd1SJulio Merino
3540677dfd1SJulio Merino    atf_add_test_case foo1
3550677dfd1SJulio Merino    atf_add_test_case foo2
3560677dfd1SJulio Merino}
3570677dfd1SJulio Merino.Ed
3580677dfd1SJulio Merino.Pp
3590677dfd1SJulio MerinoThis example demonstrates the use of the very useful
3600677dfd1SJulio Merino.Nm atf_check
3610677dfd1SJulio Merinofunction:
3620677dfd1SJulio Merino.Bd -literal -offset indent
3630677dfd1SJulio Merino# Check for silent output
364*71a1ae7cSAlan Somersatf_check -s exit:0 -o empty -e empty true
3650677dfd1SJulio Merino
3660677dfd1SJulio Merino# Check for silent output and failure
367*71a1ae7cSAlan Somersatf_check -s exit:1 -o empty -e empty false
3680677dfd1SJulio Merino
3690677dfd1SJulio Merino# Check for known stdout and silent stderr
3700677dfd1SJulio Merinoecho foo >expout
371*71a1ae7cSAlan Somersatf_check -s exit:0 -o file:expout -e empty echo foo
3720677dfd1SJulio Merino
3730677dfd1SJulio Merino# Generate a file for later inspection
374*71a1ae7cSAlan Somersatf_check -s exit:0 -o save:stdout -e empty ls
3750677dfd1SJulio Merinogrep foo ls || atf_fail "foo file not found in listing"
3760677dfd1SJulio Merino
3770677dfd1SJulio Merino# Or just do the match along the way
378*71a1ae7cSAlan Somersatf_check -s exit:0 -o match:"^foo$" -e empty ls
3790677dfd1SJulio Merino.Ed
3800677dfd1SJulio Merino.Sh SEE ALSO
3810677dfd1SJulio Merino.Xr atf-check 1 ,
3820677dfd1SJulio Merino.Xr atf-sh 1 ,
3830677dfd1SJulio Merino.Xr atf-test-program 1 ,
3840677dfd1SJulio Merino.Xr atf-test-case 4
385