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.12:



details:   https://anonhg.NetBSD.org/src/rev/34bd02a7cfd1
branches:  trunk
changeset: 758539:34bd02a7cfd1
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Sun Nov 07 17:43:22 2010 +0000

description:
Import atf 0.12:

Experimental version released on November 7th, 2010.

* Added the ATF_REQUIRE_THROW_RE to atf-c++, which is the same as
  ATF_REQUIRE_THROW but allows checking for the validity of the exception's
  error message by means of a regular expression.

* Added the ATF_REQUIRE_MATCH to atf-c++, which allows checking for a
  regular expression match in a string.

* Changed the default timeout for test cases from 5 minutes to 30 seconds.
  30 seconds is long enough for virtually all tests to complete, and 5
  minutes is a way too long pause in a test suite where a single test case
  stalls.

* Deprecated the use.fs property.  While this seemed like a good idea in
  the first place to impose more control on what test cases can do, it
  turns out to be bad.  First, use.fs=false prevents bogus test cases
  from dumping core so after-the-fact debugging is harder.  Second,
  supporting use.fs adds a lot of unnecessary complexity.  atf-run will
  now ignore any value provided to use.fs and will allow test cases to
  freely access the file system if they wish to.

* Added the atf_tc_get_config_var_as_{bool,long}{,_wd} functions to the atf-c
  library.  The 'text' module became private in 0.11 but was being used
  externally to simplify the parsing of configuration variables.

* Made atf-run recognize the 'unprivileged-user' configuration variable
  and automatically drop root privileges when a test case sets
  require.user=unprivileged.  Note that this is, by no means, done for
  security purposes; this is just for user convenience; tests should, in
  general, not be blindly run as root in the first place.

diffstat:

 external/bsd/atf/dist/NEWS                             |   36 ++++
 external/bsd/atf/dist/atf-c++/atf-c++-api.3            |   18 +-
 external/bsd/atf/dist/atf-c++/check.cpp                |    4 +-
 external/bsd/atf/dist/atf-c++/check.hpp                |    9 +-
 external/bsd/atf/dist/atf-c++/check_test.cpp           |   71 ++++----
 external/bsd/atf/dist/atf-c++/detail/fs_test.cpp       |    9 -
 external/bsd/atf/dist/atf-c++/detail/test_helpers.hpp  |    2 -
 external/bsd/atf/dist/atf-c++/macros.hpp               |   39 ++++
 external/bsd/atf/dist/atf-c++/macros_test.cpp          |  145 ++++++++++++++++-
 external/bsd/atf/dist/atf-c++/pkg_config_test.sh       |    2 -
 external/bsd/atf/dist/atf-c/atf-c-api.3                |   20 +-
 external/bsd/atf/dist/atf-c/check.c                    |   22 +-
 external/bsd/atf/dist/atf-c/check_test.c               |    3 -
 external/bsd/atf/dist/atf-c/detail/fs_test.c           |   14 -
 external/bsd/atf/dist/atf-c/detail/process_test.c      |    3 -
 external/bsd/atf/dist/atf-c/detail/test_helpers.h      |    2 -
 external/bsd/atf/dist/atf-c/detail/test_helpers_test.c |    2 -
 external/bsd/atf/dist/atf-c/macros_test.c              |    9 -
 external/bsd/atf/dist/atf-c/pkg_config_test.sh         |    2 -
 external/bsd/atf/dist/atf-c/tc.h                       |    6 +
 external/bsd/atf/dist/atf-config/integration_test.sh   |    7 -
 external/bsd/atf/dist/atf-report/integration_test.sh   |   10 -
 external/bsd/atf/dist/atf-run/atf-run.1                |   15 +-
 external/bsd/atf/dist/atf-run/atffile_test.cpp         |   20 +-
 external/bsd/atf/dist/atf-run/fs.cpp                   |   43 -----
 external/bsd/atf/dist/atf-run/fs.hpp                   |    1 -
 external/bsd/atf/dist/atf-run/fs_test.cpp              |   33 ---
 external/bsd/atf/dist/atf-run/integration_test.sh      |   56 +-----
 external/bsd/atf/dist/atf-run/misc_helpers.cpp         |    6 +-
 external/bsd/atf/dist/atf-run/requirements.cpp         |   50 +++++-
 external/bsd/atf/dist/atf-run/requirements.hpp         |    3 +
 external/bsd/atf/dist/atf-run/requirements_test.cpp    |    3 +-
 external/bsd/atf/dist/atf-run/sample/common.conf       |   11 +
 external/bsd/atf/dist/atf-run/several_tcs_helper.c     |    1 -
 external/bsd/atf/dist/atf-run/test_program_test.cpp    |   48 +---
 external/bsd/atf/dist/atf-run/user.cpp                 |   24 ++
 external/bsd/atf/dist/atf-run/user.hpp                 |    4 +
 external/bsd/atf/dist/atf-sh/atf-check.cpp             |   12 +-
 external/bsd/atf/dist/atf-sh/atf-check_test.sh         |   21 --
 external/bsd/atf/dist/atf-sh/atf_check_test.sh         |    6 -
 external/bsd/atf/dist/atf-sh/config_test.sh            |    2 -
 external/bsd/atf/dist/atf-sh/integration_test.sh       |    9 -
 external/bsd/atf/dist/atf-sh/normalize_test.sh         |    1 -
 external/bsd/atf/dist/atf-sh/tc_test.sh                |    1 -
 external/bsd/atf/dist/atf-sh/tp_test.sh                |    1 -
 external/bsd/atf/dist/doc/atf-test-case.4              |   11 +-
 external/bsd/atf/dist/test-programs/c_helpers.c        |   18 +-
 external/bsd/atf/dist/test-programs/config_test.sh     |    1 -
 external/bsd/atf/dist/test-programs/expect_test.sh     |   18 --
 external/bsd/atf/dist/test-programs/fork_test.sh       |    1 -
 external/bsd/atf/dist/test-programs/meta_data_test.sh  |    2 -
 external/bsd/atf/dist/test-programs/result_test.sh     |    3 -
 external/bsd/atf/dist/test-programs/srcdir_test.sh     |    4 -
 53 files changed, 442 insertions(+), 422 deletions(-)

