Skip to content

Commit

Permalink
test: set LD_PRELOAD only when necessary
Browse files Browse the repository at this point in the history
This patch sets LD_PRELOAD for ASan build for the required test instead
of all tests.

Follows up tarantool/tarantool#9898
  • Loading branch information
Buristan committed Sep 21, 2024
1 parent 42d9cda commit 53f3745
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions test/tarantool-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ make_lua_path(LUA_PATH

set(LUA_TEST_SUFFIX .test.lua)

# Some tests use `LD_PRELOAD` to mock system calls (like
# <lj-802-panic-at-mcode-protfail.test.lua> overwrites
# `mprotect()`. When compiling with ASan support under GCC, it is
# required that the ASan library go first in the `LD_PRELOAD`
# list. Set it manually. The test will append it to the executed
# process.
if(LUAJIT_USE_ASAN AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
# FIXME: We should set this environment variable only
# for the corresponding tests to avoid warnings from
# the GNU libc and other libc implementations.
# See https://github.com/tarantool/tarantool/issues/9898.
LibRealPath(LIB_ASAN libasan.so)
list(APPEND LUA_TEST_ENV_MORE LD_PRELOAD=${LIB_ASAN})
endif()

# FIXME: This is needed for disabling some flaky tests (like
# profilers), until LuaJIT/LuaJIT#606 will not be resolved.
if(LUAJIT_ENABLE_TABLE_BUMP)
Expand Down Expand Up @@ -188,3 +173,21 @@ foreach(test_name ${profilers_tests})
set(test_title "test/${TEST_SUITE_NAME}/${test_name}")
AppendTestEnvVar(${test_title} LUA_PATH "${PROJECT_SOURCE_DIR}/tools/?.lua\;")
endforeach()

# Some tests use `LD_PRELOAD` to mock system calls (like
# <lj-802-panic-at-mcode-protfail.test.lua> overwrites
# `mprotect()`). When compiling with ASan support under GCC, it is
# required that the ASan library go first in the `LD_PRELOAD`
# list. Set it manually. The test will append it to the executed
# process.
if(LUAJIT_USE_ASAN AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
LibRealPath(LIB_ASAN libasan.so)
set(test_title
"test/${TEST_SUITE_NAME}/lj-522-fix-dlerror-return-null.test.lua"
)
AppendTestEnvVar(${test_title} LD_PRELOAD ${LIB_ASAN})
set(test_title
"test/${TEST_SUITE_NAME}/lj-802-panic-at-mcode-protfail.test.lua"
)
AppendTestEnvVar(${test_title} LD_PRELOAD ${LIB_ASAN})
endif()

0 comments on commit 53f3745

Please sign in to comment.