From: Brian Aker Date: Tue, 19 Jul 2011 22:07:57 +0000 (-0700) Subject: Cleans up the assert and some other things that Fedora 15 found. X-Git-Tag: 0.51~1^2~1^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3c4d734f56530d43520f385bff97162c04ac81ac;p=awesomized%2Flibmemcached Cleans up the assert and some other things that Fedora 15 found. --- diff --git a/.bzrignore b/.bzrignore index 875ee548..7a79ca5e 100644 --- a/.bzrignore +++ b/.bzrignore @@ -110,3 +110,5 @@ tests/testplus tests/testudp tests/var/ unittests/unittests +out +*.orig diff --git a/Makefile.am b/Makefile.am index 17e549e7..16b22797 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 # includes append to these: SUFFIXES = +.PHONY = PHONY = TESTS = CLEANFILES = diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 1f3b172c..70f5d227 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -36,7 +36,6 @@ */ #include -#include #define MAX_ERROR_LENGTH 2048 struct memcached_error_t @@ -166,22 +165,22 @@ static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, const char *str, size_t length) { - assert(rc != MEMCACHED_ERRNO); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); memcached_string_t tmp= { str, length }; return memcached_set_error(memc, rc, at, tmp); } memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, const char *str, size_t length) { - assert(rc != MEMCACHED_ERRNO); - assert(rc != MEMCACHED_SOME_ERRORS); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); + assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); memcached_string_t tmp= { str, length }; return memcached_set_error(self, rc, at, tmp); } memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str) { - assert(rc != MEMCACHED_ERRNO); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_success(rc)) return MEMCACHED_SUCCESS; @@ -192,8 +191,8 @@ memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, memcached_string_t& str) { - assert(rc != MEMCACHED_ERRNO); - assert(rc != MEMCACHED_SOME_ERRORS); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); + assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); if (memcached_success(rc)) return MEMCACHED_SUCCESS; @@ -224,8 +223,8 @@ memcached_return_t memcached_set_error(memcached_server_st& self, memcached_retu memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at) { - assert(rc != MEMCACHED_ERRNO); - assert(rc != MEMCACHED_SOME_ERRORS); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); + assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); if (memcached_success(rc)) return MEMCACHED_SUCCESS; @@ -245,7 +244,7 @@ memcached_return_t memcached_set_error(memcached_server_st& self, memcached_retu memcached_return_t memcached_set_error(memcached_st& self, memcached_return_t rc, const char *at) { - assert(rc != MEMCACHED_ERRNO); + assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_success(rc)) return MEMCACHED_SUCCESS; diff --git a/libmemcached/get.cc b/libmemcached/get.cc index dcb9f001..794d3d15 100644 --- a/libmemcached/get.cc +++ b/libmemcached/get.cc @@ -36,7 +36,6 @@ */ #include -#include /* What happens if no servers exist? @@ -87,7 +86,7 @@ char *memcached_get_by_key(memcached_st *ptr, *error= memcached_mget_by_key_real(ptr, group_key, group_key_length, (const char * const *)&key, &key_length, 1, false); - assert(ptr->query_id == query_id +1); + assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); if (memcached_failed(*error)) @@ -105,7 +104,7 @@ char *memcached_get_by_key(memcached_st *ptr, char *value= memcached_fetch(ptr, NULL, NULL, value_length, flags, error); - assert(ptr->query_id == query_id +1); + assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); /* This is for historical reasons */ if (*error == MEMCACHED_END) @@ -157,7 +156,7 @@ char *memcached_get_by_key(memcached_st *ptr, } } } - assert(ptr->query_id == query_id +1); + assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); return NULL; } @@ -171,7 +170,7 @@ char *memcached_get_by_key(memcached_st *ptr, &dummy_error); WATCHPOINT_ASSERT(dummy_length == 0); WATCHPOINT_ASSERT(dummy_value == 0); - assert(ptr->query_id == query_id +1); + assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); return value; } diff --git a/libmemcached/io.cc b/libmemcached/io.cc index f77a0973..c04deb30 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -38,7 +38,6 @@ #include -#include enum memc_read_or_write { MEM_READ, @@ -277,12 +276,12 @@ static bool process_input_buffer(memcached_server_write_instance_st ptr) memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, void *buffer, size_t length, ssize_t *nread) { - assert(ptr); // Programmer error + assert_msg(ptr, "Programmer error, memcached_io_read() recieved an invalid memcached_server_write_instance_st"); // Programmer error char *buffer_ptr= static_cast(buffer); if (ptr->fd == INVALID_SOCKET) { - assert(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO)); + assert_msg(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO), "Programmer error, invalid socket state"); return MEMCACHED_CONNECTION_FAILURE; } @@ -322,7 +321,7 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, case ENOTSOCK: WATCHPOINT_ASSERT(0); case EBADF: - assert(ptr->fd != INVALID_SOCKET); + assert_msg(ptr->fd != INVALID_SOCKET, "Programmer error, invalid socket"); case EINVAL: case EFAULT: case ECONNREFUSED: @@ -346,7 +345,6 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, it will return EGAIN if data is not immediatly available. */ WATCHPOINT_STRING("We had a zero length recv()"); - assert(0); memcached_quit_server(ptr, true); *nread= -1; return memcached_set_error(*ptr, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); @@ -388,11 +386,11 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr) { - assert(ptr); // Programmer error + assert_msg(ptr, "Programmer error, invalid memcached_server_write_instance_st"); if (ptr->fd == INVALID_SOCKET) { - assert(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO)); + assert_msg(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO), "Invalid socket state"); return MEMCACHED_CONNECTION_FAILURE; } @@ -429,7 +427,7 @@ memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr) case ENOTSOCK: WATCHPOINT_ASSERT(0); case EBADF: - assert(ptr->fd != INVALID_SOCKET); + assert_msg(ptr->fd != INVALID_SOCKET, "Invalid socket state"); case EINVAL: case EFAULT: case ECONNREFUSED: diff --git a/libmemcached/options.cc b/libmemcached/options.cc index c1e591d8..ad28c664 100644 --- a/libmemcached/options.cc +++ b/libmemcached/options.cc @@ -38,13 +38,11 @@ #include #include -#include - #include const char *memcached_parse_filename(memcached_st *memc) { - assert(memc); + assert_msg(memc, "Invalid memcached_st"); return memcached_array_string(memc->configure.filename); } @@ -100,9 +98,8 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s bool has_filename= memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE); if (memcached_success(rc) and has_filename) { - assert(memcached_parse_filename(memc_ptr)); - assert(memcached_parse_filename_length(memc_ptr)); - memcached_string_t filename= memcached_array_to_string(memc_ptr->configure.filename); + assert_msg(memcached_parse_filename(memc_ptr), "Invalid configuration file"); + assert_msg(memcached_parse_filename_length(memc_ptr), "Invalid configuration file"); rc= _parse_file_options(*memc_ptr, memc_ptr->configure.filename); if (memcached_failed(rc) and error_buffer && error_buffer_size) @@ -134,8 +131,8 @@ memcached_return_t memcached_parse_configuration(memcached_st *self, char const void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length) { - assert(filename); - assert(filename_length); + assert_msg(filename, "Invalid filename"); + assert_msg(filename_length, "Invalid filename_length"); memcached_array_free(self->configure.filename); self->configure.filename= memcached_strcpy(self, filename, filename_length); } diff --git a/libmemcached/server.cc b/libmemcached/server.cc index 955e1b30..4187a0ab 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -39,7 +39,6 @@ This is a partial implementation for fetching/creating memcached_server_st objects. */ #include -#include static inline void _server_init(memcached_server_st *self, memcached_st *root, const char *hostname, in_port_t port, diff --git a/libmemcached/server_list.cc b/libmemcached/server_list.cc index 4da19963..a599e0b6 100644 --- a/libmemcached/server_list.cc +++ b/libmemcached/server_list.cc @@ -38,7 +38,6 @@ #include -#include memcached_server_list_st memcached_server_list_append_with_weight(memcached_server_list_st ptr, diff --git a/libmemcached/string.cc b/libmemcached/string.cc index 0e174840..7bc7fec0 100644 --- a/libmemcached/string.cc +++ b/libmemcached/string.cc @@ -37,7 +37,6 @@ #include -#include inline static memcached_return_t _string_check(memcached_string_st *string, size_t need) { @@ -231,7 +230,7 @@ const char *memcached_string_value(const memcached_string_st *self) char *memcached_string_take_value(memcached_string_st *self) { - assert(self); + assert_msg(self, "Invalid memcached_string_st"); // If we fail at adding the null, we copy and move on if (memcached_success(memcached_string_append_null(self))) { diff --git a/libtest/include.am b/libtest/include.am index 4a51fa46..4fcfa1b9 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -12,9 +12,11 @@ LIBUTEST_TMP = ${abs_top_builddir}/tests/var/tmp/ VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE -HELGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 +HELGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 -v DRD_COMMAND= $(LIBTOOL) --mode=execute valgrind --tool=drd -GDB_COMMAND= $(LIBTOOL) --mode=execute gdb +GDB_COMMAND= $(LIBTOOL) --mode=execute gdb -f -x libtest/run.gdb + +EXTRA_DIST+= libtest/run.gdb CLEANFILES+= \ tests/var/log/* \ diff --git a/libtest/run.gdb b/libtest/run.gdb new file mode 100644 index 00000000..320407a2 --- /dev/null +++ b/libtest/run.gdb @@ -0,0 +1,2 @@ +set environment LIBTEST_IN_GDB=1 +run diff --git a/libtest/server.cc b/libtest/server.cc index f547d455..d5329b11 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -188,6 +188,11 @@ bool Server::start() return false; } + if (is_valgrind() or is_helgrind()) + { + _running+= " &"; + } + if (system(_running.c_str()) == -1) { Error << "system() failed:" << strerror(errno); @@ -195,6 +200,11 @@ bool Server::start() return false; } + if (is_helgrind()) + { + sleep(4); + } + if (pid_file_option() and not pid_file().empty()) { Wait wait(pid_file()); @@ -205,7 +215,7 @@ bool Server::start() } } - int count= 5; + int count= is_helgrind() ? 20 : 5; while (not ping() and --count) { nap(); @@ -325,7 +335,12 @@ void Server::rebuild_base_command() } else if (is_valgrind()) { - _base_command+= "valgrind --log-file=tests/var/tmp/valgrind.out --leak-check=full --show-reachable=yes "; + _base_command+= "valgrind --log-file=tests/var/tmp/valgrind.out --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE "; + + } + else if (is_helgrind()) + { + _base_command+= "valgrind --log-file=tests/var/tmp/helgrind.out --tool=helgrind --read-var-info=yes --error-exitcode=1 -v "; } _base_command+= executable(); @@ -359,7 +374,7 @@ bool Server::args(std::string& options) } assert(daemon_file_option()); - if (daemon_file_option()) + if (daemon_file_option() and not is_valgrind() and not is_helgrind()) { arg_buffer << " " << daemon_file_option(); } @@ -396,6 +411,11 @@ bool Server::is_valgrind() const return bool(getenv("LIBTEST_MANUAL_VALGRIND")); } +bool Server::is_helgrind() const +{ + return bool(getenv("LIBTEST_MANUAL_HELGRIND")); +} + bool Server::kill(pid_t pid_arg) { if (check_pid(pid_arg) and kill_pid(pid_arg)) // If we kill it, reset @@ -486,6 +506,12 @@ bool server_startup_st::is_valgrind() const return bool(getenv("LIBTEST_MANUAL_VALGRIND")); } +bool server_startup_st::is_helgrind() const +{ + return bool(getenv("LIBTEST_MANUAL_HELGRIND")); +} + + bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[]) { Outn(); diff --git a/libtest/server.h b/libtest/server.h index 7a915bb9..c09469ec 100644 --- a/libtest/server.h +++ b/libtest/server.h @@ -155,6 +155,7 @@ protected: void nap(); private: + bool is_helgrind() const; bool is_valgrind() const; bool is_debug() const; bool set_log_file(); @@ -190,6 +191,7 @@ public: } bool is_debug() const; + bool is_helgrind() const; bool is_valgrind() const; void shutdown(bool remove= false); diff --git a/libtest/signal.cc b/libtest/signal.cc index d62221eb..45d0fd9e 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -36,49 +36,15 @@ #include -#include -#include #include #include using namespace libtest; -struct context_st { - sigset_t set; - sem_t lock; +#define MAGIC_MEMORY 123569 - context_st() - { - sigemptyset(&set); - sigaddset(&set, SIGQUIT); - sigaddset(&set, SIGINT); - - sem_init(&lock, 0, 0); - } - - void test() - { - assert(sigismember(&set, SIGQUIT)); - assert(sigismember(&set, SIGINT)); - } - - int wait(int& sig) - { - return sigwait(&set, &sig); - } - - ~context_st() - { - sem_destroy(&lock); - } -}; - -static volatile shutdown_t __shutdown; -static pthread_mutex_t shutdown_mutex; -static pthread_t thread; - -bool is_shutdown() +bool SignalThread::is_shutdown() { bool ret; pthread_mutex_lock(&shutdown_mutex); @@ -88,7 +54,7 @@ bool is_shutdown() return ret; } -void set_shutdown(shutdown_t arg) +void SignalThread::set_shutdown(shutdown_t arg) { pthread_mutex_lock(&shutdown_mutex); __shutdown= arg; @@ -96,14 +62,14 @@ void set_shutdown(shutdown_t arg) if (arg == SHUTDOWN_GRACEFUL) { - pthread_kill(thread, SIGQUIT); + pthread_kill(thread, SIGUSR2); void *retval; pthread_join(thread, &retval); } } -shutdown_t get_shutdown() +shutdown_t SignalThread::get_shutdown() { shutdown_t local; pthread_mutex_lock(&shutdown_mutex); @@ -113,17 +79,33 @@ shutdown_t get_shutdown() return local; } +void SignalThread::post() +{ + sem_post(&lock); +} + +void SignalThread::test() +{ + assert(magic_memory == MAGIC_MEMORY); + if (not getenv("LIBTEST_IN_GDB")) + { + assert(sigismember(&set, SIGABRT)); + assert(sigismember(&set, SIGQUIT)); + assert(sigismember(&set, SIGINT)); + } + assert(sigismember(&set, SIGUSR2)); +} + extern "C" { static void *sig_thread(void *arg) { - context_st *context= (context_st*)arg; - assert(context); + SignalThread *context= (SignalThread*)arg; context->test(); - sem_post(&context->lock); + context->post(); - while (get_shutdown() == SHUTDOWN_RUNNING) + while (context->get_shutdown() == SHUTDOWN_RUNNING) { int sig; @@ -135,12 +117,14 @@ static void *sig_thread(void *arg) switch (sig) { + case SIGABRT: + case SIGUSR2: case SIGINT: case SIGQUIT: - if (is_shutdown() == false) + if (context->is_shutdown() == false) { Error << "Signal handling thread got signal " << strsignal(sig); - set_shutdown(SHUTDOWN_FORCED); + context->set_shutdown(SHUTDOWN_FORCED); } break; @@ -150,21 +134,32 @@ static void *sig_thread(void *arg) } } - delete context; - return NULL; } } -void setup_signals() +SignalThread::SignalThread() : + magic_memory(MAGIC_MEMORY) { pthread_mutex_init(&shutdown_mutex, NULL); - set_shutdown(SHUTDOWN_RUNNING); + sigemptyset(&set); + if (not getenv("LIBTEST_IN_GDB")) + { + sigaddset(&set, SIGABRT); + sigaddset(&set, SIGQUIT); + sigaddset(&set, SIGINT); + } + + sigaddset(&set, SIGUSR2); + + sem_init(&lock, 0, 0); +} - context_st *context= new context_st; - assert(context); +bool SignalThread::setup() +{ + set_shutdown(SHUTDOWN_RUNNING); sigset_t old_set; sigemptyset(&old_set); @@ -178,19 +173,25 @@ void setup_signals() { Error << strsignal(SIGINT) << " has been previously set."; } + if (sigismember(&old_set, SIGUSR2)) + { + Error << strsignal(SIGUSR2) << " has been previously set."; + } int error; - if ((error= pthread_sigmask(SIG_BLOCK, &context->set, NULL)) != 0) + if ((error= pthread_sigmask(SIG_BLOCK, &set, NULL)) != 0) { Error << "pthread_sigmask() died during pthread_sigmask(" << strerror(error) << ")"; - exit(EXIT_FAILURE); + return false; } - if ((error= pthread_create(&thread, NULL, &sig_thread, (void *) &context->set)) != 0) + if ((error= pthread_create(&thread, NULL, &sig_thread, this)) != 0) { Error << "pthread_create() died during pthread_create(" << strerror(error) << ")"; - exit(EXIT_FAILURE); + return false; } - sem_wait(&context->lock); + sem_wait(&lock); + + return true; } diff --git a/libtest/signal.h b/libtest/signal.h index beb28b22..eb092825 100644 --- a/libtest/signal.h +++ b/libtest/signal.h @@ -37,20 +37,46 @@ #pragma once +#include +#include + enum shutdown_t { SHUTDOWN_RUNNING, SHUTDOWN_GRACEFUL, SHUTDOWN_FORCED }; -LIBTEST_INTERNAL_API -bool is_shutdown(); +namespace libtest { + +class SignalThread { + sigset_t set; + sem_t lock; + uint64_t magic_memory; + volatile shutdown_t __shutdown; + pthread_mutex_t shutdown_mutex; + pthread_t thread; + +public: + + SignalThread(); -LIBTEST_INTERNAL_API -shutdown_t get_shutdown(); + void test(); + void post(); + bool setup(); -LIBTEST_INTERNAL_API -void set_shutdown(shutdown_t arg); + int wait(int& sig) + { + return sigwait(&set, &sig); + } + + ~SignalThread() + { + sem_destroy(&lock); + } + + void set_shutdown(shutdown_t arg); + bool is_shutdown(); + shutdown_t get_shutdown(); +}; -LIBTEST_INTERNAL_API -void setup_signals(void); +} // namespace libtest diff --git a/libtest/test.cc b/libtest/test.cc index 5b1a2015..d71057d3 100644 --- a/libtest/test.cc +++ b/libtest/test.cc @@ -167,7 +167,11 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - setup_signals(); + libtest::SignalThread signal; + if (not signal.setup()) + { + return EXIT_FAILURE; + } Stats stats; @@ -203,7 +207,7 @@ int main(int argc, char *argv[]) wildcard= argv[2]; } - for (collection_st *next= world->collections; next->name and (not is_shutdown()); next++) + for (collection_st *next= world->collections; next->name and (not signal.is_shutdown()); next++) { test_return_t collection_rc= TEST_SUCCESS; bool failed= false; @@ -230,7 +234,7 @@ int main(int argc, char *argv[]) case TEST_FAILURE: Out << next->name << " [ failed ]"; failed= true; - set_shutdown(SHUTDOWN_GRACEFUL); + signal.set_shutdown(SHUTDOWN_GRACEFUL); goto cleanup; case TEST_SKIPPED: @@ -280,7 +284,7 @@ int main(int argc, char *argv[]) else if (return_code == TEST_FAILURE) { Error << " item.flush(failure)"; - set_shutdown(SHUTDOWN_GRACEFUL); + signal.set_shutdown(SHUTDOWN_GRACEFUL); } } else if (return_code == TEST_SKIPPED) @@ -288,7 +292,7 @@ int main(int argc, char *argv[]) else if (return_code == TEST_FAILURE) { Error << " item.startup(failure)"; - set_shutdown(SHUTDOWN_GRACEFUL); + signal.set_shutdown(SHUTDOWN_GRACEFUL); } stats.total++; @@ -320,7 +324,7 @@ int main(int argc, char *argv[]) if (test_failed(world->on_error(return_code, creators_ptr))) { Error << "Failed while running on_error()"; - set_shutdown(SHUTDOWN_GRACEFUL); + signal.set_shutdown(SHUTDOWN_GRACEFUL); break; } } @@ -347,13 +351,13 @@ cleanup: Outn(); } - if (not is_shutdown()) + if (not signal.is_shutdown()) { - set_shutdown(SHUTDOWN_GRACEFUL); + signal.set_shutdown(SHUTDOWN_GRACEFUL); } int exit_code= EXIT_SUCCESS; - shutdown_t status= get_shutdown(); + shutdown_t status= signal.get_shutdown(); if (status == SHUTDOWN_FORCED) { Out << "Tests were aborted."; diff --git a/tests/atomsmasher.cc b/tests/atomsmasher.cc index 3f4eb405..60f201eb 100644 --- a/tests/atomsmasher.cc +++ b/tests/atomsmasher.cc @@ -147,7 +147,7 @@ static test_return_t add_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); - test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); + test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); memcached_quit(memc); rc= memcached_add(memc, key, strlen(key), value, strlen(value), @@ -156,11 +156,11 @@ static test_return_t add_test(memcached_st *memc) /* Too many broken OS'es have broken loopback in async, so we can't be sure of the result */ if (setting_value) { - test_true(rc == MEMCACHED_NOTSTORED || rc == MEMCACHED_STORED); + test_true(rc == MEMCACHED_NOTSTORED or rc == MEMCACHED_STORED); } else { - test_true(rc == MEMCACHED_NOTSTORED); + test_compare_got(MEMCACHED_NOTSTORED, rc, memcached_strerror(NULL, rc)); } return TEST_SUCCESS; diff --git a/tests/hash_plus.cc b/tests/hash_plus.cc index 8821d74a..b355fe57 100644 --- a/tests/hash_plus.cc +++ b/tests/hash_plus.cc @@ -63,13 +63,10 @@ static test_return_t assign_test(void *obj) return TEST_SUCCESS; } -static test_return_t digest_test(void *obj) +static test_return_t digest_test(void *) { Hashkit hashk; - uint32_t value; - (void)obj; - - value= hashk.digest("Foo", sizeof("Foo")); + test_true(hashk.digest("Foo", sizeof("Foo"))); return TEST_SUCCESS; } diff --git a/tests/hashkit_functions.cc b/tests/hashkit_functions.cc index 4ddadd9e..c8ca5241 100644 --- a/tests/hashkit_functions.cc +++ b/tests/hashkit_functions.cc @@ -347,8 +347,7 @@ test_st allocation[]= { static test_return_t hashkit_digest_test(hashkit_st *hashk) { - uint32_t value; - value= hashkit_digest(hashk, "a", sizeof("a")); + test_true(hashkit_digest(hashk, "a", sizeof("a"))); return TEST_SUCCESS; } diff --git a/tests/include.am b/tests/include.am index 6c263765..ac0dd92b 100644 --- a/tests/include.am +++ b/tests/include.am @@ -257,7 +257,7 @@ UDP_COMMAND= tests/testudp HASH_COMMAND= tests/testhashkit test-mem: tests/var tests/testapp - $(MEM_COMMAND) + @tests/testapp test-udp: tests/var tests/testudp $(UDP_COMMAND) @@ -278,10 +278,10 @@ test-cycle: tests/var tests/cycle $(CYCLE_COMMAND) pahole-mem: tests/testapp - $(PAHOLE_COMMAND) $(MEM_COMMAND) + @$(PAHOLE_COMMAND) tests/testapp gdb-mem: tests/testapp - $(DEBUG_COMMAND) $(MEM_COMMAND) + @$(DEBUG_COMMAND) tests/testapp gdb-atom: tests/atomsmasher $(DEBUG_COMMAND) $(UDP_COMMAND) @@ -308,7 +308,7 @@ valgrind-cycle: tests/cycle $(VALGRIND_COMMAND) $(CYCLE_COMMAND) valgrind-mem: tests/testapp - $(VALGRIND_COMMAND) $(MEM_COMMAND) + @$(VALGRIND_COMMAND) tests/testapp valgrind-atom: tests/atomsmasher $(VALGRIND_COMMAND) $(ATOM_COMMAND) @@ -325,17 +325,14 @@ valgrind-hash: tests/testhashkit valgrind-hashplus: tests/hashplus $(VALGRIND_COMMAND) $(HASHPLUS_COMMAND) -valgrind-memslap: clients/memslap - $(VALGRIND_COMMAND) $(MEMSLAP_COMMAND) - PHONY += valgrind -valgrind: valgrind-mem valgrind-hash valgrind-memcat valgrind-memcp valgrind-memrm valgrind-memerror valgrind-memdump valgrind-memflush valgrind-memstat +valgrind: valgrind-cycle valgrind-mem valgrind-atom valgrind-udp valgrind-plus valgrind-hash valgrind-hashplus helgrind-cycle: tests/cycle $(HELGRIND_COMMAND) $(CYCLE_COMMAND) helgrind-mem: tests/testapp - $(HELGRIND_COMMAND) $(MEM_COMMAND) + @$(HELGRIND_COMMAND) tests/testapp helgrind-atom: tests/atomsmasher $(HELGRIND_COMMAND) $(ATOM_COMMAND) @@ -352,11 +349,8 @@ helgrind-hash: tests/testhashkit helgrind-hashplus: tests/hashplus $(HELGRIND_COMMAND) $(HASHPLUS_COMMAND) -helgrind-memslap: clients/memslap - $(HELGRIND_COMMAND) $(MEMSLAP_COMMAND) - -PHONY += helgrind -helgrind: helgrind-mem helgrind-hash helgrind-memcat helgrind-memcp helgrind-memrm helgrind-memerror helgrind-memdump helgrind-memflush helgrind-memstat +.PHONY += helgrind +helgrind: helgrind-cycle helgrind-mem helgrind-atom helgrind-udp helgrind-plus helgrind-hash helgrind-hashplus PHONY += cachegrind CLEANFILES += tests/cachegrind.out @@ -372,16 +366,6 @@ callgrind: $(LIBTOOL) --mode=execute valgrind --tool=callgrind --callgrind-out-file=tests/callgrind.out.%p tests/testapp callgrind_annotate tests/callgrind.out.* --auto=yes > tests/callgrind.out -PHONY += helgrind -CLEANFILES+= helgrind.out.* -helgrind: - rm -f helgrind.out.* - $(LIBTOOL) --mode=execute valgrind --tool=helgrind tests/testapp - -PHONY += helgrind-slap -helgrind-slap: - $(LIBTOOL) --mode=execute valgrind --tool=helgrind clients/memslap --server=localhost --concurrency=30 - test-no-outputdiff: test hudson-valgrind: tests/testapp diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 5c386ee0..2dcb3f44 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -1283,7 +1283,6 @@ static test_return_t mget_end(memcached_st *memc) /* Do not copy the style of this code, I just access hosts to testthis function */ static test_return_t stats_servername_test(memcached_st *memc) { - memcached_return_t rc; memcached_stat_st memc_stat; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); @@ -1292,9 +1291,9 @@ static test_return_t stats_servername_test(memcached_st *memc) if (memcached_get_sasl_callbacks(memc) != NULL) return TEST_SKIPPED; #endif - rc= memcached_stat_servername(&memc_stat, NULL, - memcached_server_name(instance), - memcached_server_port(instance)); + test_compare(MEMCACHED_SUCCESS, memcached_stat_servername(&memc_stat, NULL, + memcached_server_name(instance), + memcached_server_port(instance))); return TEST_SUCCESS; } diff --git a/util/pidfile.cc b/util/pidfile.cc index 14b28479..f9a5afbb 100644 --- a/util/pidfile.cc +++ b/util/pidfile.cc @@ -89,11 +89,12 @@ bool Pidfile::create() { _error_message+= "Could not write pid to file: "; _error_message+= _filename; + close(file); return false; } - if (close(file < 0)) + if (close(file) < 0) { _error_message+= "Could not close() file after writing pid to it: "; _error_message+= _filename;