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 A0EB44DD25F; Wed, 7 Jun 2023 19:14:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A0EB44DD25F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1686154452; bh=2WX72SypMVReQ8hJcLSvCISAklknE8yb7EQ1WlNMUeI=; 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=fQHQ1husxlX8TzHwAyaC4SuLWTBFLuQz7fPu8DMphXwf8C2/huUm8Y64gxH75LmcL +7RjWI1CxxzpD5Ceyj5c1UP18I8UNba9uwPr/vyMuKlfXHPc8+8NJsKXaQu7FqMubX qC/k5ZUCYnbjAFaJ5XD4MGzVTcEeRMbEGtpPApOk= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 65A2B4B785F for ; Wed, 7 Jun 2023 19:14:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 65A2B4B785F Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1q6vnW-000uT6-DN; Wed, 07 Jun 2023 19:14:10 +0300 Message-ID: <0bebd6b4-96ec-fb20-45c6-5646846ba50b@tarantool.org> Date: Wed, 7 Jun 2023 19:14:10 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Sergey Kaplun , Igor Munkin , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD93D74B10BAB639DE31B31AE1921AF3AAC0CC86F39E1EDFC9500894C459B0CD1B9EAF2306541399E1555730613726B11D54945AD34BC240EC16E08DF1F144DEC28 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE728F774C865CF4B07EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378BCFB34D7DDF138E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D84A418E8A57B6142A1F419CB17E784DD9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC1BE95B8C87527B4BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520CCD848CCB6FE560C6FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B2882943172349060D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE32A336C65186350916E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A529244C60B2D2354A86FC7FD5D9BC627FFCD5692063F4B28CF87CCE6106E1FC07E67D4AC08A07B9B06A1CB4668A9CA5FACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF9FEA530DA519FCA9E7D5B4581BD1435945EDBF35C8210FB1E0A33A1B7F0E1CE017C141E43CE0FC0B588A46A5EBCE8E373D308FB352541C3BFEACABC933DCC993A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojC5OBK/dlsGNRHkVv+WDXsw== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458681A39F3A8D7C093E89451DEB7213C0B425D96DA5CC5D749282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3 luajit 6/6] test: rewrite lj-49-bad-lightuserdata test in C 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" Sergey, thanks for a third version of the patch! LGTM in general, however I have a minor comment, see below. On 6/5/23 13:41, Sergey Kaplun wrote: > This patch rewrites the aforementioned test with the usage libtest > recently introduced. The approach is similar to the previous patch. > > Nevertheless, glibc `assert()` is used to check the correctness > of the `mmap()` usage. > > Part of tarantool/tarantool#7900 > --- > .../lj-49-bad-lightuserdata.test.c} | 47 ++++++++++--------- > test/tarantool-tests/CMakeLists.txt | 1 - > .../lj-49-bad-lightuserdata.test.lua | 11 ----- > .../lj-49-bad-lightuserdata/CMakeLists.txt | 1 - > 4 files changed, 25 insertions(+), 35 deletions(-) > rename test/{tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c => tarantool-c-tests/lj-49-bad-lightuserdata.test.c} (55%) > delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata.test.lua > delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt > > diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c b/test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c > similarity index 55% > rename from test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c > rename to test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c > index 1b909fc6..a9cc4763 100644 > --- a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c > +++ b/test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c > @@ -1,16 +1,21 @@ > -#include > -#include > +#include "lua.h" > +#include "lauxlib.h" > > #include > #include > > -#undef NDEBUG > -#include > +#include "test.h" > +#include "utils.h" > > #define START ((void *)-1) > > -static int crafted_ptr(lua_State *L) > +/* XXX: Still need normal assert to validate mmap correctness. */ > +#undef NDEBUG > +#include > + > +static int crafted_ptr(void *test_state) Nit: I would rename test_state to something like lua_state here and in mmaped_ptr. Feel free to ignore. > { > + lua_State *L = test_state; > /* > * We know that for arm64 at least 48 bits are available. > * So emulate manually push of lightuseradata within > @@ -18,15 +23,15 @@ static int crafted_ptr(lua_State *L) > */ > void *longptr = (void *)(1llu << 48); > lua_pushlightuserdata(L, longptr); > - assert(longptr == lua_topointer(L, -1)); > + assert_ptr_equal(longptr, lua_topointer(L, -1)); > /* Clear our stack. */ > lua_pop(L, 0); > - lua_pushboolean(L, 1); > - return 1; > + return TEST_EXIT_SUCCESS; > } > > -static int mmaped_ptr(lua_State *L) > +static int mmaped_ptr(void *test_state) > { > + lua_State *L = test_state; > /* > * If start mapping address is not NULL, then the kernel > * takes it as a hint about where to place the mapping, so > @@ -38,24 +43,22 @@ static int mmaped_ptr(lua_State *L) > -1, 0); > if (mmaped != MAP_FAILED) { > lua_pushlightuserdata(L, mmaped); > - assert(mmaped == lua_topointer(L, -1)); > + assert_ptr_equal(mmaped, lua_topointer(L, -1)); > assert(munmap(mmaped, pagesize) == 0); > } > /* Clear our stack. */ > lua_pop(L, 0); > - lua_pushboolean(L, 1); > - return 1; > + return TEST_EXIT_SUCCESS; > } > > -static const struct luaL_Reg testlightuserdata[] = { > - {"crafted_ptr", crafted_ptr}, > - {"mmaped_ptr", mmaped_ptr}, > - {NULL, NULL} > -}; > - > -LUA_API int luaopen_testlightuserdata(lua_State *L) > +int main(void) > { > - luaL_register(L, "testlightuserdata", testlightuserdata); > - return 1; > + lua_State *L = utils_lua_init(); > + const struct test_unit tgroup[] = { > + test_unit_new(crafted_ptr), > + test_unit_new(mmaped_ptr) > + }; > + const int test_result = test_run_group(tgroup, L); > + utils_lua_close(L); > + return test_result; > } > - > diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt > index b1c7207f..527905b6 100644 > --- a/test/tarantool-tests/CMakeLists.txt > +++ b/test/tarantool-tests/CMakeLists.txt > @@ -61,7 +61,6 @@ add_subdirectory(gh-5813-resolving-of-c-symbols/gnuhash) > add_subdirectory(gh-5813-resolving-of-c-symbols/stripped) > add_subdirectory(gh-6098-fix-side-exit-patching-on-arm64) > add_subdirectory(gh-6189-cur_L) > -add_subdirectory(lj-49-bad-lightuserdata) > add_subdirectory(lj-416-xor-before-jcc) > add_subdirectory(lj-601-fix-gc-finderrfunc) > add_subdirectory(lj-727-lightuserdata-itern) > diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua b/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua > deleted file mode 100644 > index 94a743c7..00000000 > --- a/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua > +++ /dev/null > @@ -1,11 +0,0 @@ > -local tap = require('tap') > - > -local test = tap.test('lj-49-bad-lightuserdata') > -test:plan(2) > - > -local testlightuserdata = require('testlightuserdata') > - > -test:ok(testlightuserdata.crafted_ptr()) > -test:ok(testlightuserdata.mmaped_ptr()) > - > -os.exit(test:check() and 0 or 1) > diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt b/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt > deleted file mode 100644 > index ec6bb62c..00000000 > --- a/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt > +++ /dev/null > @@ -1 +0,0 @@ > -BuildTestCLib(testlightuserdata testlightuserdata.c)