Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 23 additions & 20 deletions tests/ctest_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ 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()
elseif(TESTS_USE_VALGRIND)
message(WARNING "Valgrind tests can't be run on Windows - they will be skipped.")
endif()
endfunction()

Expand Down Expand Up @@ -200,34 +202,35 @@ 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()

# 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()

Expand Down
3 changes: 2 additions & 1 deletion utils/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions utils/docker/images/Dockerfile.opensuse-leap-latest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions utils/docker/images/Dockerfile.opensuse-tumbleweed-latest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 38 additions & 15 deletions utils/docker/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down Expand Up @@ -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} \
Expand Down Expand Up @@ -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} \
Expand Down Expand Up @@ -163,16 +163,9 @@ 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=/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} \
Expand All @@ -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} \
Expand All @@ -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"
}

Expand Down Expand Up @@ -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 \
Expand All @@ -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 ###"
Expand Down
2 changes: 1 addition & 1 deletion utils/docker/run-coverity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down