From da815b641bc79fb9435c79f30435d537df32bd1b Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Tue, 25 Apr 2023 17:48:20 +0200 Subject: [PATCH] ci: Add valgrind target We used to have this in the old ctest. The code should be ready for this as we already skip tracing openssh sshd (ca4fb9c6) and have workaround for openssl issues (55252e4d), but it took me some time to figure out the secret command to run tests under valgrind with cmake. This adds also convenient custom target to run the memcheck manually. Signed-off-by: Jakub Jelen Reviewed-by: Norbert Pocs --- .gitlab-ci.yml | 9 +++++++++ tests/CMakeLists.txt | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b27810f0..6f79c8d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -198,6 +198,15 @@ fedora/openssl_3.0.x/x86_64/minimal: -DWITH_GEX=OFF .. && make -j$(nproc) +fedora/valgrind: + extends: .fedora + stage: analysis + script: + - cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. && + make -j$(nproc) && + make test_memcheck + - cat Testing/Temporary/MemoryChecker.*.log | wc -l | grep "^0$" + # Address sanitizer doesn't mix well with LD_PRELOAD used in the testsuite # so, this is only enabled for unit tests right now. # TODO: add -DCLIENT_TESTING=ON -DSERVER_TESTING=ON diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 50bbe9b4..52c5be1e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -337,3 +337,12 @@ endif () if (FUZZ_TESTING) add_subdirectory(fuzz) endif() + +add_custom_target(test_memcheck + # FIXME: The threads_pki_rsa test is skipped under valgrind as it times out + # Passing suppression file is also stupid so lets go with override here: + # https://stackoverflow.com/a/56116311 + COMMAND ${CMAKE_CTEST_COMMAND} -E torture_threads_pki_rsa + --output-on-failure --force-new-ctest-process --test-action memcheck + --overwrite MemoryCheckSuppressionFile=${CMAKE_SOURCE_DIR}/tests/valgrind.supp + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")