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/atf-run In case we get a coredump from...
details: https://anonhg.NetBSD.org/src/rev/6cd506f34523
branches: trunk
changeset: 762838:6cd506f34523
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Mar 02 16:47:04 2011 +0000
description:
In case we get a coredump from a test, autorun gdb to produce a
stacktrace (or whatever gdb can give us, which unfortunately is
usually not that much).
diffstat:
external/bsd/atf/dist/atf-run/atf-run.cpp | 35 ++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 3 deletions(-)
diffs (51 lines):
diff -r 07c4bf7effe0 -r 6cd506f34523 external/bsd/atf/dist/atf-run/atf-run.cpp
--- a/external/bsd/atf/dist/atf-run/atf-run.cpp Wed Mar 02 15:09:16 2011 +0000
+++ b/external/bsd/atf/dist/atf-run/atf-run.cpp Wed Mar 02 16:47:04 2011 +0000
@@ -380,15 +380,44 @@
std::pair< std::string, const atf::process::status > s =
impl::run_test_case(tp, tcname, "body", tcmd, config,
resfile, 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");
+ 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;
Home |
Main Index |
Thread Index |
Old Index