Skip to content

Commit ce50962

Browse files
committed
test: Disable memory tests on armv7l architectures
1 parent b62129b commit ce50962

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ find_program(VALGRIND_EXECUTABLE NAMES valgrind)
2727
if(NOT SUDO_EXECUTABLE)
2828
message(FATAL_ERROR "sudo executable not found, please install sudo")
2929
endif()
30-
if(NOT VALGRIND_EXECUTABLE)
31-
message(STATUS "valgrind executable not found, memory tests will not be run")
32-
else()
30+
31+
# valgrind memcheck is buggy on armv7l and armhf architectures
32+
# unable to run tests with valgrind on these architectures
33+
# MESSAGE("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
34+
if(VALGRIND_EXECUTABLE AND CMAKE_SYSTEM_PROCESSOR AND NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv7l|armhf")
3335
message(STATUS "valgrind executable found: ${VALGRIND_EXECUTABLE}")
36+
set (MEMORY_TESTS ON)
37+
else()
38+
message(STATUS "valgrind executable not found or not supported on this architecture, memory tests will not be run")
39+
set (MEMORY_TESTS OFF)
3440
endif()
3541

3642
if(PIDUINO_LIB_DIR)
@@ -52,7 +58,7 @@ endif()
5258
# endforeach()
5359

5460
function(add_test_incl_memcheck test)
55-
message(STATUS " add test ${test}")
61+
message(STATUS "Add test ${test}")
5662
# create an executable, which instantiates a runner from UnitTest++
5763
add_executable(${test} ${test}/main.cpp)
5864
add_dependencies(${test} piduino-shared)
@@ -65,8 +71,8 @@ function(add_test_incl_memcheck test)
6571
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test}/run_as_root")
6672

6773
add_test(NAME ${test} COMMAND ${test})
68-
if(VALGRIND_EXECUTABLE)
69-
message(STATUS " test ${test} will be run with valgrind")
74+
if(MEMORY_TESTS)
75+
message(STATUS " test ${test} will be run with valgrind")
7076
# add a memory check test using valgrind
7177
# this is useful to detect memory leaks and other issues
7278
# see https://valgrind.org/docs/manual/manual.html
@@ -104,12 +110,12 @@ function(add_test_incl_memcheck test)
104110
endif()
105111
else()
106112

107-
message(STATUS " test ${test} requires root privileges, it will run with sudo")
113+
message(STATUS " test ${test} requires root privileges, it will run with sudo")
108114
add_test(NAME ${test} COMMAND ${SUDO_EXECUTABLE} $<TARGET_FILE:${test}>
109115
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
110-
if(VALGRIND_EXECUTABLE)
111116

112-
message(STATUS " test ${test} will be run with valgrind")
117+
if(MEMORY_TESTS)
118+
message(STATUS " test ${test} will be run with valgrind")
113119
add_test(NAME ${test}_memchecked
114120
COMMAND ${SUDO_EXECUTABLE} ${VALGRIND_EXECUTABLE}
115121
--error-exitcode=1

0 commit comments

Comments
 (0)