*
*/
-#include <config.h>
-#include <libtest/common.h>
+#include "libtest/yatlcon.h"
+
+#include "libtest/common.h"
using namespace libtest;
#include <fcntl.h>
#include <fstream>
#include <memory>
+#ifdef HAVE_POLL_H
+# include <poll.h>
+#endif
+#ifdef HAVE_SPAWN_H
+# include <spawn.h>
+#endif
#include <sstream>
#include <string>
#include <sys/stat.h>
std::stringstream arg_buffer;
for (vchar_ptr_t::iterator iter= built_argv.begin();
- iter == built_argv.end();
- iter++)
+ iter != built_argv.end();
+ ++iter)
{
arg_buffer << *iter << " ";
}
Application::error_t Application::join()
{
pid_t waited_pid= waitpid(_pid, &_status, 0);
-
if (waited_pid == _pid and WIFEXITED(_status) == false)
{
/*
error_string+= built_argv[0];
throw std::logic_error(error_string);
}
- else if WIFSIGNALED(_status)
+ else if (WIFSIGNALED(_status))
{
- // memcached will die with SIGHUP
if (WTERMSIG(_status) != SIGTERM and WTERMSIG(_status) != SIGHUP)
{
_app_exit_state= Application::INVALID_POSIX_SPAWN;
throw std::runtime_error(error_string);
}
- _app_exit_state= Application::SIGTERM_KILLED;
- Out << "waitpid() application terminated at request"
- << " pid:" << _pid
- << " name:" << built_argv[0];
+ // If we terminted it on purpose then it counts as a success.
+#if defined(DEBUG)
+ if (DEBUG)
+ {
+ Out << "waitpid() application terminated at request"
+ << " pid:" << _pid
+ << " name:" << built_argv[0];
+ }
+#endif
}
else
{
bool data_was_read= false;
+ libtest::vchar_t buffer;
+ buffer.resize(1024);
ssize_t read_length;
- char buffer[1024]= { 0 };
- while ((read_length= ::read(_pipe_fd[READ], buffer, sizeof(buffer))))
+ while ((read_length= ::read(_pipe_fd[READ], &buffer[0], buffer.size())))
{
if (read_length == -1)
{
built_argv.push_back(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 size_t(length) < sizeof(buffer));
- built_argv.push_back(strdup(buffer));
+ libtest::vchar_t buffer;
+ buffer.resize(1024);
+ int length= snprintf(&buffer[0], buffer.size(), "--log-file=%s", log_file.c_str());
+ fatal_assert(length > 0 and size_t(length) < buffer.size());
+ built_argv.push_back(strdup(&buffer[0]));
}
else if (_use_ptrcheck)
{
built_argv.push_back(strdup("--error-exitcode=1"));
built_argv.push_back(strdup("--tool=exp-ptrcheck"));
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 size_t(length) < sizeof(buffer));
- built_argv.push_back(strdup(buffer));
+ libtest::vchar_t buffer;
+ buffer.resize(1024);
+ int length= snprintf(&buffer[0], buffer.size(), "--log-file=%s", log_file.c_str());
+ fatal_assert(length > 0 and size_t(length) < buffer.size());
+ built_argv.push_back(strdup(&buffer[0]));
}
else if (_use_gdb)
{
template <class T>
void operator() ( T* ptr) const
{
- free(ptr);
+ if (ptr)
+ {
+ free(ptr);
+ }
}
};