svn commit: r258289 - in head: 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-report ...

Julio Merino jmmv at FreeBSD.org
Sun Nov 17 23:51:21 UTC 2013


Author: jmmv
Date: Sun Nov 17 23:51:19 2013
New Revision: 258289
URL: http://svnweb.freebsd.org/changeset/base/258289

Log:
  MFV: Import atf-0.18.
  
  Approved by:	rpaulo (mentor)

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

Modified: head/contrib/atf/NEWS
==============================================================================
--- head/contrib/atf/NEWS	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/NEWS	Sun Nov 17 23:51:19 2013	(r258289)
@@ -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: head/contrib/atf/atf-c++.hpp
==============================================================================
--- head/contrib/atf/atf-c++.hpp	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++.hpp	Sun Nov 17 23:51:19 2013	(r258289)
@@ -31,5 +31,6 @@
 #define _ATF_CXX_HPP_
 
 #include <atf-c++/macros.hpp>
+#include <atf-c++/utils.hpp>
 
 #endif // !defined(_ATF_CXX_HPP_)

Modified: head/contrib/atf/atf-c++/atf-c++-api.3
==============================================================================
--- head/contrib/atf/atf-c++/atf-c++-api.3	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/atf-c++-api.3	Sun Nov 17 23:51:19 2013	(r258289)
@@ -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: head/contrib/atf/atf-c++/check.hpp
==============================================================================
--- head/contrib/atf/atf-c++/check.hpp	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/check.hpp	Sun Nov 17 23:51:19 2013	(r258289)
@@ -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: head/contrib/atf/atf-c++/check_test.cpp
==============================================================================
--- head/contrib/atf/atf-c++/check_test.cpp	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/check_test.cpp	Sun Nov 17 23:51:19 2013	(r258289)
@@ -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: head/contrib/atf/atf-c++/detail/Atffile
==============================================================================
--- head/contrib/atf/atf-c++/detail/Atffile	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/detail/Atffile	Sun Nov 17 23:51:19 2013	(r258289)
@@ -3,6 +3,7 @@ Content-Type: application/X-atf-atffile;
 prop: test-suite = atf
 
 tp: application_test
+tp: auto_array_test
 tp: env_test
 tp: exceptions_test
 tp: expand_test

Modified: head/contrib/atf/atf-c++/detail/Kyuafile
==============================================================================
--- head/contrib/atf/atf-c++/detail/Kyuafile	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/detail/Kyuafile	Sun Nov 17 23:51:19 2013	(r258289)
@@ -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: head/contrib/atf/atf-c++/detail/auto_array.hpp (from r258239, vendor/atf/dist/atf-c++/detail/auto_array.hpp)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/atf/atf-c++/detail/auto_array.hpp	Sun Nov 17 23:51:19 2013	(r258289, copy of r258239, vendor/atf/dist/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: head/contrib/atf/atf-c++/detail/auto_array_test.cpp (from r258239, vendor/atf/dist/atf-c++/detail/auto_array_test.cpp)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/atf/atf-c++/detail/auto_array_test.cpp	Sun Nov 17 23:51:19 2013	(r258289, copy of r258239, vendor/atf/dist/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;
+
+    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;
+            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_assign_ref);
+ATF_TEST_CASE_HEAD(auto_array_assign_ref)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' "
+               "assignment operator through the auxiliary auto_array_ref "
+               "object");
+}
+ATF_TEST_CASE_BODY(auto_array_assign_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;
+            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_access);
+ATF_TEST_CASE_HEAD(auto_array_access)
+{
+    set_md_var("descr", "Tests the auto_array smart pointer class' access "
+               "operator");
+}
+ATF_TEST_CASE_BODY(auto_array_access)
+{
+    using atf::auto_array;
+
+    auto_array< test_array > t(new test_array[10]);
+
+    for (int i = 0; i < 10; i++)
+        t[i].m_value = i * 2;
+
+    for (int i = 0; i < 10; i++)
+        ATF_REQUIRE_EQ(t[i].m_value, i * 2);
+}
+
+// ------------------------------------------------------------------------
+// Main.
+// ------------------------------------------------------------------------
+
+ATF_INIT_TEST_CASES(tcs)
+{
+    // Add the test for the "auto_array" class.
+    ATF_ADD_TEST_CASE(tcs, auto_array_scope);
+    ATF_ADD_TEST_CASE(tcs, auto_array_copy);
+    ATF_ADD_TEST_CASE(tcs, auto_array_copy_ref);
+    ATF_ADD_TEST_CASE(tcs, auto_array_get);
+    ATF_ADD_TEST_CASE(tcs, auto_array_release);
+    ATF_ADD_TEST_CASE(tcs, auto_array_reset);
+    ATF_ADD_TEST_CASE(tcs, auto_array_assign);
+    ATF_ADD_TEST_CASE(tcs, auto_array_assign_ref);
+    ATF_ADD_TEST_CASE(tcs, auto_array_access);
+}

Modified: head/contrib/atf/atf-c++/detail/parser.hpp
==============================================================================
--- head/contrib/atf/atf-c++/detail/parser.hpp	Sun Nov 17 23:43:50 2013	(r258288)
+++ head/contrib/atf/atf-c++/detail/parser.hpp	Sun Nov 17 23:51:19 2013	(r258289)
@@ -259,7 +259,7 @@ tokenizer< IS >::next(void)
                 t = token(m_lineno, m_text_type, text);
                 quoted = true;
             } else {
-                m_is.unget();
+                m_is.putback(ch);
                 done = true;
             }
         } else {
@@ -271,13 +271,13 @@ tokenizer< IS >::next(void)
                     t = token(m_lineno, (*idelim).second,

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


More information about the svn-src-all mailing list