svn commit: r260029 - in stable/10: contrib/atf contrib/atf/admin contrib/atf/atf-c contrib/atf/atf-c++ contrib/atf/atf-c++/detail contrib/atf/atf-c/detail contrib/atf/atf-config contrib/atf/atf-re...

Julio Merino jmmv at FreeBSD.org
Sun Dec 29 02:57:13 UTC 2013


Author: jmmv
Date: Sun Dec 29 02:57:10 2013
New Revision: 260029
URL: http://svnweb.freebsd.org/changeset/base/260029

Log:
  Update atf to 0.18 and remove the code of the deprecated tools.
  
  This is a MFC into stable/10 of:
  - r258286 Update notes for imports of atf.
  - r258289 MFV: Import atf-0.18.
  - r258290 Drop all ATF tools code.
  
  This is "make tinderbox" clean as run on ref10-amd64 with the default
  WITHOUT_TESTS option.  A "make buildworld" with WITH_TESTS set now works
  as well.

Added:
  stable/10/contrib/atf/atf-c++/detail/auto_array.hpp
     - copied unchanged from r258289, head/contrib/atf/atf-c++/detail/auto_array.hpp
  stable/10/contrib/atf/atf-c++/detail/auto_array_test.cpp
     - copied unchanged from r258289, head/contrib/atf/atf-c++/detail/auto_array_test.cpp
  stable/10/contrib/atf/atf-c++/noncopyable.hpp
     - copied unchanged from r258289, head/contrib/atf/atf-c++/noncopyable.hpp
  stable/10/contrib/atf/atf-c++/utils.cpp
     - copied unchanged from r258289, head/contrib/atf/atf-c++/utils.cpp
Deleted:
  stable/10/contrib/atf/Atffile
  stable/10/contrib/atf/Makefile.am
  stable/10/contrib/atf/Makefile.in
  stable/10/contrib/atf/admin/
  stable/10/contrib/atf/atf-c++/Atffile
  stable/10/contrib/atf/atf-c++/Makefile.am.inc
  stable/10/contrib/atf/atf-c++/detail/Atffile
  stable/10/contrib/atf/atf-c++/detail/Makefile.am.inc
  stable/10/contrib/atf/atf-c/Atffile
  stable/10/contrib/atf/atf-c/Makefile.am.inc
  stable/10/contrib/atf/atf-c/detail/Atffile
  stable/10/contrib/atf/atf-c/detail/Makefile.am.inc
  stable/10/contrib/atf/atf-c/detail/test_helpers_test.c
  stable/10/contrib/atf/atf-config/
  stable/10/contrib/atf/atf-report/
  stable/10/contrib/atf/atf-run/
  stable/10/contrib/atf/atf-sh/Atffile
  stable/10/contrib/atf/atf-sh/Makefile.am.inc
  stable/10/contrib/atf/atf-version/
  stable/10/contrib/atf/bconfig.h.in
  stable/10/contrib/atf/configure
  stable/10/contrib/atf/configure.ac
  stable/10/contrib/atf/doc/Makefile.am.inc
  stable/10/contrib/atf/doc/atf-formats.5
  stable/10/contrib/atf/doc/atf.7.in
  stable/10/contrib/atf/test-programs/Atffile
  stable/10/contrib/atf/test-programs/Makefile.am.inc
  stable/10/contrib/atf/test-programs/fork_test.sh
