Skip to content
Snippets Groups Projects
Commit a0d55aa4 authored by Eric Cano's avatar Eric Cano
Browse files

Added missing destructor in ProcessManager to close epollfd.

Added silencing of valgrind information for child processes.
Added protocol buffers cleanup at the end of unit tests.
parent 904a5f86
No related branches found
No related tags found
No related merge requests found
......@@ -152,14 +152,14 @@ configure_file(tests/valgrind.suppr tests/valgrind.suppr COPYONLY)
configure_file(tests/helgrind.suppr tests/helgrind.suppr COPYONLY)
add_custom_target(fullunittests
tests/cta-unitTests
COMMAND valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
COMMAND valgrind --track-fds=yes --child-silent-after-fork=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
COMMAND valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests
DEPENDS tests/cta-unitTests tests/valgrind.suppr tests/helgrind.suppr
COMMENT "Running unit tests with memory leak and race conditions detection" VERBATIM)
add_custom_target(valgrind
valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
valgrind --track-fds=yes --child-silent-after-fork=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
DEPENDS tests/cta-unitTests tests/valgrind.suppr
COMMENT "Running unit tests with memory leak and race conditions detection" VERBATIM)
......
......@@ -19,6 +19,7 @@
#include "ProcessManager.hpp"
#include "common/exception/Errnum.hpp"
#include <sys/epoll.h>
#include <unistd.h>
#include <algorithm>
namespace cta {
......@@ -31,6 +32,10 @@ ProcessManager::ProcessManager() {
"In ProcessManager::ProcessManager(), failed to create an epoll file descriptor: ");
}
ProcessManager::~ProcessManager() {
::close(m_epollFd);
}
void ProcessManager::addHandler(std::unique_ptr<SubprocessHandler>&& handler) {
m_subprocessHandlers.push_back(SubprocessAndStatus());
m_subprocessHandlers.back().handler = std::move(handler);
......
......@@ -32,6 +32,7 @@ namespace daemon {
class ProcessManager {
public:
ProcessManager();
~ProcessManager();
/** Function passing ownership of a subprocess handler to the manager. */
void addHandler(std::unique_ptr<SubprocessHandler> && handler);
/** Function allowing a SubprocessHandler to register a file descriptor to epoll */
......
......@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <sqlite3.h>
#include <google/protobuf/stubs/common.h>
int main(int argc, char** argv) {
// The unit tests use SQLite it must be initialized before they are run
......@@ -46,6 +47,8 @@ int main(int argc, char** argv) {
std::cerr << "Failed to shutdown SQLite" << std::endl;
return 1; // Error
}
::google::protobuf::ShutdownProtobufLibrary();
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment