Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit ee53315

Browse files
Merge pull request #1199 from lukaszstolarczuk/avoid-libunwind-on-valgrind-tests
Avoid libunwind on valgrind tests
2 parents 9f17a83 + dc1e4fc commit ee53315

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

.github/workflows/gha.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
"TYPE=debug OS=ubuntu OS_VER=20.04 COVERAGE=1",
3535
"TYPE=release OS=fedora OS_VER=32",
3636
"TYPE=release OS=ubuntu OS_VER=20.04",
37-
"TYPE=valgrind OS=ubuntu OS_VER=20.04",
38-
"TYPE=memcheck_drd OS=ubuntu OS_VER=20.04",
37+
"TYPE=valgrind OS=ubuntu OS_VER=20.04 TESTS_VALGRIND_UNWIND=0",
38+
"TYPE=memcheck_drd OS=ubuntu OS_VER=20.04 TESTS_VALGRIND_UNWIND=0",
3939
"TYPE=package OS=fedora OS_VER=32",
4040
"TYPE=package OS=ubuntu OS_VER=20.04"]
4141
steps:

.github/workflows/weekly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
"TYPE=debug OS=ubuntu OS_VER=20.04 TESTS_UBSAN=1 TESTS_PMREORDER=0",
2929
"TYPE=debug OS=fedora OS_VER=rawhide TESTS_ASAN=1 TESTS_PMREORDER=0",
3030
"TYPE=debug OS=fedora OS_VER=rawhide TESTS_UBSAN=1 TESTS_PMREORDER=0",
31-
"TYPE=valgrind OS=fedora OS_VER=rawhide TESTS_PMREORDER=0",
32-
"TYPE=memcheck_drd OS=fedora OS_VER=rawhide TESTS_PMREORDER=0",
31+
"TYPE=valgrind OS=fedora OS_VER=rawhide TESTS_PMREORDER=0 TESTS_VALGRIND_UNWIND=0",
32+
"TYPE=memcheck_drd OS=fedora OS_VER=rawhide TESTS_PMREORDER=0 TESTS_VALGRIND_UNWIND=0",
3333
"TYPE=package OS=fedora OS_VER=34",
3434
"TYPE=package OS=fedora OS_VER=rawhide TESTS_PMREORDER=0",
3535
"TYPE=package OS=ubuntu OS_VER=devel"]

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ option(CHECK_CPP_STYLE "check code style of C++ sources" OFF)
7878
option(TRACE_TESTS "more verbose test outputs" OFF)
7979
option(USE_ASAN "enable AddressSanitizer (debugging)" OFF)
8080
option(USE_UBSAN "enable UndefinedBehaviorSanitizer (debugging)" OFF)
81+
option(USE_LIBUNWIND "use libunwind for more reliable stack traces from tests (if available)" ON)
8182
option(USE_CCACHE "use ccache if it is available in the system" ON)
8283

8384
option(TESTS_USE_FORCED_PMEM "run tests with PMEM_IS_PMEM_FORCE=1 - it speeds up tests execution on emulated pmem" OFF)

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ include(tbb)
8181

8282
add_library(test_backtrace STATIC test_backtrace.c)
8383
if(LIBUNWIND_FOUND)
84-
target_compile_definitions(test_backtrace PUBLIC USE_LIBUNWIND=1)
84+
target_compile_definitions(test_backtrace PUBLIC LIBUNWIND_ENABLED=1)
8585
endif()
8686

8787
add_library(valgrind_internal STATIC valgrind_internal.cpp)

tests/ctest_helpers.cmake

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ function(find_packages)
3434
find_package(Curses QUIET)
3535
endif()
3636

37-
if(PKG_CONFIG_FOUND)
38-
pkg_check_modules(LIBUNWIND QUIET libunwind)
39-
else()
40-
find_package(LIBUNWIND QUIET)
41-
endif()
42-
if(NOT LIBUNWIND_FOUND)
43-
message(WARNING "libunwind not found. Stack traces from tests will not be reliable")
37+
if (USE_LIBUNWIND)
38+
if(PKG_CONFIG_FOUND)
39+
pkg_check_modules(LIBUNWIND QUIET libunwind)
40+
else()
41+
find_package(LIBUNWIND QUIET)
42+
endif()
43+
if(NOT LIBUNWIND_FOUND)
44+
message(WARNING "libunwind not found. Stack traces from tests will not be reliable")
45+
else()
46+
message(STATUS "Found libunwind: ${LIBUNWIND_LIBDIR} (version: ${LIBUNWIND_VERSION})")
47+
endif()
4448
endif()
4549

4650
find_gdb()

tests/test_backtrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2015-2019, Intel Corporation */
2+
/* Copyright 2015-2021, Intel Corporation */
33

