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 483EEA5ECF2; Thu, 1 Feb 2024 17:23:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 483EEA5ECF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706797395; bh=Gw7iNxkVPW5Ic8JkcX4CNPLWi8SNrdc6p3aCH5ZIw/w=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xiEadVBqxVt7Fnnl0de4rl04dYbskz7ENZbPoG4nVWuX6hbSJWkSKvwKv4V73Z4PO EKXZ0/DUWep2mtabsaUvusmgSkzP/KVpMlF7KHhquCV4KeFDgb0lekTfUY/cR2RQMn X+D4FzlTxYISrnO+lUeVXmm7xuebMovRujraXe5Y= Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [95.163.41.80]) (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 A3B74A5ECF4 for ; Thu, 1 Feb 2024 17:23:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A3B74A5ECF4 Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1rVXyC-00000008UlM-1DuL; Thu, 01 Feb 2024 17:23:12 +0300 Message-ID: <10e11d25-d662-410a-9b34-b6d666abbd8c@tarantool.org> Date: Thu, 1 Feb 2024 17:23:11 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <5967cedfd0e3e597b34d9b873fba883c7a209518.1706520765.git.skaplun@tarantool.org> In-Reply-To: <5967cedfd0e3e597b34d9b873fba883c7a209518.1706520765.git.skaplun@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9010253A383FA2A75BEB76216D7784AEC912E83F708D1D0F2182A05F53808504039698724AA62EC4FC7A4B249DE6549FDFFDDFBB002CCD3174F260441819476B8DC8D45F6CF1587E7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77AA33865E80AF043EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B8A896DD3ADA3FA48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D81137484C4C378711E0A4C74D329BF6D76B4689247409C183CC7F00164DA146DAFE8445B8C89999728AA50765F79006372A3B24BF85B2E607389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8D2DCF9CF1F528DBCF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C4E7D9683544204AF6E0066C2D8992A164AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3B74263D4D5690889BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFE478A468B35FE7671DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3517C622C16A6DF10089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A55862F8F6A57CD2015002B1117B3ED69605D4659716920F48A9DAB4B68AE4D22F823CB91A9FED034534781492E4B8EEADFB12F4B11BB5604FBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFE70B2E21105D628431152A206B0401241DA19EF294C2B6E3E48844FB79A3A8AFA96D85E4AF70DF37BAF4CF3B87E910B1E430C0E307EF0D943C5EBE27C4A026A3128F24997A9250B65F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojqJaWtPsRtym53m3vBRRhFQ== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458F4C72EFE71B1AE1A1F93A76BF6F7B0A6CA01E6D129D67E85B8C2E6B6625C696F645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey thanks for the patch! LGTM On 1/29/24 13:45, Sergey Kaplun wrote: > This patch adds rules to build C and C++ libs from the > directory. Also, it allows these libraries to be > loaded via `require()` (since `luaL_openlib()` evolves global state). > The name of "ctest" library is changed to "libctest" to allow it to be > loaded via both `ffi.load()` and `require()`. "cpptest" library is > renamed to "libcpptest" for consistency. > > Part of tarantool/tarantool#9398 > --- > test/LuaJIT-tests/CMakeLists.txt | 29 +++++++++++++++++-- > test/LuaJIT-tests/src/CMakeLists.txt | 17 +++++++++++ > .../src/{cpptest.cpp => libcpptest.cpp} | 4 +-- > test/LuaJIT-tests/src/{ctest.c => libctest.c} | 4 +-- > test/LuaJIT-tests/test.lua | 7 +++-- > 5 files changed, 52 insertions(+), 9 deletions(-) > create mode 100644 test/LuaJIT-tests/src/CMakeLists.txt > rename test/LuaJIT-tests/src/{cpptest.cpp => libcpptest.cpp} (96%) > rename test/LuaJIT-tests/src/{ctest.c => libctest.c} (99%) > > diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt > index 9cd76ee9..c52bcc71 100644 > --- a/test/LuaJIT-tests/CMakeLists.txt > +++ b/test/LuaJIT-tests/CMakeLists.txt > @@ -1,12 +1,35 @@ > # See the rationale in the root CMakeLists.txt > cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > > -add_custom_target(LuaJIT-tests DEPENDS ${LUAJIT_TEST_BINARY}) > +add_subdirectory(src) > + > +add_custom_target(LuaJIT-tests > + DEPENDS ${LUAJIT_TEST_BINARY} LuaJIT-tests-prepare > +) > + > +make_lua_path(LUA_CPATH > + PATHS > + ${CMAKE_CURRENT_BINARY_DIR}/src/?${CMAKE_SHARED_LIBRARY_SUFFIX} > +) > + > +set(LUAJIT_TESTS_ENV > + "LUA_CPATH=\"${LUA_CPATH}\"" > +) > + > +set(LD_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/:") > + > +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") > + list(APPEND LUAJIT_TESTS_ENV DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}") > +else() > + list(APPEND LUAJIT_TESTS_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}") > +endif() > > add_custom_command(TARGET LuaJIT-tests > COMMENT "Running LuaJIT-tests" > COMMAND > - ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua > - +slow +ffi +bit +jit > + env > + ${LUAJIT_TESTS_ENV} > + ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua > + +slow +ffi +bit +jit > WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} > ) > diff --git a/test/LuaJIT-tests/src/CMakeLists.txt b/test/LuaJIT-tests/src/CMakeLists.txt > new file mode 100644 > index 00000000..fb14d6d9 > --- /dev/null > +++ b/test/LuaJIT-tests/src/CMakeLists.txt > @@ -0,0 +1,17 @@ > +# See the rationale in the root CMakeLists.txt. > +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > + > +# Build additional C/C++ libraries for tests. > +macro(BuildTestLib lib sources) > + AddTestLib(${lib} ${sources}) > + list(APPEND TESTLIBS ${lib}) > +endmacro() > + > +# Use `lib` prefix for loading via FFI and `require()`. > +BuildTestLib(libctest libctest.c) > +enable_language(CXX) > +BuildTestLib(libcpptest libcpptest.cpp) > + > +add_custom_target(LuaJIT-tests-prepare DEPENDS ${TESTLIBS}) > + > +# vim: expandtab tabstop=2 shiftwidth=2 > diff --git a/test/LuaJIT-tests/src/cpptest.cpp b/test/LuaJIT-tests/src/libcpptest.cpp > similarity index 96% > rename from test/LuaJIT-tests/src/cpptest.cpp > rename to test/LuaJIT-tests/src/libcpptest.cpp > index a5893ed6..cdfb5e32 100644 > --- a/test/LuaJIT-tests/src/cpptest.cpp > +++ b/test/LuaJIT-tests/src/libcpptest.cpp > @@ -121,9 +121,9 @@ static luaL_Reg ct_funcs[] = { > }; > > extern "C" { > -LUA_API int luaopen_cpptest(lua_State *L) > +LUA_API int luaopen_libcpptest(lua_State *L) > { > - luaL_register(L, "cpptest", ct_funcs); > + luaL_register(L, "libcpptest", ct_funcs); > return 1; > } > } > diff --git a/test/LuaJIT-tests/src/ctest.c b/test/LuaJIT-tests/src/libctest.c > similarity index 99% > rename from test/LuaJIT-tests/src/ctest.c > rename to test/LuaJIT-tests/src/libctest.c > index e99f2306..aa95b57b 100644 > --- a/test/LuaJIT-tests/src/ctest.c > +++ b/test/LuaJIT-tests/src/libctest.c > @@ -332,8 +332,8 @@ static luaL_Reg ct_funcs[] = { > {NULL, NULL} > }; > > -LUA_API int luaopen_ctest(lua_State *L) > +LUA_API int luaopen_libctest(lua_State *L) > { > - luaL_register(L, "ctest", ct_funcs); > + luaL_register(L, "libctest", ct_funcs); > return 1; > } > diff --git a/test/LuaJIT-tests/test.lua b/test/LuaJIT-tests/test.lua > index b064eff7..f2450222 100644 > --- a/test/LuaJIT-tests/test.lua > +++ b/test/LuaJIT-tests/test.lua > @@ -297,8 +297,11 @@ local function append_tree_to_plan(test_tree, opts, plan, prefix) > end > > local function seal_globals() > - local sealed_mt = {__newindex = function() > - error("Tests should not mutate global state", 3) > + local sealed_mt = {__newindex = function(_, k) > + -- Allow to load C/C++ libraries for the test. > + if k ~= "libctest" and k ~= "libcpptest" then > + error("Tests should not mutate global state", 3) > + end > end} > local function seal(t) > if getmetatable(t) then return end