diffs (truncated from 2756 to 300 lines):

diff -r 053176e8d88f -r 34bd02a7cfd1 external/bsd/atf/dist/NEWS
--- a/external/bsd/atf/dist/NEWS        Sun Nov 07 16:36:26 2010 +0000
+++ b/external/bsd/atf/dist/NEWS        Sun Nov 07 17:43:22 2010 +0000
@@ -2,6 +2,42 @@
 ===========================================================================
 
 
+Changes in version 0.12
+***********************
+
+Experimental version released on November 7th, 2010.
+
+* Added the ATF_REQUIRE_THROW_RE to atf-c++, which is the same as
+  ATF_REQUIRE_THROW but allows checking for the validity of the exception's
+  error message by means of a regular expression.
+
+* Added the ATF_REQUIRE_MATCH to atf-c++, which allows checking for a
+  regular expression match in a string.
+
+* Changed the default timeout for test cases from 5 minutes to 30 seconds.
+  30 seconds is long enough for virtually all tests to complete, and 5
+  minutes is a way too long pause in a test suite where a single test case
+  stalls.
+
+* Deprecated the use.fs property.  While this seemed like a good idea in
+  the first place to impose more control on what test cases can do, it
+  turns out to be bad.  First, use.fs=false prevents bogus test cases
+  from dumping core so after-the-fact debugging is harder.  Second,
+  supporting use.fs adds a lot of unnecessary complexity.  atf-run will
+  now ignore any value provided to use.fs and will allow test cases to
+  freely access the file system if they wish to.
+
+* Added the atf_tc_get_config_var_as_{bool,long}{,_wd} functions to the atf-c
+  library.  The 'text' module became private in 0.11 but was being used
+  externally to simplify the parsing of configuration variables.
+
+* Made atf-run recognize the 'unprivileged-user' configuration variable
+  and automatically drop root privileges when a test case sets
+  require.user=unprivileged.  Note that this is, by no means, done for
+  security purposes; this is just for user convenience; tests should, in
+  general, not be blindly run as root in the first place.
+
+
 Changes in version 0.11
 ***********************
 
diff -r 053176e8d88f -r 34bd02a7cfd1 external/bsd/atf/dist/atf-c++/atf-c++-api.3
--- a/external/bsd/atf/dist/atf-c++/atf-c++-api.3       Sun Nov 07 16:36:26 2010 +0000
+++ b/external/bsd/atf/dist/atf-c++/atf-c++-api.3       Sun Nov 07 17:43:22 2010 +0000
@@ -26,7 +26,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 4, 2010
+.Dd October 21, 2010
 .Dt ATF-C++-API 3
 .Os
 .Sh NAME
@@ -38,7 +38,9 @@
 .Nm ATF_REQUIRE ,
 .Nm ATF_REQUIRE_EQ ,
 .Nm ATF_REQUIRE_ERRNO ,
+.Nm ATF_REQUIRE_MATCH ,
 .Nm ATF_REQUIRE_THROW ,
