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 Post-import merge of atf-0.14.



details:   https://anonhg.NetBSD.org/src/rev/524301610b29
branches:  trunk
changeset: 766065:524301610b29
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Tue Jun 14 15:26:20 2011 +0000

description:
Post-import merge of atf-0.14.

diffstat:

 external/bsd/atf/dist/atf-c++/tests.cpp             |  12 +++-
 external/bsd/atf/dist/atf-c/defs.h.in               |   3 +-
 external/bsd/atf/dist/atf-c/detail/process.c        |  22 +++++++
 external/bsd/atf/dist/atf-c/tc.h                    |  22 +++---
 external/bsd/atf/dist/atf-run/atf-run.cpp           |  10 ++-
 external/bsd/atf/dist/atf-run/integration_test.sh   |  65 ++++++++++++++++++++-
 external/bsd/atf/dist/atf-run/test-program.cpp      |   5 +-
 external/bsd/atf/dist/atf-run/test_program_test.cpp |   5 +-
 external/bsd/atf/dist/doc/atf-test-case.4           |  41 +++++++++---
 9 files changed, 154 insertions(+), 31 deletions(-)

diffs (truncated from 463 to 300 lines):

diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-c++/tests.cpp
--- a/external/bsd/atf/dist/atf-c++/tests.cpp   Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-c++/tests.cpp   Tue Jun 14 15:26:20 2011 +0000
@@ -1,7 +1,7 @@
 //
 // Automated Testing Framework (atf)
 //
-// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
+// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
@@ -641,6 +641,16 @@
 
     impl::tc* tc = find_tc(init_tcs(), fields.first);
 
