From 6b83fd5838692b71a50710b9bc13680f9c586167 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 4 Dec 2012 15:44:02 -0500 Subject: [PATCH] Have just one debug test, and don't use timers during gdb operations. --- libtest/alarm.cc | 29 +++++++++++++++++++---------- libtest/comparison.cc | 5 +++++ libtest/include.am | 1 + tests/include.am | 16 ++++++---------- tests/libmemcached-1.0/include.am | 6 +++--- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/libtest/alarm.cc b/libtest/alarm.cc index 2d662622..93c8ccf7 100644 --- a/libtest/alarm.cc +++ b/libtest/alarm.cc @@ -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"; + } } } diff --git a/libtest/comparison.cc b/libtest/comparison.cc index c16399db..4a1d99a3 100644 --- a/libtest/comparison.cc +++ b/libtest/comparison.cc @@ -66,6 +66,11 @@ bool gdb_is_caller(void) return true; } + if (bool(getenv("LIBTEST_IN_GDB"))) + { + return true; + } + return false; } diff --git a/libtest/include.am b/libtest/include.am index 23cc90b2..8a823ba3 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -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 diff --git a/tests/include.am b/tests/include.am index 8f064c65..288e276b 100644 --- a/tests/include.am +++ b/tests/include.am @@ -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 diff --git a/tests/libmemcached-1.0/include.am b/tests/libmemcached-1.0/include.am index 499123d8..228f72a0 100644 --- a/tests/libmemcached-1.0/include.am +++ b/tests/libmemcached-1.0/include.am @@ -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 -- 2.30.2