Commit 5607a1ce authored by Eric Cano's avatar Eric Cano
Browse files

Split the unit tests into single and multi process parts as single process one

relies on global variables managing files which were deleted on child process exit.
Helgrind is currently disabled for the multiprocess unit test as it makes it fail.
parent da49c7be
......@@ -152,26 +152,33 @@ 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 --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 tests/cta-unitTests-multiProcess
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 --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests
COMMAND tests/cta-unitTests-multiProcess
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-multiProcess
# COMMAND valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests-multiProcess
DEPENDS tests/cta-unitTests tests/valgrind.suppr tests/helgrind.suppr
DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess 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 --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)
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-multiProcess
DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess tests/valgrind.suppr
COMMENT "Running unit tests with memory leak detection" VERBATIM)
add_custom_target(helgrind
valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests
# COMMAND valgrind --tool=helgrind -v --child-silent-after-fork=yes --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests-multiProcess
DEPENDS tests/cta-unitTests tests/helgrind.suppr
COMMENT "Running unit tests with memory leak and race conditions detection" VERBATIM)
DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess tests/helgrind.suppr
COMMENT "Running unit tests with race conditions detection" VERBATIM)
add_custom_target(shortunittests
tests/cta-unitTests
COMMAND tests/cta-unitTests-multiProcess
DEPENDS tests/cta-unitTests
DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess
COMMENT "Running unit tests" VERBATIM)
......@@ -147,6 +147,7 @@ Unit tests and system tests with virtual tape drives
%attr(0755,root,root) %{_libdir}/libsystemTestHelperTests.so
%attr(0755,root,root) %{_libdir}/libcta-tapedSystemTests.so
%attr(0755,root,root) %{_bindir}/cta-unitTests
%attr(0755,root,root) %{_bindir}/cta-unitTests-multiProcess
%attr(0755,root,root) %{_bindir}/cta-valgrindUnitTests.sh
%attr(0755,root,root) %{_bindir}/cta-unitPlusSystemTests.sh
%attr(0755,root,root) %{_libdir}/libctacatalogueunittests.so
......@@ -168,4 +169,6 @@ Unit tests and system tests with virtual tape drives
%attr(0755,root,root) %{_libdir}/libctatapeserverutilsunittests.so
%attr(0755,root,root) %{_libdir}/libctautilsunittests.so
%attr(0755,root,root) %{_libdir}/libctadaemonunittests.so
%attr(0755,root,root) %{_bindir}/cta-systemTests
%attr(0755,root,root) %{_libdir}/libctadaemonunittests-multiprocess.so
%attr(0644,root,root) %{_datadir}/%{name}-%{ctaVersion}/unittest/*.suppr
......@@ -50,6 +50,9 @@ BackendVFS::BackendVFS() : m_deleteOnExit(true) {
} else {
throw cta::exception::Errnum("Failed to create temporary directory");
}
#ifdef DEBUG_PRINT_LOGS
std::cout << "In BackendVFS::BackendVFS(): created object store" << m_root << std::endl;
#endif
}
BackendVFS::BackendVFS(std::string path):
......@@ -82,6 +85,9 @@ BackendVFS::~BackendVFS() {
if (m_deleteOnExit) {
// Delete the created directories recursively
nftw (m_root.c_str(), deleteFileOrDirectory, 100, FTW_DEPTH);
#ifdef DEBUG_PRINT_LOGS
std::cout << "In BackendVFS::BackendVFS(): deleted object store" << m_root << std::endl;
#endif
}
}
......
......@@ -14,11 +14,18 @@ add_library(ctatapedaemon
add_library(ctadaemonunittests SHARED
ConfigurationFileTests.cpp
TapedConfigurationTests.cpp
TpconfigTests.cpp
TpconfigTests.cpp)
add_library(ctadaemonunittests-multiprocess SHARED
ProcessManagerTests.cpp)
target_link_libraries(ctadaemonunittests
ctatapedaemon
unitTestHelper)
install(TARGETS ctadaemonunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
\ No newline at end of file
target_link_libraries(ctadaemonunittests-multiprocess
ctatapedaemon
unitTestHelper)
install(TARGETS ctadaemonunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ctadaemonunittests-multiprocess DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
\ No newline at end of file
......@@ -48,6 +48,19 @@ target_link_libraries(cta-unitTests
gtest
pthread)
add_executable(cta-unitTests-multiProcess
unit_tests.cpp
${GMOCK_SRC})
target_link_libraries(cta-unitTests-multiProcess
ctadaemonunittests-multiprocess
ctacommon
${GMOCK_LIB}
gtest
pthread
protobuf
sqlite3)
add_library(unitTestHelper
TempFile.cpp)
......@@ -72,7 +85,7 @@ target_link_libraries(cta-systemTests
gtest
pthread)
install(TARGETS cta-unitTests cta-systemTests DESTINATION usr/bin)
install(TARGETS cta-unitTests cta-unitTests-multiProcess cta-systemTests DESTINATION usr/bin)
install(TARGETS systemTestHelperTests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
......
......@@ -3,6 +3,8 @@
set -e
/usr/bin/cta-unitTests
/usr/bin/cta-unitTests-multiProcess
valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes \
--error-exitcode=1 --suppressions=/usr/share/cta-@CTA_VERSION@/unittest/valgrind.suppr \
/usr/bin/cta-unitTests
......@@ -10,3 +12,11 @@ valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all
valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 \
--error-exitcode=1 --suppressions=/usr/share/cta-@CTA_VERSION@/unittest/helgrind.suppr \
/usr/bin/cta-unitTests
valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes \
--error-exitcode=1 --suppressions=/usr/share/cta-@CTA_VERSION@/unittest/valgrind.suppr \
--child-silent-after-fork=yes /usr/bin/cta-unitTests-multiProcess
#valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --conflict-cache-size=30000000 \
# --error-exitcode=1 --suppressions=/usr/share/cta-@CTA_VERSION@/unittest/helgrind.suppr \
# /usr/bin/cta-unitTests-multiProcess
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment