Have just one debug test, and don't use timers during gdb operations.
authorBrian Aker <brian@tangent.org>
Tue, 4 Dec 2012 20:44:02 +0000 (15:44 -0500)
committerBrian Aker <brian@tangent.org>
Tue, 4 Dec 2012 20:44:02 +0000 (15:44 -0500)
libtest/alarm.cc
libtest/comparison.cc
libtest/include.am
tests/include.am
tests/libmemcached-1.0/include.am

index 2d662622c4bae6bf8607a26b9852ad3db4c4df8e..93c8ccf74e14b307fb198041e9ababaca60e0420 100644 (file)
@@ -51,33 +51,42 @@ static const struct itimerval cancel_timer= { default_it_interval, default_it_in
 
 void set_alarm()
 {
-  if (setitimer(ITIMER_VIRTUAL, &defualt_timer, NULL) == -1)
+  if (gdb_is_caller() == false)
   {
-    Error << "setitimer() failed";
+    if (setitimer(ITIMER_VIRTUAL, &defualt_timer, NULL) == -1)
+    {
+      Error << "setitimer() failed";
+    }
   }
 }
 
 void set_alarm(long tv_sec, long tv_usec)
 {
+  if (gdb_is_caller() == false)
+  {
 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
-  struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
+    struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
 #else
-  struct timeval it_value= { tv_sec, tv_usec };
+    struct timeval it_value= { tv_sec, tv_usec };
 #endif
 
-  struct itimerval timer= { default_it_interval, it_value };
+    struct itimerval timer= { default_it_interval, it_value };
 
-  if (setitimer(ITIMER_VIRTUAL, &timer, NULL) == -1)
-  {
-    Error << "setitimer() failed";
+    if (setitimer(ITIMER_VIRTUAL, &timer, NULL) == -1)
+    {
+      Error << "setitimer() failed";
+    }
   }
 }
 
 void cancel_alarm()
 {
-  if (setitimer(ITIMER_VIRTUAL, &cancel_timer, NULL) == -1)
+  if (gdb_is_caller() == false)
   {
-    Error << "setitimer() failed";
+    if (setitimer(ITIMER_VIRTUAL, &cancel_timer, NULL) == -1)
+    {
+      Error << "setitimer() failed";
+    }
   }
 }
 
index c16399db7a31f3e9a5d0a1d5363cb3a1180fe49f..4a1d99a301a5b2cfc63010b277e0e03cb0126935 100644 (file)
@@ -66,6 +66,11 @@ bool gdb_is_caller(void)
     return true;
   }
 
+  if (bool(getenv("LIBTEST_IN_GDB")))
+  {
+    return true;
+  }
+
   return false;
 }
 
index 23cc90b28be00fc9f48d8bcb71ccd0c9f3a8a729..8a823ba3627cc502363d7d1c0a0d972c9a0058ea 100644 (file)
@@ -12,6 +12,7 @@ DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd
 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
+PAHOLE_COMMAND= $(LIBTOOL_COMMAND) --mode=execute pahole
 
 export LIBTOOL_COMMAND
 export VALGRIND_COMMAND
index 8f064c65f669b30b25ad98a51e60cda7c814859e..288e276bd808b3b581af8bab17216383c135c64d 100644 (file)
@@ -13,10 +13,6 @@ TESTS_LDADDS+= libmemcached/libmemcached.la
 TESTS_LDADDS+= libmemcached/libmemcachedutil.la
 TESTS_LDADDS+= libtest/libtest.la
 
-DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb
-
-PAHOLE_COMMAND= $(LIBTOOL) --mode=execute pahole
-
 EXTRA_DIST+= tests/cpp_example.cc
 
 noinst_HEADERS+= tests/exist.h
@@ -62,7 +58,7 @@ test-failure: tests/failure
        @tests/failure
 
 gdb-failure: tests/failure
-       @$(DEBUG_COMMAND) tests/failure
+       @$(GDB_COMMAND) tests/failure
 
 
 tests_testhashkit_SOURCES= tests/hashkit_functions.cc
@@ -108,19 +104,19 @@ pahole-mem: tests/testapp
        @$(PAHOLE_COMMAND)  tests/testapp
 
 gdb-mem: tests/libmemcached-1.0/testapp
-       @$(DEBUG_COMMAND)  tests/libmemcached-1.0/testapp
+       @$(GDB_COMMAND)  tests/libmemcached-1.0/testapp
 
 gdb-atom: tests/atomsmasher
-       @$(DEBUG_COMMAND) tests/atomsmasher
+       @$(GDB_COMMAND) tests/atomsmasher
 
 gdb-hash: tests/testhashkit
-       @$(DEBUG_COMMAND) tests/testhashkit
+       @$(GDB_COMMAND) tests/testhashkit
 
 gdb-hashplus: tests/hash_plus
-       @$(DEBUG_COMMAND) tests/hash_plus
+       @$(GDB_COMMAND) tests/hash_plus
 
 gdb-cycle: tests/cycle
-       @$(DEBUG_COMMAND) tests/cycle
+       @$(GDB_COMMAND) tests/cycle
 
 valgrind-cycle: tests/cycle
        $(VALGRIND_COMMAND) tests/cycle
index 499123d82c508e1559f2ad416eb7ba180e92c361..228f72a06d5ee093bfedd021dfcf4cf3a951d3ba 100644 (file)
@@ -178,7 +178,7 @@ test-socket: tests/libmemcached-1.0/testsocket
        @tests/libmemcached-1.0/testsocket
 
 gdb-socket: tests/libmemcached-1.0/testsocket
-       @$(DEBUG_COMMAND) tests/libmemcached-1.0/testsocket
+       @$(GDB_COMMAND) tests/libmemcached-1.0/testsocket
 
 tests_libmemcached_1_0_sasl_SOURCES=
 tests_libmemcached_1_0_sasl_DEPENDENCIES=
@@ -225,7 +225,7 @@ test-sasl: tests/libmemcached-1.0/sasl
        @tests/libmemcached-1.0/sasl
 
 gdb-sasl: tests/libmemcached-1.0/sasl
-       @$(DEBUG_COMMAND)  tests/libmemcached-1.0/sasl
+       @$(GDB_COMMAND)  tests/libmemcached-1.0/sasl
 
 tests_atomsmasher_SOURCES=
 tests_atomsmasher_DEPENDENCIES=
@@ -287,7 +287,7 @@ test-plus: tests/testplus
        @tests/testplus
 
 gdb-plus: tests/testplus
-       $(DEBUG_COMMAND) tests/testplus
+       $(GDB_COMMAND) tests/testplus
 
 valgrind-plus: tests/testplus
        @$(VALGRIND_COMMAND) tests/testplus