Modified:
  stable/10/contrib/atf/FREEBSD-Xlist
  stable/10/contrib/atf/FREEBSD-upgrade
  stable/10/contrib/atf/NEWS
  stable/10/contrib/atf/atf-c++.hpp
  stable/10/contrib/atf/atf-c++/atf-c++-api.3
  stable/10/contrib/atf/atf-c++/check.hpp
  stable/10/contrib/atf/atf-c++/check_test.cpp
  stable/10/contrib/atf/atf-c++/detail/Kyuafile
  stable/10/contrib/atf/atf-c++/detail/parser.hpp
  stable/10/contrib/atf/atf-c++/detail/process.cpp
  stable/10/contrib/atf/atf-c++/detail/process.hpp
  stable/10/contrib/atf/atf-c++/detail/test_helpers.cpp
  stable/10/contrib/atf/atf-c++/detail/test_helpers.hpp
  stable/10/contrib/atf/atf-c++/macros_test.cpp
  stable/10/contrib/atf/atf-c++/pkg_config_test.sh
  stable/10/contrib/atf/atf-c++/tests.cpp
  stable/10/contrib/atf/atf-c++/tests.hpp
  stable/10/contrib/atf/atf-c++/utils.hpp
  stable/10/contrib/atf/atf-c++/utils_test.cpp
  stable/10/contrib/atf/atf-c.h
  stable/10/contrib/atf/atf-c/atf-c-api.3
  stable/10/contrib/atf/atf-c/check_test.c
  stable/10/contrib/atf/atf-c/detail/Kyuafile
  stable/10/contrib/atf/atf-c/detail/process_test.c
  stable/10/contrib/atf/atf-c/detail/sanity_test.c
  stable/10/contrib/atf/atf-c/detail/test_helpers.c
  stable/10/contrib/atf/atf-c/detail/test_helpers.h
  stable/10/contrib/atf/atf-c/macros.h
  stable/10/contrib/atf/atf-c/macros_test.c
  stable/10/contrib/atf/atf-c/pkg_config_test.sh
  stable/10/contrib/atf/atf-c/utils.c
  stable/10/contrib/atf/atf-c/utils.h
  stable/10/contrib/atf/atf-c/utils_test.c
  stable/10/contrib/atf/atf-sh/atf-check.cpp
  stable/10/contrib/atf/atf-sh/atf-check_test.sh
  stable/10/contrib/atf/atf-sh/atf-sh-api.3
  stable/10/contrib/atf/atf-sh/atf-sh.1
  stable/10/contrib/atf/atf-sh/atf_check_test.sh
  stable/10/contrib/atf/atf-sh/misc_helpers.sh
  stable/10/contrib/atf/bconfig.h
  stable/10/contrib/atf/test-programs/Kyuafile
  stable/10/contrib/atf/test-programs/c_helpers.c
  stable/10/contrib/atf/test-programs/cpp_helpers.cpp
  stable/10/contrib/atf/test-programs/sh_helpers.sh
  stable/10/lib/atf/libatf-c++/Makefile
  stable/10/lib/atf/libatf-c/tests/Makefile
  stable/10/lib/atf/tests/test-programs/Makefile
  stable/10/tools/build/mk/OptionalObsoleteFiles.inc
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/atf/FREEBSD-Xlist
==============================================================================
--- stable/10/contrib/atf/FREEBSD-Xlist	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/FREEBSD-Xlist	Sun Dec 29 02:57:10 2013	(r260029)
@@ -1,8 +1,21 @@
+*/*/Atffile
+*/*/Makefile*
+*/Atffile
+*/Makefile*
+Atffile
+INSTALL
+Makefile*
+aclocal.m4
+admin/
+atf-*/atf-*.m4
+atf-*/atf-*.pc.in
+atf-config/
+atf-report/
+atf-run/
+atf-version/
+bconfig.h.in
 bootstrap/
-config.log
-config.status
-libtool
-Makefile
-stamp-h1
-*/*/.deps/
-*/.deps/
+configure*
+doc/atf-formats.5
+doc/atf.7.in
+m4/

Modified: stable/10/contrib/atf/FREEBSD-upgrade
==============================================================================
--- stable/10/contrib/atf/FREEBSD-upgrade	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/FREEBSD-upgrade	Sun Dec 29 02:57:10 2013	(r260029)
@@ -1,28 +1,48 @@
 $FreeBSD$
 
-atf
+This document contains a collection of notes specific to the import
+of atf into head.  These notes are built on the instructions in
+the FreeBSD Subversion Primer that detail how to deal with vendor
+branches and you are supposed to follow those:
 
