From 1267d56c788cf8628c4111042d01b926f4a58dba Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 27 Feb 2012 09:12:15 -0800 Subject: [PATCH] Fix valgrind issues. --- libtest/blobslap_worker.cc | 2 +- libtest/cmdline.cc | 1 - libtest/gearmand.cc | 2 +- libtest/server.cc | 15 ++++++++++----- libtest/server_container.cc | 5 ++++- tests/cli.am | 5 ++++- tests/memtouch.cc | 8 +++++--- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/libtest/blobslap_worker.cc b/libtest/blobslap_worker.cc index d8684058..5bf5f535 100644 --- a/libtest/blobslap_worker.cc +++ b/libtest/blobslap_worker.cc @@ -127,7 +127,7 @@ public: return "--daemon"; } - void has_port_option() const + bool has_port_option() const { return true; } diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 5b4b64c8..6807c338 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -241,7 +241,6 @@ Application::error_t Application::wait() { Error << print_argv(built_argv, _argc, _pid); } - return exit_code; } diff --git a/libtest/gearmand.cc b/libtest/gearmand.cc index caa75f65..dda38fbd 100644 --- a/libtest/gearmand.cc +++ b/libtest/gearmand.cc @@ -195,7 +195,7 @@ public: return true; } - void has_port_option() const + bool has_port_option() const { return true; } diff --git a/libtest/server.cc b/libtest/server.cc index 0fd1bbf3..c29d8c43 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -132,7 +132,11 @@ bool Server::start() Error << "Could not kill() existing server during start() pid:" << _pid; return false; } - assert(not has_pid()); + + if (has_pid() == false) + { + fatal_message("has_pid() failed, programer error"); + } Application app(name(), is_libtool()); if (args(app) == false) @@ -141,15 +145,16 @@ bool Server::start() return false; } - if (Application::SUCCESS != app.run()) + Application::error_t ret; + if (Application::SUCCESS != (ret= app.run())) { - Error << "Application::run()"; + Error << "Application::run() " << ret; return false; } - if (Application::SUCCESS != app.wait()) + if (Application::SUCCESS != (ret= app.wait())) { - Error << "Application::wait()"; + Error << "Application::wait() " << ret; return false; } diff --git a/libtest/server_container.cc b/libtest/server_container.cc index 3c84ad85..244f80e6 100644 --- a/libtest/server_container.cc +++ b/libtest/server_container.cc @@ -144,7 +144,10 @@ bool server_startup_st::is_helgrind() const bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[]) { Outn(); - (void)try_port; + if (try_port <= 0) + { + libtest::fatal(LIBYATL_DEFAULT_PARAM, "was passed the invalid port number %d", int(try_port)); + } libtest::Server *server= NULL; if (0) diff --git a/tests/cli.am b/tests/cli.am index ecc66dda..32b87981 100644 --- a/tests/cli.am +++ b/tests/cli.am @@ -92,5 +92,8 @@ test-memstat: tests/memstat test-memerror: tests/memerror tests/memerror -valgrind-memerror: clients/memerror +valgrind-memerror: tests/memerror + @$(VALGRIND_COMMAND) tests/memerror + +valgrind-memtouch: tests/memtouch @$(VALGRIND_COMMAND) tests/memerror diff --git a/tests/memtouch.cc b/tests/memtouch.cc index 426e3c98..a09bd40a 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -65,7 +65,6 @@ static test_return_t touch_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); - const char *args[]= { "--expire=30", buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); @@ -75,6 +74,8 @@ static test_return_t touch_test(void *) test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo"))); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { "--expire=30", buffer, "foo", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo"))); @@ -87,9 +88,8 @@ static test_return_t touch_test(void *) static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); - const char *args[]= { "--expire=30", buffer, "foo", 0 }; + snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); @@ -97,6 +97,8 @@ static test_return_t NOT_FOUND_test(void *) test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { "--expire=30", buffer, "foo", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); -- 2.30.2