Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/atf/dist Import atf 0.17:
details: https://anonhg.NetBSD.org/src/rev/fd213a02b231
branches: trunk
changeset: 784958:fd213a02b231
user: jmmv <jmmv%NetBSD.org@localhost>
date: Fri Feb 15 17:04:15 2013 +0000
description:
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.
* 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.
diffstat:
external/bsd/atf/dist/NEWS | 34 +
external/bsd/atf/dist/atf-c++.hpp | 1 +
external/bsd/atf/dist/atf-c++/atf-c++-api.3 | 236 ++++++-
external/bsd/atf/dist/atf-c++/check.hpp | 4 +-
external/bsd/atf/dist/atf-c++/check_test.cpp | 38 +-
external/bsd/atf/dist/atf-c++/detail/Atffile | 1 +
external/bsd/atf/dist/atf-c++/detail/Kyuafile | 1 +
external/bsd/atf/dist/atf-c++/detail/auto_array.hpp | 179 ++++
external/bsd/atf/dist/atf-c++/detail/auto_array_test.cpp | 304 ++++++++
external/bsd/atf/dist/atf-c++/detail/process.cpp | 4 +-
external/bsd/atf/dist/atf-c++/detail/test_helpers.cpp | 41 -
external/bsd/atf/dist/atf-c++/detail/test_helpers.hpp | 2 -
external/bsd/atf/dist/atf-c++/macros_test.cpp | 47 +-
external/bsd/atf/dist/atf-c++/noncopyable.hpp | 56 +
external/bsd/atf/dist/atf-c++/utils.cpp | 104 ++
external/bsd/atf/dist/atf-c++/utils.hpp | 180 +----
external/bsd/atf/dist/atf-c++/utils_test.cpp | 565 +++++++++-----
external/bsd/atf/dist/atf-c.h | 1 +
external/bsd/atf/dist/atf-c/check_test.c | 50 +-
external/bsd/atf/dist/atf-c/detail/Atffile | 1 -
external/bsd/atf/dist/atf-c/detail/Kyuafile | 1 -
external/bsd/atf/dist/atf-c/detail/sanity_test.c | 40 +-
external/bsd/atf/dist/atf-c/detail/test_helpers.h | 2 -
external/bsd/atf/dist/atf-c/macros.h | 22 +-
external/bsd/atf/dist/atf-c/utils.c | 376 +++++++++-
external/bsd/atf/dist/atf-c/utils.h | 19 +
external/bsd/atf/dist/atf-c/utils_test.c | 480 ++++++++++++-
external/bsd/atf/dist/atf-run/io.cpp | 6 +-
external/bsd/atf/dist/atf-run/io.hpp | 18 +-
external/bsd/atf/dist/atf-sh/atf_check_test.sh | 4 +-
external/bsd/atf/dist/test-programs/Atffile | 1 -
external/bsd/atf/dist/test-programs/Kyuafile | 1 -
external/bsd/atf/dist/test-programs/c_helpers.c | 51 -
external/bsd/atf/dist/test-programs/cpp_helpers.cpp | 26 +-
external/bsd/atf/dist/test-programs/sh_helpers.sh | 39 -
35 files changed, 2287 insertions(+), 648 deletions(-)
diffs (truncated from 3772 to 300 lines):
diff -r 5ae11025d784 -r fd213a02b231 external/bsd/atf/dist/NEWS
--- a/external/bsd/atf/dist/NEWS Fri Feb 15 15:01:18 2013 +0000
+++ b/external/bsd/atf/dist/NEWS Fri Feb 15 17:04:15 2013 +0000
@@ -2,6 +2,40 @@
===========================================================================
+Changes in version 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.
+
+* 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.
+
+
Changes in version 0.16
***********************
diff -r 5ae11025d784 -r fd213a02b231 external/bsd/atf/dist/atf-c++.hpp
--- a/external/bsd/atf/dist/atf-c++.hpp Fri Feb 15 15:01:18 2013 +0000
+++ b/external/bsd/atf/dist/atf-c++.hpp Fri Feb 15 17:04:15 2013 +0000
@@ -31,5 +31,6 @@
#define _ATF_CXX_HPP_
#include <atf-c++/macros.hpp>
+#include <atf-c++/utils.hpp>
#endif // !defined(_ATF_CXX_HPP_)
diff -r 5ae11025d784 -r fd213a02b231 external/bsd/atf/dist/atf-c++/atf-c++-api.3
--- a/external/bsd/atf/dist/atf-c++/atf-c++-api.3 Fri Feb 15 15:01:18 2013 +0000
+++ b/external/bsd/atf/dist/atf-c++/atf-c++-api.3 Fri Feb 15 17:04:15 2013 +0000
@@ -26,10 +26,11 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 21, 2012
+.Dd November 30, 2012
.Dt ATF-C++-API 3
.Os
.Sh NAME
+.Nm atf-c++-api ,
.Nm ATF_ADD_TEST_CASE ,
.Nm ATF_CHECK_ERRNO ,
.Nm ATF_FAIL ,
@@ -52,6 +53,17 @@
.Nm ATF_TEST_CASE_USE ,
.Nm ATF_TEST_CASE_WITH_CLEANUP ,
.Nm ATF_TEST_CASE_WITHOUT_HEAD ,
+.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
.Nd C++ API to write ATF-based test programs
.Sh SYNOPSIS
.In atf-c++.hpp
@@ -77,6 +89,61 @@
.Fn ATF_TEST_CASE_USE "name"
.Fn ATF_TEST_CASE_WITH_CLEANUP "name"
.Fn ATF_TEST_CASE_WITHOUT_HEAD "name"
+.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
.Sh DESCRIPTION
ATF provides a mostly-macro-based programming interface to implement test
programs in C or C++.
@@ -205,7 +272,7 @@
former call.
.Ss Header definitions
The test case's header can define the meta-data by using the
-.Fn set
+.Fn set_md_var
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.
@@ -348,7 +415,7 @@
.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.
-.Fn ATF_REQUIRE_THROW_EQ
+.Fn ATF_REQUIRE_THROW_RE
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.
@@ -362,6 +429,163 @@
means that a call failed and
.Va errno
has to be checked against the first value.
+.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
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+Checks if
+.Fa path
+exists.
+.Ed
+.Pp
+.Ft pid_t
+.Fo atf::utils::fork
+.Fa "void"
+.Fc
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+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
+.Bd -offset indent
+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 .
Home |
Main Index |
Thread Index |
Old Index