<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey,<br>
</p>
<p>thanks for the updated patch!</p>
<p>I'm happy to see how much code was removed.</p>
<p>See my comments below.</p>
<p></p>
<div class="moz-cite-prefix">On 24.09.2024 13:29, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:15a3b416520eac8f799a59fa51c6dcd9515ec90b.1727172936.git.skaplun@tarantool.org">
<pre class="moz-quote-pre" wrap="">This patch sets the unique value of each of these variables for each of
the tests and only where they are needed. Also, it drops the comment
about SIP [1] tricks since it is obsolete after
29897567ee5ed57e961c730432c056a3dbaa8f09 ("test: stop using
utils.selfrun in tests").
[1]: <a class="moz-txt-link-freetext" href="https://support.apple.com/en-us/HT204899">https://support.apple.com/en-us/HT204899</a>
Resolves tarantool/tarantool#9898
---
test/tarantool-tests/CMakeLists.txt | 85 ++++++++-----------
test/tarantool-tests/ffi-ccall/CMakeLists.txt | 2 +-
.../fix-bit-shift-generation/CMakeLists.txt | 3 +-
.../gh-4427-ffi-sandwich/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../gh-6189-cur_L/CMakeLists.txt | 3 +-
.../lj-1004-oom-error-frame/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../lj-1166-error-stitch/CMakeLists.txt | 6 +-
.../lj-416-xor-before-jcc/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../lj-549-bytecode-loader/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../lj-601-fix-gc-finderrfunc/CMakeLists.txt | 3 +-
.../lj-727-lightuserdata-itern/CMakeLists.txt | 3 +-
.../CMakeLists.txt | 3 +-
.../lj-flush-on-trace/CMakeLists.txt | 3 +-
.../both/CMakeLists.txt | 4 +-
.../gnuhash/CMakeLists.txt | 4 +-
.../hash/CMakeLists.txt | 4 +-
.../stripped/CMakeLists.txt | 4 +-
21 files changed, 82 insertions(+), 69 deletions(-)
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 5e3493b6..d0964aed 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -5,17 +5,16 @@ add_custom_target(tarantool-tests-libs
DEPENDS libluajit
)
-macro(BuildTestCLib lib sources)
- AddTestLib(${lib} ${sources})
+macro(BuildTestCLib lib source for_tests)
+ AddTestLib(${lib} ${source})
add_dependencies(tarantool-tests-libs ${lib})
- # Add the directory where the lib is built to the list with
- # entries for LUA_CPATH environment variable, so LuaJIT can find
- # and load it. See the comment about extending the list in the
- # parent scope few lines above.
- set(LUA_CPATHS "${CMAKE_CURRENT_BINARY_DIR}/?${CMAKE_SHARED_LIBRARY_SUFFIX};${LUA_CPATHS}" PARENT_SCOPE)
- # Also add this directory to LD_LIBRARY_PATH environment
- # variable, so FFI machinery can find and load it.
- set(LD_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}:${LD_LIBRARY_PATH}" PARENT_SCOPE)
+ # Remember libraries for each test to be proceeded with after
+ # test targets are created.
+ foreach(testname ${for_tests})
+ set(LIBS_${testname}
+ "${CMAKE_CURRENT_BINARY_DIR};${LIBS_${testname}}" PARENT_SCOPE
+ )
+ endforeach()
endmacro()
# FIXME: This is used only due to ancient CMake requirements.
@@ -81,46 +80,8 @@ make_lua_path(LUA_PATH
${LUAJIT_BINARY_DIR}/?.lua
)
-# Update LUA_CPATH with the library paths collected within
-# <BuildTestLib> macro.
-make_lua_path(LUA_CPATH PATHS ${LUA_CPATHS})
-
set(LUA_TEST_SUFFIX .test.lua)
-# XXX: Since the auxiliary libraries are built as a dynamically
-# loaded modules on MacOS instead of shared libraries as it is
-# done on Linux and BSD, another environment variable should be
-# used to guide <ffi.load> while searching the extension.
-# XXX: Be noticed that we shouldn't use `"` here to wrap
-# the variable's content. If we do this, the variable value will
-# contain `"` at the beginning and the end, so this `"` at the
-# beginning will be treated as the directory for the first entry
-# (the last subdirectory added).
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- # XXX: Apple tries their best to "protect their users from
- # malware". As a result SIP (see the link[1] below) has been
- # designed and released. Now, Apple developers are so protected,
- # that they can load nothing being not installed in the system,
- # since some programs sanitize the environment before they start
- # child processes. Specifically, environment variables starting
- # with DYLD_ and LD_ are unset for child process started by
- # other programs (like `ctest` using for launching tests).
- # For more info, see the docs[2] below.
- #
- # These environment variables are used by FFI machinery to find
- # the proper shared library, hence we can still tweak testing
- # environment before calling <ffi.load>. However, the value
- # can't be passed via the standard environment variable, so we
- # use ENVIRONMENT property in `set_tests_properties` to get
- # around SIP magic tricks.
- #
- # [1]: <a class="moz-txt-link-freetext" href="https://support.apple.com/en-us/HT204899">https://support.apple.com/en-us/HT204899</a>
- # [2]: <a class="moz-txt-link-freetext" href="https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html">https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html</a>
- list(APPEND LUA_TEST_ENV_MORE DYLD_LIBRARY_PATH=${LD_LIBRARY_PATH})
-else()
- list(APPEND LUA_TEST_ENV_MORE LD_LIBRARY_PATH=${LD_LIBRARY_PATH})
-endif()
-
# 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
@@ -157,7 +118,7 @@ foreach(test_path ${tests})
# LUA_CPATH and LD_LIBRARY_PATH variables and also
# dependencies list with libraries are set in scope of
# BuildTestLib macro.
- ENVIRONMENT "LUA_PATH=${LUA_PATH};LUA_CPATH=${LUA_CPATH};${LUA_TEST_ENV_MORE}"
+ ENVIRONMENT "LUA_PATH=${LUA_PATH};${LUA_TEST_ENV_MORE}"
LABELS ${TEST_SUITE_NAME}
DEPENDS tarantool-tests-deps
)
@@ -169,4 +130,30 @@ foreach(test_path ${tests})
LUA_PATH "${PROJECT_SOURCE_DIR}/tools/?.lua\;"
)
endif()
+
+ if(LIBS_${test_name})
+ foreach(path ${LIBS_${test_name}})
+ # Add the directory where the library is built to the list
+ # with entries for the LUA_CPATH environment variable, so
+ # LuaJIT can find and load it.
+ AppendTestEnvVar(${test_title}
+ LUA_CPATH "${path}/?${CMAKE_SHARED_LIBRARY_SUFFIX}\;"
+ )
+ # Also, add this directory to the LD_LIBRARY_PATH environment
+ # variable so FFI machinery can find and load it.
+ # XXX: Be noticed that we shouldn't use `"` here to wrap the
+ # variable's content. If we do this, the variable value will
+ # contain `"` at the beginning and the end, so this `"` at the
+ # beginning will be treated as the directory for the entry.
+ # XXX: Since the auxiliary libraries are built as dynamically
+ # loaded modules on MacOS instead of shared libraries as it is
+ # done on Linux and BSD, another environment variable should
+ # be used to guide <ffi.load> while searching the extension.
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ AppendTestEnvVar(${test_title} DYLD_LIBRARY_PATH ${path}:)
+ else()
+ AppendTestEnvVar(${test_title} LD_LIBRARY_PATH ${path}:)
+ endif()</pre>
</blockquote>
please add unset(LIBS_${test_name})<br>
<blockquote type="cite"
cite="mid:15a3b416520eac8f799a59fa51c6dcd9515ec90b.1727172936.git.skaplun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
+ endforeach()
+ endif()
endforeach()
diff --git a/test/tarantool-tests/ffi-ccall/CMakeLists.txt b/test/tarantool-tests/ffi-ccall/CMakeLists.txt
index df937bf8..8acd8fe4 100644
--- a/test/tarantool-tests/ffi-ccall/CMakeLists.txt
+++ b/test/tarantool-tests/ffi-ccall/CMakeLists.txt
@@ -1 +1 @@
-BuildTestCLib(libfficcall libfficcall.c)
+BuildTestCLib(libfficcall libfficcall.c ffi-ccall-arm64-fp-convention.test.lua)
diff --git a/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt
index f85f875b..597b0088 100644
--- a/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt
+++ b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libtestbitshift libtestbitshift.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libtestbitshift libtestbitshift.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/gh-4427-ffi-sandwich/CMakeLists.txt b/test/tarantool-tests/gh-4427-ffi-sandwich/CMakeLists.txt
index f2be5493..7766373d 100644
--- a/test/tarantool-tests/gh-4427-ffi-sandwich/CMakeLists.txt
+++ b/test/tarantool-tests/gh-4427-ffi-sandwich/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libsandwich libsandwich.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libsandwich libsandwich.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64/CMakeLists.txt b/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64/CMakeLists.txt
index 361d0cd7..381577fb 100644
--- a/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64/CMakeLists.txt
+++ b/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libproxy libproxy.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libproxy libproxy.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/gh-6189-cur_L/CMakeLists.txt b/test/tarantool-tests/gh-6189-cur_L/CMakeLists.txt
index 1e58e560..11dbfa6b 100644
--- a/test/tarantool-tests/gh-6189-cur_L/CMakeLists.txt
+++ b/test/tarantool-tests/gh-6189-cur_L/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libcur_L libcur_L.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libcur_L libcur_L.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt b/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt
index 3bca5df8..865e4d26 100644
--- a/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt
+++ b/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(testoomframe testoomframe.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(testoomframe testoomframe.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-1066-fix-cur_L-after-coroutine-resume/CMakeLists.txt b/test/tarantool-tests/lj-1066-fix-cur_L-after-coroutine-resume/CMakeLists.txt
index c8a3731f..7b507b81 100644
--- a/test/tarantool-tests/lj-1066-fix-cur_L-after-coroutine-resume/CMakeLists.txt
+++ b/test/tarantool-tests/lj-1066-fix-cur_L-after-coroutine-resume/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libcur_L_coroutine libcur_L_coroutine.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libcur_L_coroutine libcur_L_coroutine.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt b/test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt
index 342e438e..658b3b8c 100644
--- a/test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt
+++ b/test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt
@@ -1 +1,5 @@
-BuildTestCLib(allocinject allocinject.c)
+list(APPEND tests
+ lj-1166-error-stitch-oom-ir-buff.test.lua
+ lj-1166-error-stitch-oom-snap-buff.test.lua
+)
+BuildTestCLib(allocinject allocinject.c "${tests}")
diff --git a/test/tarantool-tests/lj-416-xor-before-jcc/CMakeLists.txt b/test/tarantool-tests/lj-416-xor-before-jcc/CMakeLists.txt
index 17aa9f9b..e25863a4 100644
--- a/test/tarantool-tests/lj-416-xor-before-jcc/CMakeLists.txt
+++ b/test/tarantool-tests/lj-416-xor-before-jcc/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libtestxor testxor.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libtestxor testxor.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-522-fix-dlerror-return-null/CMakeLists.txt b/test/tarantool-tests/lj-522-fix-dlerror-return-null/CMakeLists.txt
index 903da4d3..c4383b37 100644
--- a/test/tarantool-tests/lj-522-fix-dlerror-return-null/CMakeLists.txt
+++ b/test/tarantool-tests/lj-522-fix-dlerror-return-null/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(mydlerror mydlerror.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(mydlerror mydlerror.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-549-bytecode-loader/CMakeLists.txt b/test/tarantool-tests/lj-549-bytecode-loader/CMakeLists.txt
index d66c4935..515de667 100644
--- a/test/tarantool-tests/lj-549-bytecode-loader/CMakeLists.txt
+++ b/test/tarantool-tests/lj-549-bytecode-loader/CMakeLists.txt
@@ -17,5 +17,6 @@ add_custom_target(export_bc
VERBATIM
)
-BuildTestCLib(${LIB_NAME} ${C_FILE})
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(${LIB_NAME} ${C_FILE} ${test_name}.test.lua)
add_dependencies(${LIB_NAME} export_bc)
diff --git a/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt b/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
index 1f3e8fe6..89f8583f 100644
--- a/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
+++ b/test/tarantool-tests/lj-551-bytecode-c-broken-macro/CMakeLists.txt
@@ -27,7 +27,8 @@ macro(BuildTestBCLib file_ext)
VERBATIM
)
- BuildTestCLib(${LIB_NAME} ${EXT_SOURCE})
+ get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+ BuildTestCLib(${LIB_NAME} ${EXT_SOURCE} ${test_name}.test.lua)
add_dependencies(${LIB_NAME} export_bc_${file_ext})
endmacro()
diff --git a/test/tarantool-tests/lj-601-fix-gc-finderrfunc/CMakeLists.txt b/test/tarantool-tests/lj-601-fix-gc-finderrfunc/CMakeLists.txt
index 3fed6105..31c9fa3b 100644
--- a/test/tarantool-tests/lj-601-fix-gc-finderrfunc/CMakeLists.txt
+++ b/test/tarantool-tests/lj-601-fix-gc-finderrfunc/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libmixcframe mixcframe.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libmixcframe mixcframe.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-727-lightuserdata-itern/CMakeLists.txt b/test/tarantool-tests/lj-727-lightuserdata-itern/CMakeLists.txt
index 564b688b..1161017d 100644
--- a/test/tarantool-tests/lj-727-lightuserdata-itern/CMakeLists.txt
+++ b/test/tarantool-tests/lj-727-lightuserdata-itern/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(lightuserdata lightuserdata.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(lightuserdata lightuserdata.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-802-panic-at-mcode-protfail/CMakeLists.txt b/test/tarantool-tests/lj-802-panic-at-mcode-protfail/CMakeLists.txt
index 25520a1a..39c7532a 100644
--- a/test/tarantool-tests/lj-802-panic-at-mcode-protfail/CMakeLists.txt
+++ b/test/tarantool-tests/lj-802-panic-at-mcode-protfail/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(mymprotect mymprotect.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(mymprotect mymprotect.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/lj-flush-on-trace/CMakeLists.txt b/test/tarantool-tests/lj-flush-on-trace/CMakeLists.txt
index 16f1aa8f..7dfea075 100644
--- a/test/tarantool-tests/lj-flush-on-trace/CMakeLists.txt
+++ b/test/tarantool-tests/lj-flush-on-trace/CMakeLists.txt
@@ -1 +1,2 @@
-BuildTestCLib(libflush libflush.c)
+get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+BuildTestCLib(libflush libflush.c ${test_name}.test.lua)
diff --git a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/both/CMakeLists.txt b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/both/CMakeLists.txt
index ce616fcf..bf980c7d 100644
--- a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/both/CMakeLists.txt
+++ b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/both/CMakeLists.txt
@@ -1,5 +1,7 @@
if (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
- BuildTestCLib(resboth resboth.c)
+ BuildTestCLib(resboth resboth.c
+ profilers/gh-5813-resolving-of-c-symbols.test.lua
+ )
# Unfortunately, <target_link_options> command is introduced
# since CMake 3.13, so we can't use it now considering ancient
# distros support. Just build linker flags by hands.
diff --git a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/gnuhash/CMakeLists.txt b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/gnuhash/CMakeLists.txt
index 1179601b..b80129a3 100644
--- a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/gnuhash/CMakeLists.txt
+++ b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/gnuhash/CMakeLists.txt
@@ -1,5 +1,7 @@
if (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
- BuildTestCLib(resgnuhash resgnuhash.c)
+ BuildTestCLib(resgnuhash resgnuhash.c
+ profilers/gh-5813-resolving-of-c-symbols.test.lua
+ )
# Unfortunately, <target_link_options> command is introduced
# since CMake 3.13, so we can't use it now considering ancient
# distros support. Just build linker flags by hands.
diff --git a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/hash/CMakeLists.txt b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/hash/CMakeLists.txt
index e0ad5675..0633f1f3 100644
--- a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/hash/CMakeLists.txt
+++ b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/hash/CMakeLists.txt
@@ -1,5 +1,7 @@
if (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
- BuildTestCLib(reshash reshash.c)
+ BuildTestCLib(reshash reshash.c
+ profilers/gh-5813-resolving-of-c-symbols.test.lua
+ )
# Unfortunately, <target_link_options> command is introduced
# since CMake 3.13, so we can't use it now considering ancient
# distros support. Just build linker flags by hands.
diff --git a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/stripped/CMakeLists.txt b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/stripped/CMakeLists.txt
index 243902be..2ea0b4ac 100644
--- a/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/stripped/CMakeLists.txt
+++ b/test/tarantool-tests/profilers/gh-5813-resolving-of-c-symbols/stripped/CMakeLists.txt
@@ -1,5 +1,7 @@
if (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
- BuildTestCLib(resstripped resstripped.c)
+ BuildTestCLib(resstripped resstripped.c
+ profilers/gh-5813-resolving-of-c-symbols.test.lua
+ )
# Unfortunately, <target_link_options> command is introduced
# since CMake 3.13, so we can't use it now considering ancient
# distros support. Just build linker flags by hands.
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>