2012-09-04 23:07:32 +00:00
|
|
|
.\"
|
|
|
|
.\" Automated Testing Framework (atf)
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
|
|
|
.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
|
|
.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
|
|
.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
|
|
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2014-09-23 22:29:03 +00:00
|
|
|
.Dd March 2, 2014
|
2012-09-04 23:07:32 +00:00
|
|
|
.Dt ATF-C++-API 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Nm atf-c++-api ,
|
2012-09-04 23:07:32 +00:00
|
|
|
.Nm ATF_ADD_TEST_CASE ,
|
|
|
|
.Nm ATF_CHECK_ERRNO ,
|
|
|
|
.Nm ATF_FAIL ,
|
|
|
|
.Nm ATF_INIT_TEST_CASES ,
|
|
|
|
.Nm ATF_PASS ,
|
|
|
|
.Nm ATF_REQUIRE ,
|
|
|
|
.Nm ATF_REQUIRE_EQ ,
|
|
|
|
.Nm ATF_REQUIRE_ERRNO ,
|
|
|
|
.Nm ATF_REQUIRE_IN ,
|
|
|
|
.Nm ATF_REQUIRE_MATCH ,
|
|
|
|
.Nm ATF_REQUIRE_NOT_IN ,
|
|
|
|
.Nm ATF_REQUIRE_THROW ,
|
|
|
|
.Nm ATF_REQUIRE_THROW_RE ,
|
|
|
|
.Nm ATF_SKIP ,
|
|
|
|
.Nm ATF_TEST_CASE ,
|
|
|
|
.Nm ATF_TEST_CASE_BODY ,
|
|
|
|
.Nm ATF_TEST_CASE_CLEANUP ,
|
|
|
|
.Nm ATF_TEST_CASE_HEAD ,
|
|
|
|
.Nm ATF_TEST_CASE_NAME ,
|
|
|
|
.Nm ATF_TEST_CASE_USE ,
|
|
|
|
.Nm ATF_TEST_CASE_WITH_CLEANUP ,
|
|
|
|
.Nm ATF_TEST_CASE_WITHOUT_HEAD ,
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Nm atf::utils::cat_file ,
|
|
|
|
.Nm atf::utils::compare_file ,
|
|
|
|
.Nm atf::utils::copy_file ,
|
|
|
|
.Nm atf::utils::create_file ,
|
|
|
|
.Nm atf::utils::file_exists ,
|
|
|
|
.Nm atf::utils::fork ,
|
|
|
|
.Nm atf::utils::grep_collection ,
|
|
|
|
.Nm atf::utils::grep_file ,
|
|
|
|
.Nm atf::utils::grep_string ,
|
|
|
|
.Nm atf::utils::redirect ,
|
|
|
|
.Nm atf::utils::wait
|
2012-09-04 23:07:32 +00:00
|
|
|
.Nd C++ API to write ATF-based test programs
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In atf-c++.hpp
|
|
|
|
.Fn ATF_ADD_TEST_CASE "tcs" "name"
|
|
|
|
.Fn ATF_CHECK_ERRNO "exp_errno" "bool_expression"
|
|
|
|
.Fn ATF_FAIL "reason"
|
|
|
|
.Fn ATF_INIT_TEST_CASES "tcs"
|
|
|
|
.Fn ATF_PASS
|
|
|
|
.Fn ATF_REQUIRE "expression"
|
|
|
|
.Fn ATF_REQUIRE_EQ "expression_1" "expression_2"
|
|
|
|
.Fn ATF_REQUIRE_ERRNO "exp_errno" "bool_expression"
|
|
|
|
.Fn ATF_REQUIRE_IN "element" "collection"
|
|
|
|
.Fn ATF_REQUIRE_MATCH "regexp" "string_expression"
|
|
|
|
.Fn ATF_REQUIRE_NOT_IN "element" "collection"
|
|
|
|
.Fn ATF_REQUIRE_THROW "expected_exception" "statement"
|
|
|
|
.Fn ATF_REQUIRE_THROW_RE "expected_exception" "regexp" "statement"
|
|
|
|
.Fn ATF_SKIP "reason"
|
|
|
|
.Fn ATF_TEST_CASE "name"
|
|
|
|
.Fn ATF_TEST_CASE_BODY "name"
|
|
|
|
.Fn ATF_TEST_CASE_CLEANUP "name"
|
|
|
|
.Fn ATF_TEST_CASE_HEAD "name"
|
|
|
|
.Fn ATF_TEST_CASE_NAME "name"
|
|
|
|
.Fn ATF_TEST_CASE_USE "name"
|
|
|
|
.Fn ATF_TEST_CASE_WITH_CLEANUP "name"
|
|
|
|
.Fn ATF_TEST_CASE_WITHOUT_HEAD "name"
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::cat_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& prefix"
|
|
|
|
.Fc
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::compare_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& contents"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::copy_file
|
|
|
|
.Fa "const std::string& source"
|
|
|
|
.Fa "const std::string& destination"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::create_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& contents"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::file_exists
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
|
|
|
.Ft pid_t
|
|
|
|
.Fo atf::utils::fork
|
|
|
|
.Fa "void"
|
|
|
|
.Fc
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_collection
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const Collection& collection"
|
|
|
|
.Fc
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_file
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_string
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::redirect
|
|
|
|
.Fa "const int fd"
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::wait
|
|
|
|
.Fa "const pid_t pid"
|
|
|
|
.Fa "const int expected_exit_status"
|
|
|
|
.Fa "const std::string& expected_stdout"
|
|
|
|
.Fa "const std::string& expected_stderr"
|
|
|
|
.Fc
|
2012-09-04 23:07:32 +00:00
|
|
|
.Sh DESCRIPTION
|
2013-11-16 21:57:53 +00:00
|
|
|
ATF provides a C++ programming interface to implement test programs.
|
|
|
|
C++-based test programs follow this template:
|
2012-09-04 23:07:32 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
extern "C" {
|
|
|
|
.Ns ... C-specific includes go here ...
|
|
|
|
}
|
|
|
|
|
|
|
|
.Ns ... C++-specific includes go here ...
|
|
|
|
|
|
|
|
#include <atf-c++.hpp>
|
|
|
|
|
|
|
|
ATF_TEST_CASE(tc1);
|
|
|
|
ATF_TEST_CASE_HEAD(tc1)
|
|
|
|
{
|
|
|
|
... first test case's header ...
|
|
|
|
}
|
|
|
|
ATF_TEST_CASE_BODY(tc1)
|
|
|
|
{
|
|
|
|
... first test case's body ...
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TEST_CASE_WITH_CLEANUP(tc2);
|
|
|
|
ATF_TEST_CASE_HEAD(tc2)
|
|
|
|
{
|
|
|
|
... second test case's header ...
|
|
|
|
}
|
|
|
|
ATF_TEST_CASE_BODY(tc2)
|
|
|
|
{
|
|
|
|
... second test case's body ...
|
|
|
|
}
|
|
|
|
ATF_TEST_CASE_CLEANUP(tc2)
|
|
|
|
{
|
|
|
|
... second test case's cleanup ...
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TEST_CASE(tc3);
|
|
|
|
ATF_TEST_CASE_BODY(tc3)
|
|
|
|
{
|
|
|
|
... third test case's body ...
|
|
|
|
}
|
|
|
|
|
|
|
|
.Ns ... additional test cases ...
|
|
|
|
|
|
|
|
ATF_INIT_TEST_CASES(tcs)
|
|
|
|
{
|
|
|
|
ATF_ADD_TEST_CASE(tcs, tc1);
|
|
|
|
ATF_ADD_TEST_CASE(tcs, tc2);
|
|
|
|
ATF_ADD_TEST_CASE(tcs, tc3);
|
|
|
|
... add additional test cases ...
|
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Ss Definition of test cases
|
|
|
|
Test cases have an identifier and are composed of three different parts:
|
|
|
|
the header, the body and an optional cleanup routine, all of which are
|
|
|
|
described in
|
|
|
|
.Xr atf-test-case 4 .
|
|
|
|
To define test cases, one can use the
|
|
|
|
.Fn ATF_TEST_CASE ,
|
|
|
|
.Fn ATF_TEST_CASE_WITH_CLEANUP
|
|
|
|
or the
|
|
|
|
.Fn ATF_TEST_CASE_WITHOUT_HEAD
|
|
|
|
macros, which take a single parameter specifiying the test case's
|
|
|
|
name.
|
|
|
|
.Fn ATF_TEST_CASE ,
|
|
|
|
requires to define a head and a body for the test case,
|
|
|
|
.Fn ATF_TEST_CASE_WITH_CLEANUP
|
|
|
|
requires to define a head, a body and a cleanup for the test case and
|
|
|
|
.Fn ATF_TEST_CASE_WITHOUT_HEAD
|
|
|
|
requires only a body for the test case.
|
|
|
|
It is important to note that these
|
|
|
|
.Em do not
|
|
|
|
set the test case up for execution when the program is run.
|
|
|
|
In order to do so, a later registration is needed through the
|
|
|
|
.Fn ATF_ADD_TEST_CASE
|
|
|
|
macro detailed in
|
|
|
|
.Sx Program initialization .
|
|
|
|
.Pp
|
|
|
|
Later on, one must define the three parts of the body by means of three
|
|
|
|
functions.
|
|
|
|
Their headers are given by the
|
|
|
|
.Fn ATF_TEST_CASE_HEAD ,
|
|
|
|
.Fn ATF_TEST_CASE_BODY
|
|
|
|
and
|
|
|
|
.Fn ATF_TEST_CASE_CLEANUP
|
|
|
|
macros, all of which take the test case's name.
|
|
|
|
Following each of these, a block of code is expected, surrounded by the
|
|
|
|
opening and closing brackets.
|
|
|
|
.Pp
|
|
|
|
Additionally, the
|
|
|
|
.Fn ATF_TEST_CASE_NAME
|
|
|
|
macro can be used to obtain the name of the class corresponding to a
|
|
|
|
particular test case, as the name is internally manged by the library to
|
|
|
|
prevent clashes with other user identifiers.
|
|
|
|
Similarly, the
|
|
|
|
.Fn ATF_TEST_CASE_USE
|
|
|
|
macro can be executed on a particular test case to mark it as "used" and
|
|
|
|
thus prevent compiler warnings regarding unused symbols.
|
|
|
|
Note that
|
|
|
|
.Em you should never have to use these macros during regular operation.
|
|
|
|
.Ss Program initialization
|
|
|
|
The library provides a way to easily define the test program's
|
|
|
|
.Fn main
|
|
|
|
function.
|
|
|
|
You should never define one on your own, but rely on the
|
|
|
|
library to do it for you.
|
|
|
|
This is done by using the
|
|
|
|
.Fn ATF_INIT_TEST_CASES
|
|
|
|
macro, which is passed the name of the list that will hold the test cases.
|
|
|
|
This name can be whatever you want as long as it is a valid variable value.
|
|
|
|
.Pp
|
|
|
|
After the macro, you are supposed to provide the body of a function, which
|
|
|
|
should only use the
|
|
|
|
.Fn ATF_ADD_TEST_CASE
|
|
|
|
macro to register the test cases the test program will execute.
|
|
|
|
The first parameter of this macro matches the name you provided in the
|
|
|
|
former call.
|
|
|
|
.Ss Header definitions
|
|
|
|
The test case's header can define the meta-data by using the
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Fn set_md_var
|
2012-09-04 23:07:32 +00:00
|
|
|
method, which takes two parameters: the first one specifies the
|
|
|
|
meta-data variable to be set and the second one specifies its value.
|
|
|
|
Both of them are strings.
|
|
|
|
.Ss Configuration variables
|
|
|
|
The test case has read-only access to the current configuration variables
|
|
|
|
by means of the
|
|
|
|
.Ft bool
|
|
|
|
.Fn has_config_var
|
|
|
|
and the
|
|
|
|
.Ft std::string
|
|
|
|
.Fn get_config_var
|
|
|
|
methods, which can be called in any of the three parts of a test case.
|
|
|
|
.Ss Access to the source directory
|
|
|
|
It is possible to get the path to the test case's source directory from any
|
|
|
|
of its three components by querying the
|
|
|
|
.Sq srcdir
|
|
|
|
configuration variable.
|
|
|
|
.Ss Requiring programs
|
|
|
|
Aside from the
|
|
|
|
.Va require.progs
|
|
|
|
meta-data variable available in the header only, one can also check for
|
|
|
|
additional programs in the test case's body by using the
|
|
|
|
.Fn require_prog
|
|
|
|
function, which takes the base name or full path of a single binary.
|
|
|
|
Relative paths are forbidden.
|
|
|
|
If it is not found, the test case will be automatically skipped.
|
|
|
|
.Ss Test case finalization
|
|
|
|
The test case finalizes either when the body reaches its end, at which
|
|
|
|
point the test is assumed to have
|
|
|
|
.Em passed ,
|
|
|
|
or at any explicit call to
|
|
|
|
.Fn ATF_PASS ,
|
|
|
|
.Fn ATF_FAIL
|
|
|
|
or
|
|
|
|
.Fn ATF_SKIP .
|
|
|
|
These three macros terminate the execution of the test case immediately.
|
|
|
|
The cleanup routine will be processed afterwards in a completely automated
|
|
|
|
way, regardless of the test case's termination reason.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_PASS
|
|
|
|
does not take any parameters.
|
|
|
|
.Fn ATF_FAIL
|
|
|
|
and
|
|
|
|
.Fn ATF_SKIP
|
|
|
|
take a single string that describes why the test case failed or
|
|
|
|
was skipped, respectively.
|
|
|
|
It is very important to provide a clear error message in both cases so that
|
|
|
|
the user can quickly know why the test did not pass.
|
|
|
|
.Ss Expectations
|
|
|
|
Everything explained in the previous section changes when the test case
|
|
|
|
expectations are redefined by the programmer.
|
|
|
|
.Pp
|
|
|
|
Each test case has an internal state called
|
|
|
|
.Sq expect
|
|
|
|
that describes what the test case expectations are at any point in time.
|
|
|
|
The value of this property can change during execution by any of:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fn expect_death "reason"
|
|
|
|
Expects the test case to exit prematurely regardless of the nature of the
|
|
|
|
exit.
|
|
|
|
.It Fn expect_exit "exitcode" "reason"
|
|
|
|
Expects the test case to exit cleanly.
|
|
|
|
If
|
|
|
|
.Va exitcode
|
|
|
|
is not
|
|
|
|
.Sq -1 ,
|
2014-09-23 22:29:03 +00:00
|
|
|
the runtime engine will validate that the exit code of the test case
|
|
|
|
matches the one provided in this call.
|
2012-09-04 23:07:32 +00:00
|
|
|
Otherwise, the exact value will be ignored.
|
|
|
|
.It Fn expect_fail "reason"
|
|
|
|
Any failure (be it fatal or non-fatal) raised in this mode is recorded.
|
|
|
|
However, such failures do not report the test case as failed; instead, the
|
|
|
|
test case finalizes cleanly and is reported as
|
|
|
|
.Sq expected failure ;
|
|
|
|
this report includes the provided
|
|
|
|
.Fa reason
|
|
|
|
as part of it.
|
|
|
|
If no error is raised while running in this mode, then the test case is
|
|
|
|
reported as
|
|
|
|
.Sq failed .
|
|
|
|
.Pp
|
|
|
|
This mode is useful to reproduce actual known bugs in tests.
|
|
|
|
Whenever the developer fixes the bug later on, the test case will start
|
|
|
|
reporting a failure, signaling the developer that the test case must be
|
|
|
|
adjusted to the new conditions.
|
|
|
|
In this situation, it is useful, for example, to set
|
|
|
|
.Fa reason
|
|
|
|
as the bug number for tracking purposes.
|
|
|
|
.It Fn expect_pass
|
|
|
|
This is the normal mode of execution.
|
|
|
|
In this mode, any failure is reported as such to the user and the test case
|
|
|
|
is marked as
|
|
|
|
.Sq failed .
|
|
|
|
.It Fn expect_race "reason"
|
|
|
|
Any failure or timeout during the execution of the test case will be
|
|
|
|
considered as if a race condition has been triggered and reported as such.
|
|
|
|
If no problems arise, the test will continue execution as usual.
|
|
|
|
.It Fn expect_signal "signo" "reason"
|
|
|
|
Expects the test case to terminate due to the reception of a signal.
|
|
|
|
If
|
|
|
|
.Va signo
|
|
|
|
is not
|
|
|
|
.Sq -1 ,
|
2014-09-23 22:29:03 +00:00
|
|
|
the runtime engine will validate that the signal that terminated the test
|
|
|
|
case matches the one provided in this call.
|
2012-09-04 23:07:32 +00:00
|
|
|
Otherwise, the exact value will be ignored.
|
|
|
|
.It Fn expect_timeout "reason"
|
|
|
|
Expects the test case to execute for longer than its timeout.
|
|
|
|
.El
|
|
|
|
.Ss Helper macros for common checks
|
|
|
|
The library provides several macros that are very handy in multiple
|
|
|
|
situations.
|
|
|
|
These basically check some condition after executing a given statement or
|
|
|
|
processing a given expression and, if the condition is not met, they
|
|
|
|
automatically call
|
|
|
|
.Fn ATF_FAIL
|
|
|
|
with an appropriate error message.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE
|
|
|
|
takes an expression and raises a failure if it evaluates to false.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE_EQ
|
|
|
|
takes two expressions and raises a failure if the two do not evaluate to
|
|
|
|
the same exact value.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE_IN
|
|
|
|
takes an element and a collection and validates that the element is present in
|
|
|
|
the collection.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE_MATCH
|
|
|
|
takes a regular expression and a string and raises a failure if the regular
|
|
|
|
expression does not match the string.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE_NOT_IN
|
|
|
|
takes an element and a collection and validates that the element is not present
|
|
|
|
in the collection.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_REQUIRE_THROW
|
|
|
|
takes the name of an exception and a statement and raises a failure if
|
|
|
|
the statement does not throw the specified exception.
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Fn ATF_REQUIRE_THROW_RE
|
2012-09-04 23:07:32 +00:00
|
|
|
takes the name of an exception, a regular expresion and a statement and raises a
|
|
|
|
failure if the statement does not throw the specified exception and if the
|
|
|
|
message of the exception does not match the regular expression.
|
|
|
|
.Pp
|
|
|
|
.Fn ATF_CHECK_ERRNO
|
|
|
|
and
|
|
|
|
.Fn ATF_REQUIRE_ERRNO
|
|
|
|
take, first, the error code that the check is expecting to find in the
|
|
|
|
.Va errno
|
|
|
|
variable and, second, a boolean expression that, if evaluates to true,
|
|
|
|
means that a call failed and
|
|
|
|
.Va errno
|
|
|
|
has to be checked against the first value.
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
.Ss Utility functions
|
|
|
|
The following functions are provided as part of the
|
|
|
|
.Nm
|
|
|
|
API to simplify the creation of a variety of tests.
|
|
|
|
In particular, these are useful to write tests for command-line interfaces.
|
|
|
|
.Pp
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::cat_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& prefix"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Prints the contents of
|
|
|
|
.Fa path
|
|
|
|
to the standard output, prefixing every line with the string in
|
|
|
|
.Fa prefix .
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::compare_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& contents"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Returns true if the given
|
|
|
|
.Fa path
|
|
|
|
matches exactly the expected inlined
|
|
|
|
.Fa contents .
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::copy_file
|
|
|
|
.Fa "const std::string& source"
|
|
|
|
.Fa "const std::string& destination"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Copies the file
|
|
|
|
.Fa source
|
|
|
|
to
|
|
|
|
.Fa destination .
|
|
|
|
The permissions of the file are preserved during the code.
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::create_file
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fa "const std::string& contents"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Creates
|
|
|
|
.Fa file
|
|
|
|
with the text given in
|
|
|
|
.Fa contents .
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::file_exists
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Checks if
|
|
|
|
.Fa path
|
|
|
|
exists.
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft pid_t
|
|
|
|
.Fo atf::utils::fork
|
|
|
|
.Fa "void"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Forks a process and redirects the standard output and standard error of the
|
|
|
|
child to files for later validation with
|
|
|
|
.Fn atf::utils::wait .
|
|
|
|
Fails the test case if the fork fails, so this does not return an error.
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_collection
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const Collection& collection"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Searches for the regular expression
|
|
|
|
.Fa regexp
|
|
|
|
in any of the strings contained in the
|
|
|
|
.Fa collection .
|
|
|
|
This is a template that accepts any one-dimensional container of strings.
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_file
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Searches for the regular expression
|
|
|
|
.Fa regexp
|
|
|
|
in the file
|
|
|
|
.Fa path .
|
|
|
|
The variable arguments are used to construct the regular expression.
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft bool
|
|
|
|
.Fo atf::utils::grep_string
|
|
|
|
.Fa "const std::string& regexp"
|
|
|
|
.Fa "const std::string& str"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Searches for the regular expression
|
|
|
|
.Fa regexp
|
|
|
|
in the string
|
|
|
|
.Fa str .
|
|
|
|
.Ed
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::redirect
|
|
|
|
.Fa "const int fd"
|
|
|
|
.Fa "const std::string& path"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Redirects the given file descriptor
|
|
|
|
.Fa fd
|
|
|
|
to the file
|
|
|
|
.Fa path .
|
|
|
|
This function exits the process in case of an error and does not properly mark
|
|
|
|
the test case as failed.
|
|
|
|
As a result, it should only be used in subprocesses of the test case; specially
|
|
|
|
those spawned by
|
|
|
|
.Fn atf::utils::fork .
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
.Ft void
|
|
|
|
.Fo atf::utils::wait
|
|
|
|
.Fa "const pid_t pid"
|
|
|
|
.Fa "const int expected_exit_status"
|
|
|
|
.Fa "const std::string& expected_stdout"
|
|
|
|
.Fa "const std::string& expected_stderr"
|
|
|
|
.Fc
|
2013-11-16 21:57:53 +00:00
|
|
|
.Bd -ragged -offset indent
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
Waits and validates the result of a subprocess spawned with
|
|
|
|
.Fn atf::utils::wait .
|
|
|
|
The validation involves checking that the subprocess exited cleanly and returned
|
|
|
|
the code specified in
|
|
|
|
.Fa expected_exit_status
|
|
|
|
and that its standard output and standard error match the strings given in
|
|
|
|
.Fa expected_stdout
|
|
|
|
and
|
|
|
|
.Fa expected_stderr .
|
|
|
|
.Pp
|
|
|
|
If any of the
|
|
|
|
.Fa expected_stdout
|
|
|
|
or
|
|
|
|
.Fa expected_stderr
|
|
|
|
strings are prefixed with
|
|
|
|
.Sq save: ,
|
|
|
|
then they specify the name of the file into which to store the stdout or stderr
|
|
|
|
of the subprocess, and no comparison is performed.
|
|
|
|
.Ed
|
2012-09-04 23:07:32 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
The following shows a complete test program with a single test case that
|
|
|
|
validates the addition operator:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
#include <atf-c++.hpp>
|
|
|
|
|
|
|
|
ATF_TEST_CASE(addition);
|
|
|
|
ATF_TEST_CASE_HEAD(addition)
|
|
|
|
{
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
set_md_var("descr", "Sample tests for the addition operator");
|
2012-09-04 23:07:32 +00:00
|
|
|
}
|
|
|
|
ATF_TEST_CASE_BODY(addition)
|
|
|
|
{
|
|
|
|
ATF_REQUIRE_EQ(0 + 0, 0);
|
|
|
|
ATF_REQUIRE_EQ(0 + 1, 1);
|
|
|
|
ATF_REQUIRE_EQ(1 + 0, 1);
|
|
|
|
|
|
|
|
ATF_REQUIRE_EQ(1 + 1, 2);
|
|
|
|
|
|
|
|
ATF_REQUIRE_EQ(100 + 200, 300);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TEST_CASE(open_failure);
|
|
|
|
ATF_TEST_CASE_HEAD(open_failure)
|
|
|
|
{
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
set_md_var("descr", "Sample tests for the open function");
|
2012-09-04 23:07:32 +00:00
|
|
|
}
|
|
|
|
ATF_TEST_CASE_BODY(open_failure)
|
|
|
|
{
|
|
|
|
ATF_REQUIRE_ERRNO(ENOENT, open("non-existent", O_RDONLY) == -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TEST_CASE(known_bug);
|
|
|
|
ATF_TEST_CASE_HEAD(known_bug)
|
|
|
|
{
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
set_md_var("descr", "Reproduces a known bug");
|
2012-09-04 23:07:32 +00:00
|
|
|
}
|
|
|
|
ATF_TEST_CASE_BODY(known_bug)
|
|
|
|
{
|
|
|
|
expect_fail("See bug number foo/bar");
|
|
|
|
ATF_REQUIRE_EQ(3, 1 + 1);
|
|
|
|
expect_pass();
|
|
|
|
ATF_REQUIRE_EQ(3, 1 + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_INIT_TEST_CASES(tcs)
|
|
|
|
{
|
|
|
|
ATF_ADD_TEST_CASE(tcs, addition);
|
|
|
|
ATF_ADD_TEST_CASE(tcs, open_failure);
|
|
|
|
ATF_ADD_TEST_CASE(tcs, known_bug);
|
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr atf-test-program 1 ,
|
2014-09-23 22:29:03 +00:00
|
|
|
.Xr atf-test-case 4
|