From: Brian Aker Date: Mon, 15 Apr 2013 19:02:09 +0000 (-0700) Subject: Merge libtest. X-Git-Tag: 1.0.18~29^2~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b036e172e5839d530bce7c3831a8eaf36d68eca7;p=m6w6%2Flibmemcached Merge libtest. --- diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 741d18d7..a6374060 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -412,7 +412,6 @@ Application::error_t Application::join() slurp(); if (waited_pid == _pid and WIFEXITED(_status) == false) { - /* What we are looking for here is how the exit status happened. - 127 means that posix_spawn() itself had an error. @@ -437,15 +436,18 @@ Application::error_t Application::join() { if (WTERMSIG(_status) != SIGTERM and WTERMSIG(_status) != SIGHUP) { + slurp(); _app_exit_state= Application::INVALID_POSIX_SPAWN; std::string error_string(print_argv(built_argv)); error_string+= " was killed by signal "; error_string+= strsignal(WTERMSIG(_status)); + if (stdout_result_length()) { error_string+= " stdout: "; error_string+= stdout_c_str(); } + if (stderr_result_length()) { error_string+= " stderr: "; @@ -573,6 +575,7 @@ bool Application::Pipe::read(libtest::vchar_t& arg) void Application::Pipe::nonblock() { int flags; + do { flags= fcntl(_pipe_fd[READ], F_GETFL, 0); } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); diff --git a/libtest/common.h b/libtest/common.h index b611e1a9..90d8b6a8 100644 --- a/libtest/common.h +++ b/libtest/common.h @@ -69,7 +69,7 @@ # include #endif -#if defined(_WIN32) +#if defined(WIN32) # include "win32/wrappers.h" # define get_socket_errno() WSAGetLastError() #else diff --git a/libtest/dream.cc b/libtest/dream.cc index cd7d6aa6..42f9222d 100644 --- a/libtest/dream.cc +++ b/libtest/dream.cc @@ -41,7 +41,7 @@ namespace libtest { void dream(time_t tv_sec, long tv_nsec) { -#if defined(_WIN32) +#if defined(WIN32) if (tv_sec == 0 and tv_nsec) { tv_sec++; diff --git a/libtest/drizzled.cc b/libtest/drizzled.cc index b8068ac8..3a93b666 100644 --- a/libtest/drizzled.cc +++ b/libtest/drizzled.cc @@ -74,11 +74,11 @@ bool ping_drizzled(const in_port_t _port) #if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE if (HAVE_LIBDRIZZLE) { - drizzle_st *drizzle= drizzle_create_tcp(getenv("MYSQL_SERVER"), - getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT, - getenv("MYSQL_USER"), - getenv("MYSQL_PASSWORD"), - getenv("MYSQL_SCHEMA"), drizzle_options_t()); + drizzle_st *drizzle= drizzle_create(getenv("MYSQL_SERVER"), + getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT, + getenv("MYSQL_USER"), + getenv("MYSQL_PASSWORD"), + getenv("MYSQL_SCHEMA"), 0); if (drizzle == NULL) { diff --git a/libtest/include.am b/libtest/include.am index d1ede13b..c9368c4f 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -5,10 +5,12 @@ # LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute -VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE +VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=memcheck --error-exitcode=1 --leak-check=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE +SGCHECK_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-sgcheck --error-exitcode=1 VALGRIND_COMMAND= TESTS_ENVIRONMENT="valgrind" $(VALGRIND_EXEC_COMMAND) 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 +DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd --error-exitcode=1 +SGCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-sgcheck --error-exitcode=1 MASSIF_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=massif GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb PTRCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-ptrcheck --error-exitcode=1 @@ -19,11 +21,15 @@ export LIBTOOL_COMMAND export VALGRIND_COMMAND export HELGRIND_COMMAND export DRD_COMMAND +export SGCHECK_COMMAND export GDB_COMMAND valgrind: @echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_EXEC_COMMAND)\"" +sgcheck: + @echo make check TESTS_ENVIRONMENT="\"$(SGCHECK_EXEC_COMMAND)\"" + valgrind-supressions: @echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_SUPRESSION)\"" @@ -96,6 +102,7 @@ noinst_HEADERS+= libtest/test.hpp noinst_HEADERS+= libtest/thread.hpp noinst_HEADERS+= libtest/tmpfile.hpp noinst_HEADERS+= libtest/lite.h +noinst_HEADERS+= libtest/valgrind.h noinst_HEADERS+= libtest/vchar.hpp noinst_HEADERS+= libtest/version.h noinst_HEADERS+= libtest/visibility.h @@ -204,6 +211,10 @@ helgrind-unittest: libtest/unittest drd-unittest: libtest/unittest @$(DRD_COMMAND) libtest/unittest +sgcheck-unittest: libtest/unittest + echo $(SGCHECK_COMMAND) + @$(SGCHECK_COMMAND) libtest/unittest + libtest_skiptest_LDADD= libtest/libtest.la libtest_skiptest_SOURCES= libtest/skiptest.cc check_PROGRAMS+= libtest/skiptest diff --git a/libtest/lite.h b/libtest/lite.h index 70aee2b0..342be97d 100644 --- a/libtest/lite.h +++ b/libtest/lite.h @@ -51,7 +51,7 @@ # include #endif -#if defined(_WIN32) +#if defined(WIN32) # include #else # include @@ -77,15 +77,7 @@ # define SKIP(__message_format, ...) #endif -static inline bool valgrind_is_caller(void) -{ - if (getenv("TESTS_ENVIRONMENT") && strstr(getenv("TESTS_ENVIRONMENT"), "valgrind")) - { - return true; - } - - return false; -} +#include static inline size_t yatl_strlen(const char *s) { diff --git a/libtest/main.cc b/libtest/main.cc index 80ffa769..2ceeac92 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -165,7 +165,6 @@ int main(int argc, char *argv[]) Error << "unknown value passed to --repeat: `" << optarg << "`"; exit(EXIT_FAILURE); } - break; case OPT_LIBYATL_MATCH_COLLECTION: @@ -383,9 +382,9 @@ int main(int argc, char *argv[]) std::cerr << "std::exception:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } - catch (char const*) + catch (char const* s) { - std::cerr << "Exception:" << std::endl; + std::cerr << "Exception:" << s << std::endl; exit_code= EXIT_FAILURE; } catch (...) diff --git a/libtest/memcached.hpp b/libtest/memcached.hpp index 142f167c..5d010faf 100644 --- a/libtest/memcached.hpp +++ b/libtest/memcached.hpp @@ -39,7 +39,7 @@ #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED inline bool operator== (const memcached_st& memc, const memcached_return_t rc) { - if (memcached_last_error(&memc) == rc) + if (memcached_last_error(const_cast(&memc)) == rc) { return true; } diff --git a/libtest/result.cc b/libtest/result.cc index 9a1c8fba..a102b4f7 100644 --- a/libtest/result.cc +++ b/libtest/result.cc @@ -69,6 +69,7 @@ __test_result::~__test_result() throw() } __test_result::__test_result(const __test_result& other) : + std::exception(), _line(other._line), _file(other._file), _func(other._func), diff --git a/libtest/signal.cc b/libtest/signal.cc index 51f42a4e..70012f1d 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -153,17 +153,13 @@ static void *sig_thread(void *arg) switch (sig) { case SIGALRM: - Error << "SIGALRM"; + case SIGVTALRM: + Error << strsignal(sig); if (gdb_is_caller()) { abort(); } - exit(EXIT_SKIP); - - case SIGVTALRM: - Error << "SIGVTALRM was called"; - context->unblock(); - raise(SIGVTALRM); + exit(EXIT_FAILURE); case SIGABRT: case SIGUSR2: diff --git a/libtest/unittest.cc b/libtest/unittest.cc index c7be63fa..1663e59a 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -181,6 +181,11 @@ static test_return_t test_throw_fail_TEST(void *) } #pragma GCC diagnostic ignored "-Wstack-protector" +#ifdef __clang__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-security" +#endif + static test_return_t ASSERT_FALSE__TEST(void *) { try { @@ -199,6 +204,10 @@ static test_return_t ASSERT_FALSE__TEST(void *) return TEST_FAILURE; } +#ifdef __clang__ +# pragma GCC diagnostic pop +#endif + static test_return_t ASSERT_NEQ_FAIL_TEST(void *) { try { diff --git a/libtest/vchar.cc b/libtest/vchar.cc index 9d2244b3..4af110b4 100644 --- a/libtest/vchar.cc +++ b/libtest/vchar.cc @@ -50,6 +50,11 @@ static size_t get_alpha_num(void) namespace libtest { +int random_alpha_num(void) +{ + return ALPHANUMERICS[get_alpha_num()]; +} + static std::string printer(const char *str, size_t length) { std::ostringstream buf; diff --git a/libtest/vchar.hpp b/libtest/vchar.hpp index 1cc45b44..541bb92f 100644 --- a/libtest/vchar.hpp +++ b/libtest/vchar.hpp @@ -44,6 +44,8 @@ namespace libtest { +int random_alpha_num(void); + typedef std::vector vchar_ptr_t; typedef std::vector vchar_t; @@ -61,6 +63,7 @@ void append(libtest::vchar_t& arg, const char*); } // namespace vchar #define vchar_param(__arg) (&__arg[0]), (__arg.size()) +#define vchar_printf(__arg) int(__arg.size()), (&__arg[0]) std::ostream& operator<<(std::ostream& output, const libtest::vchar_t& arg);