+.Nm ATF_REQUIRE_THROW_RE ,
 .Nm ATF_SKIP ,
 .Nm ATF_TEST_CASE ,
 .Nm ATF_TEST_CASE_BODY ,
@@ -57,7 +59,9 @@
 .Fn ATF_REQUIRE "expression"
 .Fn ATF_REQUIRE_EQ "expression_1" "expression_2"
 .Fn ATF_REQUIRE_ERRNO "exp_errno" "bool_expression"
+.Fn ATF_REQUIRE_MATCH "regexp" "string_expression"
 .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"
@@ -276,6 +280,10 @@
 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
@@ -305,9 +313,17 @@
 takes two expressions and raises a failure if the two do not evaluate to
 the same exact value.
 .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_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
+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
diff -r 053176e8d88f -r 34bd02a7cfd1 external/bsd/atf/dist/atf-c++/check.cpp
--- a/external/bsd/atf/dist/atf-c++/check.cpp   Sun Nov 07 16:36:26 2010 +0000
+++ b/external/bsd/atf/dist/atf-c++/check.cpp   Sun Nov 07 17:43:22 2010 +0000
@@ -145,7 +145,7 @@
     return success;
 }
 
-impl::check_result
+std::auto_ptr< impl::check_result >
 impl::exec(const atf::process::argv_array& argva)
 {
     atf_check_result_t result;
@@ -154,5 +154,5 @@
     if (atf_is_error(err))
         throw_atf_error(err);
 
-    return impl::check_result(&result);
+    return std::auto_ptr< impl::check_result >(new impl::check_result(&result));
 }
diff -r 053176e8d88f -r 34bd02a7cfd1 external/bsd/atf/dist/atf-c++/check.hpp
--- a/external/bsd/atf/dist/atf-c++/check.hpp   Sun Nov 07 16:36:26 2010 +0000
+++ b/external/bsd/atf/dist/atf-c++/check.hpp   Sun Nov 07 17:43:22 2010 +0000
@@ -39,6 +39,8 @@
 #include <string>
 #include <vector>
 
