From: Brian Aker Date: Sun, 11 Mar 2012 20:04:00 +0000 (-0700) Subject: Update for valgrind failure. X-Git-Tag: 1.0.5~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2dc9e4fe44119bae275257cc8d7253665fc2606b;p=m6w6%2Flibmemcached Update for valgrind failure. --- diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 76b677f4..e774113a 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -26,6 +26,7 @@ using namespace libtest; #include #include +#include #include #include #include @@ -352,26 +353,24 @@ void Application::Pipe::reset() close(WRITE); int ret; - if ((ret= pipe(_fd)) < 0) + if (pipe(_fd) == -1) { - throw strerror(ret); + throw strerror(errno); } _open[0]= true; _open[1]= true; { - ret= fcntl(_fd[0], F_GETFL, 0); - if (ret == -1) + if ((ret= fcntl(_fd[0], F_GETFL, 0)) == -1) { - Error << "fcntl(F_GETFL) " << strerror(ret); - throw strerror(ret); + Error << "fcntl(F_GETFL) " << strerror(errno); + throw strerror(errno); } - ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK); - if (ret == -1) + if ((ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK)) == -1) { - Error << "fcntl(F_SETFL) " << strerror(ret); - throw strerror(ret); + Error << "fcntl(F_SETFL) " << strerror(errno); + throw strerror(errno); } } } @@ -407,11 +406,12 @@ void Application::Pipe::close(const close_t& arg) if (_open[type]) { int ret; - if ((ret= ::close(_fd[type])) < 0) + if (::close(_fd[type]) == -1) { - Error << "close(" << strerror(ret) << ")"; + Error << "close(" << strerror(errno) << ")"; } _open[type]= false; + _fd[type]= -1; } } @@ -524,21 +524,19 @@ std::string Application::arguments() void Application::delete_argv() { - if (built_argv == NULL) - { - return; - } - - for (size_t x= 0; x < _argc; x++) + if (built_argv) { - if (built_argv[x]) + for (size_t x= 0; x < _argc; x++) { - ::free(built_argv[x]); + if (built_argv[x]) + { + ::free(built_argv[x]); + } } + delete[] built_argv; + built_argv= NULL; + _argc= 0; } - delete[] built_argv; - built_argv= NULL; - _argc= 0; } diff --git a/libtest/include.am b/libtest/include.am index 92dc7d27..7cbbb1de 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -210,7 +210,7 @@ test-unittest: libtest/unittest @libtest/unittest valgrind-unittest: libtest/unittest - @$(VALGRIND_COMMAND) libtest/unittest + @$(VALGRIND_COMMAND) libtest/unittest TESTS_ENVIRONMENT="valgrind" gdb-unittest: libtest/unittest @$(GDB_COMMAND) libtest/unittest diff --git a/libtest/server.cc b/libtest/server.cc index 31ea6eff..34d367ef 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -168,7 +168,7 @@ bool Server::start() if (Application::SUCCESS != (ret= app.wait())) { - Error << "Application::wait() " << app.print() << " " << ret; + Error << "Application::wait() " << _running << " " << ret; return false; } diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 7f0c7404..0272ee7e 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -379,7 +379,14 @@ static test_return_t application_doesnotexist_BINARY(void *) #if defined(TARGET_OS_OSX) && TARGET_OS_OSX test_compare(Application::FAILURE, true_app.wait()); #else - test_compare(Application::INVALID, true_app.wait()); + if (getenv("TESTS_ENVIRONMENT") and strstr(getenv("TESTS_ENVIRONMENT"), "valgrind")) + { + test_compare(Application::FAILURE, true_app.wait()); + } + else + { + test_compare(Application::INVALID, true_app.wait()); + } #endif } test_compare(0, true_app.stdout_result().size());