}
#endif
-
static Application::error_t int_to_error_t(int arg)
{
switch (arg)
if (exit_code == Application::INVALID)
{
Error << print_argv(built_argv, _argc);
- /
}
#endif
slurp();
+#if 0
if (exit_code == Application::INVALID)
{
- Error << print_argv(built_argv);
+ Error << print_argv(built_argv, _argc);
}
-;
+#endif
+
return exit_code;
}
}
}
- return_code= runner_code(_frame, run, _timer);
+ alarm(60);
+ try
+ {
+ return_code= runner_code(_frame, run, _timer);
+ }
+ catch (...)
+ {
+ alarm(0);
+ throw;
+ }
+ alarm(0);
}
- catch (libtest::fatal &e)
+ catch (libtest::exception &e)
{
stream::cerr(e.file(), e.line(), e.func()) << e.what();
_failed++;
namespace libtest {
-fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, const char *format, ...) :
- std::runtime_error(func_arg),
- _line(line_arg),
- _file(file_arg),
- _func(func_arg)
+exception::exception(const char *file_, int line_, const char *func_) :
+ std::runtime_error(func_),
+ _file(file_),
+ _line(line_),
+ _func(func_)
+ {
+ }
+
+fatal::fatal(const char *file_, int line_, const char *func_, const char *format, ...) :
+ exception(file_, line_, func_)
{
va_list args;
va_start(args, format);
int last_error_length= vsnprintf(last_error, sizeof(last_error), format, args);
va_end(args);
- strncpy(_mesg, last_error, sizeof(_mesg));
-
snprintf(_error_message, sizeof(_error_message), "%.*s", last_error_length, last_error);
}
_counter++;
}
-disconnected::disconnected(const char *file_arg, int line_arg, const char *func_arg,
+disconnected::disconnected(const char *file_, int line_, const char *func_,
const std::string& instance, const in_port_t port,
const char *format, ...) :
- std::runtime_error(func_arg),
- _port(port),
- _line(line_arg),
- _file(file_arg),
- _func(func_arg)
+ exception(file_, line_, func_),
+ _port(port)
+{
+ va_list args;
+ va_start(args, format);
+ char last_error[BUFSIZ];
+ (void)vsnprintf(last_error, sizeof(last_error), format, args);
+ va_end(args);
+
+ snprintf(_error_message, sizeof(_error_message), "%s:%u %s", instance.c_str(), uint32_t(port), last_error);
+}
+
+start::start(const char *file_, int line_, const char *func_,
+ const std::string& instance, const in_port_t port,
+ const char *format, ...) :
+ exception(file_, line_, func_),
+ _port(port)
{
va_list args;
va_start(args, format);
namespace libtest {
-class fatal : std::runtime_error
+class exception : public std::runtime_error
{
public:
- fatal(const char *file, int line, const char *func, const char *format, ...);
+ exception(const char *, int, const char *);
- const char* what() const throw()
+ int line() const
{
- return _error_message;
+ return _line;
}
- const char* mesg() const throw()
+ const char* file() const
{
- return _error_message;
+ return _file;
}
- // The following are just for unittesting the exception class
- static bool is_disabled();
- static void disable();
- static void enable();
- static uint32_t disabled_counter();
- static void increment_disabled_counter();
-
- int line()
+ const char* func() const
{
- return _line;
+ return _func;
}
- const char* file()
+ const char* mesg() const throw()
{
- return _file;
+ return _error_message;
}
- const char* func()
- {
- return _func;
- }
-private:
+protected:
char _error_message[BUFSIZ];
- char _mesg[BUFSIZ];
- int _line;
+
+private:
const char* _file;
+ int _line;
const char* _func;
};
-class disconnected : std::runtime_error
+class fatal : public exception
{
public:
- disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
+ fatal(const char *file, int line, const char *func, const char *format, ...);
const char* what() const throw()
{
static uint32_t disabled_counter();
static void increment_disabled_counter();
- int line()
- {
- return _line;
- }
+private:
+};
+
+class disconnected : public exception
+{
+public:
+ disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
- const char* file()
+ const char* what() const throw()
{
- return _file;
+ return _error_message;
}
- const char* func()
+ // The following are just for unittesting the exception class
+ static bool is_disabled();
+ static void disable();
+ static void enable();
+ static uint32_t disabled_counter();
+ static void increment_disabled_counter();
+
+private:
+ in_port_t _port;
+ char _instance[1024];
+};
+
+class start : public exception
+{
+public:
+ start(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
+
+ const char* what() const throw()
{
- return _func;
+ return _error_message;
}
+ // The following are just for unittesting the exception class
+ static bool is_disabled();
+ static void disable();
+ static void enable();
+ static uint32_t disabled_counter();
+ static void increment_disabled_counter();
+
private:
- char _error_message[BUFSIZ];
in_port_t _port;
char _instance[1024];
- int _line;
- const char* _file;
- const char* _func;
};
_total++;
- try {
+ try
+ {
switch ((*iter)->exec())
{
case TEST_FAILURE:
catch (libtest::disconnected& e)
{
_failed++;
- Error << "Unhandled disconnection occurred:" << e.what();
+ stream::cerr(e.file(), e.line(), e.func()) << "Unhandled disconnection occurred: " << e.mesg();
throw;
}
catch (...)
curl_easy_cleanup(curl);
- return retref == CURLE_OK;
+ return bool(retref == CURLE_OK);
#endif
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, _response);
curl_easy_cleanup(curl);
+
+ return bool(retref == CURLE_OK);
#endif
}
std::cerr << "FATAL:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
+ catch (libtest::start& e)
+ {
+ std::cerr << "Failure to start:" << e.what() << std::endl;
+ exit_code= EXIT_FAILURE;
+ }
catch (libtest::disconnected& e)
{
std::cerr << "Unhandled disconnection occurred:" << e.what() << std::endl;
if (port() == LIBTEST_FAIL_PORT)
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(), "Called failure");
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(), "Called failure");
}
if (getenv("YATL_PTRCHECK_SERVER"))
if (args(_app) == false)
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(), "Could not build command()");
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(), "Could not build command()");
}
libtest::release_port(_port);
Application::error_t ret;
if (Application::SUCCESS != (ret= _app.run()))
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(), "Application::run() %s", libtest::Application::toString(ret));
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(), "Application::run() %s", libtest::Application::toString(ret));
return false;
}
_running= _app.print();
char buf[PATH_MAX];
char *getcwd_buf= getcwd(buf, sizeof(buf));
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
hostname(), port(),
"Unable to open pidfile in %s for: %s stderr:%s",
getcwd_buf ? getcwd_buf : "",
_app.slurp();
if (kill_file(pid_file()) == false)
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(),
- "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
- this_wait,
- int(_running.size()), _running.c_str(),
- int(_app.stderr_result_length()), _app.stderr_c_str());
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(),
+ "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
+ this_wait,
+ int(_running.size()), _running.c_str(),
+ int(_app.stderr_result_length()), _app.stderr_c_str());
}
else
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(),
- "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
- int(_app.pid()),
- _app.check() ? "true" : "false",
- this_wait,
- int(_running.size()), _running.c_str(),
- int(_app.stderr_result_length()), _app.stderr_c_str());
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(),
+ "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
+ int(_app.pid()),
+ _app.check() ? "true" : "false",
+ this_wait,
+ int(_running.size()), _running.c_str(),
+ int(_app.stderr_result_length()), _app.stderr_c_str());
}
}
else
{
- throw libtest::disconnected(LIBYATL_DEFAULT_PARAM,
- hostname(), port(),
- "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
- int(_app.pid()),
- _app.check() ? "true" : "false",
- this_wait,
- int(_running.size()), _running.c_str(),
- int(_app.stderr_result_length()), _app.stderr_c_str());
+ throw libtest::start(LIBYATL_DEFAULT_PARAM,
+ hostname(), port(),
+ "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
+ int(_app.pid()),
+ _app.check() ? "true" : "false",
+ this_wait,
+ int(_running.size()), _running.c_str(),
+ int(_app.stderr_result_length()), _app.stderr_c_str());
}
_running.clear();
}
}
}
+ catch (libtest::start err)
+ {
+ stream::cerr(err.file(), err.line(), err.func()) << err.what();
+ delete server;
+ return false;
+ }
catch (libtest::disconnected err)
{
stream::cerr(err.file(), err.line(), err.func()) << err.what();
static test_return_t shutdown_servers(memcached_st *memc)
{
+ return TEST_SKIPPED;
+
test_skip_valgrind();
test_compare(memcached_server_count(memc), 1U);
static test_return_t add_shutdown_servers(memcached_st *memc)
{
+ return TEST_SKIPPED;
+
test_skip_valgrind();
while (memcached_server_count(memc) < 2)