Merge libtest.
authorBrian Aker <brian@tangent.org>
Mon, 15 Apr 2013 19:02:09 +0000 (12:02 -0700)
committerBrian Aker <brian@tangent.org>
Mon, 15 Apr 2013 19:02:09 +0000 (12:02 -0700)
13 files changed:
libtest/cmdline.cc
libtest/common.h
libtest/dream.cc
libtest/drizzled.cc
libtest/include.am
libtest/lite.h
libtest/main.cc
libtest/memcached.hpp
libtest/result.cc
libtest/signal.cc
libtest/unittest.cc
libtest/vchar.cc
libtest/vchar.hpp

index 741d18d7f7e480d9e3cf9e44c9cec60246d01807..a63740607b3f0e1f02a3e2f23d98ac59f82d043f 100644 (file)
@@ -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));
index b611e1a9fcd18a7cae461a8e5b85162e767a465e..90d8b6a8def0594cef3663b9c7d83ebe4bca8b64 100644 (file)
@@ -69,7 +69,7 @@
 # include <arpa/inet.h>
 #endif
 
-#if defined(_WIN32)
+#if defined(WIN32)
 # include "win32/wrappers.h"
 # define get_socket_errno() WSAGetLastError()
 #else
index cd7d6aa67e11e104567d8aacb0a44d53a2da4e83..42f9222dde6b12fb324f2a54c4adc9f911932abe 100644 (file)
@@ -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++;
index b8068ac89a310c98629609aec6a2ecfe9af4a366..3a93b6664817e6131349d88e72ce63b88719dc1b 100644 (file)
@@ -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)
     {
index d1ede13b2a1bb4278c9a1cd0280b7158f8057c15..c9368c4fcf561e89091dbfd8a12b0bcb1db91cf0 100644 (file)
@@ -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
index 70aee2b00cc6336cc733fe036c54ebe7b73b103f..342be97d820bc85abcd244ba4a65cffeaee33987 100644 (file)
@@ -51,7 +51,7 @@
 # include <string.h>
 #endif
 
-#if defined(_WIN32)
+#if defined(WIN32)
 # include <malloc.h>
 #else
 # include <alloca.h>
 # 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 <libtest/valgrind.h>
 
 static inline size_t yatl_strlen(const char *s)
 {
index 80ffa769344d5ac89c5d72283c0c37cfa3a23b1b..2ceeac92cf0bdba962a035e4e240a38e4409ab79 100644 (file)
@@ -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 (...)
index 142f167c31398bec78d87e2272fbd43d65b93b86..5d010faf82704189f55d58dbcc8314495b71bfc3 100644 (file)
@@ -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<memcached_st *>(&memc)) == rc)
   {
     return true;
   }
index 9a1c8fba4eae58f09b613faf0dcd01beaec187d1..a102b4f70c80e4dcb6affd72025aa1f9da8dba73 100644 (file)
@@ -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),
index 51f42a4e1439ab29140bf9518f8970427ed59afb..70012f1d94ad672e8a01d036e7e491ccd4662b66 100644 (file)
@@ -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:
index c7be63fa49c90a693e7110e8911b3788fea2cfac..1663e59a6311a41cdd423e5cdfa818c3bd291f54 100644 (file)
@@ -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 {
index 9d2244b3c32c3646bf56d02893c3a42c135c8f14..4af110b40e800988eeac7854204f64eb0650d582 100644 (file)
@@ -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;
index 1cc45b44455861952ab400918b3ab2a562d0237a..541bb92fab468585967de0211a7963301999f412 100644 (file)
@@ -44,6 +44,8 @@
 
 namespace libtest {
 
+int random_alpha_num(void);
+
 typedef std::vector<char*> vchar_ptr_t;
 typedef std::vector<char> 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);