Diff for /wikisrc/tutorials/atf.mdwn between versions 1.10 and 1.14

version 1.10, 2010/09/03 21:29:36 version 1.14, 2012/08/26 04:21:13
Line 57  tool: Line 57  tool:
 Then, you could define the following test programs and test cases:  Then, you could define the following test programs and test cases:
   
 * bin/ls/fs_test.c: Provides test cases for list_files and stat_files.  These  * bin/ls/fs_test.c: Provides test cases for list_files and stat_files.  These
   would be named list_files__empty_directory, list_files__one_file,    would be named list_files\_\_empty_directory, list_files\_\_one_file,
   list_files__multiple_files, stat_files__directory, stat_files__symlink, etc.    list_files\_\_multiple_files, stat_files\_\_directory, stat_files\_\_symlink, etc.
   
 * bin/ls/ui_test.c: Provides test cases for the format_columns function.  These  * bin/ls/ui_test.c: Provides test cases for the format_columns function.  These
   would be named format_columns__no_files, format_columns__multiple_files, etc.    would be named format_columns\_\_no_files, format_columns\_\_multiple_files, etc.
   
 * bin/ls/integration_test.sh: Provides "black box" test cases for the binary  * bin/ls/integration_test.sh: Provides "black box" test cases for the binary
   itself.  These would be named lflag, lflag_and_Fflag, no_flags, no_files, etc.    itself.  These would be named lflag, lflag_and_Fflag, no_flags, no_files, etc.
Line 203  If the subdirectory does not exist: Line 203  If the subdirectory does not exist:
   
 1. Edit the parent Makefile to recurse into the new subdirectory.  1. Edit the parent Makefile to recurse into the new subdirectory.
   
 1. Edit src/etc/mtree/NetBSD.base.dist to register the new subdirectory.  Your  1. Edit src/etc/mtree/NetBSD.dist.tests to register the new subdirectory.  Your
    test will be installed under /usr/tests/.     test will be installed under /usr/tests/.
   
 1. Edit src/distrib/sets/lists/tests/mi to register the new test program.  Do  1. Edit src/distrib/sets/lists/tests/mi to register the new test program.  Do
Line 297  specific details as to how this works fo Line 297  specific details as to how this works fo
   
 This program needs to be built with the Makefile shown below.  Once built, the  This program needs to be built with the Makefile shown below.  Once built, the
 program automatically gains a main() method that provides a consistent user  program automatically gains a main() method that provides a consistent user
 interface to all test programs.  You are simply not inteded to provide your own  interface to all test programs.  You are simply not intended to provide your own
 main method, nor to deal with the command-line of the invocation.  main method, nor to deal with the command-line of the invocation.
   
 ## How to build  ## How to build
Line 320  For example: Line 320  For example:
 The following functions are commonly used from within a test case body:  The following functions are commonly used from within a test case body:
   
 * ATF_REQUIRE(boolean_expression): Checks if the given boolean expression is  * ATF_REQUIRE(boolean_expression): Checks if the given boolean expression is
   true and, if not, aborts exectuion and markts the test as failed.  Similarly    true and, if not, aborts execution and marks the test as failed.  Similarly
   ATF_CHECK performs the same test but does not abort execution: it records the    ATF_CHECK performs the same test but does not abort execution: it records the
   failure but keeps processing the test case.  For an explanation on when to use    failure but keeps processing the test case.  For an explanation on when to use
   which, refer to the FAQ question below.    which, refer to the FAQ question below.
Line 355  The following functions are commonly use Line 355  The following functions are commonly use
   an abrupt termination of the test case, be it due to a call to exit() or to    an abrupt termination of the test case, be it due to a call to exit() or to
   the reception of a signal.    the reception of a signal.
   
 * atf_expect_exit(int exitcode, const char *fomat, ...): Same as atf_expect_fail  * atf_expect_exit(int exitcode, const char *format, ...): Same as atf_expect_fail
   but expects the test case to exit with a specific exitcode.  Provide -1 to    but expects the test case to exit with a specific exitcode.  Provide -1 to
   indicate any exit code.    indicate any exit code.
   
 * atf_expect_signal(int signo, const char *fomat, ...): Same as atf_expect_fail  * atf_expect_signal(int signo, const char *format, ...): Same as atf_expect_fail
   but expects the test case to receive a specific signal.  Provide -1 to    but expects the test case to receive a specific signal.  Provide -1 to
   indicate any signal.    indicate any signal.
   
Line 424  The details on how this works are provid Line 424  The details on how this works are provid
   
 This program needs to be built with the Makefile shown below.  The program  This program needs to be built with the Makefile shown below.  The program
 automatically gains an entry point that provides a consistent user interface to  automatically gains an entry point that provides a consistent user interface to
 all test programs.  You are simply not inteded to provide your own "main  all test programs.  You are simply not intended to provide your own "main
 method", nor to deal with the command-line of the invocation.  method", nor to deal with the command-line of the invocation.
   
 ## How to build  ## How to build
Line 467  The following functions are commonly use Line 467  The following functions are commonly use
   
 * atf_skip reason: Explicitly marks the test case as skipped and exits.  * atf_skip reason: Explicitly marks the test case as skipped and exits.
   
 * atf_pass: Explicitly markts the test case as passed and exits.  * atf_pass: Explicitly marks the test case as passed and exits.
   
 * atf_get_srcdir: Prints the path to the directory where the test case lives.  * atf_get_srcdir: Prints the path to the directory where the test case lives.
   Use as $(atf_get_srcdir)/my-static-data-file.    Use as $(atf_get_srcdir)/my-static-data-file.
Line 519  keep this in mind: Line 519  keep this in mind:
   
 * Use the ATF_CHECK* and/or atf_tc_fail functions to do the comparisons and  * Use the ATF_CHECK* and/or atf_tc_fail functions to do the comparisons and
   report errors.  Neither errx nor any other error reporting and program    report errors.  Neither errx nor any other error reporting and program
   termination functions (read: err, errx, warn, warnx, exit, abor) are to be    termination functions (read: err, errx, warn, warnx, exit, abort) are to be
   used at all.    used at all.
   
 The result would look like:  The result would look like:

Removed from v.1.10  
changed lines
  Added in v.1.14


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb