From f480628ddabcae94f8f05a135f23af6ee7cd425e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Thu, 29 Oct 2020 20:52:37 +0100 Subject: [PATCH 1/4] docker: set pkg config path to find Valgrind in OpenSUSE images --- utils/docker/images/Dockerfile.opensuse-leap-latest | 1 + utils/docker/images/Dockerfile.opensuse-tumbleweed-latest | 1 + 2 files changed, 2 insertions(+) diff --git a/utils/docker/images/Dockerfile.opensuse-leap-latest b/utils/docker/images/Dockerfile.opensuse-leap-latest index 72036471c6..35283e99b9 100644 --- a/utils/docker/images/Dockerfile.opensuse-leap-latest +++ b/utils/docker/images/Dockerfile.opensuse-leap-latest @@ -71,6 +71,7 @@ RUN ./install-libndctl.sh # Install valgrind COPY install-valgrind.sh install-valgrind.sh RUN ./install-valgrind.sh +ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/lib/pkgconfig/ # Install pmdk COPY install-pmdk.sh install-pmdk.sh diff --git a/utils/docker/images/Dockerfile.opensuse-tumbleweed-latest b/utils/docker/images/Dockerfile.opensuse-tumbleweed-latest index 3ca45a1515..d9ea71a9af 100644 --- a/utils/docker/images/Dockerfile.opensuse-tumbleweed-latest +++ b/utils/docker/images/Dockerfile.opensuse-tumbleweed-latest @@ -73,6 +73,7 @@ RUN ./install-libndctl.sh # Install valgrind COPY install-valgrind.sh install-valgrind.sh RUN ./install-valgrind.sh +ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/lib/pkgconfig/ # Install pmdk COPY install-pmdk.sh install-pmdk.sh From c7ca69959392c47e8467bce373893f528af14bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Fri, 30 Oct 2020 10:25:25 +0100 Subject: [PATCH 2/4] docker: use sys env PKG_CONFIG_PATH in builds --- utils/docker/run-build.sh | 8 ++++---- utils/docker/run-coverity.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/docker/run-build.sh b/utils/docker/run-build.sh index 76c37b73c0..c920c70455 100755 --- a/utils/docker/run-build.sh +++ b/utils/docker/run-build.sh @@ -31,7 +31,7 @@ function tests_clang_debug_cpp17_no_valgrind() { mkdir build cd build - PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig/ \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ CC=clang CXX=clang++ \ cmake .. -DDEVELOPER_MODE=1 \ -DCHECK_CPP_STYLE=${CHECK_CPP_STYLE} \ @@ -66,7 +66,7 @@ function tests_clang_release_cpp11_no_valgrind() { mkdir build cd build - PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig/ \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ CC=clang CXX=clang++ \ cmake .. -DDEVELOPER_MODE=1 \ -DCHECK_CPP_STYLE=${CHECK_CPP_STYLE} \ @@ -99,7 +99,7 @@ function build_gcc_debug_cpp14() { mkdir build cd build - PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig/ \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ CC=gcc CXX=g++ \ cmake .. -DDEVELOPER_MODE=1 \ -DCHECK_CPP_STYLE=${CHECK_CPP_STYLE} \ @@ -172,7 +172,7 @@ function tests_gcc_release_cpp17_no_valgrind() { mkdir build cd build - PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig/ \ + PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ CC=gcc CXX=g++ \ cmake .. -DDEVELOPER_MODE=1 \ -DCHECK_CPP_STYLE=${CHECK_CPP_STYLE} \ diff --git a/utils/docker/run-coverity.sh b/utils/docker/run-coverity.sh index 871688046a..a4c5057acf 100755 --- a/utils/docker/run-coverity.sh +++ b/utils/docker/run-coverity.sh @@ -41,7 +41,7 @@ sudo_password mv ${TEMP_CF} ${CERT_FILE} echo "Prepare CMake build" mkdir ${WORKDIR}/build cd ${WORKDIR}/build -PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig/ cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOC=OFF +PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOC=OFF # The 'travisci_build_coverity_scan.sh' script requires the following # environment variables to be set: From 5e0ec77ad858d493c56196bc740cc9570af10107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Fri, 6 Nov 2020 16:53:46 +0100 Subject: [PATCH 3/4] if Valgrind tests suppose to run, fail build if Valgrind not found And update check in run-build.sh to test if build really fails. --- CMakeLists.txt | 2 +- tests/ctest_helpers.cmake | 37 ++++++++++++++++---------------- utils/docker/build.sh | 3 ++- utils/docker/run-build.sh | 45 +++++++++++++++++++++++++++++---------- 4 files changed, 56 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb56834f95..11d8b301e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ option(USE_UBSAN "enable UndefinedBehaviorSanitizer (debugging)" OFF) option(USE_CCACHE "Use ccache if it is available in the system" ON) option(TESTS_USE_FORCED_PMEM "run tests with PMEM_IS_PMEM_FORCE=1 - it speeds up tests execution on emulated pmem" OFF) -option(TESTS_USE_VALGRIND "enable tests with valgrind (if found)" ON) +option(TESTS_USE_VALGRIND "enable tests with valgrind (fail build if Valgrind not found)" ON) option(TESTS_PMREORDER "enable tests with pmreorder (if pmreorder found; it requires PMDK ver. >= 1.9)" OFF) option(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND "enable concurrent_hash_map tests with drd and helgrind (can only be run on PMEM)" OFF) option(TESTS_CONCURRENT_GDB "enable concurrent gdb tests - require 'set scheduler-locking on' support (OS dependent)" OFF) diff --git a/tests/ctest_helpers.cmake b/tests/ctest_helpers.cmake index c9e039c245..b771bbe9f4 100644 --- a/tests/ctest_helpers.cmake +++ b/tests/ctest_helpers.cmake @@ -80,7 +80,7 @@ function(find_packages) message(WARNING "Pmemcheck must be installed in version 1.X for pmreorder to work - pmreorder tests will not be performed.") endif() elseif(NOT VALGRIND_FOUND AND TESTS_USE_VALGRIND) - message(WARNING "Valgrind not found. Valgrind tests will not be performed.") + message(FATAL_ERROR "Valgrind not found, but tests are enabled. To disable them set CMake option TESTS_USE_VALGRIND=OFF.") endif() endif() endfunction() @@ -200,28 +200,29 @@ function(add_test_common name tracer testcase cmake_script) set(tracer none) endif() - if (NOT WIN32 AND ((NOT VALGRIND_FOUND) OR (NOT TESTS_USE_VALGRIND)) AND ${tracer} IN_LIST vg_tracers) - # Only print "SKIPPED_*" message when option is enabled - if (TESTS_USE_VALGRIND) - skip_test(${name}_${testcase}_${tracer} "SKIPPED_BECAUSE_OF_MISSING_VALGRIND") + # Valgrind tests won't work on Windows + if(NOT WIN32 AND ${tracer} IN_LIST vg_tracers) + if(TESTS_USE_VALGRIND) + # pmemcheck is not necessarily required (because it's not always delivered with Valgrind) + if(${tracer} STREQUAL "pmemcheck" AND (NOT VALGRIND_PMEMCHECK_FOUND)) + skip_test(${name}_${testcase}_${tracer} "SKIPPED_BECAUSE_OF_MISSING_PMEMCHECK") + return() + # Valgrind on the other hand is required, because we enabled Valgrind tests + elseif(NOT VALGRIND_FOUND) + message(FATAL_ERROR "Valgrind not found, but tests are enabled. To disable them set CMake option TESTS_USE_VALGRIND=OFF.") + endif() + else() + # TESTS_USE_VALGRIND=OFF so just don't run Valgrind tests + return() endif() - return() - endif() - if (NOT WIN32 AND ((NOT VALGRIND_PMEMCHECK_FOUND) OR (NOT TESTS_USE_VALGRIND)) AND ${tracer} STREQUAL "pmemcheck") - # Only print "SKIPPED_*" message when option is enabled - if (TESTS_USE_VALGRIND) - skip_test(${name}_${testcase}_${tracer} "SKIPPED_BECAUSE_OF_MISSING_PMEMCHECK") + if(USE_ASAN OR USE_UBSAN) + skip_test(${name}_${testcase}_${tracer} "SKIPPED_BECAUSE_SANITIZER_USED") + return() endif() - return() - endif() - - if (NOT WIN32 AND (USE_ASAN OR USE_UBSAN) AND ${tracer} IN_LIST vg_tracers) - skip_test(${name}_${testcase}_${tracer} "SKIPPED_BECAUSE_SANITIZER_USED") - return() endif() - # if test was not build + # test was not build if (NOT TARGET ${name}) message(FATAL_ERROR "${executable} not build.") endif() diff --git a/utils/docker/build.sh b/utils/docker/build.sh index 1cb708490a..2baeb866a5 100755 --- a/utils/docker/build.sh +++ b/utils/docker/build.sh @@ -72,7 +72,8 @@ if [[ -z "$COMMAND" ]]; then ;; package) builds=(tests_package - tests_findLIBPMEMOBJ_cmake) + tests_findLIBPMEMOBJ_cmake + tests_cmake) COMMAND="./run-build.sh ${builds[@]}"; ;; coverity) diff --git a/utils/docker/run-build.sh b/utils/docker/run-build.sh index c920c70455..730bbca133 100755 --- a/utils/docker/run-build.sh +++ b/utils/docker/run-build.sh @@ -163,14 +163,7 @@ function tests_gcc_debug_cpp14_valgrind_other() { ############################################################################### function tests_gcc_release_cpp17_no_valgrind() { printf "\n$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} START$(tput sgr 0)\n" - # It is a test of the build system: move valgrind to other location and build with - # TESTS_USE_VALGRIND=1. Expected behaviour is to get tests with suffix - # _SKIPPED_BECAUSE_OF_MISSING_VALGRIND - VALGRIND_PC_PATH=$(find /usr -name "valgrind.pc" 2>/dev/null || true) - [ "${VALGRIND_PC_PATH}" == "" ] && echo "Error: cannot find 'valgrind.pc' file" && exit 1 - sudo_password mv ${VALGRIND_PC_PATH} tmp_valgrind_pc - mkdir build - cd build + mkdir build && cd build PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ CC=gcc CXX=g++ \ @@ -181,7 +174,7 @@ function tests_gcc_release_cpp17_no_valgrind() { -DTRACE_TESTS=1 \ -DCOVERAGE=${COVERAGE} \ -DCXX_STANDARD=17 \ - -DTESTS_USE_VALGRIND=1 \ + -DTESTS_USE_VALGRIND=0 \ -DTESTS_LONG=${TESTS_LONG} \ -DTESTS_TBB=${TESTS_TBB} \ -DTESTS_PMREORDER=${TESTS_PMREORDER} \ @@ -196,8 +189,6 @@ function tests_gcc_release_cpp17_no_valgrind() { fi workspace_cleanup - #Recover valgrind - sudo_password mv tmp_valgrind_pc ${VALGRIND_PC_PATH} printf "$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} END$(tput sgr 0)\n\n" } @@ -281,6 +272,7 @@ function tests_findLIBPMEMOBJ_cmake() CC=gcc CXX=g++ \ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ + -DTESTS_USE_VALGRIND=OFF \ -DTESTS_TBB=OFF \ -DTESTS_LONG=OFF \ -DTRACE_TESTS=1 \ @@ -295,6 +287,37 @@ function tests_findLIBPMEMOBJ_cmake() printf "$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} END$(tput sgr 0)\n\n" } +############################################################################### +# BUILD tests_cmake (tests for the build system itself) +############################################################################### +function tests_cmake() { + printf "\n$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} START$(tput sgr 0)\n" + + echo "Rename valgrind.pc and build with TESTS_USE_VALGRIND=1 CMake option." \ + "Build should fail, because Valgrind couldn't be found." + VALGRIND_PC_PATH=$(find /usr -name "valgrind.pc" 2>/dev/null || true) + [ -z "${VALGRIND_PC_PATH}" ] && echo "Error: cannot find 'valgrind.pc' file" && exit 1 + echo "valgrind.pc found in: ${VALGRIND_PC_PATH}" + sudo_password mv ${VALGRIND_PC_PATH} tmp_valgrind_pc + + mkdir build && cd build + + echo "---------------------------- Error expected! ------------------------------" + PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/opt/pmdk/lib/pkgconfig/ \ + CC=gcc CXX=g++ \ + cmake .. -DCMAKE_BUILD_TYPE=Debug \ + -DTEST_DIR=/mnt/pmem \ + -DTESTS_USE_VALGRIND=1 \ + && exit 1 + echo "----------------------------------------------------------------------------" + + workspace_cleanup + echo "Recover valgrind.pc" + sudo_password mv tmp_valgrind_pc ${VALGRIND_PC_PATH} + + printf "$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} END$(tput sgr 0)\n\n" +} + # Main echo "### run-build.sh starts here ###" From 441d42bcc275074bede3aeb536e860091295d71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Fri, 6 Nov 2020 17:00:05 +0100 Subject: [PATCH 4/4] cmake: add warning when Valgrind tests are enabled and on Windows and make sure to skip only Valgrind tests, not for all tracers. --- tests/ctest_helpers.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ctest_helpers.cmake b/tests/ctest_helpers.cmake index b771bbe9f4..2193b89447 100644 --- a/tests/ctest_helpers.cmake +++ b/tests/ctest_helpers.cmake @@ -82,6 +82,8 @@ function(find_packages) elseif(NOT VALGRIND_FOUND AND TESTS_USE_VALGRIND) message(FATAL_ERROR "Valgrind not found, but tests are enabled. To disable them set CMake option TESTS_USE_VALGRIND=OFF.") endif() + elseif(TESTS_USE_VALGRIND) + message(WARNING "Valgrind tests can't be run on Windows - they will be skipped.") endif() endfunction() @@ -227,8 +229,8 @@ function(add_test_common name tracer testcase cmake_script) message(FATAL_ERROR "${executable} not build.") endif() - # skip all valgrind tests on windows - if ((NOT ${tracer} STREQUAL none) AND WIN32) + # skip all Valgrind tests on Windows + if (WIN32 AND ${tracer} IN_LIST vg_tracers) return() endif()