aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-10 01:30:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-10 01:30:30 +0000
commit751d9d20da4554ad835e456c8a86bc256c65533a (patch)
tree20c2bc76e73377aa4fccac9dbe5d009b58e35e12
parentf2a627c66bedb9e3b3f0093c1e2f25cdf22a5b4e (diff)
downloadpaludis-751d9d20da4554ad835e456c8a86bc256c65533a.tar.gz
paludis-751d9d20da4554ad835e456c8a86bc256c65533a.tar.xz
Fix the gdb detection code to weird in a different fashion
-rw-r--r--test/test_framework.cc9
-rw-r--r--test/test_framework.hh5
-rw-r--r--test/test_runner.cc25
3 files changed, 32 insertions, 7 deletions
diff --git a/test/test_framework.cc b/test/test_framework.cc
index 1d3dbe8..a4e5203 100644
--- a/test/test_framework.cc
+++ b/test/test_framework.cc
@@ -205,9 +205,11 @@ RunTest::operator() (TestCase * test_case) const
try
{
- alarm(test_case->max_run_time());
+ if (TestCaseList::use_alarm)
+ alarm(test_case->max_run_time());
test_case->call_run();
- alarm(0);
+ if (TestCaseList::use_alarm)
+ alarm(0);
}
catch (std::exception &e)
{
@@ -248,5 +250,8 @@ TestCaseList::run_tests()
return ! had_a_failure;
}
+bool
+TestCaseList::use_alarm(true);
+
#endif
diff --git a/test/test_framework.hh b/test/test_framework.hh
index 652f3e9..d372a07 100644
--- a/test/test_framework.hh
+++ b/test/test_framework.hh
@@ -187,6 +187,11 @@ namespace test
* Run all tests.
*/
static bool run_tests();
+
+ /**
+ * Should we use alarm?
+ */
+ static bool use_alarm;
};
/**
diff --git a/test/test_runner.cc b/test/test_runner.cc
index 52f9226..066120d 100644
--- a/test/test_runner.cc
+++ b/test/test_runner.cc
@@ -19,13 +19,15 @@
#include "test_runner.hh"
#include "test_framework.hh"
+#include <paludis/stringify.hh>
#include <iostream>
+#include <fstream>
#include <cstdlib>
#include <signal.h>
#include <execinfo.h>
#include <unistd.h>
-#include <sys/ptrace.h>
+#include <sys/types.h>
/** \file
* Implementation of the default test runner.
@@ -68,11 +70,24 @@ void segfault_handler(int)
int
main(int, char * argv[])
{
- // if ptrace returns < 0, then it is being traced
- if (ptrace(PTRACE_TRACEME, 0, 1, 0) >= 0)
{
- signal(SIGALRM, &timeout_handler);
- signal(SIGSEGV, &segfault_handler);
+ std::ifstream ppid(("/proc/" + paludis::stringify(getppid()) + "/cmdline").c_str());
+ if (ppid)
+ {
+ std::string cmd;
+ std::getline(ppid, cmd, '\0');
+ std::cerr << "cmd is " << cmd << std::endl;
+ std::string::size_type slash_pos(cmd.rfind('/'));
+ if (std::string::npos != slash_pos)
+ cmd.erase(0, slash_pos);
+ if (cmd != "gdb")
+ {
+ signal(SIGALRM, &timeout_handler);
+ signal(SIGSEGV, &segfault_handler);
+ }
+ else
+ TestCaseList::use_alarm = false;
+ }
}
std::cout << "Test program " << argv[0] << ":" << std::endl;