From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 1316EC9DF8B; Mon, 23 Sep 2024 10:21:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1316EC9DF8B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1727076108; bh=/IwHwIheSmezGa0K+kMKXiRCtMH428jWWavHLc7SSpQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=h1v5qgN61KSDpnZv9snremeD4yzDyMxiKEphK1A66Bd4plS8fS3v+nojcIVSk6JrA MMys0IEPBbnRZjTsgE+9RwMYMEKL59xT46gRgG2dm7c+c7I3RC00CsSBeJuO5kC82B yhEo2UEBuz91Q3O8sGG37YMFalAfB5d73gzaQEDg= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [95.163.41.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 48C5FCC8EB1 for ; Mon, 23 Sep 2024 10:19:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 48C5FCC8EB1 Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1ssdLq-0000000C9Sx-1dqY; Mon, 23 Sep 2024 10:19:19 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 23 Sep 2024 10:18:51 +0300 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96E52E9D942F25A5FB1548CEAAB080D81A63C75D94B0233AD00894C459B0CD1B9B5A4F7D3DC9A6302C23CA552186D326566C41F4417F72F6A693F64E413CBBBEEDEB93F7F06BD0150 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FDE19FEC90BA7BD7C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7E188839ED9CF357EEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F36250CBEED6004AA8DB6F19E1A7C05B47B8A34805B755412C5A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE73AFA331E307B52169FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3A367EA73E0D98AAD117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFBE49168A74F91971BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B6D7441EF8352D599276E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249D082881546D93491E827F84554CEF50127C277FBC8AE2E8BF1175FABE1C0F9B6AAAE862A0553A39223F8577A6DFFEA7CC415C329B279CF9D43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A598FB017C3FAD2C865002B1117B3ED696B50619A746BE7EEACCE9A60C8CB01D7C823CB91A9FED034534781492E4B8EEAD412E52026C1D9715A71A35648BE338CE9510FB958DCE06DB58C12E6D310A6D53A16EC4B4EECACEB3 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34C1E32F4AD4B2486B7036D3209B6C8DA794543A04005C81D1AE198A812E25A71B83C6727B585E30AF1D7E09C32AA3244CD6F05CF3775F8F954EB7DF677E51682D93506A06E27CFB73EA455F16B58544A21C197AAF4D2E4732A5AE236DF995FB59829709634694AABAED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojcsBYxvRMKezdvh2eQTWOKw== X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B59E13280E612BD7A270578E6996F38341332C930485C787E15B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 5/7] test: shrink LUA_CPATH and {DY}LD_LIBRARY_PATH X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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]: https://support.apple.com/en-us/HT204899 Resolves tarantool/tarantool#9898 --- test/tarantool-tests/CMakeLists.txt | 110 ++++++++++++++++------------ 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt index a1339100..6f1b1ae1 100644 --- a/test/tarantool-tests/CMakeLists.txt +++ b/test/tarantool-tests/CMakeLists.txt @@ -8,14 +8,13 @@ add_custom_target(tarantool-tests-libs macro(BuildTestCLib lib sources) AddTestLib(${lib} ${sources}) 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) + # Add libraries to the list to be proceeded with after test + # targets are created. + # XXX: Workaround for profilers c-related tests, see the comment + # below. + if(NOT "${CMAKE_CURRENT_BINARY_DIR}" MATCHES profilers) + set(CLIB_DIRS "${CMAKE_CURRENT_BINARY_DIR};${CLIB_DIRS}" PARENT_SCOPE) + endif() endmacro() # FIXME: This is used only due to ancient CMake requirements. @@ -76,46 +75,8 @@ make_lua_path(LUA_PATH ${LUAJIT_BINARY_DIR}/?.lua ) -# Update LUA_CPATH with the library paths collected within -# 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 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 . 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]: https://support.apple.com/en-us/HT204899 - # [2]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html - 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 # overwrites # `mprotect()`. When compiling with ASan support under GCC, it is @@ -152,12 +113,67 @@ 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 ) endforeach() +# We use the following naming convention: the name of the +# directory containing the C library to be loaded should match the +# prefix of the test itself. The same library may be used in +# several tests. See , for example. +foreach(clib_dir ${CLIB_DIRS}) + get_filename_component(clib_dir_prefix ${clib_dir} NAME) + file(GLOB_RECURSE tests_using_clib + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "${clib_dir_prefix}*${LUA_TEST_SUFFIX}" + ) + foreach(test_name ${tests_using_clib}) + set(test_title "test/${TEST_SUITE_NAME}/${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 "${clib_dir}/?${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 while searching the extension. + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + AppendTestEnvVar(${test_title} DYLD_LIBRARY_PATH ${clib_dir}:) + else() + AppendTestEnvVar(${test_title} LD_LIBRARY_PATH ${clib_dir}:) + endif() + endforeach() +endforeach() + +# XXX: Special workaround for several different loaded libraries +# in the . Since the libs +# can't be flatterned to one directory (see the comment in their +# ), just set them manually here. +set(CSYMBOLS_DIR + ${CMAKE_CURRENT_BINARY_DIR}/profilers/gh-5813-resolving-of-c-symbols +) +make_lua_path(CSYMBOLS_CPATHS + PATHS + ${CSYMBOLS_DIR}/both/?${CMAKE_SHARED_LIBRARY_SUFFIX} + ${CSYMBOLS_DIR}/gnuhash/?${CMAKE_SHARED_LIBRARY_SUFFIX} + ${CSYMBOLS_DIR}/hash/?${CMAKE_SHARED_LIBRARY_SUFFIX} + ${CSYMBOLS_DIR}/stripped/?${CMAKE_SHARED_LIBRARY_SUFFIX} +) +AppendTestEnvVar( + test/${TEST_SUITE_NAME}/profilers/gh-5813-resolving-of-c-symbols.test.lua + LUA_CPATH "${CSYMBOLS_CPATHS}" +) + # The part of the profilers toolchain is located in the # directory, so LUA_PATH needs to be updated. file(GLOB_RECURSE profilers_tests -- 2.46.0