44
/*
55
* backtrace.c -- backtrace reporting routines
@@ -16,7 +16,7 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818

19-
#ifdef USE_LIBUNWIND
19+
#ifdef LIBUNWIND_ENABLED
2020

2121
#define UNW_LOCAL_ONLY
2222
#include <dlfcn.h>
@@ -90,7 +90,7 @@ test_dump_backtrace(void)
9090
unw_strerror(ret), ret);
9191
}
9292
}
93-
#else /* USE_LIBUNWIND */
93+
#else /* LIBUNWIND_ENABLED */
9494

9595
#define BSIZE 100
9696

@@ -162,7 +162,7 @@ test_dump_backtrace(void)
162162

163163
#endif /* _WIN32 */
164164

165-
#endif /* USE_LIBUNWIND */
165+
#endif /* LIBUNWIND_ENABLED */
166166

167167
/*
168168
* test_sighandler -- fatal signal handler

utils/docker/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ docker run --privileged=true --name=${CONTAINER_NAME} -i \
139139
--env TESTS_PACKAGES=${TESTS_PACKAGES:-ON} \
140140
--env TESTS_ASAN=${TESTS_ASAN:-OFF} \
141141
--env TESTS_UBSAN=${TESTS_UBSAN:-OFF} \
142+
--env TESTS_VALGRIND_UNWIND=${TESTS_VALGRIND_UNWIND:-OFF} \
142143
--env TEST_TIMEOUT=${TEST_TIMEOUT} \
143144
--env TZ='Europe/Warsaw' \
144145
--shm-size=4G \

utils/docker/run-build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TESTS_PACKAGES=${TESTS_PACKAGES:-ON}
2323
TESTS_USE_FORCED_PMEM=${TESTS_USE_FORCED_PMEM:-ON}
2424
TESTS_ASAN=${TESTS_ASAN:-OFF}
2525
TESTS_UBSAN=${TESTS_UBSAN:-OFF}
26+
TESTS_VALGRIND_UNWIND=${TESTS_VALGRIND_UNWIND:-OFF}
2627
TEST_TIMEOUT=${TEST_TIMEOUT:-600}
2728

2829
export PMREORDER_STACKTRACE_DEPTH=20
@@ -106,6 +107,7 @@ function tests_clang_release_cpp11_no_valgrind() {
106107
# BUILD build_gcc_debug_cpp14 (no tests)
107108
###############################################################################
108109
function build_gcc_debug_cpp14() {
110+
VALGRIND_UNWIND=${1:-ON}
109111
mkdir build
110112
cd build
111113

@@ -128,7 +130,8 @@ function build_gcc_debug_cpp14() {
128130
-DTESTS_COMPATIBILITY=1 \
129131
-DTESTS_CONCURRENT_GDB=1 \
130132
-DUSE_ASAN=${TESTS_ASAN} \
131-
-DUSE_UBSAN=${TESTS_UBSAN}
133+
-DUSE_UBSAN=${TESTS_UBSAN} \
134+
-DUSE_LIBUNWIND=${VALGRIND_UNWIND}
132135

133136
make -j$(nproc)
134137
}
@@ -152,7 +155,7 @@ function tests_gcc_debug_cpp14_no_valgrind() {
152155
###############################################################################
153156
function tests_gcc_debug_cpp14_valgrind_memcheck_drd() {
154157
printf "\n$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} START$(tput sgr 0)\n"
155-
build_gcc_debug_cpp14
158+
build_gcc_debug_cpp14 ${TESTS_VALGRIND_UNWIND}
156159
ctest -R "_memcheck|_drd" --timeout ${TEST_TIMEOUT} --output-on-failure
157160
workspace_cleanup
158161
printf "$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} END$(tput sgr 0)\n\n"
@@ -163,7 +166,7 @@ function tests_gcc_debug_cpp14_valgrind_memcheck_drd() {
163166
###############################################################################
164167
function tests_gcc_debug_cpp14_valgrind_other() {
165168
printf "\n$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} START$(tput sgr 0)\n"
166-
build_gcc_debug_cpp14
169+
build_gcc_debug_cpp14 ${TESTS_VALGRIND_UNWIND}
167170
ctest -E "_none|_memcheck|_drd" --timeout ${TEST_TIMEOUT} --output-on-failure
168171
ctest -R "_pmreorder" --timeout ${TEST_TIMEOUT} --output-on-failure
169172
workspace_cleanup
@@ -210,7 +213,6 @@ function tests_gcc_release_cpp17_no_valgrind() {
210213
###############################################################################
211214
# BUILD tests_clang_release_cpp20_no_valgrind llvm
212215
###############################################################################
213-
214216
function tests_clang_release_cpp20_no_valgrind() {
215217
printf "\n$(tput setaf 1)$(tput setab 7)BUILD ${FUNCNAME[0]} START$(tput sgr 0)\n"
216218

0 commit comments

Comments
 (0)