-The source code is hosted on GoogleCode as a subcomponent of the Kyua project:
+	http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html
 
-	http://code.google.com/p/kyua/downloads/list
-
-For the contrib directory, the sources were initially prepared like so:
-
-	./configure --prefix=/ --exec-prefix=/usr --datarootdir=/usr/share
+The ATF source code is hosted on Google Code as a subcomponent of the
+Kyua project:
 
-For the contrib directory, files and directories were pruned by:
-
-sh -c 'for F in `cat FREEBSD-Xlist`; do rm -rf ./$F ; done'
+	http://code.google.com/p/kyua/downloads/list
 
-You may check if there are any new files that we don't need.
+and is imported into the atf vendor branch (see base/vendor/atf/).
 
-The instructions for importing new release and merging to HEAD can be found
-at FreeBSD wiki:
+To merge the vendor branch into head do something like this:
 
-	http://wiki.freebsd.org/SubversionPrimer/VendorImports
+	cd .../base/head/contrib/atf
+	svn merge --accept=postpone \
+	    svn+ssh://svn.freebsd.org/base/vendor/atf/dist .
+	svn remove --force $(cat FREEBSD-Xlist)
+
+and resolve any conflicts that may arise at this point.
+
+Once this is done, you must regenerate bconfig.h.  The recommended way
+of doing so is by using the release files already imported into the
+vendor branch (which is a good justification for importing the verbatim
+sources in the first place so that this step is reproducible).  You can
+use a set of commands similar to the following:
+
+	mkdir /tmp/atf
+	cd /tmp/atf
+	.../vendor/atf/dist/configure \
+	    --prefix=/ \
+	    --exec-prefix=/usr \
+	    --datarootdir=/usr/share
+	cp bconfig.h .../base/head/contrib/atf/
+
+Please do NOT run './configure' straight from the 'dist' directory of
+the vendor branch as you easily risk committing build products into the
+tree.
 
-To make local changes to atf, simply patch and commit to the trunk
-branch (aka HEAD).  Never make local changes on the vendor branch.
+Lastly, with the list of old and new files in this import, make sure
+to udpate the reachover Makefiles accordingly.
 
-gcooper at FreeBSD.org
-5-August-2012
+Test the build (keeping in mind the WITH_TESTS/WITHOUT_TESTS knobs) and,
+if all looks good, you are ready to commit all the changes in one go.

Modified: stable/10/contrib/atf/NEWS
==============================================================================
--- stable/10/contrib/atf/NEWS	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/NEWS	Sun Dec 29 02:57:10 2013	(r260029)
@@ -2,6 +2,58 @@ Major changes between releases          
 ===========================================================================
 
 
+Changes in version 0.18
+***********************
+
+Experimental version released on November 16th, 2013.
+
+* Issue 45: Added require.memory support in atf-run for FreeBSD.
+
+* Fixed an issue with the handling of cin with libc++.
+
+* Issue 64: Fixed various mandoc formatting warnings.
+
+* NetBSD PR bin/48284: Made atf-check flush its progress message to
+  stdout so that an interrupted test case always shows the last message
+  being executed.
+
+* NetBSD PR bin/48285: Fixed atf_check examples in atf-sh-api(3).
+
+
+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
 ***********************
 

Modified: stable/10/contrib/atf/atf-c++.hpp
==============================================================================
--- stable/10/contrib/atf/atf-c++.hpp	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/atf-c++.hpp	Sun Dec 29 02:57:10 2013	(r260029)
@@ -31,5 +31,6 @@
 #define _ATF_CXX_HPP_
 
 #include <atf-c++/macros.hpp>
+#include <atf-c++/utils.hpp>
 
 #endif // !defined(_ATF_CXX_HPP_)

Modified: stable/10/contrib/atf/atf-c++/atf-c++-api.3
==============================================================================
--- stable/10/contrib/atf/atf-c++/atf-c++-api.3	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/atf-c++/atf-c++-api.3	Sun Dec 29 02:57:10 2013	(r260029)
@@ -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 15, 2013
 .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,18 +89,64 @@
 .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++.
