_use_libtool(_use_libtool_arg),
_use_valgrind(false),
_use_gdb(false),
+ _use_ptrcheck(false),
_argc(0),
_exectuble(arg),
stdin_fd(STDIN_FILENO),
const_cast<char *>(_exectuble_with_path.c_str()),
0};
- spawn_ret= posix_spawnp(&_pid, libtool(), &file_actions, &spawnattr, argv, NULL);
+ spawn_ret= posix_spawnp(&_pid, libtool(), &file_actions, &spawnattr, argv, environ);
}
else
{
const_cast<char *>(gdb_run_file.c_str()),
const_cast<char *>(_exectuble_with_path.c_str()),
0};
- spawn_ret= posix_spawnp(&_pid, "gdb", &file_actions, &spawnattr, argv, NULL);
+ spawn_ret= posix_spawnp(&_pid, "gdb", &file_actions, &spawnattr, argv, environ);
}
}
else
_argc+= 1; // For the command
/*
- valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
+ valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --track-origin=yes --malloc-fill=A5 --free-fill=DE --log-file=
*/
if (_use_valgrind)
{
- _argc+= 7;
+ _argc+= 8;
+ }
+ else if (_use_ptrcheck)
+ {
+ /*
+ valgrind --error-exitcode=1 --tool=exp-ptrcheck --log-file=
+ */
+ _argc+= 4;
}
else if (_use_gdb) // gdb
{
built_argv[x++]= strdup("--leak-check=yes");
built_argv[x++]= strdup("--show-reachable=yes");
built_argv[x++]= strdup("--track-fds=yes");
+#if 0
+ built_argv[x++]= strdup("--track-origin=yes");
+#endif
built_argv[x++]= strdup("--malloc-fill=A5");
built_argv[x++]= strdup("--free-fill=DE");
+
+ std::string log_file= create_tmpfile("valgrind");
+ char buffer[1024];
+ int length= snprintf(buffer, sizeof(buffer), "--log-file=%s", log_file.c_str());
+ fatal_assert(length > 0 and length < sizeof(buffer));
+ built_argv[x++]= strdup(buffer);
+ }
+ else if (_use_ptrcheck)
+ {
+ /*
+ valgrind --error-exitcode=1 --tool=exp-ptrcheck --log-file=
+ */
+ built_argv[x++]= strdup("valgrind");
+ built_argv[x++]= strdup("--error-exitcode=1");
+ built_argv[x++]= strdup("--tool=exp-ptrcheck");
+ _argc+= 4;
+ std::string log_file= create_tmpfile("ptrcheck");
+ char buffer[1024];
+ int length= snprintf(buffer, sizeof(buffer), "--log-file=%s", log_file.c_str());
+ fatal_assert(length > 0 and length < sizeof(buffer));
+ built_argv[x++]= strdup(buffer);
}
else if (_use_gdb)
{
_use_gdb= arg;
}
+ void use_ptrcheck(bool arg= true)
+ {
+ _use_ptrcheck= arg;
+ }
+
std::string arguments();
std::string gdb_filename()
const bool _use_libtool;
bool _use_valgrind;
bool _use_gdb;
+ bool _use_ptrcheck;
size_t _argc;
std::string _exectuble_name;
std::string _exectuble;
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
-class GetPid : public util::Instance::Finish
-{
-private:
- pid_t _pid;
-
-public:
- GetPid() :
- _pid(-1)
- { }
-
- pid_t pid()
- {
- return _pid;
- }
-
-
- bool call(const bool success, const std::string &response)
- {
- _pid= -1;
- if (success and response.size())
- {
- _pid= atoi(response.c_str());
- }
-
- if (is_pid_valid(_pid) == false)
- {
- _pid= -1;
- return false;
- }
-
- return true;
- }
-};
-
using namespace libtest;
class Gearmand : public libtest::Server
bool Gearmand::build(size_t argc, const char *argv[])
{
- std::stringstream arg_buffer;
-
if (getuid() == 0 or geteuid() == 0)
{
add_option("-u", "root");
HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 --read-var-info=yes
DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd
GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb
+PTRCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-ptrcheck --error-exitcode=1
export LIBTOOL_COMMAND
export VALGRIND_COMMAND
bool Memcached::build(size_t argc, const char *argv[])
{
- std::stringstream arg_buffer;
-
if (getuid() == 0 or geteuid() == 0)
{
add_option("-u", "root");
#include <cassert>
#include <cerrno>
+#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#include <locale>
+#include <unistd.h>
// trim from end
static inline std::string &rtrim(std::string &s)
}
#endif
- if (getenv("YATL_VALGRIND_SERVER"))
+ if (getenv("YATL_PTRCHECK_SERVER"))
+ {
+ _app.use_ptrcheck();
+ }
+ else if (getenv("YATL_VALGRIND_SERVER"))
{
_app.use_valgrind();
}
- else if (args(_app) == false)
+
+ if (args(_app) == false)
{
Error << "Could not build command()";
return false;
throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
"Unable to open pidfile for: %s",
_running.c_str());
+ char buf[PATH_MAX];
+ getcwd(buf, sizeof(buf));
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
+ "Unable to open pidfile in %s for: %s",
+ buf,
+ _running.c_str());
}
}
}
int fd;
if ((fd= mkstemp(file_buffer)) == -1)
{
- perror(file_buffer);
- return false;
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "mkstemp() failed on %s with %s", file_buffer, strerror(errno));
}
close(fd);
unlink(file_buffer);
server->build(argc, argv);
- if (gdb_is_caller() and false)
+ if (false)
{
Out << "Pausing for startup, hit return when ready.";
std::string gdb_command= server->base_command();
server->build(argc, argv);
- if (gdb_is_caller() and false)
+ if (false)
{
Out << "Pausing for startup, hit return when ready.";
std::string gdb_command= server->base_command();
static test_return_t gdb_wait_services_appliction_TEST(void *)
{
+ test_skip(true, false);
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
test_skip(0, TARGET_OS_OSX);
#endif
static test_return_t gdb_abort_services_appliction_TEST(void *)
{
+ test_skip(true, false);
test_skip(0, access("/usr/bin/gdb", X_OK ));
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX