<HTML><BODY><div>Hi, Sergey!</div><div>Thanks for the patch!</div><div>LGTM</div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Best regards,</div><div>Maxim Kokryashkin</div></div></div><div> </div><div style="border-left:1px solid #0857a6; margin-bottom:10px; margin-left:10px; margin-right:10px; margin-top:10px; padding:0px 0px 0px 10px"> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16844429460710637138_BODY">This patch rewrites the aforementioned test with the usage libtest<br>recently introduced. The approach is similar to the previous patch.<br><br>Nevertheless, glibc `assert()` is used to check the correctness<br>of the `mmap()` usage.<br><br>Part of tarantool/tarantool#7900<br>---<br> .../lj-49-bad-lightuserdata.test.c} | 47 ++++++++++---------<br> test/tarantool-tests/CMakeLists.txt | 1 -<br> .../lj-49-bad-lightuserdata.test.lua | 11 -----<br> .../lj-49-bad-lightuserdata/CMakeLists.txt | 1 -<br> 4 files changed, 25 insertions(+), 35 deletions(-)<br> rename test/{tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c => tarantool-c-tests/lj-49-bad-lightuserdata.test.c} (55%)<br> delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata.test.lua<br> delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt<br><br>diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c b/test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c<br>similarity index 55%<br>rename from test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c<br>rename to test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c<br>index 1b909fc6..a9cc4763 100644<br>--- a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c<br>+++ b/test/tarantool-c-tests/lj-49-bad-lightuserdata.test.c<br>@@ -1,16 +1,21 @@<br>-#include <lua.h><br>-#include <lauxlib.h><br>+#include "lua.h"<br>+#include "lauxlib.h"<br> <br> #include <sys/mman.h><br> #include <unistd.h><br> <br>-#undef NDEBUG<br>-#include <assert.h><br>+#include "test.h"<br>+#include "utils.h"<br> <br> #define START ((void *)-1)<br> <br>-static int crafted_ptr(lua_State *L)<br>+/* XXX: Still need normal assert to validate mmap correctness. */<br>+#undef NDEBUG<br>+#include <assert.h><br>+<br>+static int crafted_ptr(void *test_state)<br> {<br>+ lua_State *L = test_state;<br>  /*<br>  * We know that for arm64 at least 48 bits are available.<br>  * So emulate manually push of lightuseradata within<br>@@ -18,15 +23,15 @@ static int crafted_ptr(lua_State *L)<br>  */<br>  void *longptr = (void *)(1llu << 48);<br>  lua_pushlightuserdata(L, longptr);<br>- assert(longptr == lua_topointer(L, -1));<br>+ assert_ptr_equal(longptr, lua_topointer(L, -1));<br>  /* Clear our stack. */<br>  lua_pop(L, 0);<br>- lua_pushboolean(L, 1);<br>- return 1;<br>+ return TEST_EXIT_SUCCESS;<br> }<br> <br>-static int mmaped_ptr(lua_State *L)<br>+static int mmaped_ptr(void *test_state)<br> {<br>+ lua_State *L = test_state;<br>  /*<br>  * If start mapping address is not NULL, then the kernel<br>  * takes it as a hint about where to place the mapping, so<br>@@ -38,24 +43,22 @@ static int mmaped_ptr(lua_State *L)<br>  -1, 0);<br>  if (mmaped != MAP_FAILED) {<br>  lua_pushlightuserdata(L, mmaped);<br>- assert(mmaped == lua_topointer(L, -1));<br>+ assert_ptr_equal(mmaped, lua_topointer(L, -1));<br>  assert(munmap(mmaped, pagesize) == 0);<br>  }<br>  /* Clear our stack. */<br>  lua_pop(L, 0);<br>- lua_pushboolean(L, 1);<br>- return 1;<br>+ return TEST_EXIT_SUCCESS;<br> }<br> <br>-static const struct luaL_Reg testlightuserdata[] = {<br>- {"crafted_ptr", crafted_ptr},<br>- {"mmaped_ptr", mmaped_ptr},<br>- {NULL, NULL}<br>-};<br>-<br>-LUA_API int luaopen_testlightuserdata(lua_State *L)<br>+int main(void)<br> {<br>- luaL_register(L, "testlightuserdata", testlightuserdata);<br>- return 1;<br>+ lua_State *L = utils_lua_init();<br>+ const struct test_unit tgroup[] = {<br>+ test_unit_new(crafted_ptr),<br>+ test_unit_new(mmaped_ptr)<br>+ };<br>+ const int test_result = test_run_group(tgroup, L);<br>+ utils_lua_close(L);<br>+ return test_result;<br> }<br>-<br>diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt<br>index b1c7207f..527905b6 100644<br>--- a/test/tarantool-tests/CMakeLists.txt<br>+++ b/test/tarantool-tests/CMakeLists.txt<br>@@ -61,7 +61,6 @@ add_subdirectory(gh-5813-resolving-of-c-symbols/gnuhash)<br> add_subdirectory(gh-5813-resolving-of-c-symbols/stripped)<br> add_subdirectory(gh-6098-fix-side-exit-patching-on-arm64)<br> add_subdirectory(gh-6189-cur_L)<br>-add_subdirectory(lj-49-bad-lightuserdata)<br> add_subdirectory(lj-416-xor-before-jcc)<br> add_subdirectory(lj-601-fix-gc-finderrfunc)<br> add_subdirectory(lj-727-lightuserdata-itern)<br>diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua b/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua<br>deleted file mode 100644<br>index 94a743c7..00000000<br>--- a/test/tarantool-tests/lj-49-bad-lightuserdata.test.lua<br>+++ /dev/null<br>@@ -1,11 +0,0 @@<br>-local tap = require('tap')<br>-<br>-local test = tap.test('lj-49-bad-lightuserdata')<br>-test:plan(2)<br>-<br>-local testlightuserdata = require('testlightuserdata')<br>-<br>-test:ok(testlightuserdata.crafted_ptr())<br>-test:ok(testlightuserdata.mmaped_ptr())<br>-<br>-os.exit(test:check() and 0 or 1)<br>diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt b/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt<br>deleted file mode 100644<br>index ec6bb62c..00000000<br>--- a/test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt<br>+++ /dev/null<br>@@ -1 +0,0 @@<br>-BuildTestCLib(testlightuserdata testlightuserdata.c)<br>--<br>2.34.1</div></div></div></div></div><div> </div></BODY></HTML>