-This interface is backed by a C++ implementation, but this fact is
-hidden from the developer as much as possible through the use of
-macros to simplify programming.
-However, the use of C++ is not hidden everywhere and while you can
-implement test cases without knowing anything at all about the object model
-underneath the provided calls, you might need some minimum notions of the
-language in very specific circumstances.
-.Pp
-C++-based test programs always follow this template:
+ATF provides a C++ programming interface to implement test programs.
+C++-based test programs follow this template:
 .Bd -literal -offset indent
 extern "C" {
 .Ns ... C-specific includes go here ...
@@ -205,7 +263,7 @@ The first parameter of this macro matche
 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 +406,7 @@ in the collection.
 .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 +420,163 @@ variable and, second, a boolean expressi
 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 -ragged -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 -ragged -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 -ragged -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 -ragged -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 -ragged -offset indent
+Checks if
+.Fa path
+exists.
+.Ed
+.Pp
+.Ft pid_t
+.Fo atf::utils::fork
+.Fa "void"
+.Fc
+.Bd -ragged -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 -ragged -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 -ragged -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 -ragged -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 -ragged -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 .
+.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
+.Bd -ragged -offset indent
+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
 .Sh EXAMPLES
 The following shows a complete test program with a single test case that
 validates the addition operator:
@@ -371,7 +586,7 @@ validates the addition operator:
 ATF_TEST_CASE(addition);
 ATF_TEST_CASE_HEAD(addition)
 {
-    set("descr", "Sample tests for the addition operator");
+    set_md_var("descr", "Sample tests for the addition operator");
 }
 ATF_TEST_CASE_BODY(addition)
 {
@@ -387,7 +602,7 @@ ATF_TEST_CASE_BODY(addition)
 ATF_TEST_CASE(open_failure);
 ATF_TEST_CASE_HEAD(open_failure)
 {
-    set("descr", "Sample tests for the open function");
+    set_md_var("descr", "Sample tests for the open function");
 }
 ATF_TEST_CASE_BODY(open_failure)
 {
@@ -397,7 +612,7 @@ ATF_TEST_CASE_BODY(open_failure)
 ATF_TEST_CASE(known_bug);
 ATF_TEST_CASE_HEAD(known_bug)
 {
-    set("descr", "Reproduces a known bug");
+    set_md_var("descr", "Reproduces a known bug");
 }
 ATF_TEST_CASE_BODY(known_bug)
 {

Modified: stable/10/contrib/atf/atf-c++/check.hpp
==============================================================================
--- stable/10/contrib/atf/atf-c++/check.hpp	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/atf-c++/check.hpp	Sun Dec 29 02:57:10 2013	(r260029)
@@ -39,7 +39,7 @@ extern "C" {
 #include <string>
 #include <vector>
 
-#include <atf-c++/utils.hpp>
+#include <atf-c++/noncopyable.hpp>
 
 namespace atf {
 
@@ -60,7 +60,7 @@ namespace check {
 //! of executing arbitrary command and manages files containing
 //! its output.
 //!
-class check_result : utils::noncopyable {
+class check_result : noncopyable {
     //!
     //! \brief Internal representation of a result.
     //!

Modified: stable/10/contrib/atf/atf-c++/check_test.cpp
==============================================================================
--- stable/10/contrib/atf/atf-c++/check_test.cpp	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/atf-c++/check_test.cpp	Sun Dec 29 02:57:10 2013	(r260029)
@@ -193,15 +193,15 @@ ATF_TEST_CASE_BODY(build_c_o)
 {
     ATF_TEST_CASE_USE(h_build_c_o_ok);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_ok) >();
-    ATF_REQUIRE(grep_file("stdout", "-o test.o"));
-    ATF_REQUIRE(grep_file("stdout", "-c test.c"));
+    ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout"));
 
     ATF_TEST_CASE_USE(h_build_c_o_fail);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_fail) >();
-    ATF_REQUIRE(grep_file("stdout", "-o test.o"));
-    ATF_REQUIRE(grep_file("stdout", "-c test.c"));
-    ATF_REQUIRE(grep_file("stderr", "test.c"));
-    ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL"));
+    ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr"));
+    ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr"));
 }
 
 ATF_TEST_CASE(build_cpp);
@@ -213,16 +213,16 @@ ATF_TEST_CASE_BODY(build_cpp)
 {
     ATF_TEST_CASE_USE(h_build_cpp_ok);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_ok) >();
-    ATF_REQUIRE(grep_file("stdout", "-o.*test.p"));
-    ATF_REQUIRE(grep_file("stdout", "test.c"));
-    ATF_REQUIRE(grep_file("test.p", "foo bar"));
+    ATF_REQUIRE(atf::utils::grep_file("-o.*test.p", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("foo bar", "test.p"));
 
     ATF_TEST_CASE_USE(h_build_cpp_fail);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_fail) >();
-    ATF_REQUIRE(grep_file("stdout", "-o test.p"));
-    ATF_REQUIRE(grep_file("stdout", "test.c"));
-    ATF_REQUIRE(grep_file("stderr", "test.c"));
-    ATF_REQUIRE(grep_file("stderr", "non-existent.h"));
+    ATF_REQUIRE(atf::utils::grep_file("-o test.p", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr"));
+    ATF_REQUIRE(atf::utils::grep_file("non-existent.h", "stderr"));
 }
 
 ATF_TEST_CASE(build_cxx_o);
@@ -234,15 +234,15 @@ ATF_TEST_CASE_BODY(build_cxx_o)
 {
     ATF_TEST_CASE_USE(h_build_cxx_o_ok);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_ok) >();
-    ATF_REQUIRE(grep_file("stdout", "-o test.o"));
-    ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));
+    ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout"));
 
     ATF_TEST_CASE_USE(h_build_cxx_o_fail);
     run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_fail) >();
-    ATF_REQUIRE(grep_file("stdout", "-o test.o"));
-    ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));
-    ATF_REQUIRE(grep_file("stderr", "test.cpp"));
-    ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL"));
+    ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout"));
+    ATF_REQUIRE(atf::utils::grep_file("test.cpp", "stderr"));
+    ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr"));
 }
 
 ATF_TEST_CASE(exec_cleanup);

Modified: stable/10/contrib/atf/atf-c++/detail/Kyuafile
==============================================================================
--- stable/10/contrib/atf/atf-c++/detail/Kyuafile	Sun Dec 29 02:31:40 2013	(r260028)
+++ stable/10/contrib/atf/atf-c++/detail/Kyuafile	Sun Dec 29 02:57:10 2013	(r260029)
@@ -3,6 +3,7 @@ syntax("kyuafile", 1)
 test_suite("atf")
 
 atf_test_program{name="application_test"}
+atf_test_program{name="auto_array_test"}
 atf_test_program{name="env_test"}
 atf_test_program{name="exceptions_test"}
 atf_test_program{name="expand_test"}

Copied: stable/10/contrib/atf/atf-c++/detail/auto_array.hpp (from r258289, head/contrib/atf/atf-c++/detail/auto_array.hpp)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/atf/atf-c++/detail/auto_array.hpp	Sun Dec 29 02:57:10 2013	(r260029, copy of r258289, head/contrib/atf/atf-c++/detail/auto_array.hpp)
@@ -0,0 +1,179 @@
+//
+// Automated Testing Framework (atf)
+//
+// Copyright (c) 2007 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.
+//
+
+#if !defined(_ATF_CXX_AUTO_ARRAY_HPP_)
+#define _ATF_CXX_AUTO_ARRAY_HPP_
+
+#include <cstddef>
+
+namespace atf {
+
+// ------------------------------------------------------------------------
+// The "auto_array" class.
+// ------------------------------------------------------------------------
+
+template< class T >
+struct auto_array_ref {
+    T* m_ptr;
+
+    explicit auto_array_ref(T*);
+};
+
+template< class T >
+auto_array_ref< T >::auto_array_ref(T* ptr) :
+    m_ptr(ptr)
+{
+}
+
+template< class T >
+class auto_array {
+    T* m_ptr;
+
+public:
+    auto_array(T* = NULL) throw();
+    auto_array(auto_array< T >&) throw();
+    auto_array(auto_array_ref< T >) throw();
+    ~auto_array(void) throw();
+
+    T* get(void) throw();
+    const T* get(void) const throw();
+    T* release(void) throw();
+    void reset(T* = NULL) throw();
+
+    auto_array< T >& operator=(auto_array< T >&) throw();
+    auto_array< T >& operator=(auto_array_ref< T >) throw();
+
+    T& operator[](int) throw();
+    operator auto_array_ref< T >(void) throw();
+};
+
+template< class T >
+auto_array< T >::auto_array(T* ptr)
+    throw() :
+    m_ptr(ptr)
+{
+}
+
+template< class T >
+auto_array< T >::auto_array(auto_array< T >& ptr)
+    throw() :
+    m_ptr(ptr.release())
+{
+}
+
+template< class T >
+auto_array< T >::auto_array(auto_array_ref< T > ref)
+    throw() :
+    m_ptr(ref.m_ptr)
+{
+}
+
+template< class T >
+auto_array< T >::~auto_array(void)
+    throw()
+{
+    if (m_ptr != NULL)
+        delete [] m_ptr;
+}
+
+template< class T >
+T*
+auto_array< T >::get(void)
+    throw()
+{
+    return m_ptr;
+}
+
+template< class T >
+const T*
+auto_array< T >::get(void)
+    const throw()
+{
+    return m_ptr;
+}
+
+template< class T >
+T*
+auto_array< T >::release(void)
+    throw()
+{
+    T* ptr = m_ptr;
+    m_ptr = NULL;
+    return ptr;
+}
+
+template< class T >
+void
+auto_array< T >::reset(T* ptr)
+    throw()
+{
+    if (m_ptr != NULL)
+        delete [] m_ptr;
+    m_ptr = ptr;
+}
+
+template< class T >
+auto_array< T >&
+auto_array< T >::operator=(auto_array< T >& ptr)
+    throw()
+{
+    reset(ptr.release());
+    return *this;
+}
+
+template< class T >
+auto_array< T >&
+auto_array< T >::operator=(auto_array_ref< T > ref)
+    throw()
+{
+    if (m_ptr != ref.m_ptr) {
+        delete [] m_ptr;
+        m_ptr = ref.m_ptr;
+    }
+    return *this;
+}
+
+template< class T >
+T&
+auto_array< T >::operator[](int pos)
+    throw()
+{
+    return m_ptr[pos];
+}
+
+template< class T >
+auto_array< T >::operator auto_array_ref< T >(void)
+    throw()
+{
+    return auto_array_ref< T >(release());
+}
+
+} // namespace atf
+
+#endif // !defined(_ATF_CXX_AUTO_ARRAY_HPP_)

Copied: stable/10/contrib/atf/atf-c++/detail/auto_array_test.cpp (from r258289, head/contrib/atf/atf-c++/detail/auto_array_test.cpp)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/atf/atf-c++/detail/auto_array_test.cpp	Sun Dec 29 02:57:10 2013	(r260029, copy of r258289, head/contrib/atf/atf-c++/detail/auto_array_test.cpp)
@@ -0,0 +1,304 @@
+//
+// Automated Testing Framework (atf)
+//
+// Copyright (c) 2007 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.
+//
+
+extern "C" {
+#include <sys/types.h>
+}
+
+#include <iostream>
+
+#include "atf-c/defs.h"
+
+#include "../macros.hpp"
+
+#include "auto_array.hpp"
+
+// ------------------------------------------------------------------------
+// Tests for the "auto_array" class.
+// ------------------------------------------------------------------------
+
+class test_array {
+public:
+    int m_value;
+
+    static ssize_t m_nblocks;
+
+    static
+    atf::auto_array< test_array >
+    do_copy(atf::auto_array< test_array >& ta)
+    {
+        return atf::auto_array< test_array >(ta);
+    }
+
+    void* operator new(size_t size ATF_DEFS_ATTRIBUTE_UNUSED)
+    {
+        ATF_FAIL("New called but should have been new[]");
+        return new int(5);
+    }
+
+    void* operator new[](size_t size)
+    {
+        m_nblocks++;
+        void* mem = ::operator new(size);
+        std::cout << "Allocated 'test_array' object " << mem << "\n";
+        return mem;
+    }
+
+    void operator delete(void* mem ATF_DEFS_ATTRIBUTE_UNUSED)
+    {
+        ATF_FAIL("Delete called but should have been delete[]");
+    }
+
+    void operator delete[](void* mem)
+    {
+        std::cout << "Releasing 'test_array' object " << mem << "\n";
+        if (m_nblocks == 0)
+            ATF_FAIL("Unbalanced delete[]");
+        m_nblocks--;
+        ::operator delete(mem);
+    }
+};
+
+ssize_t test_array::m_nblocks = 0;
+
+ATF_TEST_CASE(auto_array_scope);
+ATF_TEST_CASE_HEAD(auto_array_scope)
+{
+    set_md_var("descr", "Tests the automatic scope handling in the "
+               "auto_array smart pointer class");
+}
+ATF_TEST_CASE_BODY(auto_array_scope)
+{
+    using atf::auto_array;
+
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    {
+        auto_array< test_array > t(new test_array[10]);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+    }
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_copy);
+ATF_TEST_CASE_HEAD(auto_array_copy)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' copy "
+               "constructor");
+}
+ATF_TEST_CASE_BODY(auto_array_copy)
+{
+    using atf::auto_array;
+
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    {
+        auto_array< test_array > t1(new test_array[10]);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+        {
+            auto_array< test_array > t2(t1);
+            ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+        }
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    }
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_copy_ref);
+ATF_TEST_CASE_HEAD(auto_array_copy_ref)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' copy "
+               "constructor through the auxiliary auto_array_ref object");
+}
+ATF_TEST_CASE_BODY(auto_array_copy_ref)
+{
+    using atf::auto_array;
+
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    {
+        auto_array< test_array > t1(new test_array[10]);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+
+        {
+            auto_array< test_array > t2 = test_array::do_copy(t1);
+            ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+        }
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    }
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_get);
+ATF_TEST_CASE_HEAD(auto_array_get)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' get "
+               "method");
+}
+ATF_TEST_CASE_BODY(auto_array_get)
+{
+    using atf::auto_array;
+
+    test_array* ta = new test_array[10];
+    auto_array< test_array > t(ta);
+    ATF_REQUIRE_EQ(t.get(), ta);
+}
+
+ATF_TEST_CASE(auto_array_release);
+ATF_TEST_CASE_HEAD(auto_array_release)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' release "
+               "method");
+}
+ATF_TEST_CASE_BODY(auto_array_release)
+{
+    using atf::auto_array;
+
+    test_array* ta1 = new test_array[10];
+    {
+        auto_array< test_array > t(ta1);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+        test_array* ta2 = t.release();
+        ATF_REQUIRE_EQ(ta2, ta1);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+    }
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+    delete [] ta1;
+}
+
+ATF_TEST_CASE(auto_array_reset);
+ATF_TEST_CASE_HEAD(auto_array_reset)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' reset "
+               "method");
+}
+ATF_TEST_CASE_BODY(auto_array_reset)
+{
+    using atf::auto_array;
+
+    test_array* ta1 = new test_array[10];
+    test_array* ta2 = new test_array[10];
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
+
+    {
+        auto_array< test_array > t(ta1);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
+        t.reset(ta2);
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
+        t.reset();
+        ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+    }
+    ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
+}
+
+ATF_TEST_CASE(auto_array_assign);
+ATF_TEST_CASE_HEAD(auto_array_assign)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' "
+               "assignment operator");
+}
+ATF_TEST_CASE_BODY(auto_array_assign)
+{
+    using atf::auto_array;
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list