Module Name:    src
Committed By:   jmmv
Date:           Thu Mar 31 16:44:18 UTC 2011

Modified Files:
        src/external/bsd/atf/dist/atf-run: atf-run.cpp
        src/external/bsd/atf/dist/atf-sh: atf-check.cpp atf-check_test.sh
        src/external/bsd/atf/dist/doc: atf-test-case.4

Log Message:
Fix import conflicts.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/atf/dist/atf-run/atf-run.cpp
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/atf/dist/atf-sh/atf-check.cpp
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/atf-sh/atf-check_test.sh
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/doc/atf-test-case.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/atf/dist/atf-run/atf-run.cpp
diff -u src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.9 src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.10
--- src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.9	Fri Mar  4 09:04:06 2011
+++ src/external/bsd/atf/dist/atf-run/atf-run.cpp	Thu Mar 31 16:44:17 2011
@@ -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
@@ -99,6 +99,45 @@
     int main(void);
 };
 
+static void
+dump_stacktrace(const atf::fs::path& tp, const atf::process::status& s,
+                const atf::fs::path& workdir, impl::atf_tps_writer& w)
+{
+    PRE(s.signaled() && s.coredump());
+
+    w.stderr_tc("Test program crashed; attempting to get stack trace");
+
+    const atf::fs::path corename = workdir / (tp.leaf_name() + ".core");
+    if (!atf::fs::exists(corename)) {
+        w.stderr_tc("Expected file " + corename.str() + " not found");
+        return;
+    }
+
+    const atf::fs::path gdb(GDB);
+    const atf::fs::path gdbout = workdir / "gdb.out";
+    const atf::process::argv_array args(gdb.leaf_name().c_str(), "-batch",
+                                        "-q", "-ex", "bt", tp.c_str(),
+                                        corename.c_str(), NULL);
+    atf::process::status status = atf::process::exec(
+        gdb, args,
+        atf::process::stream_redirect_path(gdbout),
+        atf::process::stream_redirect_path(atf::fs::path("/dev/null")));
+    if (!status.exited() || status.exitstatus() != EXIT_SUCCESS) {
+        w.stderr_tc("Execution of " GDB " failed");
+        return;
+    }
+
+    std::ifstream input(gdbout.c_str());
+    if (input) {
+        std::string line;
+        while (std::getline(input, line).good())
+            w.stderr_tc(line);
+        input.close();
+    }
+
+    w.stderr_tc("Stack trace complete");
+}
+
 const char* atf_run::m_description =
     "atf-run is a tool that runs tests programs and collects their "
     "results.";