+    if (!atf::env::has("__RUNNING_INSIDE_ATF_RUN") || atf::env::get(
+        "__RUNNING_INSIDE_ATF_RUN") != "internal-yes-value")
+    {
+        std::cerr << m_prog_name << ": WARNING: Running test cases without "
+            "atf-run(1) is unsupported\n";
+        std::cerr << m_prog_name << ": WARNING: No isolation nor timeout "
+            "control is being applied; you may get unexpected failures; see "
+            "atf-test-case(4)\n";
+    }
+
     try {
         switch (fields.second) {
         case BODY:
diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-c/defs.h.in
--- a/external/bsd/atf/dist/atf-c/defs.h.in     Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/defs.h.in     Tue Jun 14 15:26:20 2011 +0000
@@ -1,7 +1,7 @@
 /*
  * Automated Testing Framework (atf)
  *
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
 #if !defined(ATF_C_DEFS_H)
 #define ATF_C_DEFS_H
 
+#define ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(a, b) @ATTRIBUTE_FORMAT_PRINTF@
 #define ATF_DEFS_ATTRIBUTE_NORETURN @ATTRIBUTE_NORETURN@
 #define ATF_DEFS_ATTRIBUTE_PRINTF(a,b) @ATTRIBUTE_PRINTF(a,b)@
 
diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-c/detail/process.c
--- a/external/bsd/atf/dist/atf-c/detail/process.c      Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/process.c      Tue Jun 14 15:26:20 2011 +0000
@@ -412,6 +412,24 @@
 }
 
 static
+atf_error_t
+silence_stdin(void)
+{
+    atf_error_t err;
+
+    close(STDIN_FILENO);
+    int fd = open("/dev/zero", O_RDONLY);
+    if (fd == -1)
+        err = atf_libc_error(errno, "Could not open /dev/zero");
+    else {
+        INV(fd == STDIN_FILENO);
+        err = atf_no_error();
+    }
+
+    return err;
+}
+
+static
 void
 do_child(void (*)(void *),
          void *,
@@ -427,6 +445,10 @@
 {
     atf_error_t err;
 
+    err = silence_stdin();
+    if (atf_is_error(err))
+        goto out;
+
     err = child_connect(outsp, STDOUT_FILENO);
     if (atf_is_error(err))
         goto out;
diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-c/tc.h
--- a/external/bsd/atf/dist/atf-c/tc.h  Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/tc.h  Tue Jun 14 15:26:20 2011 +0000
@@ -1,7 +1,7 @@
 /*
  * Automated Testing Framework (atf)
  *
- * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -104,33 +104,33 @@
 
 /* To be run from test case bodies only. */
 void atf_tc_fail(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2)
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
     ATF_DEFS_ATTRIBUTE_NORETURN;
 void atf_tc_fail_nonfatal(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
 void atf_tc_pass(void)
     ATF_DEFS_ATTRIBUTE_NORETURN;
 void atf_tc_require_prog(const char *);
 void atf_tc_skip(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2)
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
     ATF_DEFS_ATTRIBUTE_NORETURN;
 void atf_tc_expect_pass(void);
 void atf_tc_expect_fail(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
 void atf_tc_expect_exit(const int, const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(2, 3);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
 void atf_tc_expect_signal(const int, const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(2, 3);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
 void atf_tc_expect_death(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
 void atf_tc_expect_timeout(const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(1, 2);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
 /* To be run from test case bodies only; internal to macros.h. */
 void atf_tc_fail_check(const char *, const size_t, const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(3, 4);
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4);
 void atf_tc_fail_requirement(const char *, const size_t, const char *, ...)
-    ATF_DEFS_ATTRIBUTE_PRINTF(3, 4)
+    ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4)
     ATF_DEFS_ATTRIBUTE_NORETURN;
 void atf_tc_check_errno(const char *, const size_t, const int,
                         const char *, const bool);
diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-run/atf-run.cpp
--- a/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Jun 14 15:26:20 2011 +0000
@@ -33,6 +33,7 @@
 
 extern "C" {
 #include <sys/types.h>
+#include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -67,6 +68,12 @@
 
 namespace impl = atf::atf_run;
 
+#if defined(MAXCOMLEN)
+static const std::string::size_type max_core_name_length = MAXCOMLEN;
+#else
+static const std::string::size_type max_core_name_length = std::string::npos;
+#endif
+
 class atf_run : public atf::application::app {
     static const char* m_description;
 
@@ -119,7 +126,8 @@
 
     w.stderr_tc("Test program crashed; attempting to get stack trace");
 
-    const atf::fs::path corename = workdir / (tp.leaf_name() + ".core");
+    const atf::fs::path corename = workdir /
+        (tp.leaf_name().substr(0, max_core_name_length) + ".core");
     if (!atf::fs::exists(corename)) {
         w.stderr_tc("Expected file " + corename.str() + " not found");
         return;
diff -r 12b58034e019 -r 524301610b29 external/bsd/atf/dist/atf-run/integration_test.sh
--- a/external/bsd/atf/dist/atf-run/integration_test.sh Tue Jun 14 15:23:20 2011 +0000
+++ b/external/bsd/atf/dist/atf-run/integration_test.sh Tue Jun 14 15:26:20 2011 +0000
@@ -1,7 +1,7 @@
 #
 # Automated Testing Framework (atf)
 #
-# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
+# Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -120,6 +120,18 @@
 EOF
 }
 
+atf_test_case no_warnings
+no_warnings_head()
+{
+    atf_set "descr" "Tests that atf-run suppresses warnings about not running" \
+                    "within atf-run"
+}
+no_warnings_body()
+{
+    create_helper pass
+    atf_check -s eq:0 -o ignore -e not-match:'WARNING.*atf-run' atf-run helper
+}
+
 atf_test_case config
 config_head()
 {
@@ -583,8 +595,8 @@
 isolation_env_body()
 {
     undef_vars="LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY \
-                LC_NUMERIC LC_TIME TZ"
-    def_vars="HOME"
+                LC_NUMERIC LC_TIME"
+    def_vars="HOME TZ"
 
     mangleenv="env"
     for v in ${undef_vars} ${def_vars}; do
@@ -607,6 +619,8 @@
     for v in ${def_vars}; do
         atf_check -s eq:0 -o ignore -e empty grep "^tc-so:${v}=" stdout
     done
+
+    atf_check -s eq:0 -o ignore -e empty grep "^tc-so:TZ=UTC" stdout
 }
 
 atf_test_case isolation_home
@@ -621,6 +635,18 @@
     atf_check -s eq:0 -o ignore -e ignore env HOME=foo atf-run helper
 }
 
+atf_test_case isolation_stdin
+isolation_stdin_head()
+{
+    atf_set "descr" "Tests that atf-run nullifies the stdin of test cases"
+}
+isolation_stdin_body()
+{
+    create_helper read_stdin
+    create_atffile helper
+    atf_check -s eq:0 -o ignore -e ignore -x 'echo hello world | atf-run helper'
+}
+
 atf_test_case isolation_umask
 isolation_umask_head()
 {
@@ -855,6 +881,36 @@
         -v var1=a -v var2=' ' helper
 }
 
+atf_test_case require_files
+require_files_head()
+{
+    atf_set "descr" "Tests that atf-run validates the require.files property"
+}
+require_files_body()
+{
+    create_helper require_files
+    create_atffile helper
+
+    touch i-exist
+
+    echo "Checking absolute paths"
+    atf_check -s eq:0 -o match:"${TESTCASE}, passed" -e ignore atf-run \
+        -v files='/bin/cp' helper
+    atf_check -s eq:0 -o match:"${TESTCASE}, passed" -e ignore atf-run \
+        -v files="$(pwd)/i-exist" helper
+    atf_check -s eq:0 \
+        -o match:"${TESTCASE}, skipped, .*/dont-exist" \
+        -e ignore atf-run -v files="$(pwd)/i-exist $(pwd)/dont-exist" helper
+
+    echo "Checking that relative paths are not allowed"
+    atf_check -s eq:1 \
+        -o match:"${TESTCASE}, failed, Relative paths.*not allowed.*hello" \
+        -e ignore atf-run -v files='hello' helper
+    atf_check -s eq:1 \
+        -o match:"${TESTCASE}, failed, Relative paths.*not allowed.*a/b" \
+        -e ignore atf-run -v files='a/b' helper
+}
+
 atf_test_case require_machine
 require_machine_head()
 {
@@ -1031,6 +1087,7 @@
 
 atf_init_test_cases()
 {
+    atf_add_test_case no_warnings
     atf_add_test_case config
     atf_add_test_case vflag
     atf_add_test_case atffile
@@ -1047,6 +1104,7 @@
     atf_add_test_case hooks
     atf_add_test_case isolation_env
     atf_add_test_case isolation_home
+    atf_add_test_case isolation_stdin
     atf_add_test_case isolation_umask
     atf_add_test_case cleanup_pass



Home | Main Index | Thread Index | Old Index