+#include <atf-c++/utils.hpp>
+
 namespace atf {
 
 namespace process {
@@ -58,11 +60,10 @@
 //! of executing arbitrary command and manages files containing
 //! its output.
 //!
-class check_result {
+class check_result : utils::noncopyable {
     //!
     //! \brief Internal representation of a result.
     //!
-    // XXX: This is non-copyable!  The class must define it as such.
     atf_check_result_t m_result;
 
     //!
@@ -72,7 +73,7 @@
     check_result(const atf_check_result_t* result);
 
     friend check_result test_constructor(const char* const*);
-    friend check_result exec(const atf::process::argv_array&);
+    friend std::auto_ptr< check_result > exec(const atf::process::argv_array&);
 
 public:
     //!
@@ -121,7 +122,7 @@
                const atf::process::argv_array&);
 bool build_cxx_o(const std::string&, const std::string&,
                  const atf::process::argv_array&);
-check_result exec(const atf::process::argv_array&);
+std::auto_ptr< check_result > exec(const atf::process::argv_array&);
 
 // Useful for testing only.
 check_result test_constructor(void);
diff -r 053176e8d88f -r 34bd02a7cfd1 external/bsd/atf/dist/atf-c++/check_test.cpp
--- a/external/bsd/atf/dist/atf-c++/check_test.cpp      Sun Nov 07 16:36:26 2010 +0000
+++ b/external/bsd/atf/dist/atf-c++/check_test.cpp      Sun Nov 07 17:43:22 2010 +0000
@@ -57,7 +57,7 @@
 // ------------------------------------------------------------------------
 
 static
-atf::check::check_result
+std::auto_ptr< atf::check::check_result >
 do_exec(const atf::tests::tc* tc, const char* helper_name)
 {
     std::vector< std::string > argv;
@@ -70,7 +70,7 @@
 }
 
 static
-atf::check::check_result
+std::auto_ptr< atf::check::check_result >
 do_exec(const atf::tests::tc* tc, const char* helper_name, const char *carg2)
 {
     std::vector< std::string > argv;
@@ -188,7 +188,6 @@
 ATF_TEST_CASE_HEAD(build_c_o)
 {
     set_md_var("descr", "Tests the build_c_o function");
-    set_md_var("use.fs", "true");
 }
 ATF_TEST_CASE_BODY(build_c_o)
 {
@@ -207,7 +206,6 @@
 ATF_TEST_CASE_HEAD(build_cpp)
 {
     set_md_var("descr", "Tests the build_cpp function");
-    set_md_var("use.fs", "true");
 }
 ATF_TEST_CASE_BODY(build_cpp)
 {
@@ -227,7 +225,6 @@
 ATF_TEST_CASE_HEAD(build_cxx_o)
 {
     set_md_var("descr", "Tests the build_cxx_o function");
-    set_md_var("use.fs", "true");
 }
 ATF_TEST_CASE_BODY(build_cxx_o)
 {
@@ -254,9 +251,10 @@
     std::auto_ptr< atf::fs::path > err;
 
     {
-        const atf::check::check_result r = do_exec(this, "exit-success");
-        out.reset(new atf::fs::path(r.stdout_path()));
-        err.reset(new atf::fs::path(r.stderr_path()));
+        std::auto_ptr< atf::check::check_result > r =
+            do_exec(this, "exit-success");
+        out.reset(new atf::fs::path(r->stdout_path()));
+        err.reset(new atf::fs::path(r->stderr_path()));
         ATF_REQUIRE(atf::fs::exists(*out.get()));
         ATF_REQUIRE(atf::fs::exists(*err.get()));
     }
@@ -273,24 +271,27 @@
 ATF_TEST_CASE_BODY(exec_exitstatus)
 {
     {
-        atf::check::check_result r = do_exec(this, "exit-success");
-        ATF_REQUIRE(r.exited());
-        ATF_REQUIRE(!r.signaled());
-        ATF_REQUIRE_EQ(r.exitcode(), EXIT_SUCCESS);
+        std::auto_ptr< atf::check::check_result > r =
+            do_exec(this, "exit-success");
+        ATF_REQUIRE(r->exited());
+        ATF_REQUIRE(!r->signaled());
+        ATF_REQUIRE_EQ(r->exitcode(), EXIT_SUCCESS);
     }
 
     {
-        atf::check::check_result r = do_exec(this, "exit-failure");
-        ATF_REQUIRE(r.exited());
-        ATF_REQUIRE(!r.signaled());
-        ATF_REQUIRE_EQ(r.exitcode(), EXIT_FAILURE);
+        std::auto_ptr< atf::check::check_result > r =
+            do_exec(this, "exit-failure");
+        ATF_REQUIRE(r->exited());
+        ATF_REQUIRE(!r->signaled());
+        ATF_REQUIRE_EQ(r->exitcode(), EXIT_FAILURE);
     }
 
     {
-        atf::check::check_result r = do_exec(this, "exit-signal");
-        ATF_REQUIRE(!r.exited());
-        ATF_REQUIRE(r.signaled());
-        ATF_REQUIRE_EQ(r.termsig(), SIGKILL);
+        std::auto_ptr< atf::check::check_result > r =
+            do_exec(this, "exit-signal");
+        ATF_REQUIRE(!r->exited());
+        ATF_REQUIRE(r->signaled());
+        ATF_REQUIRE_EQ(r->termsig(), SIGKILL);
     }
 }
 
@@ -319,20 +320,20 @@
 }
 ATF_TEST_CASE_BODY(exec_stdout_stderr)
 {
-    const atf::check::check_result r1 = do_exec(this, "stdout-stderr",
-                                                "result1");
-    ATF_REQUIRE(r1.exited());
-    ATF_REQUIRE_EQ(r1.exitcode(), EXIT_SUCCESS);
+    std::auto_ptr< atf::check::check_result > r1 =
+        do_exec(this, "stdout-stderr", "result1");
+    ATF_REQUIRE(r1->exited());
+    ATF_REQUIRE_EQ(r1->exitcode(), EXIT_SUCCESS);
 
-    const atf::check::check_result r2 = do_exec(this, "stdout-stderr",
-                                                "result2");
-    ATF_REQUIRE(r2.exited());
-    ATF_REQUIRE_EQ(r2.exitcode(), EXIT_SUCCESS);
+    std::auto_ptr< atf::check::check_result > r2 =
+        do_exec(this, "stdout-stderr", "result2");
+    ATF_REQUIRE(r2->exited());
+    ATF_REQUIRE_EQ(r2->exitcode(), EXIT_SUCCESS);
 
-    const std::string out1 = r1.stdout_path();
-    const std::string out2 = r2.stdout_path();
-    const std::string err1 = r1.stderr_path();
-    const std::string err2 = r2.stderr_path();
+    const std::string out1 = r1->stdout_path();
+    const std::string out2 = r2->stdout_path();
+    const std::string err1 = r1->stderr_path();
+    const std::string err2 = r2->stderr_path();
 
     ATF_REQUIRE(out1.find("check.XXXXXX") == std::string::npos);



Home | Main Index | Thread Index | Old Index