@@ -370,8 +409,8 @@
                 if (user.first != -1 && user.second != -1) {
                     if (::chown(workdir.get_path().c_str(), user.first,
                                 user.second) == -1) {
-                        throw atf::system_error("chmod(" +
-                            workdir.get_path().str() + ")", "chmod(2) failed",
+                        throw atf::system_error("chown(" +
+                            workdir.get_path().str() + ")", "chown(2) failed",
                             errno);
                     }
                     resfile = workdir.get_path() / "tcr";
@@ -380,45 +419,17 @@
                 std::pair< std::string, const atf::process::status > s =
                     impl::run_test_case(tp, tcname, "body", tcmd, config,
                                             resfile, workdir.get_path(), w);
+                if (s.second.signaled() && s.second.coredump())
+                    dump_stacktrace(tp, s.second, workdir.get_path(), w);
+                if (has_cleanup)
+                    (void)impl::run_test_case(tp, tcname, "cleanup", tcmd,
+                            config, resfile, workdir.get_path(), w);
 
                 // TODO: Force deletion of workdir.
 
                 impl::test_case_result tcr = get_test_case_result(s.first,
                     s.second, resfile);
 
-		/* if we have a core, scope out stacktrace */
-		size_t slashpos = tp.str().rfind("/");
-		std::string corename = workdir.get_path().str()
-		    + std::string("/") + tp.str().substr(slashpos+1)
-		    + std::string(".core");
-		if (s.second.signaled() && s.second.coredump() &&
-		    access(corename.c_str(), F_OK) == 0) {
-			std::string gdbcmd;
-			char buf[256];
-			char *p;
-
-			gdbcmd = std::string("gdb -batch -q -ex bt ") +
-			    tp.str() + std::string(" ") + corename +
-			    std::string(" 2> /dev/null | grep -v ") +
-			    std::string("'(no debugging symbols found)'");
-			FILE *gdbstrm = popen(gdbcmd.c_str(), "r");
-			if (gdbstrm) {
-				w.stderr_tc(std::string("test program crashed, "
-				    "autolisting stacktrace:"));
-				while (fgets(buf, sizeof(buf), gdbstrm)) {
-					if ((p = strchr(buf, '\n')) != NULL)
-						*p = '\0';
-					w.stderr_tc(std::string(buf));
-				}
-				pclose(gdbstrm);
-				w.stderr_tc(std::string("stacktrace complete"));
-			}
-		}
-
-                if (has_cleanup)
-                    (void)impl::run_test_case(tp, tcname, "cleanup", tcmd,
-                            config, resfile, workdir.get_path(), w);
-
                 w.end_tc(tcr.state(), tcr.reason());
                 if (tcr.state() == "failed")
                     errcode = EXIT_FAILURE;

Index: src/external/bsd/atf/dist/atf-sh/atf-check.cpp
diff -u src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.4 src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.5
--- src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.4	Mon Dec 27 20:36:17 2010
+++ src/external/bsd/atf/dist/atf-sh/atf-check.cpp	Thu Mar 31 16:44:17 2011
@@ -33,12 +33,14 @@
 
 #include <limits.h>
 #include <signal.h>
+#include <unistd.h>
 }
 
 #include <cerrno>
 #include <cstdlib>
 #include <cstring>
 #include <fstream>
+#include <ios>
 #include <iostream>
 #include <iterator>
 #include <list>

Index: src/external/bsd/atf/dist/atf-sh/atf-check_test.sh
diff -u src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.2 src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.3
--- src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.2	Mon Dec  6 18:04:02 2010
+++ src/external/bsd/atf/dist/atf-sh/atf-check_test.sh	Thu Mar 31 16:44:17 2011
@@ -27,7 +27,7 @@
 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
-# The Atf_Check variable is set by atf-sh.
+# The Atf_Check and Atf-Shell variables are set by atf-sh.
 
 h_pass()
 {
@@ -36,7 +36,7 @@
     echo "Running [atf-check $*] against [${cmd}]"
 
     cat >script.sh <<EOF
-#! $(atf-config -t atf_shell)
+#! ${Atf_Shell}
 ${cmd}
 EOF
     chmod +x script.sh
@@ -54,7 +54,7 @@
     echo "Running [atf-check $*] against [${cmd}]"
 
     cat >script.sh <<EOF
-#! $(atf-config -t atf_shell)
+#! ${Atf_Shell}
 ${cmd}
 EOF
     chmod +x script.sh

Index: src/external/bsd/atf/dist/doc/atf-test-case.4
diff -u src/external/bsd/atf/dist/doc/atf-test-case.4:1.2 src/external/bsd/atf/dist/doc/atf-test-case.4:1.3
--- src/external/bsd/atf/dist/doc/atf-test-case.4:1.2	Tue Nov 16 17:55:56 2010
+++ src/external/bsd/atf/dist/doc/atf-test-case.4	Thu Mar 31 16:44:17 2011
@@ -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 November 16, 2010
+.Dd December 13, 2010
 .Dt ATF-TEST-CASE 4
 .Os
 .Sh NAME
@@ -274,8 +274,11 @@
 The test program always creates a temporary directory
 and switches to it before running the test case's body.
 This way the test case is free to modify its current directory as it
-wishes, and the test program will be able to clean it up later on in a
+wishes, and the runtime engine will be able to clean it up later on in a
 safe way, removing any traces of its execution from the system.
+To do so, the runtime engine will perform a recursive removal of the work
+directory without crossing mount points; if a mount point is found, the
+file system will be unmounted (if possible).
 .Ss File creation mode mask (umask)
 Test cases are always executed with a file creation mode mask (umask) of
 .Sq 0022 .

Reply via email to