Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
@ 2024-01-29 10:45 Sergey Kaplun via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
                   ` (29 more replies)
  0 siblings, 30 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patchset enables most of the LuaJIT-tests related to FFI and
testing of C libraries (cpptest, ctest). More tests (from the <misc>
directory) will be enabled in the future series.

FFI tests from the <unportable> directory aren't enabled because of their
inconsistency, see also [1].

This increases coverage up to 92.5%, see here [2].

Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-9398-more-luajit-tests
Tarantool PR: https://github.com/tarantool/tarantool/pull/9603
Related issues:
* https://github.com/tarantool/tarantool/issues/9398
* https://github.com/tarantool/tarantool/issues/7834

[1]: https://github.com/LuaJIT/LuaJIT/pull/415
[2]: https://coveralls.io/github/tarantool/luajit?branch=skaplun/gh-9398-more-luajit-tests

Changes in the v2:
* Introduce the AddTestLib macro to avoid copy-pasting. It only adds a
  target with necessary flags without setting any variables.
* <cpptest.cpp> is renamed to <libcpptest.cpp> for consistency with
  <libctest.c>
* Rename some tests with uninformative naming (like `call_10i` ->
  `10 int args`)
* Add adjusments of arguments for long calls (~10 arguments) to make them
  comparable without changing test semantics.
* Fix some typos

Sergey Kaplun (26):
  cmake: introduce AddTestLib macro
  test: prepare lauxilarily libs for LuaJIT-tests
  test: separate LuaJIT helpers from ffi_util.inc
  test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
  test: enable <ffi_bitfield.lua> in LuaJIT-tests
  test: enable <ffi_call.lua> in LuaJIT-tests
  test: enable <ffi_callback.lua> in LuaJIT-tests
  test: enable <ffi_const.lua> in LuaJIT-tests
  test: enable <ffi_convert.lua> in LuaJIT-tests
  test: enable <ffi_enum.lua> in LuaJIT-tests
  test: enable <ffi_gcstep_recursive.lua>
  test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  test: enable <ffi_jit_call.lua> in LuaJIT-tests
  test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  test: enable <ffi_lex_number.lua> in LuaJIT-tests
  test: enable <ffi_metatype.lua> in LuaJIT-tests
  test: enable <ffi_new.lua> in LuaJIT-tests
  test: enable <ffi_parse_array.lua> in LuaJIT-tests
  test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  test: enable <ffi_parse_struct.lua> LuaJIT test
  test: enable <ffi_tabov.lua> LuaJIT test
  test: enable <lightud.lua> LuaJIT test
  test: enable <api_call.lua> LuaJIT test
  test: enable <catch_wrap.lua> LuaJIT test
  test: enable <catch_cpp.lua> LuaJIT test

 test/CMakeLists.txt                           |   3 +
 test/LuaJIT-tests/CMakeLists.txt              |  45 ++-
 test/LuaJIT-tests/common/fails.lua            |   3 +
 test/LuaJIT-tests/common/ffi/checkfail.lua    |  14 +
 test/LuaJIT-tests/common/ffi/checktypes.lua   |  15 +
 test/LuaJIT-tests/common/ffi_util.inc         |  23 --
 test/LuaJIT-tests/{misc => lang}/api_call.lua |  32 +-
 .../{sysdep => lang}/catch_cpp.lua            |  36 +-
 .../{misc => lang}/catch_wrap.lua             |  29 +-
 test/LuaJIT-tests/lang/index                  |   4 +
 test/LuaJIT-tests/lang/lightud.lua            |  89 +++++
 test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua   |  13 +-
 test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua    |   4 +-
 test/LuaJIT-tests/lib/ffi/ffi_call.lua        | 185 +++++-----
 test/LuaJIT-tests/lib/ffi/ffi_callback.lua    |  45 +--
 test/LuaJIT-tests/lib/ffi/ffi_const.lua       |   4 +-
 test/LuaJIT-tests/lib/ffi/ffi_convert.lua     |  35 +-
 test/LuaJIT-tests/lib/ffi/ffi_enum.lua        |  11 +-
 .../lib/ffi/ffi_gcstep_recursive.lua          |  27 +-
 test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua   |  22 +-
 test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua    |  70 ++--
 test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua    |  70 ++--
 test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua  |  72 ++--
 test/LuaJIT-tests/lib/ffi/ffi_metatype.lua    |  16 +-
 test/LuaJIT-tests/lib/ffi/ffi_new.lua         |  50 +--
 test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 +++---
 test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 ++++++-------
 test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua  | 141 ++++----
 .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua       |  12 -
 test/LuaJIT-tests/lib/ffi/index               |  18 +
 test/LuaJIT-tests/misc/lightud.lua            |  88 -----
 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 +-
 .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt |  25 +-
 test/cmake/AddTestLib.cmake                   |  28 ++
 test/tarantool-tests/CMakeLists.txt           |  27 +-
 test/tarantool-tests/ffi-tabov.test.lua       |  27 ++
 40 files changed, 1086 insertions(+), 921 deletions(-)
 create mode 100644 test/LuaJIT-tests/common/fails.lua
 create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
 create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
 rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)
 rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
 rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)
 create mode 100644 test/LuaJIT-tests/lang/lightud.lua
 delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
 delete mode 100644 test/LuaJIT-tests/misc/lightud.lua
 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%)
 create mode 100644 test/cmake/AddTestLib.cmake
 create mode 100644 test/tarantool-tests/ffi-tabov.test.lua

-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 11:25   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 14:20   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches
                   ` (28 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes copy-pasting in macros used to add a new library for
testing and places this in the include test file.

Needed for tarantool/tarantool#9398
---
 test/CMakeLists.txt                           |  3 ++
 .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 25 +----------------
 test/cmake/AddTestLib.cmake                   | 28 +++++++++++++++++++
 test/tarantool-tests/CMakeLists.txt           | 27 +-----------------
 4 files changed, 33 insertions(+), 50 deletions(-)
 create mode 100644 test/cmake/AddTestLib.cmake

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8afc42df..3ad5d15f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -74,6 +74,9 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS
 set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
 separate_arguments(LUAJIT_TEST_COMMAND)
 
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+include(AddTestLib)
+
 add_subdirectory(LuaJIT-tests)
 add_subdirectory(PUC-Rio-Lua-5.1-tests)
 add_subdirectory(lua-Harness-tests)
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
index 8501b767..e68e6aef 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
@@ -6,30 +6,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
 # Build additional C libraries for tests.
 macro(BuildTestCLib lib sources)
-  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
-  target_include_directories(${lib} PRIVATE
-    ${LUAJIT_SOURCE_DIR}
-  )
-  set_target_properties(${lib} PROPERTIES
-    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
-    PREFIX ""
-  )
-  # XXX: The dynamic libraries are loaded with LuaJIT binary and
-  # use symbols from it. So it is totally OK to have unresolved
-  # symbols at build time.
-  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set_target_properties(${lib} PROPERTIES
-      LINK_FLAGS "-undefined dynamic_lookup"
-    )
-  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    # XXX: This is necessary mostly for openSUSE builds, see also
-    # https://bugzilla.suse.com/show_bug.cgi?id=1012388.
-    # Just strip out the linker flag to suppress this linker
-    # option.
-    string(REPLACE "-Wl,--no-undefined" ""
-      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
-    )
-  endif()
+  AddTestLib(${lib} ${sources})
   list(APPEND TESTLIBS ${lib})
 endmacro()
 
diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
new file mode 100644
index 00000000..3764ee5c
--- /dev/null
+++ b/test/cmake/AddTestLib.cmake
@@ -0,0 +1,28 @@
+macro(AddTestLib lib sources)
+  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
+  target_include_directories(${lib} PRIVATE
+    ${LUAJIT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+  )
+  set_target_properties(${lib} PROPERTIES
+    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+    PREFIX ""
+  )
+
+  # XXX: This change affects the current cmake variable scope and
+  # so a user should care to don't use it in a top level scope.
+  # The dynamic libraries are loaded with LuaJIT binary and use
+  # symbols from it. So it is totally OK to have unresolved
+  # symbols at build time.
+  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set_target_properties(${lib} PROPERTIES
+      LINK_FLAGS "-undefined dynamic_lookup"
+    )
+  else()
+    # FIXME: Unfortunately, there is no another way to suppress
+    # this linker option, so just strip it out from the flags.
+    string(REPLACE "-Wl,--no-undefined" ""
+      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
+    )
+  endif()
+endmacro()
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 6d686876..80d94a78 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -11,32 +11,7 @@ if(NOT PROVE)
 endif()
 
 macro(BuildTestCLib lib sources)
-  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
-  target_include_directories(${lib} PRIVATE
-    ${LUAJIT_SOURCE_DIR}
-    ${CMAKE_CURRENT_SOURCE_DIR}
-  )
-  set_target_properties(${lib} PROPERTIES
-    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
-    PREFIX ""
-  )
-
-  # XXX: This change affects the current cmake variable scope and
-  # so a user should care to don't use it in a top level scope.
-  # The dynamic libraries are loaded with LuaJIT binary and use
-  # symbols from it. So it is totally OK to have unresolved
-  # symbols at build time.
-  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set_target_properties(${lib} PROPERTIES
-      LINK_FLAGS "-undefined dynamic_lookup"
-    )
-  else()
-    # FIXME: Unfortunately, there is no another way to suppress
-    # this linker option, so just strip it out from the flags.
-    string(REPLACE "-Wl,--no-undefined" ""
-      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
-    )
-  endif()
+  AddTestLib(${lib} ${sources})
   # XXX: Append the lib to be built to the dependency list.
   # Unfortunately, there is no convenient way in CMake to extend
   # the list in parent scope other than join two strings with
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 11:48   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 14:23   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches
                   ` (27 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch adds rules to build C and C++ libs from the
<LuaJIT-tests/src/> 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
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 11:58   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:45   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
                   ` (26 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>
into separate files by analogy with <common/expect_error.lua>. The
`include()` helper isn't touched since it is used in system dependend
tests, which won't be modified for now.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/common/fails.lua          |  3 +++
 test/LuaJIT-tests/common/ffi/checkfail.lua  | 14 +++++++++++++
 test/LuaJIT-tests/common/ffi/checktypes.lua | 15 ++++++++++++++
 test/LuaJIT-tests/common/ffi_util.inc       | 23 ---------------------
 4 files changed, 32 insertions(+), 23 deletions(-)
 create mode 100644 test/LuaJIT-tests/common/fails.lua
 create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
 create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua

diff --git a/test/LuaJIT-tests/common/fails.lua b/test/LuaJIT-tests/common/fails.lua
new file mode 100644
index 00000000..d555a2b5
--- /dev/null
+++ b/test/LuaJIT-tests/common/fails.lua
@@ -0,0 +1,3 @@
+return function(f, ...)
+  if pcall(f, ...) ~= false then error("failure expected", 2) end
+end
diff --git a/test/LuaJIT-tests/common/ffi/checkfail.lua b/test/LuaJIT-tests/common/ffi/checkfail.lua
new file mode 100644
index 00000000..d3ca74e8
--- /dev/null
+++ b/test/LuaJIT-tests/common/ffi/checkfail.lua
@@ -0,0 +1,14 @@
+local ffi = require("ffi")
+
+-- Checker that takes an array of strings that should represent
+-- different invalid CTypes (a more common pattern). Also, the
+-- second argument may be also the `loadstring` function to check
+-- invalid literals or `ffi.cdef` to check invalid C definitions.
+return function(t, f)
+  f = f or ffi.typeof
+  for i=1,1e9 do
+    local tp = t[i]
+    if not tp then break end
+    assert(pcall(f, tp) == false, tp)
+  end
+end
diff --git a/test/LuaJIT-tests/common/ffi/checktypes.lua b/test/LuaJIT-tests/common/ffi/checktypes.lua
new file mode 100644
index 00000000..c995d667
--- /dev/null
+++ b/test/LuaJIT-tests/common/ffi/checktypes.lua
@@ -0,0 +1,15 @@
+local ffi = require("ffi")
+
+-- Checker that takes an array with the following each 3 elements:
+-- 1) Sizeof for the given C type to be checked.
+-- 2) Alignof for the given C type to be checked.
+-- 3) String representing the C type.
+return function(t)
+  for i=1,1e9,3 do
+    local tp = t[i+2]
+    if not tp then break end
+    local id = ffi.typeof(tp)
+    assert(ffi.sizeof(id) == t[i], tp)
+    assert(ffi.alignof(id) == t[i+1], tp)
+  end
+end
diff --git a/test/LuaJIT-tests/common/ffi_util.inc b/test/LuaJIT-tests/common/ffi_util.inc
index 1eee8dd9..9604d7b0 100644
--- a/test/LuaJIT-tests/common/ffi_util.inc
+++ b/test/LuaJIT-tests/common/ffi_util.inc
@@ -4,29 +4,6 @@
 
 local ffi = require("ffi")
 
-function checkfail(t, f)
-  f = f or ffi.typeof
-  for i=1,1e9 do
-    local tp = t[i]
-    if not tp then break end
-    assert(pcall(f, tp) == false, tp)
-  end
-end
-
-function checktypes(t)
-  for i=1,1e9,3 do
-    local tp = t[i+2]
-    if not tp then break end
-    local id = ffi.typeof(tp)
-    assert(ffi.sizeof(id) == t[i], tp)
-    assert(ffi.alignof(id) == t[i+1], tp)
-  end
-end
-
-function fails(f, ...)
-  if pcall(f, ...) ~= false then error("failure expected", 2) end
-end
-
 local incroot = os.getenv("INCROOT") or "/usr/include"
 local cdefs = os.getenv("CDEFS") or ""
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (2 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 12:21   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:50   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches
                   ` (25 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper function. It adds test names and
includes the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua | 13 ++++++-------
 test/LuaJIT-tests/lib/ffi/index             |  1 +
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua b/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
index 8cf890c6..f7fac0d8 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
@@ -1,6 +1,5 @@
 local ffi = require("ffi")
-
-dofile("../common/ffi_util.inc")
+local fails = require("common.fails")
 
 ffi.cdef[[
 typedef struct { int a,b,c; } foo1_t;
@@ -9,7 +8,7 @@ void *malloc(size_t);
 struct incomplete;
 ]]
 
-do
+do --- base pointer arithmetic and comparisons
   local a = ffi.new("int[10]")
   local p1 = a+0
   p1[0] = 1;
@@ -61,7 +60,7 @@ do
   assert(b - a == 5)
 end
 
-do
+do --- pointer comparisons for different types
   local p1 = ffi.cast("void *", 0)
   local p2 = ffi.cast("int *", 1)
   assert(p1 == p1)
@@ -71,7 +70,7 @@ do
   assert(p2 ~= nil)
 end
 
-do
+do --- pointer comparisons for functions
   local f1 = ffi.C.free
   local f2 = ffi.C.malloc
   local p1 = ffi.cast("void *", f1)
@@ -84,7 +83,7 @@ do
   fails(function(f1) return f1 + 1 end, f1)
 end
 
-do
+do --- pointer arithmetic for structures
   local s = ffi.new("foo1_t[10]")
   local p1 = s+3
   p1.a = 1; p1.b = 2; p1.c = 3
@@ -96,7 +95,7 @@ do
   assert(p1 - p2 == -3)
 end
 
-do
+do --- pointer arithmetic for structure with unknown size
   local mem = ffi.new("int[1]")
   local p = ffi.cast("struct incomplete *", mem)
   fails(function(p) return p+1 end, p)
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 59e36dd8..7e046908 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -2,6 +2,7 @@ bit64.lua +luajit>=2.1
 cdata_var.lua
 copy_fill.lua
 err.lua
+ffi_arith_ptr.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (3 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 12:26   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:52   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches
                   ` (24 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes unused `dofile()`. Also, it names the only one test
as "misc" and includes the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua | 4 +---
 test/LuaJIT-tests/lib/ffi/index            | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
index cd0b1815..fa74e45d 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
@@ -1,8 +1,6 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
-
-do
+do --- misc
   local x = ffi.new([[
     union {
       uint32_t u;
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 7e046908..8d833107 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -3,6 +3,7 @@ cdata_var.lua
 copy_fill.lua
 err.lua
 ffi_arith_ptr.lua
+ffi_bitfield.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (4 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 12:34   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:58   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches
                   ` (23 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes unused `dofile()`. Also, it uses the basename of the
ctest library to be loaded via ffi. It adds groups with names of
subtests and enables the test in <index>. Complex type is undefined on
Windows, so the correponding tests are not enabled for this platform.
Fastcalls are enabled only for the x86 architecture. Stdcalls are
enabled only for Windows on x86. Tests with calls with 10 arguments with
sizes less than 8 bits are dummy for M1. This suite lacks a mechanism to
skip subtests satisfying complicated conditions, so it is done manually
by the corresponding `if` check.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_call.lua | 185 +++++++++++++------------
 test/LuaJIT-tests/lib/ffi/index        |   1 +
 2 files changed, 97 insertions(+), 89 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_call.lua b/test/LuaJIT-tests/lib/ffi/ffi_call.lua
index 1eb5e906..0844b686 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_call.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_call.lua
@@ -1,8 +1,5 @@
-
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
-
 local tonumber = tonumber
 
 ffi.cdef[[
@@ -73,81 +70,92 @@ double __stdcall stdcall_dd(double a, double b);
 float __stdcall stdcall_ff(float a, float b);
 ]]
 
-local C = ffi.load("../clib/ctest")
+local C = ffi.load("ctest")
 
-assert(C.call_i(-42) == -41)
-assert(C.call_ii(-42, 17) == -42+17)
-assert(C.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) == -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
+do --- int enum double float args
+  assert(C.call_i(-42) == -41)
+  assert(C.call_ii(-42, 17) == -42+17)
 
-assert(C.call_ie(123) == 124)
+  assert(C.call_ie(123) == 124)
 
-assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
-assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17))
-assert(tonumber(C.call_jj(-42, 17)) == -42+17)
-assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) == tonumber(0x123456789abcdef0LL-0x789abcde99887766LL))
+  assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
+  assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17))
+  assert(tonumber(C.call_jj(-42, 17)) == -42+17)
+  assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) ==
+                   tonumber(0x123456789abcdef0LL - 0x789abcde99887766LL))
 
-assert(C.call_dd(12.5, -3.25) == 12.5-3.25)
-assert(C.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
+  assert(C.call_dd(12.5, -3.25) == 12.5-3.25)
 
-assert(C.call_ff(12.5, -3.25) == 12.5-3.25)
-assert(C.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
+  assert(C.call_ff(12.5, -3.25) == 12.5-3.25)
 
-assert(C.call_idifjd(-42, 17.125, 0x12345, -100.625, 12345678901234, -789012.75) == -42+17.125+0x12345-100.625+12345678901234-789012.75)
+  assert(C.call_idifjd(-42,  17.125,  0x12345, -100.625,  12345678901234, -789012.75) ==
+                       -42 + 17.125 + 0x12345 - 100.625 + 12345678901234 - 789012.75)
+end
+
+do --- 10 ints, 10 floats, 10 doubles
+  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
+    assert(C.call_10i(-42,  17,  12345,  9987, -100,  11,  51,  0x12345678,  338, -78901234) ==
+                      -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
+    assert(C.call_10f(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x123456,  338, -789012.75) ==
+                      -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x123456 + 338 - 789012.75)
+  end
+  assert(C.call_10d(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x12345678,  338, -78901234.75) ==
+                    -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x12345678 + 338 - 78901234.75)
+end
 
-do
+do --- pointers
   local a = ffi.new("int[10]", -42)
   assert(C.call_p_i(a) == -42+1)
   assert(tonumber(ffi.cast("intptr_t", C.call_p_p(a+3))) == tonumber(ffi.cast("intptr_t", a+4)))
   assert(C.call_pp_i(a+8, a+5) == 3)
 end
 
--- vararg
-assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131)
+do --- vararg
+  assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131)
+end
 
 -- complex
-if pcall(function() return C.call_dd_cd end) then
-  do
-    local c = C.call_dd_cd(12.5, -3.25)
-    assert(c.re == 12.5 and c.im == -3.25*2)
-  end
-  do
-    local c1 = ffi.new("complex", 12.5, -3.25)
-    local cz = C.call_cd(c1)
-    assert(cz.re == 12.5+1 and cz.im == -3.25-2)
-  end
-  do
-    local c1 = ffi.new("complex", 12.5, -3.25)
-    local c2 = ffi.new("complex", -17.125, 100.625)
-    local cz = C.call_cdcd(c1, c2)
-    assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
-  end
+do --- complex double, 2 double args -windows
+  local c = C.call_dd_cd(12.5, -3.25)
+  assert(c.re == 12.5 and c.im == -3.25*2)
+end
+do --- complex double, 1 complex arg -windows
+  local c1 = ffi.new("complex", 12.5, -3.25)
+  local cz = C.call_cd(c1)
+  assert(cz.re == 12.5+1 and cz.im == -3.25-2)
+end
+do --- complex double, 2 complex args -windows
+  local c1 = ffi.new("complex", 12.5, -3.25)
+  local c2 = ffi.new("complex", -17.125, 100.625)
+  local cz = C.call_cdcd(c1, c2)
+  assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
+end
 
-  do
-    local c = C.call_ff_cf(12.5, -3.25)
-    assert(c.re == 12.5 and c.im == -3.25*2)
-  end
-  do
-    local c1 = ffi.new("complex float", 12.5, -3.25)
-    local cz = C.call_cf(c1)
-    assert(cz.re == 12.5+1 and cz.im == -3.25-2)
-  end
-  do
-    local c1 = ffi.new("complex float", 12.5, -3.25)
-    local c2 = ffi.new("complex float", -17.125, 100.625)
-    local cz = C.call_cfcf(c1, c2)
-    assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
-  end
+do --- complex float, 2 float args -windows
+  local c = C.call_ff_cf(12.5, -3.25)
+  assert(c.re == 12.5 and c.im == -3.25*2)
+end
+do --- complex float, 1 complex float arg -windows
+  local c1 = ffi.new("complex float", 12.5, -3.25)
+  local cz = C.call_cf(c1)
+  assert(cz.re == 12.5+1 and cz.im == -3.25-2)
+end
+do --- complex float, 2 complex float args -windows
+  local c1 = ffi.new("complex float", 12.5, -3.25)
+  local c2 = ffi.new("complex float", -17.125, 100.625)
+  local cz = C.call_cfcf(c1, c2)
+  assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
 end
 
 -- structs
-do
+do --- struct {int; int;} arg, return struct {int; int;}
   local s1 = ffi.new("s_ii", -42, 17)
   local sz = C.call_sii(s1)
   assert(s1.x == -42 and s1.y == 17)
   assert(sz.x == -42 and sz.y == 17)
 end
 
-do
+do --- struct {int64_t; int64_t;} arg, return struct {int64_t; int64_t;}
   local s1 = ffi.new("s_jj", 0x123456789abcdef0LL, -0x789abcde99887766LL)
   local sz = C.call_sjj(s1)
   assert(s1.x == 0x123456789abcdef0LL)
@@ -156,28 +164,28 @@ do
   assert(sz.y == -0x789abcde99887766LL)
 end
 
-do
+do --- struct {float; float;} arg, return struct {float; float;}
   local s1 = ffi.new("s_ff", 12.5, -3.25)
   local sz = C.call_sff(s1)
   assert(s1.x == 12.5 and s1.y == -3.25)
   assert(sz.x == 12.5 and sz.y == -3.25)
 end
 
-do
+do --- struct {double; double;} arg, return struct {double; double;}
   local s1 = ffi.new("s_dd", 12.5, -3.25)
   local sz = C.call_sdd(s1)
   assert(s1.x == 12.5 and s1.y == -3.25)
   assert(sz.x == 12.5 and sz.y == -3.25)
 end
 
-do
+do --- struct composed of 8 ints arg, same result
   local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
   local sz = C.call_s8i(s1)
   assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678)
   assert(sz.a+sz.b+sz.c+sz.d+sz.e+sz.f+sz.g+sz.h == -42+17+12345+9987-100+11+51+0x12345678)
 end
 
-do
+do --- 2 struct {int; int;} args, return struct {int; int;}
   local s1 = ffi.new("s_ii", -42, 17)
   local s2 = ffi.new("s_ii", 0x12345, -98765)
   local sz = C.call_siisii(s1, s2)
@@ -186,7 +194,7 @@ do
   assert(sz.x == -42+0x12345 and sz.y == 17-98765)
 end
 
-do
+do --- 2 struct {float; float;} args, return struct {float; float;}
   local s1 = ffi.new("s_ff", 12.5, -3.25)
   local s2 = ffi.new("s_ff", -17.125, 100.625)
   local sz = C.call_sffsff(s1, s2)
@@ -195,7 +203,7 @@ do
   assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
 end
 
-do
+do --- 2 struct {double; double;} args, return struct {double; double;}
   local s1 = ffi.new("s_dd", 12.5, -3.25)
   local s2 = ffi.new("s_dd", -17.125, 100.625)
   local sz = C.call_sddsdd(s1, s2)
@@ -204,7 +212,7 @@ do
   assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
 end
 
-do
+do --- 2 struct composed of 8 ints args, same struct in result
   local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
   local s2 = ffi.new("s_8i", 99, 311, 98765, -51, 312, 97, 17, 0x44332211)
   local sz = C.call_s8is8i(s1, s2)
@@ -215,7 +223,7 @@ do
   assert(sz.h == 0x12345678+0x44332211)
 end
 
-do
+do --- int, struct composed of 8 ints, int
   local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
   local sz = C.call_is8ii(19, s1, -51)
   assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678)
@@ -225,42 +233,41 @@ do
 end
 
 -- target-specific
-if jit.arch == "x86" then
+do --- fastcall void int double +x86
   assert(C.fastcall_void() == 1)
   assert(C.fastcall_i(-42) == -41)
   assert(C.fastcall_ii(-42, 17) == -42+17)
   assert(C.fastcall_iii(-42, 17, 139) == -42+17+139)
   assert(tonumber(C.fastcall_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
   assert(C.fastcall_dd(12.5, -3.25) == 12.5-3.25)
+end
 
-  do
-    local a = ffi.new("int[10]", -42)
-    assert(C.fastcall_pp_i(a+8, a+5) == 3)
-  end
-
-  do
-    local s1 = ffi.new("s_ii", -42, 17)
-    local s2 = ffi.new("s_ii", 0x12345, -98765)
-    local sz = C.fastcall_siisii(s1, s2)
-    assert(s1.x == -42 and s1.y == 17)
-    assert(s2.x == 0x12345 and s2.y == -98765)
-    assert(sz.x == -42+0x12345 and sz.y == 17-98765)
-  end
+do --- fastcall 2 pointer args +x86
+  local a = ffi.new("int[10]", -42)
+  assert(C.fastcall_pp_i(a+8, a+5) == 3)
+end
 
-  do
-    local s1 = ffi.new("s_dd", 12.5, -3.25)
-    local s2 = ffi.new("s_dd", -17.125, 100.625)
-    local sz = C.fastcall_sddsdd(s1, s2)
-    assert(s1.x == 12.5 and s1.y == -3.25)
-    assert(s2.x == -17.125 and s2.y == 100.625)
-    assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
-  end
+do --- fastcall 2 struct {int; int;} args +x86
+  local s1 = ffi.new("s_ii", -42, 17)
+  local s2 = ffi.new("s_ii", 0x12345, -98765)
+  local sz = C.fastcall_siisii(s1, s2)
+  assert(s1.x == -42 and s1.y == 17)
+  assert(s2.x == 0x12345 and s2.y == -98765)
+  assert(sz.x == -42+0x12345 and sz.y == 17-98765)
+end
 
-  if jit.os == "Windows" then
-    assert(C.stdcall_i(-42) == -41)
-    assert(C.stdcall_ii(-42, 17) == -42+17)
-    assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25)
-    assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25)
-  end
+do --- fastcall 2 struct {double; double;} args +x86
+  local s1 = ffi.new("s_dd", 12.5, -3.25)
+  local s2 = ffi.new("s_dd", -17.125, 100.625)
+  local sz = C.fastcall_sddsdd(s1, s2)
+  assert(s1.x == 12.5 and s1.y == -3.25)
+  assert(s2.x == -17.125 and s2.y == 100.625)
+  assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
 end
 
+do --- stdcall +x86 +windows
+  assert(C.stdcall_i(-42) == -41)
+  assert(C.stdcall_ii(-42, 17) == -42+17)
+  assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25)
+  assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25)
+end
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 8d833107..599a0182 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -4,6 +4,7 @@ copy_fill.lua
 err.lua
 ffi_arith_ptr.lua
 ffi_bitfield.lua
+ffi_call.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (5 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 13:02   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:01   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
                   ` (22 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch names all subtests and includes the test in <index>.
The test with calls with 10 arguments with sizes less than 8 bits are
dummy for M1. This suite lacks a mechanism to skip subtests satisfying
complicated conditions, so it is done manually by the corresponding `if`
check.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_callback.lua | 45 +++++++++++-----------
 test/LuaJIT-tests/lib/ffi/index            |  1 +
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_callback.lua b/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
index 1fd14bd0..44fac680 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
@@ -6,7 +6,7 @@ void qsort(void *base, size_t nmemb, size_t size,
 	   int (*compar)(const uint8_t *, const uint8_t *));
 ]]
 
-do
+do --- blacklisted callback
   local cb = ffi.cast("int (*)(int, int, int)", function(a, b, c)
     return a+b+c
   end)
@@ -19,11 +19,11 @@ do
   end
 end
 
-do
+do --- cast to function
   assert(ffi.cast("int64_t (*)(int64_t, int64_t, int64_t)", function(a, b, c)
       return a+b+c
-    end)(12345678901234567LL, 70000000000000001LL, 10000000909090904LL) ==
-    12345678901234567LL+70000000000000001LL+10000000909090904LL)
+    end)(12345678901234567LL,  70000000000000001LL,  10000000909090904LL) ==
+         12345678901234567LL + 70000000000000001LL + 10000000909090904LL)
 
   assert(ffi.cast("double (*)(double, float, double)", function(a, b, c)
       return a+b+c
@@ -37,21 +37,23 @@ do
       return a+b+c
     end)(7.125, -123.25, 9999.33) == 9883.205078125)
 
-  assert(ffi.cast("int (*)(int, int, int, int, int, int, int, int, int, int)",
-    function(a, b, c, d, e, f, g, h, i, j)
-      return a+b+c+d+e+f+g+h+i+j
-    end)(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) ==
-    -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
+  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
+    assert(ffi.cast("int (*)(int, int, int, int, int, int, int, int, int, int)",
+      function(a, b, c, d, e, f, g, h, i, j)
+        return a+b+c+d+e+f+g+h+i+j
+      end)(-42,  17,  12345,  9987, -100,  11,  51,  0x12345678,  338, -78901234) ==
+           -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
+  end
 
   assert(ffi.cast("double (*)(double, double, double, double, double, double, double, double, double, double)",
     function(a, b, c, d, e, f, g, h, i, j)
       return a+b+c+d+e+f+g+h+i+j
-    end)(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) ==
-    -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
+    end)(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x12345678,  338, -78901234.75) ==
+         -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x12345678 + 338 - 78901234.75)
 end
 
 -- Target-specific tests.
-if jit.arch == "x86" then
+do --- cast with fastcall attribute +x86
   assert(ffi.cast("__fastcall int (*)(int, int, int)", function(a, b, c)
       return a+b+c
     end)(10, 99, 13) == 122)
@@ -63,12 +65,11 @@ if jit.arch == "x86" then
   -- Test reordering.
   assert(ffi.cast("int64_t __fastcall (*)(int64_t, int, int)", function(a, b, c)
       return a+b+c
-    end)(12345678901234567LL, 12345, 989797123) ==
-    12345678901234567LL+12345+989797123)
+    end)(12345678901234567LL,  12345,  989797123) ==
+         12345678901234567LL + 12345 + 989797123)
 end
 
--- Error handling.
-do
+do --- error handling
   local function f()
     return
   end -- Error for result conversion triggered here.
@@ -84,7 +85,7 @@ do
   assert(pcall(ffi.cast("int (*)(int,int,int,int, int,int,int,int, int)", function() error("test") end), 1,1,1,1, 1,1,1,1, 1) == false)
 end
 
-do
+do --- qsort
   local function cmp(pa, pb)
     local a, b = pa[0], pb[0]
     if a < b then
@@ -102,7 +103,7 @@ do
   for i=0,254 do assert(arr[i] <= arr[i+1]) end
 end
 
-if ffi.abi"win" then
+do --- EnumWindows +windows
   ffi.cdef[[
   typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
   int EnumWindows(WNDENUMPROC func, intptr_t l);
@@ -123,7 +124,7 @@ if ffi.abi"win" then
   assert(count > 10)
 end
 
-do
+do --- callback free, callback set
   local cb = ffi.cast("int(*)(void)", function() return 1 end)
   assert(cb() == 1)
   cb:free()
@@ -136,7 +137,7 @@ do
   assert(cb() == 3)
 end
 
-do
+do --- compiled free of function
   local ft = ffi.typeof("void(*)(void)")
   local function f() end
   local t = {}
@@ -146,11 +147,11 @@ do
   end
 end
 
-do
+do --- fast function cast string.byte
   assert(ffi.cast("int (*)()", function() return string.byte"A" end)() == 65)
 end
 
-do
+do --- debug.traceback cast
   local f = ffi.cast("void (*)(void)", function() debug.traceback() end)
   debug.sethook(function() debug.sethook(nil, "", 0); f() end, "", 1)
   local x
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 599a0182..9a22104a 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -5,6 +5,7 @@ err.lua
 ffi_arith_ptr.lua
 ffi_bitfield.lua
 ffi_call.lua
+ffi_callback.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (6 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
                     ` (2 more replies)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
                   ` (21 subsequent siblings)
  29 siblings, 3 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes the `dofile()` (which uses an unreliable relative
file path and mutates `_G` with global functions to be defined) to the
corresponding `require()`.  Also, it names the only one test as "misc"
and includes the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_const.lua | 4 ++--
 test/LuaJIT-tests/lib/ffi/index         | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
index d42133ad..3213156d 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
@@ -1,6 +1,6 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local fails = require("common.fails")
 
 ffi.cdef[[
 typedef struct s_t {
@@ -41,7 +41,7 @@ typedef struct foo_t {
 } foo_t;
 ]]
 
-do
+do --- misc
   local foo_t = ffi.typeof("foo_t")
   local x = foo_t()
 
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 9a22104a..0a72daed 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -6,6 +6,7 @@ ffi_arith_ptr.lua
 ffi_bitfield.lua
 ffi_call.lua
 ffi_callback.lua
+ffi_const.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (7 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
                     ` (2 more replies)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches
                   ` (20 subsequent siblings)
  29 siblings, 3 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding require and renames the C library in the `require()` call.
It adds groups with the names of subtests and enables the test in
<index>. It renames structure and enum typedefs to avoid conflicts with
cdef in other tests. The GC threshold is increased since all tests run
in a single process, so the number of GC objects is greater.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_convert.lua | 35 +++++++++++------------
 test/LuaJIT-tests/lib/ffi/index           |  1 +
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
index bd3fb1f9..284f2b53 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
@@ -1,8 +1,7 @@
 local ffi = require("ffi")
 
-local ctest = require("ctest")
-
-dofile("../common/ffi_util.inc")
+local ctest = require("libctest")
+local fails = require("common.fails")
 
 local tonumber = tonumber
 
@@ -32,15 +31,15 @@ typedef struct arrinc_t {
   int a[];
 } arrinc_t;
 
-typedef enum uenum_t {
+typedef enum uenum_convert_t {
   UE0, UE71 = 71, UE72
-} uenum_t;
+} uenum_convert_t;
 
-typedef enum ienum_t {
+typedef enum ienum_convert_t {
   IE0, IEM12 = -12, IEM11
-} ienum_t;
+} ienum_convert_t;
 
-typedef struct foo_t {
+typedef struct foo_convert_t {
   bool b;
   int8_t i8;
   uint8_t u8;
@@ -79,9 +78,9 @@ typedef struct foo_t {
   int si_guard;
   nest_t sn;
   uni_t ui;
-  uenum_t ue;
-  ienum_t ie;
-} foo_t;
+  uenum_convert_t ue;
+  ienum_convert_t ie;
+} foo_convert_t;
 
 char *strcpy(char *dest, const char *src);
 typedef struct FILE FILE;
@@ -89,11 +88,11 @@ int fileno(FILE *stream);
 int _fileno(FILE *stream);
 ]]
 
-do
-  local foo_t = ffi.typeof("foo_t")
-  local sz = ffi.sizeof(foo_t)
-  local x = foo_t()
-  local y = foo_t()
+do --- misc
+  local foo_convert_t = ffi.typeof("foo_convert_t")
+  local sz = ffi.sizeof(foo_convert_t)
+  local x = foo_convert_t()
+  local y = foo_convert_t()
   ffi.fill(x, sz, 0xff)
   ffi.fill(y, sz, 0xee)
 
@@ -769,7 +768,7 @@ do
   x.ppf = ffi.C.strcpy
 end
 
-do
+do --- GC cdata __index
   collectgarbage()
   local oc = collectgarbage("count")
   local cd = ffi.new"struct { struct { int a; } x;}"
@@ -780,7 +779,7 @@ do
   for i=1,2 do
     f(cd)
     local nc = collectgarbage("count")
-    assert(nc < oc + 200, "GC step missing for cdata __index")
+    assert(nc < oc * 3, "GC step missing for cdata __index")
     jit.off(f)
   end
 end
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 0a72daed..5c2be87f 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -7,6 +7,7 @@ ffi_bitfield.lua
 ffi_call.lua
 ffi_callback.lua
 ffi_const.lua
+ffi_convert.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (8 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 14:59   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:07   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches
                   ` (19 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes the `dofile()` (which uses an unreliable relative
file path and mutates `_G` with global functions to be defined) to the
corresponding `require()` call and renames the C library in the
`require()` call. Also, it names all subtests and includes the test in
<index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_enum.lua | 11 +++++------
 test/LuaJIT-tests/lib/ffi/index        |  1 +
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
index e8e40ad0..49c874c7 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
@@ -1,7 +1,7 @@
 
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local fails = require("common.fails")
 
 ffi.cdef[[
 typedef enum enum_i { FOO_I = -1, II = 10 } enum_i;
@@ -13,10 +13,9 @@ int call_i_ei(enum_i a) asm("call_i");
 int call_i_eu(enum_u a) asm("call_i");
 ]]
 
-local C = ffi.load("../clib/ctest")
-
-do
+local C = ffi.load("ctest")
 
+do --- base
   local t = ffi.new("enum_i[100]")
   for i=0,99 do t[i] = "II" end
   for i=0,99 do assert(t[i] == "II") end
@@ -42,14 +41,14 @@ do
   for i=0,99 do assert(t[i] ~= u[i]) end
 end
 
-do
+do --- calls
   for i=0,99 do assert(C.call_ei_i(9) == "II") end
   for i=0,99 do assert(C.call_eu_i(9) == "UU") end
   for i=0,99 do assert(C.call_i_ei("II") == 11) end
   for i=0,99 do assert(C.call_i_eu("UU") == 11) end
 end
 
-do
+do --- cast to bool
   local f = ffi.cast("bool (*)(enum_i)", function(e) return e == "II" end)
   assert(f("II"))
   assert(not f(0))
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 5c2be87f..b11e5aa4 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -8,6 +8,7 @@ ffi_call.lua
 ffi_callback.lua
 ffi_const.lua
 ffi_convert.lua
+ffi_enum.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (9 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 15:07   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:10   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
                   ` (18 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch declares functions as local to avoid pollution of the global
environment. It separates the body of the test in the `do` `while` block
and includes the test in <index>.

Part of tarantool/tarantool#9398
---
 .../lib/ffi/ffi_gcstep_recursive.lua          | 27 ++++++++++---------
 test/LuaJIT-tests/lib/ffi/index               |  1 +
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
index cb19df11..f6e0b009 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
@@ -1,6 +1,6 @@
 -- From Robert G. Jakabosky, 2012-03-20
 
-local N=tonumber(arg[1] or 10000)
+local N= 10000
 
 local ffi=require"ffi"
 
@@ -19,7 +19,7 @@ local function obj_to_id(ptr)
   return tonumber(ffi.cast('uintptr_t', ffi.cast('void *', ptr)))
 end
 
-function obj_type_Buffer_push(val)
+local function obj_type_Buffer_push(val)
   local obj = Buffer(val)
   local id = obj_to_id(obj)
   nobj_obj_flags[id] = true
@@ -31,7 +31,7 @@ local function Buffer_new(len)
   return obj_type_Buffer_push(buf)
 end
 
-function obj_type_Buffer_delete(obj)
+local function obj_type_Buffer_delete(obj)
   local id = obj_to_id(obj)
   if not nobj_obj_flags[id] then return nil end
   nobj_obj_flags[id] = nil
@@ -52,15 +52,16 @@ Buffer_mt.__index.close = Buffer_close
 
 ffi.metatype(Buffer, Buffer_mt)
 
-local cdata = {}
-for x=1,2 do
-  cdata = {}
-  for i=1,N do
-    cdata[i] = Buffer_new(1)
+do --- buffer test
+  local cdata = {}
+  for x=1,2 do
+    cdata = {}
+    for i=1,N do
+      cdata[i] = Buffer_new(1)
+    end
+    for i=1,N do
+      cdata[i]:close()
+    end
+    cdata = nil
   end
-  for i=1,N do
-    cdata[i]:close()
-  end
-  cdata = nil
 end
-
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index b11e5aa4..8236ab98 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -9,6 +9,7 @@ ffi_callback.lua
 ffi_const.lua
 ffi_convert.lua
 ffi_enum.lua
+ffi_gcstep_recursive.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (10 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-01-31 15:15   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:12   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches
                   ` (17 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch names all subtests and includes the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua | 22 ++++++++++-----------
 test/LuaJIT-tests/lib/ffi/index             |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
index 0554fe60..efe83cfd 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
@@ -1,6 +1,6 @@
 local ffi = require("ffi")
 
-do
+do --- int64_t arithmetic
   local a = ffi.new("int64_t[?]", 101)
   for i=1,100 do a[i] = -2 end
   for i=1,100 do a[i] = i end
@@ -29,7 +29,7 @@ do
   assert(w == 5050)
 end
 
-do
+do --- uint64_t arithmetic
   local a = ffi.new("uint64_t[?]", 101)
   for i=1,100 do a[i] = i end
   local x, y, m = 0ull, 0ull, 0ull
@@ -48,32 +48,32 @@ do
   assert(z == 0x123456789abcdef0ull % 100)
 end
 
-do
+do --- bit operations LL
   local x = 0ll
   for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ll) end
   assert(x == 262120)
 end
 
-do
+do --- bit operations LL, non-const base on trace
   local x, a = 0ll, -2ll
   for i=1,100 do x = x + a ^ (bit.band(i, 15)+1ll) end
   assert(x == 262120)
 end
 
-do
+do --- bit operations ULL
   local x = 0ull
   for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ull) end
   assert(x == 262120)
 end
 
-do
+do --- number vs. cdata interoperability
   for i=1,200 do local j = bit.band(i, 7); assert((j == 0ll) == (j == 0)) end
   for i=1,200 do assert((i < 100ll) == (i < 100)) end
   for i=1,200 do assert((i <= 100ll) == (i <= 100)) end
   for i=-100,100 do assert((i > 100ull) == (i < 0)) end
 end
 
-do
+do --- comparisons checksum
   local a = ffi.new("int64_t[?]", 100)
   for i=0,99 do
     a[i] = math.random(0, 2^32)*0x100000000LL + math.random(0, 2^32)
@@ -121,13 +121,13 @@ do
   end
 end
 
-do
+do --- pointer subtraction
   local a, b = ffi.new("char *"), ffi.new("char *")
   local z
   for i=1,100 do z = a-b end
 end
 
-do
+do --- char and 0LL base comparisons
   local x = true
   local abc = ffi.cast("const char *", "abc")
   for i=1,100 do x = abc == "abc" end
@@ -142,8 +142,8 @@ do
   assert(x == false)
 end
 
--- ra_destpair
-do
+
+do --- ra_destpair
   local x, y = 0, 0
   for i=1,100 do
     x = x + i/3LL
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 8236ab98..0c1e5e66 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -10,6 +10,7 @@ ffi_const.lua
 ffi_convert.lua
 ffi_enum.lua
 ffi_gcstep_recursive.lua
+ffi_jit_arith.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (11 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  8:30   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:15   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches
                   ` (16 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch uses the basename of the ctest library to be loaded via FFI.
It adds groups with the names of subtests and enables the test in
<index>. The corresponding conditions are changed to the tags checked by
analogy with other tests. Tests with calls with 10 arguments with sizes
less than 8 bits are dummy for M1. This suite lacks a mechanism to skip
subtests satisfying complicated conditions, so it is done manually by
the corresponding `if` check.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua | 70 ++++++++++++----------
 test/LuaJIT-tests/lib/ffi/index            |  1 +
 2 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
index b79d60b1..ee9dd5f0 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
@@ -35,33 +35,37 @@ double __stdcall stdcall_dd(double a, double b);
 float __stdcall stdcall_ff(float a, float b);
 ]]
 
-local lib = ffi.load("../clib/ctest")
-
-do
-  local x
-  for i=1,100 do
-    x = lib.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234)
+local lib = ffi.load("ctest")
+
+do --- 10 int args
+  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
+    local x
+    for i=1,100 do
+      x = lib.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234)
+    end
+    assert(x == -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
   end
-  assert(x == -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
 end
 
-do
+do --- 17 double args
   for i=1,100 do
     pcall(lib.call_max, i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i)
   end
 end
 
-if ffi.abi("64bit") then
-  local y = ffi.cast("void *", 0x123456789abcdefLL)
-  local x
-  for i=1,100 do
-    lib.call_10j_p(0,0,0,0,0,0,0,0,0, y)
-    x = lib.call_10j_p(0,0,0,0,0,0,0,0,0, nil)
+do --- 10 ints 1 pointer args +abi64
+  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
+    local y = ffi.cast("void *", 0x123456789abcdefLL)
+    local x
+    for i=1,100 do
+      lib.call_10j_p(0,0,0,0,0,0,0,0,0, y)
+      x = lib.call_10j_p(0,0,0,0,0,0,0,0,0, nil)
+    end
+    assert(x == 0)
   end
-  assert(x == 0)
 end
 
-do
+do --- int, int64_t args
   local x = 0
   for i=1,100 do
     x = x + lib.call_ij(100+i, i*0x300000002LL)
@@ -69,7 +73,7 @@ do
   assert(x == 0x3b2e0000623eLL)
 end
 
-do
+do --- 10 double args
   local x
   for i=1,100 do
     x = lib.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75)
@@ -77,15 +81,17 @@ do
   assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
 end
 
-do
-  local x
-  for i=1,100 do
-    x = lib.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75)
+do --- 10 float args
+  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
+    local x
+    for i=1,100 do
+      x = lib.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75)
+    end
+    assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
   end
-  assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
 end
 
-do
+do --- boolean result
   local x
   for i=-100,100 do
     if not lib.call_b(i) then x = i end
@@ -100,14 +106,14 @@ do
   assert(x == 90)
 end
 
-do
+do --- boolean result, tail call
   local function tail(x)
     return lib.call_b(x)
   end
   for i=1,100 do local a,b,c = tail(1), tail(1), tail(1) end
 end
 
-do
+do --- int8_t, uint8_t, int16_t, uint16_t args and results
   local x = 0
   for i=0x01010080,0x010100ff do x = x + lib.call_i_i8(i) end
   assert(x == -8128)
@@ -135,7 +141,7 @@ do
 end
 
 -- target-specific
-if jit.arch == "x86" then
+do --- fastcall +x86
   for i=1,100 do assert(lib.fastcall_i(-42) == -41) end
   for i=1,100 do assert(lib.fastcall_ii(-42, 17) == -42+17) end
   for i=1,100 do assert(lib.fastcall_iii(-42, 17, 139) == -42+17+139) end
@@ -143,12 +149,12 @@ if jit.arch == "x86" then
   for i=1,100 do assert(lib.fastcall_dd(12.5, -3.25) == 12.5-3.25) end
   local x = lib.fastcall_ji
   for i=1,100 do assert(x(0x123456789LL, -17) == 0x123456789LL-17) end
+end
 
-  if jit.os == "Windows" then
-    for i=1,100 do assert(lib.stdcall_i(-42) == -41) end
-    for i=1,100 do assert(lib.stdcall_ii(-42, 17) == -42+17) end
-    for i=1,100 do assert(lib.stdcall_dd(12.5, -3.25) == 12.5-3.25) end
-    for i=1,100 do assert(lib.stdcall_ff(12.5, -3.25) == 12.5-3.25) end
-  end
+do --- stdcall +x86 +windows
+  for i=1,100 do assert(lib.stdcall_i(-42) == -41) end
+  for i=1,100 do assert(lib.stdcall_ii(-42, 17) == -42+17) end
+  for i=1,100 do assert(lib.stdcall_dd(12.5, -3.25) == 12.5-3.25) end
+  for i=1,100 do assert(lib.stdcall_ff(12.5, -3.25) == 12.5-3.25) end
 end
 
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 0c1e5e66..d6e2b64a 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -11,6 +11,7 @@ ffi_convert.lua
 ffi_enum.lua
 ffi_gcstep_recursive.lua
 ffi_jit_arith.lua
+ffi_jit_call.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (12 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  8:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 12:51   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches
                   ` (15 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch renames the C library in the `require()` call. It adds
groups with the names of subtests and enables the test in <index>. It
renames enum definitions to avoid conflicts with cdef in other tests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua | 70 +++++++++++-----------
 test/LuaJIT-tests/lib/ffi/index            |  1 +
 2 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
index d4707db7..0e64fe75 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
@@ -1,8 +1,8 @@
 local ffi = require("ffi")
 
-local ctest = require("ctest")
+local ctest = require("libctest")
 
-do
+do --- int32_t, narrowed
   local s = ffi.new("struct { int32_t x; }")
   s.x = -0x12345678
   for i=1,100 do
@@ -11,7 +11,7 @@ do
   assert(s.x == -0x12345678+100)
 end
 
-do
+do --- uint32_t, CONV num.u32 u32.num
   local s = ffi.new("struct { uint32_t x; }")
   s.x = 0x81234567
   for i=1,100 do
@@ -20,7 +20,7 @@ do
   assert(s.x == 0x81234567+100)
 end
 
-do
+do --- int8_t, CONV.int.i8 forwarding
   local s = ffi.new("struct { int8_t x; }")
   s.x = 42
   for i=1,100 do
@@ -30,7 +30,7 @@ do
   assert(s.x == 142-256)
 end
 
-do
+do --- uint8_t, CONV.int.u8 forwarding
   local s = ffi.new("struct { uint8_t x; }")
   s.x = 200
   for i=1,100 do
@@ -40,7 +40,7 @@ do
   assert(s.x == 300-256)
 end
 
-do
+do --- int16_t, CONV.int.i16 forwarding
   local s = ffi.new("struct { int16_t x; }")
   s.x = 32700
   for i=1,100 do
@@ -50,7 +50,7 @@ do
   assert(s.x == 32800-65536)
 end
 
-do
+do --- uint16_t, CONV.int.u16 forwarding
   local s = ffi.new("struct { uint16_t x; }")
   s.x = 65450
   for i=1,100 do
@@ -60,7 +60,7 @@ do
   assert(s.x == 65550-65536)
 end
 
-do
+do --- union i32 u32, forwarding num.int num.u32
   local s = ffi.new("union { int32_t x; uint32_t y; }")
   s.x = 0x7fffffff - 60
   local x,y = 0,0
@@ -75,7 +75,7 @@ do
   assert(x == y - 40*2^32)
 end
 
-do
+do --- union i32 u32, forwarding CONV.int.u32
   local s = ffi.new("union { int32_t x; uint32_t y; }")
   local x, z = 0, 2^31 + 42
   for i=1,100 do
@@ -85,7 +85,7 @@ do
   assert(x == 100*(-2^31 + 42))
 end
 
-do
+do --- union i8 u8, forwarding CONV.int.i8 CONV.num.int
   local s = ffi.new("union { int8_t x; uint8_t y; }")
   s.x = 42
   local x,y = 0,0
@@ -100,7 +100,7 @@ do
   assert(x == y - (100-(127-42))*256)
 end
 
-do
+do --- tobit + CONV.num.u32, 1
   local a = ffi.new("uint32_t[?]", 101)
   for i=1,100 do a[i] = 0x80000000+i end
   local x = 0
@@ -110,7 +110,7 @@ do
   assert(x == 100)
 end
 
-do
+do --- tobit + CONV.num.u32, 2
   local a = ffi.new("uint32_t[?]", 101)
   for i=1,100 do a[i] = 0x80000000+i end
   local x = 0
@@ -120,7 +120,7 @@ do
   assert(x == -0x80000000+100)
 end
 
-do
+do --- CONV.num.flt
   local v = ffi.new("float", 12.5)
   local x = 0
   for i=1,100 do
@@ -129,7 +129,7 @@ do
   assert(x == 100*12.5)
 end
 
-do
+do --- CONV.num.u32
   local v = ffi.new("uint32_t", 0x80000000)
   local x = 0
   for i=1,100 do
@@ -138,7 +138,7 @@ do
   assert(x == 100*0x80000000)
 end
 
-do
+do --- CONV.num.i64
   local v = ffi.new("int64_t", 0x1234567800000000ll)
   local x = 0
   for i=1,100 do
@@ -147,7 +147,7 @@ do
   assert(x == 100*0x12345678*2^32)
 end
 
-do
+do --- CONV.num.u64
   local v = ffi.new("uint64_t", 0x89abcdef00000000ull)
   local x = 0
   for i=1,100 do
@@ -156,7 +156,7 @@ do
   assert(x == 100*0x89abcdef*2^32)
 end
 
-do
+do --- CONV.num.i64, overflow
   local a = ffi.new("int64_t[?]", 101)
   for i=1,100 do a[i] = -i end
   local x = 0
@@ -166,7 +166,7 @@ do
   assert(x == -5050)
 end
 
-do
+do --- CONV.num.u64, overflow
   local a = ffi.new("uint64_t[?]", 101)
   for i=1,100 do a[i] = 2^63+2^32*i end
   local x = 0
@@ -176,7 +176,7 @@ do
   assert(x == 2^63*100+2^32*5050)
 end
 
-do
+do --- tonumber(complex)
   local v = ffi.new("complex", 12.5, -3.25)
   local x = 0
   for i=1,100 do
@@ -185,7 +185,7 @@ do
   assert(x == 100*12.5)
 end
 
-do
+do --- const on trace i64
   local s = ffi.new("struct { int64_t x;}")
   for i=1,100 do
     s.x = 0x123456789abcdef0LL
@@ -193,7 +193,7 @@ do
   assert(tonumber(s.x) == tonumber(0x123456789abcdef0LL))
 end
 
-do
+do --- const on trace u64
   local s = ffi.new("struct { uint64_t x;}")
   for i=1,100 do
     s.x = 0x823456789abcdef0ULL
@@ -201,27 +201,27 @@ do
   assert(tonumber(s.x) == tonumber(0x823456789abcdef0ULL))
 end
 
-do
+do --- enum recording
   ffi.cdef[[
-  typedef enum { AA, BB, CC = -42 } foo_i;
-  typedef enum { DD, EE, FF = 0x80000000u } foo_u;
+  typedef enum { AAA, BBB, CCC = -42 } foo_i;
+  typedef enum { DDD, EEE, FFF = 0x80000000u } foo_u;
   ]]
   local s = ffi.new("struct { foo_i x; foo_u y;}")
   for i=1,100 do
-    s.x = "CC"
+    s.x = "CCC"
     assert(s.x == -42)
-    s.x = "BB"
+    s.x = "BBB"
     assert(s.x == 1)
-    s.y = "FF"
+    s.y = "FFF"
     assert(s.y == 0x80000000)
   end
   local st = ffi.typeof(s)
   for i=1,100 do s = st() end
   assert(s.x == 0 and s.y == 0)
-  for i=1,100 do s = st("CC", "EE") end
+  for i=1,100 do s = st("CCC", "EEE") end
   assert(s.x == -42 and s.y == 1)
-  local ei = ffi.new("foo_i", "CC")
-  local eu = ffi.new("foo_u", "EE")
+  local ei = ffi.new("foo_i", "CCC")
+  local eu = ffi.new("foo_u", "EEE")
   for i=1,100 do s = st(ei, eu) end
   assert(s.x == -42 and s.y == 1)
   local x
@@ -229,7 +229,7 @@ do
   assert(x == -42)
 end
 
-do
+do --- const char* recording
   local s = ffi.new("struct { const char *x; const char *y;}")
   local a, tmp = "abcd", "ab"
   for i=1,100 do
@@ -240,7 +240,7 @@ do
   assert(ffi.string(s.y) == "ab")
 end
 
-do
+do --- bool int double recording
   local s = ffi.new("struct { bool b[200]; int i[200]; double d[200];}")
   for i=0,199 do s.i[i] = i-100; s.d[i] = i-100 end
   for i=0,99 do s.b[i] = 0 end
@@ -253,13 +253,13 @@ do
   for i=0,199 do assert(s.b[i] == (i ~= 100)) end
 end
 
-do
+do --- int16_t array arithmetic
   local a = ffi.new("int16_t[100]", 1)
   for i=1,99 do a[i] = a[i] + a[i-1] end
   assert(a[99] == 100)
 end
 
-do
+do --- ligud to pointer
   local ud = ctest.lightud(12345678)
   local s = ffi.new("struct { void *p; }")
   for i=1,100 do
@@ -269,7 +269,7 @@ do
   assert(ffi.cast("uintptr_t", s.p) == 12345678)
 end
 
-do
+do --- reference type initialization
   local x = ffi.new("struct { int & x;}", ffi.new("int[1]", 42))
   local z
   for i=1,100 do z = x.x end
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index d6e2b64a..71def57b 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -12,6 +12,7 @@ ffi_enum.lua
 ffi_gcstep_recursive.lua
 ffi_jit_arith.lua
 ffi_jit_call.lua
+ffi_jit_conv.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (13 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  8:38   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 12:53   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches
                   ` (14 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes the `dofile()` (which uses an unreliable relative
file path and mutates `_G` with global functions to be defined) to the
corresponding `require()`. Also, it adds groups with the names of
subtests and enables the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua | 72 +++++++++++---------
 test/LuaJIT-tests/lib/ffi/index              |  1 +
 2 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
index e26650ef..ca6c65c5 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
@@ -1,6 +1,6 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local checkfail = require("common.ffi.checkfail")
 
 local function checklex(t)
   for i=1,1e9,2 do
@@ -14,38 +14,42 @@ local function checklex(t)
   end
 end
 
-checklex{
-  "0LL",			"0ll",
-  "0LL",			"0LL",
-  "0ULL",			"0ull",
-  "0ULL",			"0ULl",
-  "18446744073709551615ULL",	"18446744073709551615llu",
-  "9223372036854775807LL",	"0x7fffffffffffffffll",
-  "9223372036854775808ULL",	"0x8000000000000000ull",
-  "1311768467463790320LL",	"0x123456789abcdef0ll",
-  "-1LL",			"-1ll",
-  "18446744073709551615ULL",	"-1ull",
-  "-9223372036854775807LL",	"-0x7fffffffffffffffll",
-  "9223372036854775808ULL",	"-0x8000000000000000ull",
-  "0+0i",			"0i",
-  "0+0i",			"0I",
-  "0+12.5i",			"12.5i",
-  "0+4660i",			"0x1234i",
-  "0+infI",			"1e400i",
-  "0-infI",			"-1e400i",
-  "0-12.5i",			"-12.5i",
-  "0-0i",			"-0i",
-}
+do --- checklex
+  checklex{
+    "0LL",			"0ll",
+    "0LL",			"0LL",
+    "0ULL",			"0ull",
+    "0ULL",			"0ULl",
+    "18446744073709551615ULL",	"18446744073709551615llu",
+    "9223372036854775807LL",	"0x7fffffffffffffffll",
+    "9223372036854775808ULL",	"0x8000000000000000ull",
+    "1311768467463790320LL",	"0x123456789abcdef0ll",
+    "-1LL",			"-1ll",
+    "18446744073709551615ULL",	"-1ull",
+    "-9223372036854775807LL",	"-0x7fffffffffffffffll",
+    "9223372036854775808ULL",	"-0x8000000000000000ull",
+    "0+0i",			"0i",
+    "0+0i",			"0I",
+    "0+12.5i",			"12.5i",
+    "0+4660i",			"0x1234i",
+    "0+infI",			"1e400i",
+    "0-infI",			"-1e400i",
+    "0-12.5i",			"-12.5i",
+    "0-0i",			"-0i",
+  }
+end
 
-checkfail({
-  "0l",
-  "0lll",
-  "0u",
-  "0ul",
-  "0ulll",
-  "0wll",
-  "0xll",
-  ".0ll",
-  "0ii",
-}, function(s) assert(loadstring("return "..s)) end)
+do --- checkfail
+  checkfail({
+    "0l",
+    "0lll",
+    "0u",
+    "0ul",
+    "0ulll",
+    "0wll",
+    "0xll",
+    ".0ll",
+    "0ii",
+  }, function(s) assert(loadstring("return "..s)) end)
+end
 
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 71def57b..833c31e3 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -13,6 +13,7 @@ ffi_gcstep_recursive.lua
 ffi_jit_arith.lua
 ffi_jit_call.lua
 ffi_jit_conv.lua
+ffi_lex_number.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (14 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  8:40   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 12:58   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches
                   ` (13 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper function. It adds test names and
includes the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_metatype.lua | 16 ++++++++--------
 test/LuaJIT-tests/lib/ffi/index            |  1 +
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
index 2db717f4..b0054b1a 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
@@ -1,6 +1,6 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local fails = require("common.fails")
 
 ffi.cdef[[
 typedef struct { int x; } idx1_t;
@@ -14,7 +14,7 @@ local function ptreq(a, b)
   return ffi.cast("void *", a) == ffi.cast("void *", b)
 end
 
-do
+do --- metatype index newindex
   local nidx = {}
   local tp = ffi.metatype("idx1_t", {
     __index = { foo = 99, method = function(c, v) return v end },
@@ -45,7 +45,7 @@ do
   fails(function(cp) cp.bar = 42 end, cp)
 end
 
-do
+do --- metatype index newindex with upvalues
   local uc, uk, uv
   local tp = ffi.metatype("idx2_t", {
     __index = function(c, k, x, y)
@@ -78,7 +78,7 @@ do
   fails(function(p) p[0] = 11 end, p)
 end
 
-do
+do --- metatype index newindex with upvalues via setmetatable
   local uc, uk, uv
   local ti, tn = {}, {}
   local tp = ffi.metatype("idx3_t", {
@@ -103,7 +103,7 @@ do
   uc, uk, uv = nil, nil, nil
 end
 
-do
+do --- metatype arith
   local tp
   tp = ffi.metatype("arith_t", {
     __add = function(a, b) return tp(a.x+b.x, a.y+b.y) end,
@@ -174,7 +174,7 @@ do
   assert(x == 3000)
 end
 
-do
+do --- metatype GC
   local count = 0
   local tp = ffi.metatype("gc_t", {
     __gc = function(x) count = count + 1 end,
@@ -206,7 +206,7 @@ do
   assert(count == 103)
 end
 
-do
+do --- metatype new, type change
   local tp = ffi.metatype([[
 struct {
   static const int Z42 = 42;
@@ -236,7 +236,7 @@ struct {
   assert(o.x == 5)
 end
 
-do
+do --- metatype is other cdata
   local fb = ffi.new("struct { int x; }", 99)
   local xt = ffi.metatype("struct { }", { __index = fb })
   local o = xt()
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 833c31e3..338a6930 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -14,6 +14,7 @@ ffi_jit_arith.lua
 ffi_jit_call.lua
 ffi_jit_conv.lua
 ffi_lex_number.lua
+ffi_metatype.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (15 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  8:43   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:03   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches
                   ` (12 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding require of the helper function. It adds groups with the
names of subtests and enables the test in <index>. It renames structures
typedefs to avoid conflicts with cdef in other tests. The GC threshold
is increased since all tests run in a single process, so the number of
GC objects is greater.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_new.lua | 50 +++++++++++++--------------
 test/LuaJIT-tests/lib/ffi/index       |  1 +
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
index 9cdbd538..e5b19053 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
@@ -1,37 +1,37 @@
 local ffi = require("ffi")
 local bit = require("bit")
 
-dofile("../common/ffi_util.inc")
+local fails = require("common.fails")
 
 ffi.cdef([[
-typedef struct { int a,b,c; } foo1_t;
-typedef int foo2_t[?];
+typedef struct { int a,b,c; } foo1_new_t;
+typedef int foo2_new_t[?];
 void *malloc(size_t size);
 void free(void *ptr);
 ]])
 
-do
-  assert(ffi.sizeof("foo1_t") == 12)
-  local cd = ffi.new("foo1_t")
+do --- foo1_new_t
+  assert(ffi.sizeof("foo1_new_t") == 12)
+  local cd = ffi.new("foo1_new_t")
   assert(ffi.sizeof(cd) == 12)
-  local foo1_t = ffi.typeof("foo1_t")
-  assert(ffi.sizeof(foo1_t) == 12)
-  cd = foo1_t()
+  local foo1_new_t = ffi.typeof("foo1_new_t")
+  assert(ffi.sizeof(foo1_new_t) == 12)
+  cd = foo1_new_t()
   assert(ffi.sizeof(cd) == 12)
 end
 
-do
-  assert(ffi.sizeof("foo2_t", 3) == 12)
-  local cd = ffi.new("foo2_t", 3)
+do --- foo2_new_t
+  assert(ffi.sizeof("foo2_new_t", 3) == 12)
+  local cd = ffi.new("foo2_new_t", 3)
   assert(ffi.sizeof(cd) == 12)
-  local foo2_t = ffi.typeof("foo2_t")
-  fails(ffi.sizeof, foo2_t)
-  assert(ffi.sizeof(foo2_t, 3) == 12)
-  cd = foo2_t(3)
+  local foo2_new_t = ffi.typeof("foo2_new_t")
+  fails(ffi.sizeof, foo2_new_t)
+  assert(ffi.sizeof(foo2_new_t, 3) == 12)
+  cd = foo2_new_t(3)
   assert(ffi.sizeof(cd) == 12)
 end
 
-do
+do --- byte to int cast
   local tpi = ffi.typeof("int")
   local tpb = ffi.typeof("uint8_t")
   local t = {}
@@ -42,7 +42,7 @@ do
   assert(x == 199*257 + 1)
 end
 
-do
+do --- aligned structure GC
   local oc = collectgarbage("count")
   for al=0,15 do
     local align = 2^al -- 1, 2, 4, ..., 32768
@@ -54,17 +54,17 @@ do
     end
   end
   local nc = collectgarbage("count")
-  assert(nc < oc + 3000, "GC step missing for ffi.new")
+  assert(nc < oc * 10, "GC step missing for ffi.new")
 end
 
-do
+do --- VLA
   local t = {}
   for i=1,100 do t[i] = ffi.new("int[?]", i) end
   assert(ffi.sizeof(t[100]) == 400)
   for i=0,99 do assert(t[100][i] == 0) end
 end
 
-do
+do --- VLS
   local t = {}
   local ct = ffi.typeof("struct { double x; int y[?];}")
   for i=1,100 do t[i] = ct(i) end
@@ -72,7 +72,7 @@ do
   for i=0,99 do assert(t[100].y[i] == 0) end
 end
 
-do
+do --- aligned(16) structure exit from trace
   local ct = ffi.typeof("struct __attribute__((aligned(16))) { int x; }")
   local y
   for i=1,200 do
@@ -82,7 +82,7 @@ do
   assert(bit.band(ffi.cast("intptr_t", ffi.cast("void *", y)), 15) == 0)
 end
 
-do
+do --- cdata resurrecting
   local q
   local p = ffi.gc(ffi.new("int[1]"), function(x) q = x end)
   p = nil
@@ -93,13 +93,13 @@ do
   assert(q == nil)
 end
 
-do
+do --- GC malloc free
   local p = ffi.gc(ffi.C.malloc(2^20), ffi.C.free)
   p = nil
   collectgarbage()
 end
 
-do
+do --- test lua_close() cleanup
   local p = ffi.gc(ffi.new("int[1]"), function(x) assert(type(x) == "cdata") end)
   -- test for lua_close() cleanup.
 end
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 338a6930..e6c1fd0f 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -15,6 +15,7 @@ ffi_jit_call.lua
 ffi_jit_conv.lua
 ffi_lex_number.lua
 ffi_metatype.lua
+ffi_new.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (16 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:01   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:08   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches
                   ` (11 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper functions. It adds groups with
the names of subtests and enables the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 ++++++++++--------
 test/LuaJIT-tests/lib/ffi/index               |   1 +
 2 files changed, 58 insertions(+), 49 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
index 3a9616d7..d3b02759 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
@@ -1,58 +1,66 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local checkfail = require("common.ffi.checkfail")
+local checktypes = require("common.ffi.checktypes")
+local fails = require("common.fails")
 
-checkfail{
-  "int [",
-  "int [-1]",
-  "int [[1]]",
-  "int [10][]",
-  "int [10][?]",
-  "int [][]",
-  "int [][?]",
-  "int [?][]",
-  "int [?][?]",
-  "int [0x10000][0x2000]",
-  "int [256][256][256][256]",
-  "int [10](void)",
-  "int (void)[10]",
-  "int &[10]",
-  "union { double x; int a[?]; }",
-}
+do --- checkfail
+  checkfail{
+    "int [",
+    "int [-1]",
+    "int [[1]]",
+    "int [10][]",
+    "int [10][?]",
+    "int [][]",
+    "int [][?]",
+    "int [?][]",
+    "int [?][?]",
+    "int [0x10000][0x2000]",
+    "int [256][256][256][256]",
+    "int [10](void)",
+    "int (void)[10]",
+    "int &[10]",
+    "union { double x; int a[?]; }",
+  }
+end
 
-ffi.cdef([[
-  typedef int foo1_t[10];
-  typedef foo1_t foo2_t[5];
-]])
-assert(ffi.sizeof("foo1_t") == 40)
-assert(ffi.sizeof("foo2_t") == 200)
+do --- sizeof of arrays
+  ffi.cdef([[
+    typedef int foo1_array_t[10];
+    typedef foo1_array_t foo2_array_t[5];
+  ]])
+  assert(ffi.sizeof("foo1_array_t") == 40)
+  assert(ffi.sizeof("foo2_array_t") == 200)
+end
 
-local P = ffi.sizeof("void *")
 
-checktypes{
-  10,	1,	"char [10]",
-  4*10,	4,	"int [10]",
-  4*10,	4,	"int [10]",
-  4*10*5, 4,	"int [10][5]",
-  4*10*5*3*2*7, 4,	"int [10][5][3][2][7]",
-  4*10*5, 4,	"int ([10])[5]",
-  P*10,	P,	"int *[10]",
-  P,	P,	"int (*)[10]",
-  P*5,	P,	"int (*[5])[10]",
-  8*10,	4,	"struct { int x; char y; } [10]",
-  P*5*10, P,	"volatile int *(* const *[5][10])(void)",
-  nil,	4,	"int []",
-  4*10,	8,	"int __attribute__((aligned(8))) [10]",
-  4*10,	8,	"__attribute__((aligned(8))) int [10]",
-  4*10,	8,	"int [10] __attribute__((aligned(8)))",
-  97,	1,	"char ['a']",
-  83,	1,	"char ['\\123']",
-  79,	1,	"char ['\x4F']",
-  5,	1,	"char [sizeof(\"aa\" \"bb\")]",
-  80,	8,	"double [10]",
-}
+do --- checktypes
+  local P = ffi.sizeof("void *")
+  checktypes{
+    10,	1,	"char [10]",
+    4*10,	4,	"int [10]",
+    4*10,	4,	"int [10]",
+    4*10*5, 4,	"int [10][5]",
+    4*10*5*3*2*7, 4,	"int [10][5][3][2][7]",
+    4*10*5, 4,	"int ([10])[5]",
+    P*10,	P,	"int *[10]",
+    P,	P,	"int (*)[10]",
+    P*5,	P,	"int (*[5])[10]",
+    8*10,	4,	"struct { int x; char y; } [10]",
+    P*5*10, P,	"volatile int *(* const *[5][10])(void)",
+    nil,	4,	"int []",
+    4*10,	8,	"int __attribute__((aligned(8))) [10]",
+    4*10,	8,	"__attribute__((aligned(8))) int [10]",
+    4*10,	8,	"int [10] __attribute__((aligned(8)))",
+    97,	1,	"char ['a']",
+    83,	1,	"char ['\\123']",
+    79,	1,	"char ['\x4F']",
+    5,	1,	"char [sizeof(\"aa\" \"bb\")]",
+    80,	8,	"double [10]",
+  }
+end
 
-do
+do --- sizeof VLA
   assert(ffi.sizeof("int [?]", 10) == 4*10)
   local id = ffi.typeof("const short [?]")
   assert(ffi.sizeof(id, 10) == 2*10)
@@ -64,7 +72,7 @@ do
   assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
 end
 
-do
+do --- sizeof VLS
   assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
   local id = ffi.typeof("struct { int x; short a[?]; }")
   assert(ffi.sizeof(id, 10) == 4+2*10)
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index e6c1fd0f..89773c0c 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -16,6 +16,7 @@ ffi_jit_conv.lua
 ffi_lex_number.lua
 ffi_metatype.lua
 ffi_new.lua
+ffi_parse_array.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (17 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:03   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:10   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches
                   ` (10 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper functions. It adds groups with
the names of subtests and enables the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 +++++++++---------
 test/LuaJIT-tests/lib/ffi/index               |   1 +
 2 files changed, 132 insertions(+), 120 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
index c054bcfb..3b49648c 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
@@ -1,131 +1,142 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local checkfail = require("common.ffi.checkfail")
+local checktypes = require("common.ffi.checktypes")
 
-checkfail{
-  "",
-  " ",
-  "\n",
-  "1",
-  ".",
-  ";",
-  ",",
-  "*",
-  "[]",
-  "()",
-  "(*)",
-  "//",
-  "/*",
-  "xyz",
-  "const",
-  "volatile",
-  "typedef",
-  "extern",
-  "static",
-  "auto",
-  "register",
-  "struct",
-  "union",
-  "sizeof",
-  "int int",
-  "int char",
-  "int double",
-  "int;",
-}
+do --- checkfail
+  checkfail{
+    "",
+    " ",
+    "\n",
+    "1",
+    ".",
+    ";",
+    ",",
+    "*",
+    "[]",
+    "()",
+    "(*)",
+    "//",
+    "/*",
+    "xyz",
+    "const",
+    "volatile",
+    "typedef",
+    "extern",
+    "static",
+    "auto",
+    "register",
+    "struct",
+    "union",
+    "sizeof",
+    "int int",
+    "int char",
+    "int double",
+    "int;",
+  }
+end
 
-checktypes{
-  1,	1,	"char",
-  1,	1,	" \n\r\t\vchar \n\r\t\v",
-  1,	1,	"ch\\\nar",
-  1,	1,	"char /* abc */",
-  1,	1,	"char /* abc */ const",
-  1,	1,	"char // abc\n const",
-}
+do --- char newlines
+  checktypes{
+    1,	1,	"char",
+    1,	1,	" \n\r\t\vchar \n\r\t\v",
+    1,	1,	"ch\\\nar",
+    1,	1,	"char /* abc */",
+    1,	1,	"char /* abc */ const",
+    1,	1,	"char // abc\n const",
+  }
+end
 
-checktypes{
-  nil,	1,	"void",
-  1,	1,	"bool",
-  1,	1,	"_Bool",
-  4,	4,	"_Bool int",
-  1,	1,	"char",
-  1,	1,	"signed char",
-  1,	1,	"unsigned char",
-  2,	2,	"short",
-  2,	2,	"signed short",
-  2,	2,	"unsigned short",
-  4,	4,	"int",
-  4,	4,	"signed int",
-  4,	4,	"unsigned int",
-  4,	4,	"signed",
-  4,	4,	"unsigned",
-  4,	4,	"float",
-  8,	8,	"long long",
-  8,	8,	"signed long long",
-  8,	8,	"unsigned long long",
-  8,	8,	"double",
-  -- NYI: long double is architecture- and compiler-specific.
-  8,	4,	"_Complex float",
-  16,	8,	"_Complex",
-  16,	8,	"_Complex double",
-}
+do --- base types
+  checktypes{
+    nil,	1,	"void",
+    1,	1,	"bool",
+    1,	1,	"_Bool",
+    4,	4,	"_Bool int",
+    1,	1,	"char",
+    1,	1,	"signed char",
+    1,	1,	"unsigned char",
+    2,	2,	"short",
+    2,	2,	"signed short",
+    2,	2,	"unsigned short",
+    4,	4,	"int",
+    4,	4,	"signed int",
+    4,	4,	"unsigned int",
+    4,	4,	"signed",
+    4,	4,	"unsigned",
+    4,	4,	"float",
+    8,	8,	"long long",
+    8,	8,	"signed long long",
+    8,	8,	"unsigned long long",
+    8,	8,	"double",
+    -- NYI: long double is architecture- and compiler-specific.
+    8,	4,	"_Complex float",
+    16,	8,	"_Complex",
+    16,	8,	"_Complex double",
+  }
+end
 
--- mode/vector_size attributes
-checktypes{
-  1,	1,	"int __attribute__((mode(QI)))",
-  2,	2,	"int __attribute__((mode(HI)))",
-  4,	4,	"int __attribute__((mode(SI)))",
-  8,	8,	"int __attribute__((mode(DI)))",
-  16,	16,	"int __attribute__((mode(TI)))",
-  32,	16,	"int __attribute__((mode(OI)))",
-  4,	4,	"float __attribute__((mode(SF)))",
-  8,	8,	"float __attribute__((mode(DF)))",
-  2,	2,	"int __attribute__((mode(V2QI)))",
-  16,	16,	"float __attribute__((mode(V4SF)))",
-  32,	16,	"double __attribute__((mode(V8SF)))",
-  8,	8,	"char __attribute__((vector_size(8)))",
-  16,	16,	"int __attribute__((vector_size(16)))",
-  32,	16,	"double __attribute__((vector_size(32)))",
-  64,	16,	"double __attribute__((vector_size(64)))",
-}
+do --- mode/vector_size attributes
+  checktypes{
+    1,	1,	"int __attribute__((mode(QI)))",
+    2,	2,	"int __attribute__((mode(HI)))",
+    4,	4,	"int __attribute__((mode(SI)))",
+    8,	8,	"int __attribute__((mode(DI)))",
+    16,	16,	"int __attribute__((mode(TI)))",
+    32,	16,	"int __attribute__((mode(OI)))",
+    4,	4,	"float __attribute__((mode(SF)))",
+    8,	8,	"float __attribute__((mode(DF)))",
+    2,	2,	"int __attribute__((mode(V2QI)))",
+    16,	16,	"float __attribute__((mode(V4SF)))",
+    32,	16,	"double __attribute__((mode(V8SF)))",
+    8,	8,	"char __attribute__((vector_size(8)))",
+    16,	16,	"int __attribute__((vector_size(16)))",
+    32,	16,	"double __attribute__((vector_size(32)))",
+    64,	16,	"double __attribute__((vector_size(64)))",
+  }
+end
 
--- ABI-specific types:
-local L = (ffi.abi("32bit") or ffi.abi("win")) and 4 or 8
-local P = ffi.abi("32bit") and 4 or 8
-local W = ffi.abi("win") and 2 or 4
+do --- ABI-specific types:
+  local L = (ffi.abi("32bit") or ffi.abi("win")) and 4 or 8
+  local P = ffi.abi("32bit") and 4 or 8
+  local W = ffi.abi("win") and 2 or 4
 
-checktypes{
-  L,	L,	"long",
-  L,	L,	"signed long",
-  L,	L,	"unsigned long",
-  P,	P,	"int *",
-  P,	P,	"int **",
-  4,	4,	"int * __ptr32",
-}
+  checktypes{
+    L,	L,	"long",
+    L,	L,	"signed long",
+    L,	L,	"unsigned long",
+    P,	P,	"int *",
+    P,	P,	"int **",
+    4,	4,	"int * __ptr32",
+  }
 
-checktypes{
-  P,	P,	"ptrdiff_t",
-  P,	P,	"size_t",
-  W,	W,	"wchar_t",
-  1,	1,	"int8_t",
-  2,	2,	"int16_t",
-  4,	4,	"int32_t",
-  8,	8,	"int64_t",
-  1,	1,	"uint8_t",
-  2,	2,	"uint16_t",
-  4,	4,	"uint32_t",
-  8,	8,	"uint64_t",
-  P,	P,	"intptr_t",
-  P,	P,	"uintptr_t",
-}
+  checktypes{
+    P,	P,	"ptrdiff_t",
+    P,	P,	"size_t",
+    W,	W,	"wchar_t",
+    1,	1,	"int8_t",
+    2,	2,	"int16_t",
+    4,	4,	"int32_t",
+    8,	8,	"int64_t",
+    1,	1,	"uint8_t",
+    2,	2,	"uint16_t",
+    4,	4,	"uint32_t",
+    8,	8,	"uint64_t",
+    P,	P,	"intptr_t",
+    P,	P,	"uintptr_t",
+  }
+end
 
-checktypes{
-  1,	8,	"char __attribute__((aligned(8)))",
-  1,	8,	"char __attribute((aligned(8)))",
-  1,	8,	"char __attribute__((__aligned__(8)))",
-  1,	8,	"__attribute__((aligned(8))) char",
-  1,	8,	"char __declspec(align(8))",
-  1,	8,	"__declspec(align(8)) char",
-  1,	2,	"char __attribute__((aligned(8))) const __attribute__((aligned(2)))",
-  1,	16,	"char __attribute__((aligned(8))) const __attribute__((aligned(16)))",
-}
+do --- attributes
+  checktypes{
+    1,	8,	"char __attribute__((aligned(8)))",
+    1,	8,	"char __attribute((aligned(8)))",
+    1,	8,	"char __attribute__((__aligned__(8)))",
+    1,	8,	"__attribute__((aligned(8))) char",
+    1,	8,	"char __declspec(align(8))",
+    1,	8,	"__declspec(align(8)) char",
+    1,	2,	"char __attribute__((aligned(8))) const __attribute__((aligned(2)))",
+    1,	16,	"char __attribute__((aligned(8))) const __attribute__((aligned(16)))",
+  }
+end
 
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 89773c0c..a805bdd0 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -17,6 +17,7 @@ ffi_lex_number.lua
 ffi_metatype.lua
 ffi_new.lua
 ffi_parse_array.lua
+ffi_parse_basic.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (18 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:05   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:11   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
                   ` (9 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper functions. It adds groups with
the names of subtests and enables the test in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua | 141 ++++++++++---------
 test/LuaJIT-tests/lib/ffi/index              |   1 +
 2 files changed, 77 insertions(+), 65 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
index 4bb5d903..cc123808 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
@@ -1,77 +1,88 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local checkfail = require("common.ffi.checkfail")
+local checktypes = require("common.ffi.checktypes")
 
-checkfail({
-  "int",
-  "int aa1; int aa2 ",
-  "static int x;",
-  "static const long long x = 1;", -- NYI
-  "static const double x = 1;",	   -- NYI
-  "static const bool x = 1;",	   -- NYI (intentional, need true/false)
-  "struct { static int x = 1; };",
-  ";;static int y"
-}, ffi.cdef)
+do --- checkfail
+  checkfail({
+    "int",
+    "int aa1; int aa2 ",
+    "static int x;",
+    "static const long long x = 1;", -- NYI
+    "static const double x = 1;",	   -- NYI
+    "static const bool x = 1;",	   -- NYI (intentional, need true/false)
+    "struct { static int x = 1; };",
+    ";;static int y"
+  }, ffi.cdef)
+end
 
-ffi.cdef[[
-static const int K_42a = 42;
-static const char K_42b = 42+256;
-static const short K_M1a = 65535;
-static const unsigned short K_65535a = 65535;
-static const int K_1b = 0xffffffff >> 31;
-static const int K_1c = 0xffffffffu >> 31;
-static const int K_M1b = (int)0xffffffff >> 31;
-]]
+do --- constants declarations
+   ffi.cdef[[
+   static const int K_42a = 42;
+   static const char K_42b = 42+256;
+   static const short K_M1a = 65535;
+   static const unsigned short K_65535a = 65535;
+   static const int K_1b = 0xffffffff >> 31;
+   static const int K_1c = 0xffffffffu >> 31;
+   static const int K_M1b = (int)0xffffffff >> 31;
+   ]]
 
-checktypes{
-  42,	1,	"char[K_42a]",
-  42,	1,	"char[K_42b]",
-  1,	1,	"char[-K_M1a]",
-  65535, 1,	"char[K_65535a]",
-  1,	1,	"char[K_1b]",
-  1,	1,	"char[K_1c]",
-  1,	1,	"char[-K_M1b]",
-}
+   checktypes{
+     42,	1,	"char[K_42a]",
+     42,	1,	"char[K_42b]",
+     1,	1,	"char[-K_M1a]",
+     65535, 1,	"char[K_65535a]",
+     1,	1,	"char[K_1b]",
+     1,	1,	"char[K_1c]",
+     1,	1,	"char[-K_M1b]",
+   }
+end
 
-ffi.cdef[[
-struct str1 {
-  enum {
-    K_99 = 99
-  };
-  static const int K_55 = 55;
-} extk;
-]]
+do --- constant struct
+  ffi.cdef[[
+  struct str1 {
+    enum {
+      K_99 = 99
+    };
+    static const int K_55 = 55;
+  } extk;
+  ]]
 
-checktypes{
-  99,	1,	"char[K_99]",
-  99,	1,	"char[extk.K_99]",
-  99,	1,	"char[((struct str1)0).K_99]",
-  99,	1,	"char[((struct str1 *)0)->K_99]",
-  55,	1,	"char[extk.K_55]",
-}
+  checktypes{
+    99,	1,	"char[K_99]",
+    99,	1,	"char[extk.K_99]",
+    99,	1,	"char[((struct str1)0).K_99]",
+    99,	1,	"char[((struct str1 *)0)->K_99]",
+    55,	1,	"char[extk.K_55]",
+  }
 
-checkfail{
-  "char[K_55]",
-}
+  checkfail{
+    "char[K_55]",
+  }
+end
 
-ffi.cdef[[
-extern int func1(void);
-extern int func2();
-static int func3();
-static inline int func4(int n)
-{
-  int i, k = 0;
-  float x = 1.0f;
-  for (i = 0; i < n; i++) {
-    k += i;
+do --- parse functions declaration
+  ffi.cdef[[
+  extern int func1(void);
+  extern int func2();
+  static int func3();
+  static inline int func4(int n)
+  {
+    int i, k = 0;
+    float x = 1.0f;
+    for (i = 0; i < n; i++) {
+      k += i;
+    }
+    return k;
   }
-  return k;
-}
-;;;
-]]
+  ;;;
+  ]]
+end
 
-ffi.cdef[[
-int ext1;
-extern int ext2;
-]]
+do --- parse extern
+  ffi.cdef[[
+  int ext1;
+  extern int ext2;
+  ]]
+end
 
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index a805bdd0..12b6387f 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -18,6 +18,7 @@ ffi_metatype.lua
 ffi_new.lua
 ffi_parse_array.lua
 ffi_parse_basic.lua
+ffi_parse_cdef.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (19 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:16   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:14   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches
                   ` (8 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch changes `dofile()` (which uses an unreliable relative file
path and mutates `_G` with global functions to be defined) to the
corresponding `require()` of the helper functions. It adds groups with
the names of subtests and enables the test in <index>.

Part of tarantool/tarantool#9398
---
 .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
 test/LuaJIT-tests/lib/ffi/index               |   1 +
 2 files changed, 176 insertions(+), 160 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
index 16a3d053..cb231c33 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
@@ -1,113 +1,123 @@
 local ffi = require("ffi")
 
-dofile("../common/ffi_util.inc")
+local checkfail = require("common.ffi.checkfail")
+local checktypes = require("common.ffi.checktypes")
+local fails = require("common.fails")
 
-checkfail{
-  "struct",
-  "struct {",
-  "struct xx xx {}",
-  "struct { int x  }",
-  "struct { int x,  }",
-  "struct { int x,y  }",
-  "struct { void x; }",
-  "struct { int x(void); }",
-  "struct recursive1 { struct recursive1 { } x; }",
-  "union",
-  "union {",
-  "union xx xx {}",
-  "union { int x  }",
-  "union { int x,  }",
-  "union { int x,y  }",
-  "union { void x; }",
-  "union { int x(void); }",
-  "union recursive1 { union recursive1 { } x; }",
-}
+local P = ffi.sizeof("void *")
+local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8
+
+do --- checkfail
+  checkfail{
+    "struct",
+    "struct {",
+    "struct xx xx {}",
+    "struct { int x  }",
+    "struct { int x,  }",
+    "struct { int x,y  }",
+    "struct { void x; }",
+    "struct { int x(void); }",
+    "struct recursive1 { struct recursive1 { } x; }",
+    "union",
+    "union {",
+    "union xx xx {}",
+    "union { int x  }",
+    "union { int x,  }",
+    "union { int x,y  }",
+    "union { void x; }",
+    "union { int x(void); }",
+    "union recursive1 { union recursive1 { } x; }",
+  }
+end
 
 -- NYI: rollback doesn't recover struct state
 -- ffi.cdef("struct zzz")
 -- fails(ffi.cdef, "struct zzz { int")
 -- ffi.cdef("struct zzz { int x; }")
 
-ffi.cdef("struct foo; typedef struct foo foo_t;")
-assert(ffi.sizeof("struct foo") == nil)
-assert(ffi.sizeof("foo_t") == nil)
-ffi.cdef("struct foo { int x,y; };")
-assert(ffi.sizeof("struct foo") == 8)
-assert(ffi.sizeof("foo_t") == 8)
-assert(ffi.sizeof(ffi.typeof("struct foo")) == 8)
-assert(ffi.sizeof(ffi.typeof("foo_t")) == 8)
-ffi.cdef("struct foo;")
-fails(ffi.cdef, "struct foo {};")
-fails(ffi.cdef, "union foo;")
-fails(ffi.cdef, "union foo {};")
-fails(ffi.cdef, "enum foo;")
-fails(ffi.cdef, "enum foo { ZZZ1 };")
-
-local P = ffi.sizeof("void *")
-local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8
+do --- siezeofs and invalid decalarations
+  ffi.cdef("struct foo; typedef struct foo struct_foo_t;")
+  assert(ffi.sizeof("struct foo") == nil)
+  assert(ffi.sizeof("struct_foo_t") == nil)
+  ffi.cdef("struct foo { int x,y; };")
+  assert(ffi.sizeof("struct foo") == 8)
+  assert(ffi.sizeof("struct_foo_t") == 8)
+  assert(ffi.sizeof(ffi.typeof("struct foo")) == 8)
+  assert(ffi.sizeof(ffi.typeof("struct_foo_t")) == 8)
+  ffi.cdef("struct foo;")
+  fails(ffi.cdef, "struct foo {};")
+  fails(ffi.cdef, "union foo;")
+  fails(ffi.cdef, "union foo {};")
+  fails(ffi.cdef, "enum foo;")
+  fails(ffi.cdef, "enum foo { ZZZ1 };")
+end
 
-checktypes{
-  0,	1,	"struct {}",
-  1,	1,	"struct { char x; }",
-  2,	1,	"struct { char x,y; }",
-  4,	1,	"struct { char x,y; char a,b; }",
-  4,	2,	"struct { char x; short y; }",
-  4,	2,	"struct { short x; char y; }",
-  8,	4,	"struct { char x; int y; }",
-  8,	4,	"struct { int x; char y; }",
-  12,	4,	"struct { char x; int y; char z; }",
-  P*4,	P,	"struct { char x,*y,**z,a,b,c,d; }",
-  64,	4,	"struct { struct { struct { struct { int x,y; } a,b; } a,b; } a,b; }",
-  4,	4,	"struct { struct { struct { struct { int x; }; }; }; }",
-  8,	4,	"struct { struct foo; }",
-  8,	4,	"struct { foo_t; }",
-  8,	8,	"struct __attribute__((aligned(sizeof(foo_t)))) { int a; }",
-  6,	2,	"struct { char a; char x; short y; char z; char c; }",
-  10,	2,	"struct { char a; struct { char x; short y; char z; } b; char c; }",
-  8,	A,	"struct { double a; }",
-  A+8,	A,	"struct { int a; double b; }",
-  8,	A,	"struct { long long a; }",
-  A+8,	A,	"struct { int a; long long b; }",
-  16,	A,	"struct { _Complex a; }",
-  A+16,	A,	"struct { int a; _Complex b; }",
-  8,	8,	"struct { float __attribute__((mode(__V2SF__))) a; }",
-  16,	8,	"struct { int a; float __attribute__((mode(__V2SF__))) b; }",
-  16,	8,	"struct { float __attribute__((mode(__V2SF__))) a[2]; }",
-  24,	8,	"struct { int a; float __attribute__((mode(__V2SF__))) b[2]; }",
-  16,	16,	"struct { float __attribute__((vector_size(16))) a; }",
-  32,	16,	"struct { int a; float __attribute__((vector_size(16))) b; }",
-}
+do --- struct base
+  checktypes{
+    0,	1,	"struct {}",
+    1,	1,	"struct { char x; }",
+    2,	1,	"struct { char x,y; }",
+    4,	1,	"struct { char x,y; char a,b; }",
+    4,	2,	"struct { char x; short y; }",
+    4,	2,	"struct { short x; char y; }",
+    8,	4,	"struct { char x; int y; }",
+    8,	4,	"struct { int x; char y; }",
+    12,	4,	"struct { char x; int y; char z; }",
+    P*4,	P,	"struct { char x,*y,**z,a,b,c,d; }",
+    64,	4,	"struct { struct { struct { struct { int x,y; } a,b; } a,b; } a,b; }",
+    4,	4,	"struct { struct { struct { struct { int x; }; }; }; }",
+    8,	4,	"struct { struct foo; }",
+    8,	4,	"struct { struct_foo_t; }",
+    8,	8,	"struct __attribute__((aligned(sizeof(struct_foo_t)))) { int a; }",
+    6,	2,	"struct { char a; char x; short y; char z; char c; }",
+    10,	2,	"struct { char a; struct { char x; short y; char z; } b; char c; }",
+    8,	A,	"struct { double a; }",
+    A+8,	A,	"struct { int a; double b; }",
+    8,	A,	"struct { long long a; }",
+    A+8,	A,	"struct { int a; long long b; }",
+    16,	A,	"struct { _Complex a; }",
+    A+16,	A,	"struct { int a; _Complex b; }",
+    8,	8,	"struct { float __attribute__((mode(__V2SF__))) a; }",
+    16,	8,	"struct { int a; float __attribute__((mode(__V2SF__))) b; }",
+    16,	8,	"struct { float __attribute__((mode(__V2SF__))) a[2]; }",
+    24,	8,	"struct { int a; float __attribute__((mode(__V2SF__))) b[2]; }",
+    16,	16,	"struct { float __attribute__((vector_size(16))) a; }",
+    32,	16,	"struct { int a; float __attribute__((vector_size(16))) b; }",
+  }
+end
 
-checktypes{
-  0,	1,	"union {}",
-  1,	1,	"union { char x; }",
-  1,	1,	"union { char x,y; }",
-  2,	2,	"union { char x; short y; }",
-  2,	2,	"union { short x; char y; }",
-  4,	4,	"union { char x; int y; }",
-  4,	4,	"union { int x; char y; }",
-  4,	4,	"union { char x; int y; short z; }",
-  P,	P,	"union { char x,*y,**z,a,b,c,d; }",
-  4,	4,	"union { union { union { union { int x,y; } a,b; } a,b; } a,b; }",
-  4,	4,	"union { union { union { union { int x; }; }; }; }",
-  2,	2,	"union { union { short x; }; char y; }",
-  2,	2,	"union { struct { short x; }; char y; }",
-  4,	2,	"struct { union { short x; }; char y; }",
-  2,	1,	"union { struct { char a,b; }; char y; }",
-  2,	1,	"struct { union { char a,b; }; char y; }",
-  8,	A,	"union { double a; }",
-  8,	A,	"union { int a; double b; }",
-  8,	A,	"union { long long a; }",
-  8,	A,	"union { int a; long long b; }",
-  16,	A,	"union { _Complex a; }",
-  16,	A,	"union { int a; _Complex b; }",
-  8,	8,	"union { float __attribute__((mode(__V2SF__))) a; }",
-  8,	8,	"union { int a; float __attribute__((mode(__V2SF__))) b; }",
-  16,	16,	"union { float __attribute__((vector_size(16))) a; }",
-  16,	16,	"union { int a; float __attribute__((vector_size(16))) b; }",
-}
+do --- unions
+  checktypes{
+    0,	1,	"union {}",
+    1,	1,	"union { char x; }",
+    1,	1,	"union { char x,y; }",
+    2,	2,	"union { char x; short y; }",
+    2,	2,	"union { short x; char y; }",
+    4,	4,	"union { char x; int y; }",
+    4,	4,	"union { int x; char y; }",
+    4,	4,	"union { char x; int y; short z; }",
+    P,	P,	"union { char x,*y,**z,a,b,c,d; }",
+    4,	4,	"union { union { union { union { int x,y; } a,b; } a,b; } a,b; }",
+    4,	4,	"union { union { union { union { int x; }; }; }; }",
+    2,	2,	"union { union { short x; }; char y; }",
+    2,	2,	"union { struct { short x; }; char y; }",
+    4,	2,	"struct { union { short x; }; char y; }",
+    2,	1,	"union { struct { char a,b; }; char y; }",
+    2,	1,	"struct { union { char a,b; }; char y; }",
+    8,	A,	"union { double a; }",
+    8,	A,	"union { int a; double b; }",
+    8,	A,	"union { long long a; }",
+    8,	A,	"union { int a; long long b; }",
+    16,	A,	"union { _Complex a; }",
+    16,	A,	"union { int a; _Complex b; }",
+    8,	8,	"union { float __attribute__((mode(__V2SF__))) a; }",
+    8,	8,	"union { int a; float __attribute__((mode(__V2SF__))) b; }",
+    16,	16,	"union { float __attribute__((vector_size(16))) a; }",
+    16,	16,	"union { int a; float __attribute__((vector_size(16))) b; }",
+  }
+end
 
-do
+do --- struct offsetof
   local ct
   ct = ffi.typeof("struct { int a; char b; short c; int d; }")
   assert(ffi.offsetof(ct, "a") == 0)
@@ -129,40 +139,44 @@ do
   assert(ffi.offsetof(ct, "b") == A)
 end
 
-checkfail{
-  "struct { int :; }",
-  "struct { int a:; }",
-  "struct { int a:bad; }",
-  "struct { int a:0; }",
-  "struct { int a:33; }",
-  "struct { int a:-1; }",
-  "struct { _Bool a:2; }",
-  "struct { double a:2; }",
-  "struct { complex a:2; }",
-  "struct { int __attribute__((mode(__TI__))) a:2; }",
-  "struct { int __attribute__((vector_size(16))) a:2; }",
-  "struct { int a[2]:2; }",
-  "struct { void a:2; }",
-}
+do --- checkfail bitfields
+  checkfail{
+    "struct { int :; }",
+    "struct { int a:; }",
+    "struct { int a:bad; }",
+    "struct { int a:0; }",
+    "struct { int a:33; }",
+    "struct { int a:-1; }",
+    "struct { _Bool a:2; }",
+    "struct { double a:2; }",
+    "struct { complex a:2; }",
+    "struct { int __attribute__((mode(__TI__))) a:2; }",
+    "struct { int __attribute__((vector_size(16))) a:2; }",
+    "struct { int a[2]:2; }",
+    "struct { void a:2; }",
+  }
+end
 
-checktypes{
-  4,	4,	"struct { unsigned a:1; }",
-  4,	4,	"struct { unsigned a:1, b:1, c:1; }",
-  1,	1,	"struct { _Bool a:1, b:1, c:1; }",
-  8,	4,	"struct { unsigned a:16, b:16, c:16; }",
-  8,	4,	"struct { unsigned a:17, b:16, c:16; }",
-  12,	4,	"struct { unsigned a:17, b:16, c:17; }",
-  12,	4,	"struct { unsigned a:16, b:17, c:16; }",
-  8,	4,	"struct { unsigned a:16, :16, c:16; }",
-  8,	4,	"struct { unsigned a:17, :16, c:16; }",
-  12,	4,	"struct { unsigned a:17, :16, c:17; }",
-  12,	4,	"struct { unsigned a:16, :17, c:16; }",
-  8,	4,	"struct { unsigned a:16, :0, c:16; }",
-  4,	4,	"struct { unsigned a:16, b:16, :0, :0; }",
-  8,	4,	"struct { unsigned a:16, :0, :0, :0, c:16; }",
-  1,	1,	"struct { char a:1; _Bool b:1; }",
-  1,	1,	"struct { char a:1; signed char b:1; unsigned char c:1; }",
-}
+do --- bitfields
+  checktypes{
+    4,	4,	"struct { unsigned a:1; }",
+    4,	4,	"struct { unsigned a:1, b:1, c:1; }",
+    1,	1,	"struct { _Bool a:1, b:1, c:1; }",
+    8,	4,	"struct { unsigned a:16, b:16, c:16; }",
+    8,	4,	"struct { unsigned a:17, b:16, c:16; }",
+    12,	4,	"struct { unsigned a:17, b:16, c:17; }",
+    12,	4,	"struct { unsigned a:16, b:17, c:16; }",
+    8,	4,	"struct { unsigned a:16, :16, c:16; }",
+    8,	4,	"struct { unsigned a:17, :16, c:16; }",
+    12,	4,	"struct { unsigned a:17, :16, c:17; }",
+    12,	4,	"struct { unsigned a:16, :17, c:16; }",
+    8,	4,	"struct { unsigned a:16, :0, c:16; }",
+    4,	4,	"struct { unsigned a:16, b:16, :0, :0; }",
+    8,	4,	"struct { unsigned a:16, :0, :0, :0, c:16; }",
+    1,	1,	"struct { char a:1; _Bool b:1; }",
+    1,	1,	"struct { char a:1; signed char b:1; unsigned char c:1; }",
+  }
+end
 
 -- NYI: bit fields > 32 bit
 -- local L = ffi.alignof("struct { long long a; }")
@@ -170,35 +184,36 @@ checktypes{
 --   L,	L,	"struct { long long a:1; }",
 -- }
 
--- Bit field packing.
-checktypes{
-  1,	1,	"struct { _Bool a:1, b:1, c:1; }",
-  4,	4,	"struct { short a:9; int b:9; char c; }",
-  4,	4,	"struct { char a; int b:7; }",
-  4,	4,	"struct { short a; char b; int c:7; }",
-  4,	4,	"struct { char a:7; int b:7; int c:7; int d:10; }",
-  4,	1,	"struct { char a:7; char b:7; char c:7; char d:7; }",
-  4,	4,	"struct { char a:7; int  b:7, c:7, d:7; int  e:4; }",
-  4,	4,	"struct { char a:7; int  b:7, c:7, d:7; char e:4; }",
-  5,	1,	"struct { char a:7; char b:7, c:7, d:7; char e:4; }",
-  4,	1,	"struct __attribute__((packed)) { char a:7; char b:7, c:7, d:7; char e:4; }",
-  4,	4,	"struct { char a:7; int b:7; int  c:7; int d:10; }",
-  8,	4,	"struct { char a:7; int b:7; char c:7; int d:10; }",
-  4,	1,	"struct __attribute__((packed)) { char a:7; int b:7; char c:7; int d:10; }",
-  4,	1,	"struct { char a:7; int b:7; char c:7; int d:10; } __attribute__((packed))",
-  2,	1,	"struct __attribute__((packed)) { char a:4; char b:8; }",
-  2,	1,	"struct __attribute__((packed)) { char a:4; char :0; char b:4; }",
-  1,	1,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1; }",
-  2,	1,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(1))); }",
-  4,	2,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(2))); }",
-  8,	4,	"struct { _Bool a:1; int b __attribute((aligned(2))); }",
-  16,	8,	"struct { _Bool a:1; int b __attribute((aligned(8))); }",
-  6,	2,	"struct { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }",
-  6,	2,	"struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))); }",
-  6,	2,	"struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }",
-}
+do --- Bit field packing.
+  checktypes{
+    1,	1,	"struct { _Bool a:1, b:1, c:1; }",
+    4,	4,	"struct { short a:9; int b:9; char c; }",
+    4,	4,	"struct { char a; int b:7; }",
+    4,	4,	"struct { short a; char b; int c:7; }",
+    4,	4,	"struct { char a:7; int b:7; int c:7; int d:10; }",
+    4,	1,	"struct { char a:7; char b:7; char c:7; char d:7; }",
+    4,	4,	"struct { char a:7; int  b:7, c:7, d:7; int  e:4; }",
+    4,	4,	"struct { char a:7; int  b:7, c:7, d:7; char e:4; }",
+    5,	1,	"struct { char a:7; char b:7, c:7, d:7; char e:4; }",
+    4,	1,	"struct __attribute__((packed)) { char a:7; char b:7, c:7, d:7; char e:4; }",
+    4,	4,	"struct { char a:7; int b:7; int  c:7; int d:10; }",
+    8,	4,	"struct { char a:7; int b:7; char c:7; int d:10; }",
+    4,	1,	"struct __attribute__((packed)) { char a:7; int b:7; char c:7; int d:10; }",
+    4,	1,	"struct { char a:7; int b:7; char c:7; int d:10; } __attribute__((packed))",
+    2,	1,	"struct __attribute__((packed)) { char a:4; char b:8; }",
+    2,	1,	"struct __attribute__((packed)) { char a:4; char :0; char b:4; }",
+    1,	1,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1; }",
+    2,	1,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(1))); }",
+    4,	2,	"struct __attribute__((packed)) { _Bool a:1; _Bool b:1 __attribute((aligned(2))); }",
+    8,	4,	"struct { _Bool a:1; int b __attribute((aligned(2))); }",
+    16,	8,	"struct { _Bool a:1; int b __attribute((aligned(8))); }",
+    6,	2,	"struct { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }",
+    6,	2,	"struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))); }",
+    6,	2,	"struct __attribute__((packed)) { _Bool a:1; int b __attribute((aligned(2))) __attribute((packed)); }",
+  }
+end
 
-do
+do --- pragma pack pop
   ffi.cdef[[
     struct foo_packorig { char a; int b; short c; };
     #pragma pack(1)
@@ -236,7 +251,7 @@ do
   assert(ffi.sizeof("struct foo_packpop2") == 12)
 end
 
-do
+do --- pragma pack aligment
   ffi.cdef[[
     #pragma pack(2)
     struct foo_packalign8 {
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index 12b6387f..e3a34e30 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -19,6 +19,7 @@ ffi_new.lua
 ffi_parse_array.lua
 ffi_parse_basic.lua
 ffi_parse_cdef.lua
+ffi_parse_struct.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (20 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:19   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:20   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches
                   ` (7 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <ffi_tabov.lua> test from the LuaJIT-tests suite to
the tarantool-tests suite, because this test should be run separately to
avoid overflow of the table with ctypes for other tests from
LuaJIT-tests suite.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua | 12 -----------
 test/tarantool-tests/ffi-tabov.test.lua | 27 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 12 deletions(-)
 delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
 create mode 100644 test/tarantool-tests/ffi-tabov.test.lua

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua b/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
deleted file mode 100644
index ba621960..00000000
--- a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local ffi = require("ffi")
-
-local last = 0
-
-assert(pcall(function()
-  for i=1,65536 do
-    last = i
-    ffi.typeof"struct {}"
-  end
-end) == false)
-
-assert(last > 20000)
diff --git a/test/tarantool-tests/ffi-tabov.test.lua b/test/tarantool-tests/ffi-tabov.test.lua
new file mode 100644
index 00000000..7ea8b24b
--- /dev/null
+++ b/test/tarantool-tests/ffi-tabov.test.lua
@@ -0,0 +1,27 @@
+local tap = require('tap')
+local ffi = require('ffi')
+
+-- This test is moved here from the LuaJIT-tests suite since it
+-- should be run separately because it exhausts the ctype table.
+local test = tap.test('ffi-tabov')
+
+test:plan(3)
+
+-- XXX: Amount of ctypes available to the user of a platform.
+local MIN_AVAILABLE_CTYPES = 20000
+
+local last = 0
+
+local res, errmsg = pcall(function()
+  for i = 1, 2^16 do
+    last = i
+    ffi.typeof('struct {}')
+  end
+end)
+
+test:ok(res == false, 'correct status')
+test:like(errmsg, 'table overflow', 'correct error message')
+
+test:ok(last > MIN_AVAILABLE_CTYPES, 'huge enough amount of free ctypes')
+
+test:done(true)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (21 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:23   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:27   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches
                   ` (6 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <lightud.lua> test from the <misc> to <lang>
directory, includes it in <index>, and names subtests. Also, it enables
tests for all arches and fixes tests for 47-bit lightuserdata because it
is available since the commit
2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64
bit lightuserdata.")

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index       |  1 +
 test/LuaJIT-tests/lang/lightud.lua | 89 ++++++++++++++++++++++++++++++
 test/LuaJIT-tests/misc/lightud.lua | 88 -----------------------------
 3 files changed, 90 insertions(+), 88 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/lightud.lua
 delete mode 100644 test/LuaJIT-tests/misc/lightud.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 88e2edfa..60cbecfb 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -5,6 +5,7 @@ compare_nan.lua
 constant
 for.lua
 length.lua
+lightud.lua
 modulo.lua
 concat.lua
 self.lua
diff --git a/test/LuaJIT-tests/lang/lightud.lua b/test/LuaJIT-tests/lang/lightud.lua
new file mode 100644
index 00000000..aee9e85c
--- /dev/null
+++ b/test/LuaJIT-tests/lang/lightud.lua
@@ -0,0 +1,89 @@
+local ctest = require("libctest")
+
+local lightud = ctest.lightud
+local assert = assert
+
+-- x64 lightud tests
+do --- light userdata comparison and tostring +x64
+  local ud1 = lightud(0x12345678)
+  local ud2 = lightud(0x12345678)
+  assert(ud1 == ud2)
+  assert(tostring(ud1) == "userdata: 0x12345678")
+end
+
+do --- unequal light userdata comparison +x64
+  local ud1 = lightud(1)
+  local ud2 = lightud(2)
+  assert(ud1 ~= ud2)
+end
+
+do --- big light userdata comparison and tostring +x64
+  local ud1 = lightud(2^47-1)
+  local ud2 = lightud(2^47-1)
+  assert(ud1 == ud2)
+  assert(tostring(ud1) == "userdata: 0x7fffffffffff")
+end
+
+do --- unequal light userdata comparison JIT +x64
+  local ud1 = lightud(0x12345678+123*2^32)
+  local ud2 = lightud(0x12345678+456*2^32)
+  for i=1,100 do assert(ud1 ~= ud2) end
+end
+
+do --- 47 bits light userdata +x64
+  assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234")
+  -- Now more than 47 bits are available.
+  assert(pcall(lightud, 2^47) == true)
+  assert(pcall(lightud, 2^64-2048) == true)
+end
+
+do --- metatable check
+  assert(getmetatable(lightud(1)) == nil)
+end
+
+do --- lightuserdata SLOAD value and HREF key
+  local ud = lightud(12345)
+  local t = {[ud] = 42}
+  for i=1,100 do
+    assert(t[ud] == 42)
+  end
+end
+
+do --- lightuserdata NEWREF key
+  local ud = lightud(12345)
+  for i=1,100 do
+    local t = {[ud] = 42}
+    assert(t[ud] == 42)
+  end
+end
+
+do --- lightuserdata ASTORE/HSTORE value
+  local ud = lightud(12345)
+  local t = {}
+  for i=1,100 do
+    t[i] = ud
+  end
+  assert(t[100] == ud)
+end
+
+do --- lightuserdata sync to stack
+  local ud = lightud(12345)
+  local x = nil
+  for j=1,20 do
+    for i=1,50 do
+      x = ud
+    end
+    assert(x == ud)
+  end
+end
+
+do --- lightuserdata vs. number type check
+  local t = {}
+  for i=1,200 do t[i] = i end
+  t[180] = lightud(12345)
+  local x = 0
+  assert(not pcall(function(t)
+    for i=1,200 do x = x + t[i] end
+  end, t))
+  assert(x == 16110)
+end
diff --git a/test/LuaJIT-tests/misc/lightud.lua b/test/LuaJIT-tests/misc/lightud.lua
deleted file mode 100644
index 4974d50f..00000000
--- a/test/LuaJIT-tests/misc/lightud.lua
+++ /dev/null
@@ -1,88 +0,0 @@
-local ctest = require("ctest")
-
-local lightud = ctest.lightud
-local assert = assert
-
--- x64 lightud tests
-if jit and jit.arch == "x64" then
-  do
-    local ud1 = lightud(0x12345678)
-    local ud2 = lightud(0x12345678)
-    assert(ud1 == ud2)
-    assert(tostring(ud1) == "userdata: 0x12345678")
-  end
-  do
-    local ud1 = lightud(1)
-    local ud2 = lightud(2)
-    assert(ud1 ~= ud2)
-  end
-  do
-    local ud1 = lightud(2^47-1)
-    local ud2 = lightud(2^47-1)
-    assert(ud1 == ud2)
-    assert(tostring(ud1) == "userdata: 0x7fffffffffff")
-  end
-  do
-    local ud1 = lightud(0x12345678+123*2^32)
-    local ud2 = lightud(0x12345678+456*2^32)
-    for i=1,100 do assert(ud1 ~= ud2) end
-  end
-  assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234")
-  assert(pcall(lightud, 2^47) == false)
-  assert(pcall(lightud, 2^64-2048) == false)
-end
-
-assert(getmetatable(lightud(1)) == nil)
-
--- lightuserdata SLOAD value and HREF key
-do
-  local ud = lightud(12345)
-  local t = {[ud] = 42}
-  for i=1,100 do
-    assert(t[ud] == 42)
-  end
-end
-
--- lightuserdata NEWREF key
-do
-  local ud = lightud(12345)
-  for i=1,100 do
-    local t = {[ud] = 42}
-    assert(t[ud] == 42)
-  end
-end
-
--- lightuserdata ASTORE/HSTORE value
-do
-  local ud = lightud(12345)
-  local t = {}
-  for i=1,100 do
-    t[i] = ud
-  end
-  assert(t[100] == ud)
-end
-
--- lightuserdata sync to stack
-do
-  local ud = lightud(12345)
-  local x = nil
-  for j=1,20 do
-    for i=1,50 do
-      x = ud
-    end
-    assert(x == ud)
-  end
-end
-
--- lightuserdata vs. number type check
-do
-  local t = {}
-  for i=1,200 do t[i] = i end
-  t[180] = lightud(12345)
-  local x = 0
-  assert(not pcall(function(t)
-    for i=1,200 do x = x + t[i] end
-  end, t))
-  assert(x == 16110)
-end
-
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (22 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:25   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:28   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches
                   ` (5 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <api_call.lua> test from the <misc> to <lang>
directory, includes it in <index>, and names subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/{misc => lang}/api_call.lua | 32 +++++++++++--------
 test/LuaJIT-tests/lang/index                  |  1 +
 2 files changed, 19 insertions(+), 14 deletions(-)
 rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)

diff --git a/test/LuaJIT-tests/misc/api_call.lua b/test/LuaJIT-tests/lang/api_call.lua
similarity index 79%
rename from test/LuaJIT-tests/misc/api_call.lua
rename to test/LuaJIT-tests/lang/api_call.lua
index 7dbd5e40..142959c5 100644
--- a/test/LuaJIT-tests/misc/api_call.lua
+++ b/test/LuaJIT-tests/lang/api_call.lua
@@ -1,4 +1,4 @@
-local ctest = require("ctest")
+local ctest = require("libctest")
 
 local function ret0() end
 local function ret1() return 1 end
@@ -57,19 +57,10 @@ local function test_adjust_results(testfunc)
   ck(cc(-1, retva, 1, 2), 1, 2)
 end
 
-test_adjust_results(ctest.call)
-test_adjust_results(ctest.pcall_err)
-
-
 local function gcshrink()
   for i=1,10 do collectgarbage() end
 end
 
-assert(select('#', ctest.call(2000, gcshrink)) == 2000)
-gcshrink()
-assert(select('#', ctest.call(7000, gcshrink)) == 7000)
-gcshrink()
-
 local function test_yield(resume, yield)
   local function inpcall()
     ck(pack(yield(6, 7)), 18, 19)
@@ -91,8 +82,21 @@ local function test_yield(resume, yield)
   assert(resume(co) == false)
 end
 
-test_yield(coroutine.resume, coroutine.yield)
-test_yield(ctest.resume, coroutine.yield)
-test_yield(coroutine.resume, ctest.yield)
-test_yield(ctest.resume, ctest.yield)
+do --- adjust results
+  test_adjust_results(ctest.call)
+  test_adjust_results(ctest.pcall_err)
+end
 
+do --- GC shrink
+  assert(select('#', ctest.call(2000, gcshrink)) == 2000)
+  gcshrink()
+  assert(select('#', ctest.call(7000, gcshrink)) == 7000)
+  gcshrink()
+end
+
+do --- yield
+  test_yield(coroutine.resume, coroutine.yield)
+  test_yield(ctest.resume, coroutine.yield)
+  test_yield(coroutine.resume, ctest.yield)
+  test_yield(ctest.resume, ctest.yield)
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 60cbecfb..dc0c2e14 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -1,4 +1,5 @@
 andor.lua
+api_call.lua
 assignment.lua
 compare.lua
 compare_nan.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (23 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:31   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches
                   ` (4 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <catch_wrap.lua> test from the <misc> to <lang>
directory, includes it in <index>, and names subtests. Also, since the
tests may be shuffled, `cp.wrapon()` and `cp.wrapoff()` are used for
each test separately. Also, this patch adds a workaround for the
internal ASAN bug, see details in the comment in the <CMakeLists.txt>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/CMakeLists.txt              | 16 ++++++++++
 .../{misc => lang}/catch_wrap.lua             | 29 +++++++++++++------
 test/LuaJIT-tests/lang/index                  |  1 +
 3 files changed, 37 insertions(+), 9 deletions(-)
 rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)

diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index c52bcc71..8ecfe3f6 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -24,6 +24,22 @@ else()
   list(APPEND LUAJIT_TESTS_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
 endif()
 
+if(LUAJIT_USE_ASAN)
+  # When running LuaJIT-tests under ASAN, the internal ASAN check
+  # failed:
+  # AddressSanitizer: CHECK failed: asan_interceptors.cpp:356
+  # "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
+  # This is a workaround suggested at
+  # https://github.com/google/sanitizers/issues/934.
+  execute_process(
+    COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.so
+    OUTPUT_VARIABLE LIB_STDCPP
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+  # Fortunately, we are not interested in macOS here.
+  list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_STDCPP}")
+endif()
+
 add_custom_command(TARGET LuaJIT-tests
   COMMENT "Running LuaJIT-tests"
   COMMAND
diff --git a/test/LuaJIT-tests/misc/catch_wrap.lua b/test/LuaJIT-tests/lang/catch_wrap.lua
similarity index 71%
rename from test/LuaJIT-tests/misc/catch_wrap.lua
rename to test/LuaJIT-tests/lang/catch_wrap.lua
index 7f656bcc..9d1e3478 100644
--- a/test/LuaJIT-tests/misc/catch_wrap.lua
+++ b/test/LuaJIT-tests/lang/catch_wrap.lua
@@ -1,45 +1,56 @@
+local cp = require("libcpptest")
 
-local cp = require("cpptest")
-cp.wrapon()
+local unwind
 
-do
+do --- catch, no error
+  cp.wrapon()
   local a, b = pcall(cp.catch, function() return "x" end)
   assert(a == true and b == "x")
+  cp.wrapoff()
 end
 
-do
+do --- pcall throw
+  cp.wrapon()
   local a, b = pcall(function() cp.throw("foo") end)
   assert(a == false and b == "foo")
+  cp.wrapoff()
 end
 
-local unwind
-do
+do --- catch throw
+  cp.wrapon()
   local a, b = pcall(cp.catch, function() cp.throw("foo") end)
   unwind = a
   assert((a == false and b == "foo") or (a == true and b == "catch ..."))
+  cp.wrapoff()
 end
 
-do
+do --- alloc, no error
+  cp.wrapon()
   local st = cp.alloc(function() return cp.isalloc() end)
   assert(st == true)
   assert(cp.isalloc() == false)
+  cp.wrapoff()
 end
 
-do
+do --- throw in alloc
+  cp.wrapon()
   local a, b = pcall(cp.alloc, function()
     assert(cp.isalloc() == true)
     return "foo", cp.throw
   end)
   assert(a == false and b == "foo")
   assert(cp.isalloc() == false)
+  cp.wrapoff()
 end
 
-do
+do --- error in alloc
+  cp.wrapon()
   local a, b = pcall(cp.alloc, function()
     assert(cp.isalloc() == true)
     return "foo", error
   end)
   assert(a == false and b == "foo")
   if unwind then assert(cp.isalloc() == false) end
+  cp.wrapoff()
 end
 
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index dc0c2e14..87b0c5a0 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -1,6 +1,7 @@
 andor.lua
 api_call.lua
 assignment.lua
+catch_wrap.lua
 compare.lua
 compare_nan.lua
 constant
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> LuaJIT test
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (24 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-29 10:45 ` Sergey Kaplun via Tarantool-patches
  2024-02-01  9:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  2024-02-01 16:32 ` [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
                   ` (3 subsequent siblings)
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-01-29 10:45 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <catch_cpp.lua> test from the <sysdep> to <lang>
directory, includes it in <index>, and names subtests.

Resolves of tarantool/tarantool#7834
Part of tarantool/tarantool#9398
---
 .../{sysdep => lang}/catch_cpp.lua            | 36 ++++++++++---------
 test/LuaJIT-tests/lang/index                  |  1 +
 2 files changed, 20 insertions(+), 17 deletions(-)
 rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)

diff --git a/test/LuaJIT-tests/sysdep/catch_cpp.lua b/test/LuaJIT-tests/lang/catch_cpp.lua
similarity index 75%
rename from test/LuaJIT-tests/sysdep/catch_cpp.lua
rename to test/LuaJIT-tests/lang/catch_cpp.lua
index b2251009..6c52c78c 100644
--- a/test/LuaJIT-tests/sysdep/catch_cpp.lua
+++ b/test/LuaJIT-tests/lang/catch_cpp.lua
@@ -1,30 +1,30 @@
+local cp = require("libcpptest")
 
-local cp = require("cpptest")
+local unwind
 
-do
+do --- catch, no error
   local a, b = pcall(cp.catch, function() return "x" end)
   assert(a == true and b == "x")
 end
 
-do
+do --- pcall throw
   local a, b = pcall(function() cp.throw("foo") end)
   assert(a == false and b == "C++ exception")
 end
 
-local unwind
-do
+do --- catch throw
   local a, b = pcall(cp.catch, function() cp.throw("foo") end)
   unwind = a
   assert((a == false and b == "C++ exception") or (a == true and b == "foo"))
 end
 
-do
+do --- alloc, no error
   local st = cp.alloc(function() return cp.isalloc() end)
   assert(st == true)
   assert(cp.isalloc() == false)
 end
 
-do
+do --- throw in alloc
   local a, b = pcall(cp.alloc, function()
     assert(cp.isalloc() == true)
     return "foo", cp.throw
@@ -33,21 +33,23 @@ do
   assert(cp.isalloc() == false)
 end
 
-if unwind then
-  local a, b = pcall(cp.alloc, function()
-    assert(cp.isalloc() == true)
-    return "foo", error
-  end)
-  assert(a == false and b == "foo")
-  assert(cp.isalloc() == false)
+do --- error in alloc
+  if unwind then
+    local a, b = pcall(cp.alloc, function()
+      assert(cp.isalloc() == true)
+      return "foo", error
+    end)
+    assert(a == false and b == "foo")
+    assert(cp.isalloc() == false)
+  end
 end
 
-do
+do --- usereg nop
   local a,b,c,d,e,f = cp.usereg(100, 50, function() end, false)
   assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
 end
 
-do
+do --- usereg error
   local function test()
     cp.usereg(100, 40, error, "foo")
   end
@@ -55,7 +57,7 @@ do
   assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
 end
 
-do
+do --- usereg trace with self table lookup
   local t = {};
   t.t = t;
   local function foo()
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 87b0c5a0..41f7e7db 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -1,6 +1,7 @@
 andor.lua
 api_call.lua
 assignment.lua
+catch_cpp.lua
 catch_wrap.lua
 compare.lua
 compare_nan.lua
-- 
2.43.0


^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
@ 2024-01-31 11:25   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 11:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 14:20   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 11:25 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:01PM +0300, Sergey Kaplun wrote:
> This patch removes copy-pasting in macros used to add a new library for
> testing and places this in the include test file.
>
> Needed for tarantool/tarantool#9398
> ---
>  test/CMakeLists.txt                           |  3 ++
>  .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 25 +----------------
>  test/cmake/AddTestLib.cmake                   | 28 +++++++++++++++++++
>  test/tarantool-tests/CMakeLists.txt           | 27 +-----------------
>  4 files changed, 33 insertions(+), 50 deletions(-)
>  create mode 100644 test/cmake/AddTestLib.cmake
>
> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
> index 8afc42df..3ad5d15f 100644
> --- a/test/CMakeLists.txt
> +++ b/test/CMakeLists.txt
> @@ -74,6 +74,9 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS
>  set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
>  separate_arguments(LUAJIT_TEST_COMMAND)
>
> +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
> +include(AddTestLib)
> +
>  add_subdirectory(LuaJIT-tests)
>  add_subdirectory(PUC-Rio-Lua-5.1-tests)
>  add_subdirectory(lua-Harness-tests)
> diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> index 8501b767..e68e6aef 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> +++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> @@ -6,30 +6,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
>
>  # Build additional C libraries for tests.
>  macro(BuildTestCLib lib sources)
> -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> -  target_include_directories(${lib} PRIVATE
> -    ${LUAJIT_SOURCE_DIR}
> -  )
> -  set_target_properties(${lib} PROPERTIES
> -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> -    PREFIX ""
> -  )
> -  # XXX: The dynamic libraries are loaded with LuaJIT binary and
> -  # use symbols from it. So it is totally OK to have unresolved
> -  # symbols at build time.
> -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> -    set_target_properties(${lib} PROPERTIES
> -      LINK_FLAGS "-undefined dynamic_lookup"
> -    )
> -  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> -    # XXX: This is necessary mostly for openSUSE builds, see also
> -    # https://bugzilla.suse.com/show_bug.cgi?id=1012388.
> -    # Just strip out the linker flag to suppress this linker
> -    # option.
> -    string(REPLACE "-Wl,--no-undefined" ""
> -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> -    )
> -  endif()
> +  AddTestLib(${lib} ${sources})
>    list(APPEND TESTLIBS ${lib})
>  endmacro()
This macro now seems redundant, maybe we should get rid of it.
>
> diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
> new file mode 100644
> index 00000000..3764ee5c
> --- /dev/null
> +++ b/test/cmake/AddTestLib.cmake
> @@ -0,0 +1,28 @@
> +macro(AddTestLib lib sources)
> +  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> +  target_include_directories(${lib} PRIVATE
> +    ${LUAJIT_SOURCE_DIR}
> +    ${CMAKE_CURRENT_SOURCE_DIR}
> +  )
> +  set_target_properties(${lib} PROPERTIES
> +    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> +    PREFIX ""
> +  )
> +
> +  # XXX: This change affects the current cmake variable scope and
Typo: s/cmake/CMake/
Typo: s/scope and/scope,/
> +  # so a user should care to don't use it in a top level scope.
Typo: s/should care to don't use/shouldn't use/
Typo: s/top level/top-level/
> +  # The dynamic libraries are loaded with LuaJIT binary and use
> +  # symbols from it. So it is totally OK to have unresolved
> +  # symbols at build time.
> +  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> +    set_target_properties(${lib} PROPERTIES
> +      LINK_FLAGS "-undefined dynamic_lookup"
> +    )
> +  else()
> +    # FIXME: Unfortunately, there is no another way to suppress
> +    # this linker option, so just strip it out from the flags.
> +    string(REPLACE "-Wl,--no-undefined" ""
> +      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> +    )
I wonder why you've omitted the condition along with the comment here.
> +  endif()
> +endmacro()
> diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
> index 6d686876..80d94a78 100644
> --- a/test/tarantool-tests/CMakeLists.txt
> +++ b/test/tarantool-tests/CMakeLists.txt
> @@ -11,32 +11,7 @@ if(NOT PROVE)
>  endif()
>
>  macro(BuildTestCLib lib sources)
> -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> -  target_include_directories(${lib} PRIVATE
> -    ${LUAJIT_SOURCE_DIR}
> -    ${CMAKE_CURRENT_SOURCE_DIR}
> -  )
> -  set_target_properties(${lib} PROPERTIES
> -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> -    PREFIX ""
> -  )
> -
> -  # XXX: This change affects the current cmake variable scope and
> -  # so a user should care to don't use it in a top level scope.
> -  # The dynamic libraries are loaded with LuaJIT binary and use
> -  # symbols from it. So it is totally OK to have unresolved
> -  # symbols at build time.
> -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> -    set_target_properties(${lib} PROPERTIES
> -      LINK_FLAGS "-undefined dynamic_lookup"
> -    )
> -  else()
> -    # FIXME: Unfortunately, there is no another way to suppress
> -    # this linker option, so just strip it out from the flags.
> -    string(REPLACE "-Wl,--no-undefined" ""
> -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> -    )
> -  endif()
> +  AddTestLib(${lib} ${sources})
Same comments as for the above section.
>    # XXX: Append the lib to be built to the dependency list.
>    # Unfortunately, there is no convenient way in CMake to extend
>    # the list in parent scope other than join two strings with
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-31 11:48   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 11:24     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 14:23   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 11:48 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.
On Mon, Jan 29, 2024 at 01:45:02PM +0300, Sergey Kaplun wrote:
> This patch adds rules to build C and C++ libs from the
> <LuaJIT-tests/src/> 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
I think something like `LuaJIT-tests-libs` is better name for the
target.
> +)
> +
> +make_lua_path(LUA_CPATH
> +  PATHS
> +  ${CMAKE_CURRENT_BINARY_DIR}/src/?${CMAKE_SHARED_LIBRARY_SUFFIX}
> +)
> +
> +set(LUAJIT_TESTS_ENV
> +  "LUA_CPATH=\"${LUA_CPATH}\""
IINM, outer quotes are redundant here.
> +)
> +
> +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()
See the comment about this macro in the previous patch.
> +
> +# 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
Editor configuration should not be there.

> 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
Let's change the `k` here to a more clear name.
> +      error("Tests should not mutate global state", 3)
> +    end
>    end}
>    local function seal(t)
>      if getmetatable(t) then return end
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches
@ 2024-01-31 11:58   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 11:47     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 15:45   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 11:58 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, except for a few nits below.

On Mon, Jan 29, 2024 at 01:45:03PM +0300, Sergey Kaplun wrote:
> This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>
> into separate files by analogy with <common/expect_error.lua>. The
> `include()` helper isn't touched since it is used in system dependend
> tests, which won't be modified for now.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/common/fails.lua          |  3 +++
>  test/LuaJIT-tests/common/ffi/checkfail.lua  | 14 +++++++++++++
>  test/LuaJIT-tests/common/ffi/checktypes.lua | 15 ++++++++++++++
>  test/LuaJIT-tests/common/ffi_util.inc       | 23 ---------------------
>  4 files changed, 32 insertions(+), 23 deletions(-)
>  create mode 100644 test/LuaJIT-tests/common/fails.lua
>  create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
>  create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
>
> diff --git a/test/LuaJIT-tests/common/fails.lua b/test/LuaJIT-tests/common/fails.lua
> new file mode 100644
> index 00000000..d555a2b5
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/fails.lua
> @@ -0,0 +1,3 @@
<snipped>

> diff --git a/test/LuaJIT-tests/common/ffi/checkfail.lua b/test/LuaJIT-tests/common/ffi/checkfail.lua
> new file mode 100644
> index 00000000..d3ca74e8
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/ffi/checkfail.lua
> @@ -0,0 +1,14 @@
<snipped>

> diff --git a/test/LuaJIT-tests/common/ffi/checktypes.lua b/test/LuaJIT-tests/common/ffi/checktypes.lua
> new file mode 100644
> index 00000000..c995d667
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/ffi/checktypes.lua
> @@ -0,0 +1,15 @@
> +local ffi = require("ffi")
> +
> +-- Checker that takes an array with the following each 3 elements:
Typo: s/each 3 elements/triplets/
> +-- 1) Sizeof for the given C type to be checked.
> +-- 2) Alignof for the given C type to be checked.
Nit: `sizeof()` and `alignof()` or something like that? Feel free to
ignore.
> +-- 3) String representing the C type.
> +return function(t)
> +  for i=1,1e9,3 do
> +    local tp = t[i+2]
> +    if not tp then break end
> +    local id = ffi.typeof(tp)
> +    assert(ffi.sizeof(id) == t[i], tp)
> +    assert(ffi.alignof(id) == t[i+1], tp)
> +  end
> +end
> diff --git a/test/LuaJIT-tests/common/ffi_util.inc b/test/LuaJIT-tests/common/ffi_util.inc
> index 1eee8dd9..9604d7b0 100644
> --- a/test/LuaJIT-tests/common/ffi_util.inc
> +++ b/test/LuaJIT-tests/common/ffi_util.inc
> @@ -4,29 +4,6 @@
<snipped>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-31 12:21   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:50   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 12:21 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 12:26   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 11:54     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 15:52   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 12:26 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, except for the single nit below.

On Mon, Jan 29, 2024 at 01:45:05PM +0300, Sergey Kaplun wrote:
> This patch removes unused `dofile()`. Also, it names the only one test
> as "misc" and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua | 4 +---
>  test/LuaJIT-tests/lib/ffi/index            | 1 +
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> index cd0b1815..fa74e45d 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> @@ -1,8 +1,6 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> -
> -do
> +do --- misc
Nit: Maybe `misc bitfield tests` then for it to be more elaborate?
Or maybe it should be spplitted according to the sections inside the
test.
>    local x = ffi.new([[
>      union {
>        uint32_t u;
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 7e046908..8d833107 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -3,6 +3,7 @@ cdata_var.lua
>  copy_fill.lua
>  err.lua
>  ffi_arith_ptr.lua
> +ffi_bitfield.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 12:34   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 15:58   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 12:34 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM


^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 13:02   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:01   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 13:02 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 12:09     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 14:32   ` Sergey Bronnikov via Tarantool-patches
  2024-02-01 16:02   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 14:32 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, except for the question below.
On Mon, Jan 29, 2024 at 01:45:08PM +0300, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()`.  Also, it names the only one test as "misc"
> and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_const.lua | 4 ++--
>  test/LuaJIT-tests/lib/ffi/index         | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> index d42133ad..3213156d 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> @@ -1,6 +1,6 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>
>  ffi.cdef[[
>  typedef struct s_t {
> @@ -41,7 +41,7 @@ typedef struct foo_t {
>  } foo_t;
>  ]]
>
> -do
> +do --- misc
Again, maybe it is worth splitting into the subcategories that are
mentioned below.
>    local foo_t = ffi.typeof("foo_t")
>    local x = foo_t()
>
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 9a22104a..0a72daed 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -6,6 +6,7 @@ ffi_arith_ptr.lua
>  ffi_bitfield.lua
>  ffi_call.lua
>  ffi_callback.lua
> +ffi_const.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 13:11     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 16:06   ` Sergey Bronnikov via Tarantool-patches
  2024-02-01 16:19   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 14:55 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:09PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding require and renames the C library in the `require()` call.
> It adds groups with the names of subtests and enables the test in
> <index>. It renames structure and enum typedefs to avoid conflicts with
> cdef in other tests. The GC threshold is increased since all tests run
> in a single process, so the number of GC objects is greater.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_convert.lua | 35 +++++++++++------------
>  test/LuaJIT-tests/lib/ffi/index           |  1 +
>  2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> index bd3fb1f9..284f2b53 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> @@ -1,8 +1,7 @@
>  local ffi = require("ffi")
>
> -local ctest = require("ctest")
> -
> -dofile("../common/ffi_util.inc")
> +local ctest = require("libctest")
> +local fails = require("common.fails")
>
>  local tonumber = tonumber
>
> @@ -32,15 +31,15 @@ typedef struct arrinc_t {
>    int a[];
>  } arrinc_t;
>
> -typedef enum uenum_t {
> +typedef enum uenum_convert_t {
>    UE0, UE71 = 71, UE72
> -} uenum_t;
> +} uenum_convert_t;
`convert` acts as a namespace here, and those are usually used as a
prefix. Here and below.
>
> -typedef enum ienum_t {
> +typedef enum ienum_convert_t {
>    IE0, IEM12 = -12, IEM11
> -} ienum_t;
> +} ienum_convert_t;
>
> -typedef struct foo_t {
> +typedef struct foo_convert_t {
>    bool b;
>    int8_t i8;
>    uint8_t u8;
> @@ -79,9 +78,9 @@ typedef struct foo_t {
>    int si_guard;
>    nest_t sn;
>    uni_t ui;
> -  uenum_t ue;
> -  ienum_t ie;
> -} foo_t;
> +  uenum_convert_t ue;
> +  ienum_convert_t ie;
> +} foo_convert_t;
>
>  char *strcpy(char *dest, const char *src);
>  typedef struct FILE FILE;
> @@ -89,11 +88,11 @@ int fileno(FILE *stream);
>  int _fileno(FILE *stream);
>  ]]
>
> -do
> -  local foo_t = ffi.typeof("foo_t")
> -  local sz = ffi.sizeof(foo_t)
> -  local x = foo_t()
> -  local y = foo_t()
> +do --- misc
Is there any chance to split it up?
> +  local foo_convert_t = ffi.typeof("foo_convert_t")
> +  local sz = ffi.sizeof(foo_convert_t)
> +  local x = foo_convert_t()
> +  local y = foo_convert_t()
>    ffi.fill(x, sz, 0xff)
>    ffi.fill(y, sz, 0xee)
>
> @@ -769,7 +768,7 @@ do
>    x.ppf = ffi.C.strcpy
>  end
>
> -do
> +do --- GC cdata __index
>    collectgarbage()
>    local oc = collectgarbage("count")
>    local cd = ffi.new"struct { struct { int a; } x;}"
> @@ -780,7 +779,7 @@ do
>    for i=1,2 do
>      f(cd)
>      local nc = collectgarbage("count")
> -    assert(nc < oc + 200, "GC step missing for cdata __index")
Are you sure it is the lower bound threshold?
> +    assert(nc < oc * 3, "GC step missing for cdata __index")
>      jit.off(f)
>    end
>  end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 0a72daed..5c2be87f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -7,6 +7,7 @@ ffi_bitfield.lua
>  ffi_call.lua
>  ffi_callback.lua
>  ffi_const.lua
> +ffi_convert.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-01-31 14:59   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:07   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 14:59 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM


^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches
@ 2024-01-31 15:07   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 13:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 16:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 15:07 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, except for the single nit below.

On Mon, Jan 29, 2024 at 01:45:11PM +0300, Sergey Kaplun wrote:
> This patch declares functions as local to avoid pollution of the global
> environment. It separates the body of the test in the `do` `while` block
> and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  .../lib/ffi/ffi_gcstep_recursive.lua          | 27 ++++++++++---------
>  test/LuaJIT-tests/lib/ffi/index               |  1 +
>  2 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> index cb19df11..f6e0b009 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> @@ -1,6 +1,6 @@
>  -- From Robert G. Jakabosky, 2012-03-20
>
> -local N=tonumber(arg[1] or 10000)
> +local N= 10000
Something wrong with formatting here.

<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
@ 2024-01-31 15:15   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 13:29     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 16:12   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-01-31 15:15 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, except for the single minor comment below.
On Mon, Jan 29, 2024 at 01:45:12PM +0300, Sergey Kaplun wrote:
> This patch names all subtests and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua | 22 ++++++++++-----------
>  test/LuaJIT-tests/lib/ffi/index             |  1 +
>  2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> index 0554fe60..efe83cfd 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> @@ -1,6 +1,6 @@
>  local ffi = require("ffi")
>
> -do
> +do --- int64_t arithmetic
>    local a = ffi.new("int64_t[?]", 101)
>    for i=1,100 do a[i] = -2 end
>    for i=1,100 do a[i] = i end
> @@ -29,7 +29,7 @@ do
>    assert(w == 5050)
>  end
>
> -do
> +do --- uint64_t arithmetic
>    local a = ffi.new("uint64_t[?]", 101)
>    for i=1,100 do a[i] = i end
>    local x, y, m = 0ull, 0ull, 0ull
> @@ -48,32 +48,32 @@ do
>    assert(z == 0x123456789abcdef0ull % 100)
>  end
>
> -do
> +do --- bit operations LL
>    local x = 0ll
>    for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ll) end
>    assert(x == 262120)
>  end
>
> -do
> +do --- bit operations LL, non-const base on trace
>    local x, a = 0ll, -2ll
>    for i=1,100 do x = x + a ^ (bit.band(i, 15)+1ll) end
>    assert(x == 262120)
>  end
>
> -do
> +do --- bit operations ULL
>    local x = 0ull
>    for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ull) end
>    assert(x == 262120)
>  end
>
> -do
> +do --- number vs. cdata interoperability
>    for i=1,200 do local j = bit.band(i, 7); assert((j == 0ll) == (j == 0)) end
>    for i=1,200 do assert((i < 100ll) == (i < 100)) end
>    for i=1,200 do assert((i <= 100ll) == (i <= 100)) end
>    for i=-100,100 do assert((i > 100ull) == (i < 0)) end
>  end
>
> -do
> +do --- comparisons checksum
>    local a = ffi.new("int64_t[?]", 100)
>    for i=0,99 do
>      a[i] = math.random(0, 2^32)*0x100000000LL + math.random(0, 2^32)
> @@ -121,13 +121,13 @@ do
>    end
>  end
>
> -do
> +do --- pointer subtraction
>    local a, b = ffi.new("char *"), ffi.new("char *")
>    local z
>    for i=1,100 do z = a-b end
>  end
>
> -do
> +do --- char and 0LL base comparisons
>    local x = true
>    local abc = ffi.cast("const char *", "abc")
>    for i=1,100 do x = abc == "abc" end
> @@ -142,8 +142,8 @@ do
>    assert(x == false)
>  end
>
> --- ra_destpair
> -do
> +
> +do --- ra_destpair
Does `ra` means `register allocator`?
>    local x, y = 0, 0
>    for i=1,100 do
>      x = x + i/3LL
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 8236ab98..0c1e5e66 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -10,6 +10,7 @@ ffi_const.lua
>  ffi_convert.lua
>  ffi_enum.lua
>  ffi_gcstep_recursive.lua
> +ffi_jit_arith.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  8:30   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:15   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  8:30 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  8:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 12:51   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  8:32 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  8:38   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 13:39     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 12:53   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  8:38 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider two comments below.

On Mon, Jan 29, 2024 at 01:45:15PM +0300, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()`. Also, it adds groups with the names of
> subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua | 72 +++++++++++---------
>  test/LuaJIT-tests/lib/ffi/index              |  1 +
>  2 files changed, 39 insertions(+), 34 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> index e26650ef..ca6c65c5 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> @@ -1,6 +1,6 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
>
>  local function checklex(t)
>    for i=1,1e9,2 do
> @@ -14,38 +14,42 @@ local function checklex(t)
>    end
>  end
>
> -checklex{
> -  "0LL",			"0ll",
> -  "0LL",			"0LL",
> -  "0ULL",			"0ull",
> -  "0ULL",			"0ULl",
> -  "18446744073709551615ULL",	"18446744073709551615llu",
> -  "9223372036854775807LL",	"0x7fffffffffffffffll",
> -  "9223372036854775808ULL",	"0x8000000000000000ull",
> -  "1311768467463790320LL",	"0x123456789abcdef0ll",
> -  "-1LL",			"-1ll",
> -  "18446744073709551615ULL",	"-1ull",
> -  "-9223372036854775807LL",	"-0x7fffffffffffffffll",
> -  "9223372036854775808ULL",	"-0x8000000000000000ull",
> -  "0+0i",			"0i",
> -  "0+0i",			"0I",
> -  "0+12.5i",			"12.5i",
> -  "0+4660i",			"0x1234i",
> -  "0+infI",			"1e400i",
> -  "0-infI",			"-1e400i",
> -  "0-12.5i",			"-12.5i",
> -  "0-0i",			"-0i",
> -}
> +do --- checklex
Maybe we can come up with a more elaborate name?
> +  checklex{
> +    "0LL",			"0ll",
> +    "0LL",			"0LL",
> +    "0ULL",			"0ull",
> +    "0ULL",			"0ULl",
> +    "18446744073709551615ULL",	"18446744073709551615llu",
> +    "9223372036854775807LL",	"0x7fffffffffffffffll",
> +    "9223372036854775808ULL",	"0x8000000000000000ull",
> +    "1311768467463790320LL",	"0x123456789abcdef0ll",
> +    "-1LL",			"-1ll",
> +    "18446744073709551615ULL",	"-1ull",
> +    "-9223372036854775807LL",	"-0x7fffffffffffffffll",
> +    "9223372036854775808ULL",	"-0x8000000000000000ull",
> +    "0+0i",			"0i",
> +    "0+0i",			"0I",
> +    "0+12.5i",			"12.5i",
> +    "0+4660i",			"0x1234i",
> +    "0+infI",			"1e400i",
> +    "0-infI",			"-1e400i",
> +    "0-12.5i",			"-12.5i",
> +    "0-0i",			"-0i",
> +  }
> +end
>
> -checkfail({
> -  "0l",
> -  "0lll",
> -  "0u",
> -  "0ul",
> -  "0ulll",
> -  "0wll",
> -  "0xll",
> -  ".0ll",
> -  "0ii",
> -}, function(s) assert(loadstring("return "..s)) end)
> +do --- checkfail
Same here.
> +  checkfail({
> +    "0l",
> +    "0lll",
> +    "0u",
> +    "0ul",
> +    "0ulll",
> +    "0wll",
> +    "0xll",
> +    ".0ll",
> +    "0ii",
> +  }, function(s) assert(loadstring("return "..s)) end)
> +end
>
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 71def57b..833c31e3 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -13,6 +13,7 @@ ffi_gcstep_recursive.lua
>  ffi_jit_arith.lua
>  ffi_jit_call.lua
>  ffi_jit_conv.lua
> +ffi_lex_number.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  8:40   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 12:58   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  8:40 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  8:43   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 13:55     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:03   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  8:43 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.
On Mon, Jan 29, 2024 at 01:45:17PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding require of the helper function. It adds groups with the
> names of subtests and enables the test in <index>. It renames structures
> typedefs to avoid conflicts with cdef in other tests. The GC threshold
> is increased since all tests run in a single process, so the number of
> GC objects is greater.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_new.lua | 50 +++++++++++++--------------
>  test/LuaJIT-tests/lib/ffi/index       |  1 +
>  2 files changed, 26 insertions(+), 25 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> index 9cdbd538..e5b19053 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> @@ -1,37 +1,37 @@
>  local ffi = require("ffi")
>  local bit = require("bit")
>
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>
>  ffi.cdef([[
> -typedef struct { int a,b,c; } foo1_t;
> -typedef int foo2_t[?];
> +typedef struct { int a,b,c; } foo1_new_t;
> +typedef int foo2_new_t[?];
`new` acts as a namespace here, which are conventionally go at the
beginning. Here and below.
>  void *malloc(size_t size);
>  void free(void *ptr);
>  ]])
>
> -do
> -  assert(ffi.sizeof("foo1_t") == 12)
> -  local cd = ffi.new("foo1_t")
> +do --- foo1_new_t
> +  assert(ffi.sizeof("foo1_new_t") == 12)
> +  local cd = ffi.new("foo1_new_t")
>    assert(ffi.sizeof(cd) == 12)
> -  local foo1_t = ffi.typeof("foo1_t")
> -  assert(ffi.sizeof(foo1_t) == 12)
> -  cd = foo1_t()
> +  local foo1_new_t = ffi.typeof("foo1_new_t")
> +  assert(ffi.sizeof(foo1_new_t) == 12)
> +  cd = foo1_new_t()
>    assert(ffi.sizeof(cd) == 12)
>  end
>
> -do
> -  assert(ffi.sizeof("foo2_t", 3) == 12)
> -  local cd = ffi.new("foo2_t", 3)
> +do --- foo2_new_t
> +  assert(ffi.sizeof("foo2_new_t", 3) == 12)
> +  local cd = ffi.new("foo2_new_t", 3)
>    assert(ffi.sizeof(cd) == 12)
> -  local foo2_t = ffi.typeof("foo2_t")
> -  fails(ffi.sizeof, foo2_t)
> -  assert(ffi.sizeof(foo2_t, 3) == 12)
> -  cd = foo2_t(3)
> +  local foo2_new_t = ffi.typeof("foo2_new_t")
> +  fails(ffi.sizeof, foo2_new_t)
> +  assert(ffi.sizeof(foo2_new_t, 3) == 12)
> +  cd = foo2_new_t(3)
>    assert(ffi.sizeof(cd) == 12)
>  end
>
> -do
> +do --- byte to int cast
>    local tpi = ffi.typeof("int")
>    local tpb = ffi.typeof("uint8_t")
>    local t = {}
> @@ -42,7 +42,7 @@ do
>    assert(x == 199*257 + 1)
>  end
>
> -do
> +do --- aligned structure GC
>    local oc = collectgarbage("count")
>    for al=0,15 do
>      local align = 2^al -- 1, 2, 4, ..., 32768
> @@ -54,17 +54,17 @@ do
>      end
>    end
>    local nc = collectgarbage("count")
> -  assert(nc < oc + 3000, "GC step missing for ffi.new")
> +  assert(nc < oc * 10, "GC step missing for ffi.new")
Are you sure that this is the lower bound of the GC threshold?
>  end
>
> -do
> +do --- VLA
>    local t = {}
>    for i=1,100 do t[i] = ffi.new("int[?]", i) end
>    assert(ffi.sizeof(t[100]) == 400)
>    for i=0,99 do assert(t[100][i] == 0) end
>  end
>
> -do
> +do --- VLS
>    local t = {}
>    local ct = ffi.typeof("struct { double x; int y[?];}")
>    for i=1,100 do t[i] = ct(i) end
> @@ -72,7 +72,7 @@ do
>    for i=0,99 do assert(t[100].y[i] == 0) end
>  end
>
> -do
> +do --- aligned(16) structure exit from trace
>    local ct = ffi.typeof("struct __attribute__((aligned(16))) { int x; }")
>    local y
>    for i=1,200 do
> @@ -82,7 +82,7 @@ do
>    assert(bit.band(ffi.cast("intptr_t", ffi.cast("void *", y)), 15) == 0)
>  end
>
> -do
> +do --- cdata resurrecting
>    local q
>    local p = ffi.gc(ffi.new("int[1]"), function(x) q = x end)
>    p = nil
> @@ -93,13 +93,13 @@ do
>    assert(q == nil)
>  end
>
> -do
> +do --- GC malloc free
>    local p = ffi.gc(ffi.C.malloc(2^20), ffi.C.free)
>    p = nil
>    collectgarbage()
>  end
>
> -do
> +do --- test lua_close() cleanup
>    local p = ffi.gc(ffi.new("int[1]"), function(x) assert(type(x) == "cdata") end)
>    -- test for lua_close() cleanup.
>  end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 338a6930..e6c1fd0f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -15,6 +15,7 @@ ffi_jit_call.lua
>  ffi_jit_conv.lua
>  ffi_lex_number.lua
>  ffi_metatype.lua
> +ffi_new.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:01   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:11     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:08   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:01 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.
On Mon, Jan 29, 2024 at 01:45:18PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 ++++++++++--------
>  test/LuaJIT-tests/lib/ffi/index               |   1 +
>  2 files changed, 58 insertions(+), 49 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> index 3a9616d7..d3b02759 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> @@ -1,58 +1,66 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
> +local fails = require("common.fails")
>
> -checkfail{
> -  "int [",
> -  "int [-1]",
> -  "int [[1]]",
> -  "int [10][]",
> -  "int [10][?]",
> -  "int [][]",
> -  "int [][?]",
> -  "int [?][]",
> -  "int [?][?]",
> -  "int [0x10000][0x2000]",
> -  "int [256][256][256][256]",
> -  "int [10](void)",
> -  "int (void)[10]",
> -  "int &[10]",
> -  "union { double x; int a[?]; }",
> -}
I would prefer a more elaborate name here.
> +do --- checkfail
> +  checkfail{
> +    "int [",
> +    "int [-1]",
> +    "int [[1]]",
> +    "int [10][]",
> +    "int [10][?]",
> +    "int [][]",
> +    "int [][?]",
> +    "int [?][]",
> +    "int [?][?]",
> +    "int [0x10000][0x2000]",
> +    "int [256][256][256][256]",
> +    "int [10](void)",
> +    "int (void)[10]",
> +    "int &[10]",
> +    "union { double x; int a[?]; }",
> +  }
> +end
>
> -ffi.cdef([[
> -  typedef int foo1_t[10];
> -  typedef foo1_t foo2_t[5];
> -]])
> -assert(ffi.sizeof("foo1_t") == 40)
> -assert(ffi.sizeof("foo2_t") == 200)
> +do --- sizeof of arrays
> +  ffi.cdef([[
> +    typedef int foo1_array_t[10];
> +    typedef foo1_array_t foo2_array_t[5];
> +  ]])
> +  assert(ffi.sizeof("foo1_array_t") == 40)
> +  assert(ffi.sizeof("foo2_array_t") == 200)
> +end
>
> -local P = ffi.sizeof("void *")
>
> -checktypes{
> -  10,	1,	"char [10]",
> -  4*10,	4,	"int [10]",
> -  4*10,	4,	"int [10]",
> -  4*10*5, 4,	"int [10][5]",
> -  4*10*5*3*2*7, 4,	"int [10][5][3][2][7]",
> -  4*10*5, 4,	"int ([10])[5]",
> -  P*10,	P,	"int *[10]",
> -  P,	P,	"int (*)[10]",
> -  P*5,	P,	"int (*[5])[10]",
> -  8*10,	4,	"struct { int x; char y; } [10]",
> -  P*5*10, P,	"volatile int *(* const *[5][10])(void)",
> -  nil,	4,	"int []",
> -  4*10,	8,	"int __attribute__((aligned(8))) [10]",
> -  4*10,	8,	"__attribute__((aligned(8))) int [10]",
> -  4*10,	8,	"int [10] __attribute__((aligned(8)))",
> -  97,	1,	"char ['a']",
> -  83,	1,	"char ['\\123']",
> -  79,	1,	"char ['\x4F']",
> -  5,	1,	"char [sizeof(\"aa\" \"bb\")]",
> -  80,	8,	"double [10]",
> -}
Same here.
> +do --- checktypes
> +  local P = ffi.sizeof("void *")
> +  checktypes{
> +    10,	1,	"char [10]",
> +    4*10,	4,	"int [10]",
> +    4*10,	4,	"int [10]",
> +    4*10*5, 4,	"int [10][5]",
> +    4*10*5*3*2*7, 4,	"int [10][5][3][2][7]",
> +    4*10*5, 4,	"int ([10])[5]",
> +    P*10,	P,	"int *[10]",
> +    P,	P,	"int (*)[10]",
> +    P*5,	P,	"int (*[5])[10]",
> +    8*10,	4,	"struct { int x; char y; } [10]",
> +    P*5*10, P,	"volatile int *(* const *[5][10])(void)",
> +    nil,	4,	"int []",
> +    4*10,	8,	"int __attribute__((aligned(8))) [10]",
> +    4*10,	8,	"__attribute__((aligned(8))) int [10]",
> +    4*10,	8,	"int [10] __attribute__((aligned(8)))",
> +    97,	1,	"char ['a']",
> +    83,	1,	"char ['\\123']",
> +    79,	1,	"char ['\x4F']",
> +    5,	1,	"char [sizeof(\"aa\" \"bb\")]",
> +    80,	8,	"double [10]",
> +  }
> +end
>
> -do
> +do --- sizeof VLA
>    assert(ffi.sizeof("int [?]", 10) == 4*10)
>    local id = ffi.typeof("const short [?]")
>    assert(ffi.sizeof(id, 10) == 2*10)
> @@ -64,7 +72,7 @@ do
>    assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
>  end
>
> -do
> +do --- sizeof VLS
>    assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
>    local id = ffi.typeof("struct { int x; short a[?]; }")
>    assert(ffi.sizeof(id, 10) == 4+2*10)
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index e6c1fd0f..89773c0c 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -16,6 +16,7 @@ ffi_jit_conv.lua
>  ffi_lex_number.lua
>  ffi_metatype.lua
>  ffi_new.lua
> +ffi_parse_array.lua
>  istype.lua
>  jit_array.lua
>  jit_complex.lua
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:03   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:15     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:03 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:19PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 +++++++++---------
>  test/LuaJIT-tests/lib/ffi/index               |   1 +
>  2 files changed, 132 insertions(+), 120 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> index c054bcfb..3b49648c 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> @@ -1,131 +1,142 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
>
> -checkfail{
> -  "",
> -  " ",
> -  "\n",
> -  "1",
> -  ".",
> -  ";",
> -  ",",
> -  "*",
> -  "[]",
> -  "()",
> -  "(*)",
> -  "//",
> -  "/*",
> -  "xyz",
> -  "const",
> -  "volatile",
> -  "typedef",
> -  "extern",
> -  "static",
> -  "auto",
> -  "register",
> -  "struct",
> -  "union",
> -  "sizeof",
> -  "int int",
> -  "int char",
> -  "int double",
> -  "int;",
> -}
> +do --- checkfail
I would prefer a more elaborate name here.
> +  checkfail{
> +    "",
> +    " ",
> +    "\n",
> +    "1",
> +    ".",
> +    ";",
> +    ",",
> +    "*",
> +    "[]",
> +    "()",
> +    "(*)",
> +    "//",
> +    "/*",
> +    "xyz",
> +    "const",
> +    "volatile",
> +    "typedef",
> +    "extern",
> +    "static",
> +    "auto",
> +    "register",
> +    "struct",
> +    "union",
> +    "sizeof",
> +    "int int",
> +    "int char",
> +    "int double",
> +    "int;",
> +  }
> +end
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:05   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:21     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:11   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:05 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:20PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua | 141 ++++++++++---------
>  test/LuaJIT-tests/lib/ffi/index              |   1 +
>  2 files changed, 77 insertions(+), 65 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> index 4bb5d903..cc123808 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> @@ -1,77 +1,88 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
>
> -checkfail({
> -  "int",
> -  "int aa1; int aa2 ",
> -  "static int x;",
> -  "static const long long x = 1;", -- NYI
> -  "static const double x = 1;",	   -- NYI
> -  "static const bool x = 1;",	   -- NYI (intentional, need true/false)
> -  "struct { static int x = 1; };",
> -  ";;static int y"
> -}, ffi.cdef)
> +do --- checkfail
More elaborate name would be nice.
> +  checkfail({
> +    "int",
> +    "int aa1; int aa2 ",
> +    "static int x;",
> +    "static const long long x = 1;", -- NYI
> +    "static const double x = 1;",	   -- NYI
> +    "static const bool x = 1;",	   -- NYI (intentional, need true/false)
> +    "struct { static int x = 1; };",
> +    ";;static int y"
> +  }, ffi.cdef)
> +end
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:16   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:14   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:16 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:21PM +0300, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>  .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
>  test/LuaJIT-tests/lib/ffi/index               |   1 +
>  2 files changed, 176 insertions(+), 160 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> index 16a3d053..cb231c33 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> @@ -1,113 +1,123 @@
>  local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
> +local fails = require("common.fails")
>
> -checkfail{
> -  "struct",
> -  "struct {",
> -  "struct xx xx {}",
> -  "struct { int x  }",
> -  "struct { int x,  }",
> -  "struct { int x,y  }",
> -  "struct { void x; }",
> -  "struct { int x(void); }",
> -  "struct recursive1 { struct recursive1 { } x; }",
> -  "union",
> -  "union {",
> -  "union xx xx {}",
> -  "union { int x  }",
> -  "union { int x,  }",
> -  "union { int x,y  }",
> -  "union { void x; }",
> -  "union { int x(void); }",
> -  "union recursive1 { union recursive1 { } x; }",
> -}
> +local P = ffi.sizeof("void *")
> +local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8
> +
> +do --- checkfail
A more elaborate name would be nice.
> +  checkfail{
> +    "struct",
> +    "struct {",
> +    "struct xx xx {}",
> +    "struct { int x  }",
> +    "struct { int x,  }",
> +    "struct { int x,y  }",
> +    "struct { void x; }",
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:19   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:37     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:20   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:19 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On Mon, Jan 29, 2024 at 01:45:22PM +0300, Sergey Kaplun wrote:
> This patch moves the <ffi_tabov.lua> test from the LuaJIT-tests suite to
> the tarantool-tests suite, because this test should be run separately to
> avoid overflow of the table with ctypes for other tests from
> LuaJIT-tests suite.
>
> Part of tarantool/tarantool#9398
> ---
>  test/LuaJIT-tests/lib/ffi/ffi_tabov.lua | 12 -----------
>  test/tarantool-tests/ffi-tabov.test.lua | 27 +++++++++++++++++++++++++
>  2 files changed, 27 insertions(+), 12 deletions(-)
>  delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
>  create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua b/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> deleted file mode 100644
> index ba621960..00000000
> --- a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -local ffi = require("ffi")
> -
> -local last = 0
> -
> -assert(pcall(function()
> -  for i=1,65536 do
> -    last = i
> -    ffi.typeof"struct {}"
> -  end
> -end) == false)
> -
> -assert(last > 20000)
> diff --git a/test/tarantool-tests/ffi-tabov.test.lua b/test/tarantool-tests/ffi-tabov.test.lua
> new file mode 100644
> index 00000000..7ea8b24b
> --- /dev/null
> +++ b/test/tarantool-tests/ffi-tabov.test.lua
> @@ -0,0 +1,27 @@
> +local tap = require('tap')
> +local ffi = require('ffi')
> +
> +-- This test is moved here from the LuaJIT-tests suite since it
> +-- should be run separately because it exhausts the ctype table.
> +local test = tap.test('ffi-tabov')
> +
> +test:plan(3)
> +
> +-- XXX: Amount of ctypes available to the user of a platform.
Where does this number comes from? Drop a comment.
> +local MIN_AVAILABLE_CTYPES = 20000
> +
> +local last = 0
> +
> +local res, errmsg = pcall(function()
> +  for i = 1, 2^16 do
Drop a comment explaining the number of iterations.
> +    last = i
> +    ffi.typeof('struct {}')
> +  end
> +end)
> +
> +test:ok(res == false, 'correct status')
> +test:like(errmsg, 'table overflow', 'correct error message')
> +
> +test:ok(last > MIN_AVAILABLE_CTYPES, 'huge enough amount of free ctypes')
> +
> +test:done(true)
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:23   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:43     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:27   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:23 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, with a question below.
On Mon, Jan 29, 2024 at 01:45:23PM +0300, Sergey Kaplun wrote:
> This patch moves the <lightud.lua> test from the <misc> to <lang>
What is the rationale for that?
> directory, includes it in <index>, and names subtests. Also, it enables
> tests for all arches and fixes tests for 47-bit lightuserdata because it
> is available since the commit
> 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64
> bit lightuserdata.")
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:25   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-06 14:44     ` Sergey Kaplun via Tarantool-patches
  2024-02-05 13:28   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:25 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, with the same question about moving from <misc> to <lang>.
On Mon, Jan 29, 2024 at 01:45:24PM +0300, Sergey Kaplun wrote:
> This patch moves the <api_call.lua> test from the <misc> to <lang>
> directory, includes it in <index>, and names subtests.
>
> Part of tarantool/tarantool#9398
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:31   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:31 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01  9:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-01  9:32 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
  2024-01-31 11:25   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 14:20   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 14:20 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey


thanks for the patch! LGTM


On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch removes copy-pasting in macros used to add a new library for
> testing and places this in the include test file.
>
> Needed for tarantool/tarantool#9398
> ---
>   test/CMakeLists.txt                           |  3 ++
>   .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 25 +----------------
>   test/cmake/AddTestLib.cmake                   | 28 +++++++++++++++++++
>   test/tarantool-tests/CMakeLists.txt           | 27 +-----------------
>   4 files changed, 33 insertions(+), 50 deletions(-)
>   create mode 100644 test/cmake/AddTestLib.cmake
>
> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
> index 8afc42df..3ad5d15f 100644
> --- a/test/CMakeLists.txt
> +++ b/test/CMakeLists.txt
> @@ -74,6 +74,9 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS
>   set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
>   separate_arguments(LUAJIT_TEST_COMMAND)
>   
> +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
> +include(AddTestLib)
> +
>   add_subdirectory(LuaJIT-tests)
>   add_subdirectory(PUC-Rio-Lua-5.1-tests)
>   add_subdirectory(lua-Harness-tests)
> diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> index 8501b767..e68e6aef 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> +++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> @@ -6,30 +6,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
>   
>   # Build additional C libraries for tests.
>   macro(BuildTestCLib lib sources)
> -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> -  target_include_directories(${lib} PRIVATE
> -    ${LUAJIT_SOURCE_DIR}
> -  )
> -  set_target_properties(${lib} PROPERTIES
> -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> -    PREFIX ""
> -  )
> -  # XXX: The dynamic libraries are loaded with LuaJIT binary and
> -  # use symbols from it. So it is totally OK to have unresolved
> -  # symbols at build time.
> -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> -    set_target_properties(${lib} PROPERTIES
> -      LINK_FLAGS "-undefined dynamic_lookup"
> -    )
> -  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> -    # XXX: This is necessary mostly for openSUSE builds, see also
> -    # https://bugzilla.suse.com/show_bug.cgi?id=1012388.
> -    # Just strip out the linker flag to suppress this linker
> -    # option.
> -    string(REPLACE "-Wl,--no-undefined" ""
> -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> -    )
> -  endif()
> +  AddTestLib(${lib} ${sources})
>     list(APPEND TESTLIBS ${lib})
>   endmacro()
>   
> diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
> new file mode 100644
> index 00000000..3764ee5c
> --- /dev/null
> +++ b/test/cmake/AddTestLib.cmake
> @@ -0,0 +1,28 @@
> +macro(AddTestLib lib sources)
> +  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> +  target_include_directories(${lib} PRIVATE
> +    ${LUAJIT_SOURCE_DIR}
> +    ${CMAKE_CURRENT_SOURCE_DIR}
> +  )
> +  set_target_properties(${lib} PROPERTIES
> +    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> +    PREFIX ""
> +  )
> +
> +  # XXX: This change affects the current cmake variable scope and
> +  # so a user should care to don't use it in a top level scope.
> +  # The dynamic libraries are loaded with LuaJIT binary and use
> +  # symbols from it. So it is totally OK to have unresolved
> +  # symbols at build time.
> +  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> +    set_target_properties(${lib} PROPERTIES
> +      LINK_FLAGS "-undefined dynamic_lookup"
> +    )
> +  else()
> +    # FIXME: Unfortunately, there is no another way to suppress
> +    # this linker option, so just strip it out from the flags.
> +    string(REPLACE "-Wl,--no-undefined" ""
> +      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> +    )
> +  endif()
> +endmacro()
> diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
> index 6d686876..80d94a78 100644
> --- a/test/tarantool-tests/CMakeLists.txt
> +++ b/test/tarantool-tests/CMakeLists.txt
> @@ -11,32 +11,7 @@ if(NOT PROVE)
>   endif()
>   
>   macro(BuildTestCLib lib sources)
> -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> -  target_include_directories(${lib} PRIVATE
> -    ${LUAJIT_SOURCE_DIR}
> -    ${CMAKE_CURRENT_SOURCE_DIR}
> -  )
> -  set_target_properties(${lib} PROPERTIES
> -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> -    PREFIX ""
> -  )
> -
> -  # XXX: This change affects the current cmake variable scope and
> -  # so a user should care to don't use it in a top level scope.
> -  # The dynamic libraries are loaded with LuaJIT binary and use
> -  # symbols from it. So it is totally OK to have unresolved
> -  # symbols at build time.
> -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> -    set_target_properties(${lib} PROPERTIES
> -      LINK_FLAGS "-undefined dynamic_lookup"
> -    )
> -  else()
> -    # FIXME: Unfortunately, there is no another way to suppress
> -    # this linker option, so just strip it out from the flags.
> -    string(REPLACE "-Wl,--no-undefined" ""
> -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> -    )
> -  endif()
> +  AddTestLib(${lib} ${sources})
>     # XXX: Append the lib to be built to the dependency list.
>     # Unfortunately, there is no convenient way in CMake to extend
>     # the list in parent scope other than join two strings with

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches
  2024-01-31 11:48   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 14:23   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 14:23 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: 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
> <LuaJIT-tests/src/> 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

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 14:32   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 12:10     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 16:02   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 14:32 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with a minor comment below

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()`.  Also, it names the only one test as "misc"
extra whitespace before "Also"
> and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_const.lua | 4 ++--
>   test/LuaJIT-tests/lib/ffi/index         | 1 +
>   2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> index d42133ad..3213156d 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> @@ -1,6 +1,6 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef[[
>   typedef struct s_t {
> @@ -41,7 +41,7 @@ typedef struct foo_t {
>   } foo_t;
>   ]]
>   
> -do
> +do --- misc
>     local foo_t = ffi.typeof("foo_t")
>     local x = foo_t()
>   
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 9a22104a..0a72daed 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -6,6 +6,7 @@ ffi_arith_ptr.lua
>   ffi_bitfield.lua
>   ffi_call.lua
>   ffi_callback.lua
> +ffi_const.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches
  2024-01-31 11:58   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 15:45   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 11:48     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 15:45 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with a minor comment below

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>
> into separate files by analogy with <common/expect_error.lua>. The
> `include()` helper isn't touched since it is used in system dependend
typo: dependent?
> tests, which won't be modified for now.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/common/fails.lua          |  3 +++
>   test/LuaJIT-tests/common/ffi/checkfail.lua  | 14 +++++++++++++
>   test/LuaJIT-tests/common/ffi/checktypes.lua | 15 ++++++++++++++
>   test/LuaJIT-tests/common/ffi_util.inc       | 23 ---------------------
>   4 files changed, 32 insertions(+), 23 deletions(-)
>   create mode 100644 test/LuaJIT-tests/common/fails.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
>
> diff --git a/test/LuaJIT-tests/common/fails.lua b/test/LuaJIT-tests/common/fails.lua
> new file mode 100644
> index 00000000..d555a2b5
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/fails.lua
> @@ -0,0 +1,3 @@
> +return function(f, ...)
> +  if pcall(f, ...) ~= false then error("failure expected", 2) end
> +end
> diff --git a/test/LuaJIT-tests/common/ffi/checkfail.lua b/test/LuaJIT-tests/common/ffi/checkfail.lua
> new file mode 100644
> index 00000000..d3ca74e8
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/ffi/checkfail.lua
> @@ -0,0 +1,14 @@
> +local ffi = require("ffi")
> +
> +-- Checker that takes an array of strings that should represent
> +-- different invalid CTypes (a more common pattern). Also, the
> +-- second argument may be also the `loadstring` function to check
> +-- invalid literals or `ffi.cdef` to check invalid C definitions.
> +return function(t, f)
> +  f = f or ffi.typeof
> +  for i=1,1e9 do
> +    local tp = t[i]
> +    if not tp then break end
> +    assert(pcall(f, tp) == false, tp)
> +  end
> +end
> diff --git a/test/LuaJIT-tests/common/ffi/checktypes.lua b/test/LuaJIT-tests/common/ffi/checktypes.lua
> new file mode 100644
> index 00000000..c995d667
> --- /dev/null
> +++ b/test/LuaJIT-tests/common/ffi/checktypes.lua
> @@ -0,0 +1,15 @@
> +local ffi = require("ffi")
> +
> +-- Checker that takes an array with the following each 3 elements:
> +-- 1) Sizeof for the given C type to be checked.
> +-- 2) Alignof for the given C type to be checked.
> +-- 3) String representing the C type.
> +return function(t)
> +  for i=1,1e9,3 do
> +    local tp = t[i+2]
> +    if not tp then break end
> +    local id = ffi.typeof(tp)
> +    assert(ffi.sizeof(id) == t[i], tp)
> +    assert(ffi.alignof(id) == t[i+1], tp)
> +  end
> +end
> diff --git a/test/LuaJIT-tests/common/ffi_util.inc b/test/LuaJIT-tests/common/ffi_util.inc
> index 1eee8dd9..9604d7b0 100644
> --- a/test/LuaJIT-tests/common/ffi_util.inc
> +++ b/test/LuaJIT-tests/common/ffi_util.inc
> @@ -4,29 +4,6 @@
>   
>   local ffi = require("ffi")
>   
> -function checkfail(t, f)
> -  f = f or ffi.typeof
> -  for i=1,1e9 do
> -    local tp = t[i]
> -    if not tp then break end
> -    assert(pcall(f, tp) == false, tp)
> -  end
> -end
> -
> -function checktypes(t)
> -  for i=1,1e9,3 do
> -    local tp = t[i+2]
> -    if not tp then break end
> -    local id = ffi.typeof(tp)
> -    assert(ffi.sizeof(id) == t[i], tp)
> -    assert(ffi.alignof(id) == t[i+1], tp)
> -  end
> -end
> -
> -function fails(f, ...)
> -  if pcall(f, ...) ~= false then error("failure expected", 2) end
> -end
> -
>   local incroot = os.getenv("INCROOT") or "/usr/include"
>   local cdefs = os.getenv("CDEFS") or ""
>   

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
  2024-01-31 12:21   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 15:50   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 15:50 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper function. It adds test names and
> includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua | 13 ++++++-------
>   test/LuaJIT-tests/lib/ffi/index             |  1 +
>   2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua b/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
> index 8cf890c6..f7fac0d8 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua
> @@ -1,6 +1,5 @@
>   local ffi = require("ffi")
> -
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef[[
>   typedef struct { int a,b,c; } foo1_t;
> @@ -9,7 +8,7 @@ void *malloc(size_t);
>   struct incomplete;
>   ]]
>   
> -do
> +do --- base pointer arithmetic and comparisons
>     local a = ffi.new("int[10]")
>     local p1 = a+0
>     p1[0] = 1;
> @@ -61,7 +60,7 @@ do
>     assert(b - a == 5)
>   end
>   
> -do
> +do --- pointer comparisons for different types
>     local p1 = ffi.cast("void *", 0)
>     local p2 = ffi.cast("int *", 1)
>     assert(p1 == p1)
> @@ -71,7 +70,7 @@ do
>     assert(p2 ~= nil)
>   end
>   
> -do
> +do --- pointer comparisons for functions
>     local f1 = ffi.C.free
>     local f2 = ffi.C.malloc
>     local p1 = ffi.cast("void *", f1)
> @@ -84,7 +83,7 @@ do
>     fails(function(f1) return f1 + 1 end, f1)
>   end
>   
> -do
> +do --- pointer arithmetic for structures
>     local s = ffi.new("foo1_t[10]")
>     local p1 = s+3
>     p1.a = 1; p1.b = 2; p1.c = 3
> @@ -96,7 +95,7 @@ do
>     assert(p1 - p2 == -3)
>   end
>   
> -do
> +do --- pointer arithmetic for structure with unknown size
>     local mem = ffi.new("int[1]")
>     local p = ffi.cast("struct incomplete *", mem)
>     fails(function(p) return p+1 end, p)
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 59e36dd8..7e046908 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -2,6 +2,7 @@ bit64.lua +luajit>=2.1
>   cdata_var.lua
>   copy_fill.lua
>   err.lua
> +ffi_arith_ptr.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 12:26   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 15:52   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 11:55     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 15:52 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM after renaming testcase (I'm agree with Maxim).

BTW don't forget to update commit description after renaming.


On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch removes unused `dofile()`. Also, it names the only one test
> as "misc" and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua | 4 +---
>   test/LuaJIT-tests/lib/ffi/index            | 1 +
>   2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> index cd0b1815..fa74e45d 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> @@ -1,8 +1,6 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> -
> -do
> +do --- misc
>     local x = ffi.new([[
>       union {
>         uint32_t u;
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 7e046908..8d833107 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -3,6 +3,7 @@ cdata_var.lua
>   copy_fill.lua
>   err.lua
>   ffi_arith_ptr.lua
> +ffi_bitfield.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 12:34   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 15:58   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 12:01     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 15:58 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with minor comment below

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch removes unused `dofile()`. Also, it uses the basename of the
> ctest library to be loaded via ffi. It adds groups with names of
> subtests and enables the test in <index>. Complex type is undefined on
> Windows, so the correponding tests are not enabled for this platform.
> Fastcalls are enabled only for the x86 architecture. Stdcalls are
> enabled only for Windows on x86. Tests with calls with 10 arguments with
> sizes less than 8 bits are dummy for M1. This suite lacks a mechanism to

too much "with" for my taste :) feel free to ignore

Thanks for reformatting testcases, much more readable now.

> skip subtests satisfying complicated conditions, so it is done manually
> by the corresponding `if` check.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_call.lua | 185 +++++++++++++------------
>   test/LuaJIT-tests/lib/ffi/index        |   1 +
>   2 files changed, 97 insertions(+), 89 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_call.lua b/test/LuaJIT-tests/lib/ffi/ffi_call.lua
> index 1eb5e906..0844b686 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_call.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_call.lua
> @@ -1,8 +1,5 @@
> -
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> -
>   local tonumber = tonumber
>   
>   ffi.cdef[[
> @@ -73,81 +70,92 @@ double __stdcall stdcall_dd(double a, double b);
>   float __stdcall stdcall_ff(float a, float b);
>   ]]
>   
> -local C = ffi.load("../clib/ctest")
> +local C = ffi.load("ctest")
>   
> -assert(C.call_i(-42) == -41)
> -assert(C.call_ii(-42, 17) == -42+17)
> -assert(C.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) == -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
> +do --- int enum double float args
> +  assert(C.call_i(-42) == -41)
> +  assert(C.call_ii(-42, 17) == -42+17)
>   
> -assert(C.call_ie(123) == 124)
> +  assert(C.call_ie(123) == 124)
>   
> -assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
> -assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17))
> -assert(tonumber(C.call_jj(-42, 17)) == -42+17)
> -assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) == tonumber(0x123456789abcdef0LL-0x789abcde99887766LL))
> +  assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
> +  assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17))
> +  assert(tonumber(C.call_jj(-42, 17)) == -42+17)
> +  assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) ==
> +                   tonumber(0x123456789abcdef0LL - 0x789abcde99887766LL))
>   
> -assert(C.call_dd(12.5, -3.25) == 12.5-3.25)
> -assert(C.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
> +  assert(C.call_dd(12.5, -3.25) == 12.5-3.25)
>   
> -assert(C.call_ff(12.5, -3.25) == 12.5-3.25)
> -assert(C.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
> +  assert(C.call_ff(12.5, -3.25) == 12.5-3.25)
>   
> -assert(C.call_idifjd(-42, 17.125, 0x12345, -100.625, 12345678901234, -789012.75) == -42+17.125+0x12345-100.625+12345678901234-789012.75)
> +  assert(C.call_idifjd(-42,  17.125,  0x12345, -100.625,  12345678901234, -789012.75) ==
> +                       -42 + 17.125 + 0x12345 - 100.625 + 12345678901234 - 789012.75)
> +end
> +
> +do --- 10 ints, 10 floats, 10 doubles
> +  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
> +    assert(C.call_10i(-42,  17,  12345,  9987, -100,  11,  51,  0x12345678,  338, -78901234) ==
> +                      -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
> +    assert(C.call_10f(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x123456,  338, -789012.75) ==
> +                      -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x123456 + 338 - 789012.75)
> +  end
> +  assert(C.call_10d(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x12345678,  338, -78901234.75) ==
> +                    -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x12345678 + 338 - 78901234.75)
> +end
>   
> -do
> +do --- pointers
>     local a = ffi.new("int[10]", -42)
>     assert(C.call_p_i(a) == -42+1)
>     assert(tonumber(ffi.cast("intptr_t", C.call_p_p(a+3))) == tonumber(ffi.cast("intptr_t", a+4)))
>     assert(C.call_pp_i(a+8, a+5) == 3)
>   end
>   
> --- vararg
> -assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131)
> +do --- vararg
> +  assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131)
> +end
>   
>   -- complex
> -if pcall(function() return C.call_dd_cd end) then
> -  do
> -    local c = C.call_dd_cd(12.5, -3.25)
> -    assert(c.re == 12.5 and c.im == -3.25*2)
> -  end
> -  do
> -    local c1 = ffi.new("complex", 12.5, -3.25)
> -    local cz = C.call_cd(c1)
> -    assert(cz.re == 12.5+1 and cz.im == -3.25-2)
> -  end
> -  do
> -    local c1 = ffi.new("complex", 12.5, -3.25)
> -    local c2 = ffi.new("complex", -17.125, 100.625)
> -    local cz = C.call_cdcd(c1, c2)
> -    assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
> -  end
> +do --- complex double, 2 double args -windows
> +  local c = C.call_dd_cd(12.5, -3.25)
> +  assert(c.re == 12.5 and c.im == -3.25*2)
> +end
> +do --- complex double, 1 complex arg -windows
> +  local c1 = ffi.new("complex", 12.5, -3.25)
> +  local cz = C.call_cd(c1)
> +  assert(cz.re == 12.5+1 and cz.im == -3.25-2)
> +end
> +do --- complex double, 2 complex args -windows
> +  local c1 = ffi.new("complex", 12.5, -3.25)
> +  local c2 = ffi.new("complex", -17.125, 100.625)
> +  local cz = C.call_cdcd(c1, c2)
> +  assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
> +end
>   
> -  do
> -    local c = C.call_ff_cf(12.5, -3.25)
> -    assert(c.re == 12.5 and c.im == -3.25*2)
> -  end
> -  do
> -    local c1 = ffi.new("complex float", 12.5, -3.25)
> -    local cz = C.call_cf(c1)
> -    assert(cz.re == 12.5+1 and cz.im == -3.25-2)
> -  end
> -  do
> -    local c1 = ffi.new("complex float", 12.5, -3.25)
> -    local c2 = ffi.new("complex float", -17.125, 100.625)
> -    local cz = C.call_cfcf(c1, c2)
> -    assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
> -  end
> +do --- complex float, 2 float args -windows
> +  local c = C.call_ff_cf(12.5, -3.25)
> +  assert(c.re == 12.5 and c.im == -3.25*2)
> +end
> +do --- complex float, 1 complex float arg -windows
> +  local c1 = ffi.new("complex float", 12.5, -3.25)
> +  local cz = C.call_cf(c1)
> +  assert(cz.re == 12.5+1 and cz.im == -3.25-2)
> +end
> +do --- complex float, 2 complex float args -windows
> +  local c1 = ffi.new("complex float", 12.5, -3.25)
> +  local c2 = ffi.new("complex float", -17.125, 100.625)
> +  local cz = C.call_cfcf(c1, c2)
> +  assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625)
>   end
>   
>   -- structs
> -do
> +do --- struct {int; int;} arg, return struct {int; int;}
>     local s1 = ffi.new("s_ii", -42, 17)
>     local sz = C.call_sii(s1)
>     assert(s1.x == -42 and s1.y == 17)
>     assert(sz.x == -42 and sz.y == 17)
>   end
>   
> -do
> +do --- struct {int64_t; int64_t;} arg, return struct {int64_t; int64_t;}
>     local s1 = ffi.new("s_jj", 0x123456789abcdef0LL, -0x789abcde99887766LL)
>     local sz = C.call_sjj(s1)
>     assert(s1.x == 0x123456789abcdef0LL)
> @@ -156,28 +164,28 @@ do
>     assert(sz.y == -0x789abcde99887766LL)
>   end
>   
> -do
> +do --- struct {float; float;} arg, return struct {float; float;}
>     local s1 = ffi.new("s_ff", 12.5, -3.25)
>     local sz = C.call_sff(s1)
>     assert(s1.x == 12.5 and s1.y == -3.25)
>     assert(sz.x == 12.5 and sz.y == -3.25)
>   end
>   
> -do
> +do --- struct {double; double;} arg, return struct {double; double;}
>     local s1 = ffi.new("s_dd", 12.5, -3.25)
>     local sz = C.call_sdd(s1)
>     assert(s1.x == 12.5 and s1.y == -3.25)
>     assert(sz.x == 12.5 and sz.y == -3.25)
>   end
>   
> -do
> +do --- struct composed of 8 ints arg, same result
>     local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
>     local sz = C.call_s8i(s1)
>     assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678)
>     assert(sz.a+sz.b+sz.c+sz.d+sz.e+sz.f+sz.g+sz.h == -42+17+12345+9987-100+11+51+0x12345678)
>   end
>   
> -do
> +do --- 2 struct {int; int;} args, return struct {int; int;}
>     local s1 = ffi.new("s_ii", -42, 17)
>     local s2 = ffi.new("s_ii", 0x12345, -98765)
>     local sz = C.call_siisii(s1, s2)
> @@ -186,7 +194,7 @@ do
>     assert(sz.x == -42+0x12345 and sz.y == 17-98765)
>   end
>   
> -do
> +do --- 2 struct {float; float;} args, return struct {float; float;}
>     local s1 = ffi.new("s_ff", 12.5, -3.25)
>     local s2 = ffi.new("s_ff", -17.125, 100.625)
>     local sz = C.call_sffsff(s1, s2)
> @@ -195,7 +203,7 @@ do
>     assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
>   end
>   
> -do
> +do --- 2 struct {double; double;} args, return struct {double; double;}
>     local s1 = ffi.new("s_dd", 12.5, -3.25)
>     local s2 = ffi.new("s_dd", -17.125, 100.625)
>     local sz = C.call_sddsdd(s1, s2)
> @@ -204,7 +212,7 @@ do
>     assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
>   end
>   
> -do
> +do --- 2 struct composed of 8 ints args, same struct in result
>     local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
>     local s2 = ffi.new("s_8i", 99, 311, 98765, -51, 312, 97, 17, 0x44332211)
>     local sz = C.call_s8is8i(s1, s2)
> @@ -215,7 +223,7 @@ do
>     assert(sz.h == 0x12345678+0x44332211)
>   end
>   
> -do
> +do --- int, struct composed of 8 ints, int
>     local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678)
>     local sz = C.call_is8ii(19, s1, -51)
>     assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678)
> @@ -225,42 +233,41 @@ do
>   end
>   
>   -- target-specific
> -if jit.arch == "x86" then
> +do --- fastcall void int double +x86
>     assert(C.fastcall_void() == 1)
>     assert(C.fastcall_i(-42) == -41)
>     assert(C.fastcall_ii(-42, 17) == -42+17)
>     assert(C.fastcall_iii(-42, 17, 139) == -42+17+139)
>     assert(tonumber(C.fastcall_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17))
>     assert(C.fastcall_dd(12.5, -3.25) == 12.5-3.25)
> +end
>   
> -  do
> -    local a = ffi.new("int[10]", -42)
> -    assert(C.fastcall_pp_i(a+8, a+5) == 3)
> -  end
> -
> -  do
> -    local s1 = ffi.new("s_ii", -42, 17)
> -    local s2 = ffi.new("s_ii", 0x12345, -98765)
> -    local sz = C.fastcall_siisii(s1, s2)
> -    assert(s1.x == -42 and s1.y == 17)
> -    assert(s2.x == 0x12345 and s2.y == -98765)
> -    assert(sz.x == -42+0x12345 and sz.y == 17-98765)
> -  end
> +do --- fastcall 2 pointer args +x86
> +  local a = ffi.new("int[10]", -42)
> +  assert(C.fastcall_pp_i(a+8, a+5) == 3)
> +end
>   
> -  do
> -    local s1 = ffi.new("s_dd", 12.5, -3.25)
> -    local s2 = ffi.new("s_dd", -17.125, 100.625)
> -    local sz = C.fastcall_sddsdd(s1, s2)
> -    assert(s1.x == 12.5 and s1.y == -3.25)
> -    assert(s2.x == -17.125 and s2.y == 100.625)
> -    assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
> -  end
> +do --- fastcall 2 struct {int; int;} args +x86
> +  local s1 = ffi.new("s_ii", -42, 17)
> +  local s2 = ffi.new("s_ii", 0x12345, -98765)
> +  local sz = C.fastcall_siisii(s1, s2)
> +  assert(s1.x == -42 and s1.y == 17)
> +  assert(s2.x == 0x12345 and s2.y == -98765)
> +  assert(sz.x == -42+0x12345 and sz.y == 17-98765)
> +end
>   
> -  if jit.os == "Windows" then
> -    assert(C.stdcall_i(-42) == -41)
> -    assert(C.stdcall_ii(-42, 17) == -42+17)
> -    assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25)
> -    assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25)
> -  end
> +do --- fastcall 2 struct {double; double;} args +x86
> +  local s1 = ffi.new("s_dd", 12.5, -3.25)
> +  local s2 = ffi.new("s_dd", -17.125, 100.625)
> +  local sz = C.fastcall_sddsdd(s1, s2)
> +  assert(s1.x == 12.5 and s1.y == -3.25)
> +  assert(s2.x == -17.125 and s2.y == 100.625)
> +  assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625)
>   end
>   
> +do --- stdcall +x86 +windows
> +  assert(C.stdcall_i(-42) == -41)
> +  assert(C.stdcall_ii(-42, 17) == -42+17)
> +  assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25)
> +  assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25)
> +end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 8d833107..599a0182 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -4,6 +4,7 @@ copy_fill.lua
>   err.lua
>   ffi_arith_ptr.lua
>   ffi_bitfield.lua
> +ffi_call.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 13:02   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:01   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:01 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch names all subtests and includes the test in <index>.
> The test with calls with 10 arguments with sizes less than 8 bits are
> dummy for M1. This suite lacks a mechanism to skip subtests satisfying
> complicated conditions, so it is done manually by the corresponding `if`
> check.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_callback.lua | 45 +++++++++++-----------
>   test/LuaJIT-tests/lib/ffi/index            |  1 +
>   2 files changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_callback.lua b/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
> index 1fd14bd0..44fac680 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_callback.lua
> @@ -6,7 +6,7 @@ void qsort(void *base, size_t nmemb, size_t size,
>   	   int (*compar)(const uint8_t *, const uint8_t *));
>   ]]
>   
> -do
> +do --- blacklisted callback
>     local cb = ffi.cast("int (*)(int, int, int)", function(a, b, c)
>       return a+b+c
>     end)
> @@ -19,11 +19,11 @@ do
>     end
>   end
>   
> -do
> +do --- cast to function
>     assert(ffi.cast("int64_t (*)(int64_t, int64_t, int64_t)", function(a, b, c)
>         return a+b+c
> -    end)(12345678901234567LL, 70000000000000001LL, 10000000909090904LL) ==
> -    12345678901234567LL+70000000000000001LL+10000000909090904LL)
> +    end)(12345678901234567LL,  70000000000000001LL,  10000000909090904LL) ==
> +         12345678901234567LL + 70000000000000001LL + 10000000909090904LL)
>   
>     assert(ffi.cast("double (*)(double, float, double)", function(a, b, c)
>         return a+b+c
> @@ -37,21 +37,23 @@ do
>         return a+b+c
>       end)(7.125, -123.25, 9999.33) == 9883.205078125)
>   
> -  assert(ffi.cast("int (*)(int, int, int, int, int, int, int, int, int, int)",
> -    function(a, b, c, d, e, f, g, h, i, j)
> -      return a+b+c+d+e+f+g+h+i+j
> -    end)(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) ==
> -    -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
> +  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
> +    assert(ffi.cast("int (*)(int, int, int, int, int, int, int, int, int, int)",
> +      function(a, b, c, d, e, f, g, h, i, j)
> +        return a+b+c+d+e+f+g+h+i+j
> +      end)(-42,  17,  12345,  9987, -100,  11,  51,  0x12345678,  338, -78901234) ==
> +           -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
> +  end
>   
>     assert(ffi.cast("double (*)(double, double, double, double, double, double, double, double, double, double)",
>       function(a, b, c, d, e, f, g, h, i, j)
>         return a+b+c+d+e+f+g+h+i+j
> -    end)(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) ==
> -    -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
> +    end)(-42.5,  17.125,  12345.5,  9987, -100.625,  11,  51,  0x12345678,  338, -78901234.75) ==
> +         -42.5 + 17.125 + 12345.5 + 9987 - 100.625 + 11 + 51 + 0x12345678 + 338 - 78901234.75)
>   end
>   
>   -- Target-specific tests.
> -if jit.arch == "x86" then
> +do --- cast with fastcall attribute +x86
>     assert(ffi.cast("__fastcall int (*)(int, int, int)", function(a, b, c)
>         return a+b+c
>       end)(10, 99, 13) == 122)
> @@ -63,12 +65,11 @@ if jit.arch == "x86" then
>     -- Test reordering.
>     assert(ffi.cast("int64_t __fastcall (*)(int64_t, int, int)", function(a, b, c)
>         return a+b+c
> -    end)(12345678901234567LL, 12345, 989797123) ==
> -    12345678901234567LL+12345+989797123)
> +    end)(12345678901234567LL,  12345,  989797123) ==
> +         12345678901234567LL + 12345 + 989797123)
>   end
>   
> --- Error handling.
> -do
> +do --- error handling
>     local function f()
>       return
>     end -- Error for result conversion triggered here.
> @@ -84,7 +85,7 @@ do
>     assert(pcall(ffi.cast("int (*)(int,int,int,int, int,int,int,int, int)", function() error("test") end), 1,1,1,1, 1,1,1,1, 1) == false)
>   end
>   
> -do
> +do --- qsort
>     local function cmp(pa, pb)
>       local a, b = pa[0], pb[0]
>       if a < b then
> @@ -102,7 +103,7 @@ do
>     for i=0,254 do assert(arr[i] <= arr[i+1]) end
>   end
>   
> -if ffi.abi"win" then
> +do --- EnumWindows +windows
>     ffi.cdef[[
>     typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
>     int EnumWindows(WNDENUMPROC func, intptr_t l);
> @@ -123,7 +124,7 @@ if ffi.abi"win" then
>     assert(count > 10)
>   end
>   
> -do
> +do --- callback free, callback set
>     local cb = ffi.cast("int(*)(void)", function() return 1 end)
>     assert(cb() == 1)
>     cb:free()
> @@ -136,7 +137,7 @@ do
>     assert(cb() == 3)
>   end
>   
> -do
> +do --- compiled free of function
>     local ft = ffi.typeof("void(*)(void)")
>     local function f() end
>     local t = {}
> @@ -146,11 +147,11 @@ do
>     end
>   end
>   
> -do
> +do --- fast function cast string.byte
>     assert(ffi.cast("int (*)()", function() return string.byte"A" end)() == 65)
>   end
>   
> -do
> +do --- debug.traceback cast
>     local f = ffi.cast("void (*)(void)", function() debug.traceback() end)
>     debug.sethook(function() debug.sethook(nil, "", 0); f() end, "", 1)
>     local x
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 599a0182..9a22104a 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -5,6 +5,7 @@ err.lua
>   ffi_arith_ptr.lua
>   ffi_bitfield.lua
>   ffi_call.lua
> +ffi_callback.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 14:32   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-01 16:02   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:02 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM after fixing testcase name.

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()`.  Also, it names the only one test as "misc"
> and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_const.lua | 4 ++--
>   test/LuaJIT-tests/lib/ffi/index         | 1 +
>   2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> index d42133ad..3213156d 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> @@ -1,6 +1,6 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef[[
>   typedef struct s_t {
> @@ -41,7 +41,7 @@ typedef struct foo_t {
>   } foo_t;
>   ]]
>   
> -do
> +do --- misc
>     local foo_t = ffi.typeof("foo_t")
>     local x = foo_t()
>   
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 9a22104a..0a72daed 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -6,6 +6,7 @@ ffi_arith_ptr.lua
>   ffi_bitfield.lua
>   ffi_call.lua
>   ffi_callback.lua
> +ffi_const.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:06   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 13:13     ` Sergey Kaplun via Tarantool-patches
  2024-02-01 16:19   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:06 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM after renaming test

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding require and renames the C library in the `require()` call.
> It adds groups with the names of subtests and enables the test in
> <index>. It renames structure and enum typedefs to avoid conflicts with
> cdef in other tests. The GC threshold is increased since all tests run
> in a single process, so the number of GC objects is greater.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_convert.lua | 35 +++++++++++------------
>   test/LuaJIT-tests/lib/ffi/index           |  1 +
>   2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> index bd3fb1f9..284f2b53 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> @@ -1,8 +1,7 @@
>   local ffi = require("ffi")
>   
> -local ctest = require("ctest")
> -
> -dofile("../common/ffi_util.inc")
> +local ctest = require("libctest")
> +local fails = require("common.fails")
>   
>   local tonumber = tonumber
>   
> @@ -32,15 +31,15 @@ typedef struct arrinc_t {
>     int a[];
>   } arrinc_t;
>   
> -typedef enum uenum_t {
> +typedef enum uenum_convert_t {
>     UE0, UE71 = 71, UE72
> -} uenum_t;
> +} uenum_convert_t;
>   
> -typedef enum ienum_t {
> +typedef enum ienum_convert_t {
>     IE0, IEM12 = -12, IEM11
> -} ienum_t;
> +} ienum_convert_t;
>   
> -typedef struct foo_t {
> +typedef struct foo_convert_t {
>     bool b;
>     int8_t i8;
>     uint8_t u8;
> @@ -79,9 +78,9 @@ typedef struct foo_t {
>     int si_guard;
>     nest_t sn;
>     uni_t ui;
> -  uenum_t ue;
> -  ienum_t ie;
> -} foo_t;
> +  uenum_convert_t ue;
> +  ienum_convert_t ie;
> +} foo_convert_t;
>   
>   char *strcpy(char *dest, const char *src);
>   typedef struct FILE FILE;
> @@ -89,11 +88,11 @@ int fileno(FILE *stream);
>   int _fileno(FILE *stream);
>   ]]
>   
> -do
> -  local foo_t = ffi.typeof("foo_t")
> -  local sz = ffi.sizeof(foo_t)
> -  local x = foo_t()
> -  local y = foo_t()
> +do --- misc
> +  local foo_convert_t = ffi.typeof("foo_convert_t")
> +  local sz = ffi.sizeof(foo_convert_t)
> +  local x = foo_convert_t()
> +  local y = foo_convert_t()
>     ffi.fill(x, sz, 0xff)
>     ffi.fill(y, sz, 0xee)
>   
> @@ -769,7 +768,7 @@ do
>     x.ppf = ffi.C.strcpy
>   end
>   
> -do
> +do --- GC cdata __index
>     collectgarbage()
>     local oc = collectgarbage("count")
>     local cd = ffi.new"struct { struct { int a; } x;}"
> @@ -780,7 +779,7 @@ do
>     for i=1,2 do
>       f(cd)
>       local nc = collectgarbage("count")
> -    assert(nc < oc + 200, "GC step missing for cdata __index")
> +    assert(nc < oc * 3, "GC step missing for cdata __index")
>       jit.off(f)
>     end
>   end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 0a72daed..5c2be87f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -7,6 +7,7 @@ ffi_bitfield.lua
>   ffi_call.lua
>   ffi_callback.lua
>   ffi_const.lua
> +ffi_convert.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 14:59   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:07   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:07 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` call and renames the C library in the
> `require()` call. Also, it names all subtests and includes the test in
> <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_enum.lua | 11 +++++------
>   test/LuaJIT-tests/lib/ffi/index        |  1 +
>   2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> index e8e40ad0..49c874c7 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> @@ -1,7 +1,7 @@
>   
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef[[
>   typedef enum enum_i { FOO_I = -1, II = 10 } enum_i;
> @@ -13,10 +13,9 @@ int call_i_ei(enum_i a) asm("call_i");
>   int call_i_eu(enum_u a) asm("call_i");
>   ]]
>   
> -local C = ffi.load("../clib/ctest")
> -
> -do
> +local C = ffi.load("ctest")
>   
> +do --- base
>     local t = ffi.new("enum_i[100]")
>     for i=0,99 do t[i] = "II" end
>     for i=0,99 do assert(t[i] == "II") end
> @@ -42,14 +41,14 @@ do
>     for i=0,99 do assert(t[i] ~= u[i]) end
>   end
>   
> -do
> +do --- calls
>     for i=0,99 do assert(C.call_ei_i(9) == "II") end
>     for i=0,99 do assert(C.call_eu_i(9) == "UU") end
>     for i=0,99 do assert(C.call_i_ei("II") == 11) end
>     for i=0,99 do assert(C.call_i_eu("UU") == 11) end
>   end
>   
> -do
> +do --- cast to bool
>     local f = ffi.cast("bool (*)(enum_i)", function(e) return e == "II" end)
>     assert(f("II"))
>     assert(not f(0))
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 5c2be87f..b11e5aa4 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -8,6 +8,7 @@ ffi_call.lua
>   ffi_callback.lua
>   ffi_const.lua
>   ffi_convert.lua
> +ffi_enum.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches
  2024-01-31 15:07   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:10 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch declares functions as local to avoid pollution of the global
> environment. It separates the body of the test in the `do` `while` block
> and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   .../lib/ffi/ffi_gcstep_recursive.lua          | 27 ++++++++++---------
>   test/LuaJIT-tests/lib/ffi/index               |  1 +
>   2 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> index cb19df11..f6e0b009 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> @@ -1,6 +1,6 @@
>   -- From Robert G. Jakabosky, 2012-03-20
>   
> -local N=tonumber(arg[1] or 10000)
> +local N= 10000
>   
>   local ffi=require"ffi"
>   
> @@ -19,7 +19,7 @@ local function obj_to_id(ptr)
>     return tonumber(ffi.cast('uintptr_t', ffi.cast('void *', ptr)))
>   end
>   
> -function obj_type_Buffer_push(val)
> +local function obj_type_Buffer_push(val)
>     local obj = Buffer(val)
>     local id = obj_to_id(obj)
>     nobj_obj_flags[id] = true
> @@ -31,7 +31,7 @@ local function Buffer_new(len)
>     return obj_type_Buffer_push(buf)
>   end
>   
> -function obj_type_Buffer_delete(obj)
> +local function obj_type_Buffer_delete(obj)
>     local id = obj_to_id(obj)
>     if not nobj_obj_flags[id] then return nil end
>     nobj_obj_flags[id] = nil
> @@ -52,15 +52,16 @@ Buffer_mt.__index.close = Buffer_close
>   
>   ffi.metatype(Buffer, Buffer_mt)
>   
> -local cdata = {}
> -for x=1,2 do
> -  cdata = {}
> -  for i=1,N do
> -    cdata[i] = Buffer_new(1)
> +do --- buffer test
> +  local cdata = {}
> +  for x=1,2 do
> +    cdata = {}
> +    for i=1,N do
> +      cdata[i] = Buffer_new(1)
> +    end
> +    for i=1,N do
> +      cdata[i]:close()
> +    end
> +    cdata = nil
>     end
> -  for i=1,N do
> -    cdata[i]:close()
> -  end
> -  cdata = nil
>   end
> -
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index b11e5aa4..8236ab98 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -9,6 +9,7 @@ ffi_callback.lua
>   ffi_const.lua
>   ffi_convert.lua
>   ffi_enum.lua
> +ffi_gcstep_recursive.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
  2024-01-31 15:15   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:12   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:12 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch names all subtests and includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua | 22 ++++++++++-----------
>   test/LuaJIT-tests/lib/ffi/index             |  1 +
>   2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> index 0554fe60..efe83cfd 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
> @@ -1,6 +1,6 @@
>   local ffi = require("ffi")
>   
> -do
> +do --- int64_t arithmetic
>     local a = ffi.new("int64_t[?]", 101)
>     for i=1,100 do a[i] = -2 end
>     for i=1,100 do a[i] = i end
> @@ -29,7 +29,7 @@ do
>     assert(w == 5050)
>   end
>   
> -do
> +do --- uint64_t arithmetic
>     local a = ffi.new("uint64_t[?]", 101)
>     for i=1,100 do a[i] = i end
>     local x, y, m = 0ull, 0ull, 0ull
> @@ -48,32 +48,32 @@ do
>     assert(z == 0x123456789abcdef0ull % 100)
>   end
>   
> -do
> +do --- bit operations LL
>     local x = 0ll
>     for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ll) end
>     assert(x == 262120)
>   end
>   
> -do
> +do --- bit operations LL, non-const base on trace
>     local x, a = 0ll, -2ll
>     for i=1,100 do x = x + a ^ (bit.band(i, 15)+1ll) end
>     assert(x == 262120)
>   end
>   
> -do
> +do --- bit operations ULL
>     local x = 0ull
>     for i=1,100 do x = x + (-2ll) ^ (bit.band(i, 15)+1ull) end
>     assert(x == 262120)
>   end
>   
> -do
> +do --- number vs. cdata interoperability
>     for i=1,200 do local j = bit.band(i, 7); assert((j == 0ll) == (j == 0)) end
>     for i=1,200 do assert((i < 100ll) == (i < 100)) end
>     for i=1,200 do assert((i <= 100ll) == (i <= 100)) end
>     for i=-100,100 do assert((i > 100ull) == (i < 0)) end
>   end
>   
> -do
> +do --- comparisons checksum
>     local a = ffi.new("int64_t[?]", 100)
>     for i=0,99 do
>       a[i] = math.random(0, 2^32)*0x100000000LL + math.random(0, 2^32)
> @@ -121,13 +121,13 @@ do
>     end
>   end
>   
> -do
> +do --- pointer subtraction
>     local a, b = ffi.new("char *"), ffi.new("char *")
>     local z
>     for i=1,100 do z = a-b end
>   end
>   
> -do
> +do --- char and 0LL base comparisons
>     local x = true
>     local abc = ffi.cast("const char *", "abc")
>     for i=1,100 do x = abc == "abc" end
> @@ -142,8 +142,8 @@ do
>     assert(x == false)
>   end
>   
> --- ra_destpair
> -do
> +
> +do --- ra_destpair
>     local x, y = 0, 0
>     for i=1,100 do
>       x = x + i/3LL
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 8236ab98..0c1e5e66 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -10,6 +10,7 @@ ffi_const.lua
>   ffi_convert.lua
>   ffi_enum.lua
>   ffi_gcstep_recursive.lua
> +ffi_jit_arith.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  8:30   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-01 16:15   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:15 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

HI, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch uses the basename of the ctest library to be loaded via FFI.
> It adds groups with the names of subtests and enables the test in
> <index>. The corresponding conditions are changed to the tags checked by
> analogy with other tests. Tests with calls with 10 arguments with sizes
> less than 8 bits are dummy for M1.
with, with, with... feel free to ignore
> This suite lacks a mechanism to skip
> subtests satisfying complicated conditions, so it is done manually by
> the corresponding `if` check.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua | 70 ++++++++++++----------
>   test/LuaJIT-tests/lib/ffi/index            |  1 +
>   2 files changed, 39 insertions(+), 32 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
> index b79d60b1..ee9dd5f0 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua
> @@ -35,33 +35,37 @@ double __stdcall stdcall_dd(double a, double b);
>   float __stdcall stdcall_ff(float a, float b);
>   ]]
>   
> -local lib = ffi.load("../clib/ctest")
> -
> -do
> -  local x
> -  for i=1,100 do
> -    x = lib.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234)
> +local lib = ffi.load("ctest")
> +
> +do --- 10 int args
> +  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
> +    local x
> +    for i=1,100 do
> +      x = lib.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234)
> +    end
> +    assert(x == -42 + 17 + 12345 + 9987 - 100 + 11 + 51 + 0x12345678 + 338 - 78901234)
>     end
> -  assert(x == -42+17+12345+9987-100+11+51+0x12345678+338-78901234)
>   end
>   
> -do
> +do --- 17 double args
>     for i=1,100 do
>       pcall(lib.call_max, i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i)
>     end
>   end
>   
> -if ffi.abi("64bit") then
> -  local y = ffi.cast("void *", 0x123456789abcdefLL)
> -  local x
> -  for i=1,100 do
> -    lib.call_10j_p(0,0,0,0,0,0,0,0,0, y)
> -    x = lib.call_10j_p(0,0,0,0,0,0,0,0,0, nil)
> +do --- 10 ints 1 pointer args +abi64
> +  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
> +    local y = ffi.cast("void *", 0x123456789abcdefLL)
> +    local x
> +    for i=1,100 do
> +      lib.call_10j_p(0,0,0,0,0,0,0,0,0, y)
> +      x = lib.call_10j_p(0,0,0,0,0,0,0,0,0, nil)
> +    end
> +    assert(x == 0)
>     end
> -  assert(x == 0)
>   end
>   
> -do
> +do --- int, int64_t args
>     local x = 0
>     for i=1,100 do
>       x = x + lib.call_ij(100+i, i*0x300000002LL)
> @@ -69,7 +73,7 @@ do
>     assert(x == 0x3b2e0000623eLL)
>   end
>   
> -do
> +do --- 10 double args
>     local x
>     for i=1,100 do
>       x = lib.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75)
> @@ -77,15 +81,17 @@ do
>     assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75)
>   end
>   
> -do
> -  local x
> -  for i=1,100 do
> -    x = lib.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75)
> +do --- 10 float args
> +  if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI
> +    local x
> +    for i=1,100 do
> +      x = lib.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75)
> +    end
> +    assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
>     end
> -  assert(x == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75)
>   end
>   
> -do
> +do --- boolean result
>     local x
>     for i=-100,100 do
>       if not lib.call_b(i) then x = i end
> @@ -100,14 +106,14 @@ do
>     assert(x == 90)
>   end
>   
> -do
> +do --- boolean result, tail call
>     local function tail(x)
>       return lib.call_b(x)
>     end
>     for i=1,100 do local a,b,c = tail(1), tail(1), tail(1) end
>   end
>   
> -do
> +do --- int8_t, uint8_t, int16_t, uint16_t args and results
>     local x = 0
>     for i=0x01010080,0x010100ff do x = x + lib.call_i_i8(i) end
>     assert(x == -8128)
> @@ -135,7 +141,7 @@ do
>   end
>   
>   -- target-specific
> -if jit.arch == "x86" then
> +do --- fastcall +x86
>     for i=1,100 do assert(lib.fastcall_i(-42) == -41) end
>     for i=1,100 do assert(lib.fastcall_ii(-42, 17) == -42+17) end
>     for i=1,100 do assert(lib.fastcall_iii(-42, 17, 139) == -42+17+139) end
> @@ -143,12 +149,12 @@ if jit.arch == "x86" then
>     for i=1,100 do assert(lib.fastcall_dd(12.5, -3.25) == 12.5-3.25) end
>     local x = lib.fastcall_ji
>     for i=1,100 do assert(x(0x123456789LL, -17) == 0x123456789LL-17) end
> +end
>   
> -  if jit.os == "Windows" then
> -    for i=1,100 do assert(lib.stdcall_i(-42) == -41) end
> -    for i=1,100 do assert(lib.stdcall_ii(-42, 17) == -42+17) end
> -    for i=1,100 do assert(lib.stdcall_dd(12.5, -3.25) == 12.5-3.25) end
> -    for i=1,100 do assert(lib.stdcall_ff(12.5, -3.25) == 12.5-3.25) end
> -  end
> +do --- stdcall +x86 +windows
> +  for i=1,100 do assert(lib.stdcall_i(-42) == -41) end
> +  for i=1,100 do assert(lib.stdcall_ii(-42, 17) == -42+17) end
> +  for i=1,100 do assert(lib.stdcall_dd(12.5, -3.25) == 12.5-3.25) end
> +  for i=1,100 do assert(lib.stdcall_ff(12.5, -3.25) == 12.5-3.25) end
>   end
>   
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 0c1e5e66..d6e2b64a 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -11,6 +11,7 @@ ffi_convert.lua
>   ffi_enum.lua
>   ffi_gcstep_recursive.lua
>   ffi_jit_arith.lua
> +ffi_jit_call.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
  2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-01 16:06   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-01 16:19   ` Sergey Bronnikov via Tarantool-patches
  2 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:19 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM after renaming test

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding require and renames the C library in the `require()` call.
> It adds groups with the names of subtests and enables the test in
> <index>. It renames structure and enum typedefs to avoid conflicts with
> cdef in other tests. The GC threshold is increased since all tests run
> in a single process, so the number of GC objects is greater.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_convert.lua | 35 +++++++++++------------
>   test/LuaJIT-tests/lib/ffi/index           |  1 +
>   2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> index bd3fb1f9..284f2b53 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> @@ -1,8 +1,7 @@
>   local ffi = require("ffi")
>   
> -local ctest = require("ctest")
> -
> -dofile("../common/ffi_util.inc")
> +local ctest = require("libctest")
> +local fails = require("common.fails")
>   
>   local tonumber = tonumber
>   
> @@ -32,15 +31,15 @@ typedef struct arrinc_t {
>     int a[];
>   } arrinc_t;
>   
> -typedef enum uenum_t {
> +typedef enum uenum_convert_t {
>     UE0, UE71 = 71, UE72
> -} uenum_t;
> +} uenum_convert_t;
>   
> -typedef enum ienum_t {
> +typedef enum ienum_convert_t {
>     IE0, IEM12 = -12, IEM11
> -} ienum_t;
> +} ienum_convert_t;
>   
> -typedef struct foo_t {
> +typedef struct foo_convert_t {
>     bool b;
>     int8_t i8;
>     uint8_t u8;
> @@ -79,9 +78,9 @@ typedef struct foo_t {
>     int si_guard;
>     nest_t sn;
>     uni_t ui;
> -  uenum_t ue;
> -  ienum_t ie;
> -} foo_t;
> +  uenum_convert_t ue;
> +  ienum_convert_t ie;
> +} foo_convert_t;
>   
>   char *strcpy(char *dest, const char *src);
>   typedef struct FILE FILE;
> @@ -89,11 +88,11 @@ int fileno(FILE *stream);
>   int _fileno(FILE *stream);
>   ]]
>   
> -do
> -  local foo_t = ffi.typeof("foo_t")
> -  local sz = ffi.sizeof(foo_t)
> -  local x = foo_t()
> -  local y = foo_t()
> +do --- misc
> +  local foo_convert_t = ffi.typeof("foo_convert_t")
> +  local sz = ffi.sizeof(foo_convert_t)
> +  local x = foo_convert_t()
> +  local y = foo_convert_t()
>     ffi.fill(x, sz, 0xff)
>     ffi.fill(y, sz, 0xee)
>   
> @@ -769,7 +768,7 @@ do
>     x.ppf = ffi.C.strcpy
>   end
>   
> -do
> +do --- GC cdata __index
>     collectgarbage()
>     local oc = collectgarbage("count")
>     local cd = ffi.new"struct { struct { int a; } x;}"
> @@ -780,7 +779,7 @@ do
>     for i=1,2 do
>       f(cd)
>       local nc = collectgarbage("count")
> -    assert(nc < oc + 200, "GC step missing for cdata __index")
> +    assert(nc < oc * 3, "GC step missing for cdata __index")
>       jit.off(f)
>     end
>   end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 0a72daed..5c2be87f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -7,6 +7,7 @@ ffi_bitfield.lua
>   ffi_call.lua
>   ffi_callback.lua
>   ffi_const.lua
> +ffi_convert.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (25 preceding siblings ...)
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-02-01 16:32 ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 17:03   ` Sergey Kaplun via Tarantool-patches
  2024-02-07  8:14 ` Sergey Bronnikov via Tarantool-patches
                   ` (2 subsequent siblings)
  29 siblings, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-01 16:32 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

there is a problem with running under ASAN:


cmake -S . -B build -DLUAJIT_USE_ASAN=ON

<snipped>

cmake --build build/ -t LuaJIT-tests

<snipped>

[100%] Linking C executable luajit
[100%] Built target luajit_static
Running LuaJIT-tests
==320737==ASan runtime does not come first in initial library list; you 
should either link runtime to your application or manually preload it 
with LD_PRELOAD.
gmake[3]: *** 
[test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/build.make:74: 
LuaJIT-tests] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:1193: 
test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:1200: 
test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/rule] Error 2
gmake: *** [Makefile:455: LuaJIT-tests] Error 2

cannot reproduce on tarantool/master


On 1/29/24 13:45, Sergey Kaplun wrote:
> This patchset enables most of the LuaJIT-tests related to FFI and
> testing of C libraries (cpptest, ctest). More tests (from the <misc>
> directory) will be enabled in the future series.
>
> FFI tests from the <unportable> directory aren't enabled because of their
> inconsistency, see also [1].
>
> This increases coverage up to 92.5%, see here [2].
>
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-9398-more-luajit-tests
> Tarantool PR: https://github.com/tarantool/tarantool/pull/9603
> Related issues:
> * https://github.com/tarantool/tarantool/issues/9398
> * https://github.com/tarantool/tarantool/issues/7834
>
> [1]: https://github.com/LuaJIT/LuaJIT/pull/415
> [2]: https://coveralls.io/github/tarantool/luajit?branch=skaplun/gh-9398-more-luajit-tests
>
> Changes in the v2:
> * Introduce the AddTestLib macro to avoid copy-pasting. It only adds a
>    target with necessary flags without setting any variables.
> * <cpptest.cpp> is renamed to <libcpptest.cpp> for consistency with
>    <libctest.c>
> * Rename some tests with uninformative naming (like `call_10i` ->
>    `10 int args`)
> * Add adjusments of arguments for long calls (~10 arguments) to make them
>    comparable without changing test semantics.
> * Fix some typos
>
> Sergey Kaplun (26):
>    cmake: introduce AddTestLib macro
>    test: prepare lauxilarily libs for LuaJIT-tests
>    test: separate LuaJIT helpers from ffi_util.inc
>    test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
>    test: enable <ffi_bitfield.lua> in LuaJIT-tests
>    test: enable <ffi_call.lua> in LuaJIT-tests
>    test: enable <ffi_callback.lua> in LuaJIT-tests
>    test: enable <ffi_const.lua> in LuaJIT-tests
>    test: enable <ffi_convert.lua> in LuaJIT-tests
>    test: enable <ffi_enum.lua> in LuaJIT-tests
>    test: enable <ffi_gcstep_recursive.lua>
>    test: enable <ffi_jit_arith.lua> in LuaJIT-tests
>    test: enable <ffi_jit_call.lua> in LuaJIT-tests
>    test: enable <ffi_jit_conv.lua> in LuaJIT-tests
>    test: enable <ffi_lex_number.lua> in LuaJIT-tests
>    test: enable <ffi_metatype.lua> in LuaJIT-tests
>    test: enable <ffi_new.lua> in LuaJIT-tests
>    test: enable <ffi_parse_array.lua> in LuaJIT-tests
>    test: enable <ffi_parse_basic.lua> in LuaJIT-tests
>    test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
>    test: enable <ffi_parse_struct.lua> LuaJIT test
>    test: enable <ffi_tabov.lua> LuaJIT test
>    test: enable <lightud.lua> LuaJIT test
>    test: enable <api_call.lua> LuaJIT test
>    test: enable <catch_wrap.lua> LuaJIT test
>    test: enable <catch_cpp.lua> LuaJIT test
>
>   test/CMakeLists.txt                           |   3 +
>   test/LuaJIT-tests/CMakeLists.txt              |  45 ++-
>   test/LuaJIT-tests/common/fails.lua            |   3 +
>   test/LuaJIT-tests/common/ffi/checkfail.lua    |  14 +
>   test/LuaJIT-tests/common/ffi/checktypes.lua   |  15 +
>   test/LuaJIT-tests/common/ffi_util.inc         |  23 --
>   test/LuaJIT-tests/{misc => lang}/api_call.lua |  32 +-
>   .../{sysdep => lang}/catch_cpp.lua            |  36 +-
>   .../{misc => lang}/catch_wrap.lua             |  29 +-
>   test/LuaJIT-tests/lang/index                  |   4 +
>   test/LuaJIT-tests/lang/lightud.lua            |  89 +++++
>   test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua   |  13 +-
>   test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua    |   4 +-
>   test/LuaJIT-tests/lib/ffi/ffi_call.lua        | 185 +++++-----
>   test/LuaJIT-tests/lib/ffi/ffi_callback.lua    |  45 +--
>   test/LuaJIT-tests/lib/ffi/ffi_const.lua       |   4 +-
>   test/LuaJIT-tests/lib/ffi/ffi_convert.lua     |  35 +-
>   test/LuaJIT-tests/lib/ffi/ffi_enum.lua        |  11 +-
>   .../lib/ffi/ffi_gcstep_recursive.lua          |  27 +-
>   test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua   |  22 +-
>   test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua    |  70 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua    |  70 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua  |  72 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_metatype.lua    |  16 +-
>   test/LuaJIT-tests/lib/ffi/ffi_new.lua         |  50 +--
>   test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 +++---
>   test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 ++++++-------
>   test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua  | 141 ++++----
>   .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
>   test/LuaJIT-tests/lib/ffi/ffi_tabov.lua       |  12 -
>   test/LuaJIT-tests/lib/ffi/index               |  18 +
>   test/LuaJIT-tests/misc/lightud.lua            |  88 -----
>   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 +-
>   .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt |  25 +-
>   test/cmake/AddTestLib.cmake                   |  28 ++
>   test/tarantool-tests/CMakeLists.txt           |  27 +-
>   test/tarantool-tests/ffi-tabov.test.lua       |  27 ++
>   40 files changed, 1086 insertions(+), 921 deletions(-)
>   create mode 100644 test/LuaJIT-tests/common/fails.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
>   rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)
>   rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
>   rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)
>   create mode 100644 test/LuaJIT-tests/lang/lightud.lua
>   delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
>   delete mode 100644 test/LuaJIT-tests/misc/lightud.lua
>   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%)
>   create mode 100644 test/cmake/AddTestLib.cmake
>   create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  8:32   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 12:51   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 13:33     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 12:51 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch. LGTM with a minor comment

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch renames the C library in the `require()` call. It adds
> groups with the names of subtests and enables the test in <index>. It
> renames enum definitions to avoid conflicts with cdef in other tests.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua | 70 +++++++++++-----------
>   test/LuaJIT-tests/lib/ffi/index            |  1 +
>   2 files changed, 36 insertions(+), 35 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> index d4707db7..0e64fe75 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> @@ -1,8 +1,8 @@
<snipped>
>   
> -do
> +do --- int16_t array arithmetic
>     local a = ffi.new("int16_t[100]", 1)
>     for i=1,99 do a[i] = a[i] + a[i-1] end
>     assert(a[99] == 100)
>   end
>   
> -do
> +do --- ligud to pointer
typo: ligud -> lightud
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  8:38   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 12:53   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 12:53 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey!

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()`. Also, it adds groups with the names of
> subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  8:40   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 12:58   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 13:48     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 12:58 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with a minor comment

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper function. It adds test names and
> includes the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_metatype.lua | 16 ++++++++--------
>   test/LuaJIT-tests/lib/ffi/index            |  1 +
>   2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> index 2db717f4..b0054b1a 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> @@ -1,6 +1,6 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef[[
>   typedef struct { int x; } idx1_t;
> @@ -14,7 +14,7 @@ local function ptreq(a, b)
>     return ffi.cast("void *", a) == ffi.cast("void *", b)
>   end
>   
> -do
> +do --- metatype index newindex

isn't better: "metatype with index and newindex metamethods" or smthing 
like this?

This descriptions are for humans mostly and would be better to convert 
these keywords to readable sentence.

same for test names below

>     local nidx = {}
>     local tp = ffi.metatype("idx1_t", {
>       __index = { foo = 99, method = function(c, v) return v end },
> @@ -45,7 +45,7 @@ do
>     fails(function(cp) cp.bar = 42 end, cp)
>   end
>   
> -do
> +do --- metatype index newindex with upvalues
>     local uc, uk, uv
>     local tp = ffi.metatype("idx2_t", {
>       __index = function(c, k, x, y)
> @@ -78,7 +78,7 @@ do
>     fails(function(p) p[0] = 11 end, p)
>   end
>   
> -do
> +do --- metatype index newindex with upvalues via setmetatable
>     local uc, uk, uv
>     local ti, tn = {}, {}
>     local tp = ffi.metatype("idx3_t", {
> @@ -103,7 +103,7 @@ do
>     uc, uk, uv = nil, nil, nil
>   end
>   
> -do
> +do --- metatype arith
>     local tp
>     tp = ffi.metatype("arith_t", {
>       __add = function(a, b) return tp(a.x+b.x, a.y+b.y) end,
> @@ -174,7 +174,7 @@ do
>     assert(x == 3000)
>   end
>   
> -do
> +do --- metatype GC
>     local count = 0
>     local tp = ffi.metatype("gc_t", {
>       __gc = function(x) count = count + 1 end,
> @@ -206,7 +206,7 @@ do
>     assert(count == 103)
>   end
>   
> -do
> +do --- metatype new, type change
>     local tp = ffi.metatype([[
>   struct {
>     static const int Z42 = 42;
> @@ -236,7 +236,7 @@ struct {
>     assert(o.x == 5)
>   end
>   
> -do
> +do --- metatype is other cdata
>     local fb = ffi.new("struct { int x; }", 99)
>     local xt = ffi.metatype("struct { }", { __index = fb })
>     local o = xt()
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 833c31e3..338a6930 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -14,6 +14,7 @@ ffi_jit_arith.lua
>   ffi_jit_call.lua
>   ffi_jit_conv.lua
>   ffi_lex_number.lua
> +ffi_metatype.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  8:43   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:03   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 13:58     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:03 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with minor comments

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding require of the helper function. It adds groups with the
> names of subtests and enables the test in <index>. It renames structures
> typedefs to avoid conflicts with cdef in other tests. The GC threshold
> is increased since all tests run in a single process, so the number of
> GC objects is greater.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_new.lua | 50 +++++++++++++--------------
>   test/LuaJIT-tests/lib/ffi/index       |  1 +
>   2 files changed, 26 insertions(+), 25 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> index 9cdbd538..e5b19053 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> @@ -1,37 +1,37 @@
>   local ffi = require("ffi")
>   local bit = require("bit")
>   
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>   
>   ffi.cdef([[
> -typedef struct { int a,b,c; } foo1_t;
> -typedef int foo2_t[?];
> +typedef struct { int a,b,c; } foo1_new_t;
> +typedef int foo2_new_t[?];
>   void *malloc(size_t size);
>   void free(void *ptr);
>   ]])
>   
> -do
> -  assert(ffi.sizeof("foo1_t") == 12)
> -  local cd = ffi.new("foo1_t")
> +do --- foo1_new_t

test desc says nothing about what test tests.

I would rename to something like "ffi.sizeof with custom struct"

same below

> +  assert(ffi.sizeof("foo1_new_t") == 12)
> +  local cd = ffi.new("foo1_new_t")
>     assert(ffi.sizeof(cd) == 12)
> -  local foo1_t = ffi.typeof("foo1_t")
> -  assert(ffi.sizeof(foo1_t) == 12)
> -  cd = foo1_t()
> +  local foo1_new_t = ffi.typeof("foo1_new_t")
> +  assert(ffi.sizeof(foo1_new_t) == 12)
> +  cd = foo1_new_t()
>     assert(ffi.sizeof(cd) == 12)
>   end
>   
> -do
> -  assert(ffi.sizeof("foo2_t", 3) == 12)
> -  local cd = ffi.new("foo2_t", 3)
> +do --- foo2_new_t
> +  assert(ffi.sizeof("foo2_new_t", 3) == 12)
> +  local cd = ffi.new("foo2_new_t", 3)
>     assert(ffi.sizeof(cd) == 12)
> -  local foo2_t = ffi.typeof("foo2_t")
> -  fails(ffi.sizeof, foo2_t)
> -  assert(ffi.sizeof(foo2_t, 3) == 12)
> -  cd = foo2_t(3)
> +  local foo2_new_t = ffi.typeof("foo2_new_t")
> +  fails(ffi.sizeof, foo2_new_t)
> +  assert(ffi.sizeof(foo2_new_t, 3) == 12)
> +  cd = foo2_new_t(3)
>     assert(ffi.sizeof(cd) == 12)
>   end
>   
> -do
> +do --- byte to int cast
>     local tpi = ffi.typeof("int")
>     local tpb = ffi.typeof("uint8_t")
>     local t = {}
> @@ -42,7 +42,7 @@ do
>     assert(x == 199*257 + 1)
>   end
>   
> -do
> +do --- aligned structure GC
>     local oc = collectgarbage("count")
>     for al=0,15 do
>       local align = 2^al -- 1, 2, 4, ..., 32768
> @@ -54,17 +54,17 @@ do
>       end
>     end
>     local nc = collectgarbage("count")
> -  assert(nc < oc + 3000, "GC step missing for ffi.new")
> +  assert(nc < oc * 10, "GC step missing for ffi.new")
>   end
>   
> -do
> +do --- VLA
>     local t = {}
>     for i=1,100 do t[i] = ffi.new("int[?]", i) end
>     assert(ffi.sizeof(t[100]) == 400)
>     for i=0,99 do assert(t[100][i] == 0) end
>   end
>   
> -do
> +do --- VLS
>     local t = {}
>     local ct = ffi.typeof("struct { double x; int y[?];}")
>     for i=1,100 do t[i] = ct(i) end
> @@ -72,7 +72,7 @@ do
>     for i=0,99 do assert(t[100].y[i] == 0) end
>   end
>   
> -do
> +do --- aligned(16) structure exit from trace
>     local ct = ffi.typeof("struct __attribute__((aligned(16))) { int x; }")
>     local y
>     for i=1,200 do
> @@ -82,7 +82,7 @@ do
>     assert(bit.band(ffi.cast("intptr_t", ffi.cast("void *", y)), 15) == 0)
>   end
>   
> -do
> +do --- cdata resurrecting
>     local q
>     local p = ffi.gc(ffi.new("int[1]"), function(x) q = x end)
>     p = nil
> @@ -93,13 +93,13 @@ do
>     assert(q == nil)
>   end
>   
> -do
> +do --- GC malloc free
>     local p = ffi.gc(ffi.C.malloc(2^20), ffi.C.free)
>     p = nil
>     collectgarbage()
>   end
>   
> -do
> +do --- test lua_close() cleanup
>     local p = ffi.gc(ffi.new("int[1]"), function(x) assert(type(x) == "cdata") end)
>     -- test for lua_close() cleanup.
>   end
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 338a6930..e6c1fd0f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -15,6 +15,7 @@ ffi_jit_call.lua
>   ffi_jit_conv.lua
>   ffi_lex_number.lua
>   ffi_metatype.lua
> +ffi_new.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:01   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:08   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 14:12     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:08 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM wit a minor comment

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 ++++++++++--------
>   test/LuaJIT-tests/lib/ffi/index               |   1 +
>   2 files changed, 58 insertions(+), 49 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> index 3a9616d7..d3b02759 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> @@ -1,58 +1,66 @@
>   local ffi = require("ffi")
<snipped>
>   
> -do
> +do --- sizeof VLA

it is inconsistent with test name at least in a previous patch.

Here: "sizeof VLA", in a previous patch "VLA".

Feel free to ignore.



>     assert(ffi.sizeof("int [?]", 10) == 4*10)
>     local id = ffi.typeof("const short [?]")
>     assert(ffi.sizeof(id, 10) == 2*10)
> @@ -64,7 +72,7 @@ do
>     assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
>   end
>   
> -do
> +do --- sizeof VLS
>     assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
>     local id = ffi.typeof("struct { int x; short a[?]; }")
>     assert(ffi.sizeof(id, 10) == 4+2*10)
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index e6c1fd0f..89773c0c 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -16,6 +16,7 @@ ffi_jit_conv.lua
>   ffi_lex_number.lua
>   ffi_metatype.lua
>   ffi_new.lua
> +ffi_parse_array.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:03   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:10 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 +++++++++---------
>   test/LuaJIT-tests/lib/ffi/index               |   1 +
>   2 files changed, 132 insertions(+), 120 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> index c054bcfb..3b49648c 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
> @@ -1,131 +1,142 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
>   
> -checkfail{
> -  "",
> -  " ",
> -  "\n",
> -  "1",
> -  ".",
> -  ";",
> -  ",",
> -  "*",
> -  "[]",
> -  "()",
> -  "(*)",
> -  "//",
> -  "/*",
> -  "xyz",
> -  "const",
> -  "volatile",
> -  "typedef",
> -  "extern",
> -  "static",
> -  "auto",
> -  "register",
> -  "struct",
> -  "union",
> -  "sizeof",
> -  "int int",
> -  "int char",
> -  "int double",
> -  "int;",
> -}
> +do --- checkfail
> +  checkfail{
> +    "",
> +    " ",
> +    "\n",
> +    "1",
> +    ".",
> +    ";",
> +    ",",
> +    "*",
> +    "[]",
> +    "()",
> +    "(*)",
> +    "//",
> +    "/*",
> +    "xyz",
> +    "const",
> +    "volatile",
> +    "typedef",
> +    "extern",
> +    "static",
> +    "auto",
> +    "register",
> +    "struct",
> +    "union",
> +    "sizeof",
> +    "int int",
> +    "int char",
> +    "int double",
> +    "int;",
> +  }
> +end
>   
> -checktypes{
> -  1,	1,	"char",
> -  1,	1,	" \n\r\t\vchar \n\r\t\v",
> -  1,	1,	"ch\\\nar",
> -  1,	1,	"char /* abc */",
> -  1,	1,	"char /* abc */ const",
> -  1,	1,	"char // abc\n const",
> -}
> +do --- char newlines
> +  checktypes{
> +    1,	1,	"char",
> +    1,	1,	" \n\r\t\vchar \n\r\t\v",
> +    1,	1,	"ch\\\nar",
> +    1,	1,	"char /* abc */",
> +    1,	1,	"char /* abc */ const",
> +    1,	1,	"char // abc\n const",
> +  }
> +end
>   
> -checktypes{
> -  nil,	1,	"void",
> -  1,	1,	"bool",
> -  1,	1,	"_Bool",
> -  4,	4,	"_Bool int",
> -  1,	1,	"char",
> -  1,	1,	"signed char",
> -  1,	1,	"unsigned char",
> -  2,	2,	"short",
> -  2,	2,	"signed short",
> -  2,	2,	"unsigned short",
> -  4,	4,	"int",
> -  4,	4,	"signed int",
> -  4,	4,	"unsigned int",
> -  4,	4,	"signed",
> -  4,	4,	"unsigned",
> -  4,	4,	"float",
> -  8,	8,	"long long",
> -  8,	8,	"signed long long",
> -  8,	8,	"unsigned long long",
> -  8,	8,	"double",
> -  -- NYI: long double is architecture- and compiler-specific.
> -  8,	4,	"_Complex float",
> -  16,	8,	"_Complex",
> -  16,	8,	"_Complex double",
> -}
> +do --- base types
> +  checktypes{
> +    nil,	1,	"void",
> +    1,	1,	"bool",
> +    1,	1,	"_Bool",
> +    4,	4,	"_Bool int",
> +    1,	1,	"char",
> +    1,	1,	"signed char",
> +    1,	1,	"unsigned char",
> +    2,	2,	"short",
> +    2,	2,	"signed short",
> +    2,	2,	"unsigned short",
> +    4,	4,	"int",
> +    4,	4,	"signed int",
> +    4,	4,	"unsigned int",
> +    4,	4,	"signed",
> +    4,	4,	"unsigned",
> +    4,	4,	"float",
> +    8,	8,	"long long",
> +    8,	8,	"signed long long",
> +    8,	8,	"unsigned long long",
> +    8,	8,	"double",
> +    -- NYI: long double is architecture- and compiler-specific.
> +    8,	4,	"_Complex float",
> +    16,	8,	"_Complex",
> +    16,	8,	"_Complex double",
> +  }
> +end
>   
> --- mode/vector_size attributes
> -checktypes{
> -  1,	1,	"int __attribute__((mode(QI)))",
> -  2,	2,	"int __attribute__((mode(HI)))",
> -  4,	4,	"int __attribute__((mode(SI)))",
> -  8,	8,	"int __attribute__((mode(DI)))",
> -  16,	16,	"int __attribute__((mode(TI)))",
> -  32,	16,	"int __attribute__((mode(OI)))",
> -  4,	4,	"float __attribute__((mode(SF)))",
> -  8,	8,	"float __attribute__((mode(DF)))",
> -  2,	2,	"int __attribute__((mode(V2QI)))",
> -  16,	16,	"float __attribute__((mode(V4SF)))",
> -  32,	16,	"double __attribute__((mode(V8SF)))",
> -  8,	8,	"char __attribute__((vector_size(8)))",
> -  16,	16,	"int __attribute__((vector_size(16)))",
> -  32,	16,	"double __attribute__((vector_size(32)))",
> -  64,	16,	"double __attribute__((vector_size(64)))",
> -}
> +do --- mode/vector_size attributes
> +  checktypes{
> +    1,	1,	"int __attribute__((mode(QI)))",
> +    2,	2,	"int __attribute__((mode(HI)))",
> +    4,	4,	"int __attribute__((mode(SI)))",
> +    8,	8,	"int __attribute__((mode(DI)))",
> +    16,	16,	"int __attribute__((mode(TI)))",
> +    32,	16,	"int __attribute__((mode(OI)))",
> +    4,	4,	"float __attribute__((mode(SF)))",
> +    8,	8,	"float __attribute__((mode(DF)))",
> +    2,	2,	"int __attribute__((mode(V2QI)))",
> +    16,	16,	"float __attribute__((mode(V4SF)))",
> +    32,	16,	"double __attribute__((mode(V8SF)))",
> +    8,	8,	"char __attribute__((vector_size(8)))",
> +    16,	16,	"int __attribute__((vector_size(16)))",
> +    32,	16,	"double __attribute__((vector_size(32)))",
> +    64,	16,	"double __attribute__((vector_size(64)))",
> +  }
> +end
>   
> --- ABI-specific types:
> -local L = (ffi.abi("32bit") or ffi.abi("win")) and 4 or 8
> -local P = ffi.abi("32bit") and 4 or 8
> -local W = ffi.abi("win") and 2 or 4
> +do --- ABI-specific types:
> +  local L = (ffi.abi("32bit") or ffi.abi("win")) and 4 or 8
> +  local P = ffi.abi("32bit") and 4 or 8
> +  local W = ffi.abi("win") and 2 or 4
>   
> -checktypes{
> -  L,	L,	"long",
> -  L,	L,	"signed long",
> -  L,	L,	"unsigned long",
> -  P,	P,	"int *",
> -  P,	P,	"int **",
> -  4,	4,	"int * __ptr32",
> -}
> +  checktypes{
> +    L,	L,	"long",
> +    L,	L,	"signed long",
> +    L,	L,	"unsigned long",
> +    P,	P,	"int *",
> +    P,	P,	"int **",
> +    4,	4,	"int * __ptr32",
> +  }
>   
> -checktypes{
> -  P,	P,	"ptrdiff_t",
> -  P,	P,	"size_t",
> -  W,	W,	"wchar_t",
> -  1,	1,	"int8_t",
> -  2,	2,	"int16_t",
> -  4,	4,	"int32_t",
> -  8,	8,	"int64_t",
> -  1,	1,	"uint8_t",
> -  2,	2,	"uint16_t",
> -  4,	4,	"uint32_t",
> -  8,	8,	"uint64_t",
> -  P,	P,	"intptr_t",
> -  P,	P,	"uintptr_t",
> -}
> +  checktypes{
> +    P,	P,	"ptrdiff_t",
> +    P,	P,	"size_t",
> +    W,	W,	"wchar_t",
> +    1,	1,	"int8_t",
> +    2,	2,	"int16_t",
> +    4,	4,	"int32_t",
> +    8,	8,	"int64_t",
> +    1,	1,	"uint8_t",
> +    2,	2,	"uint16_t",
> +    4,	4,	"uint32_t",
> +    8,	8,	"uint64_t",
> +    P,	P,	"intptr_t",
> +    P,	P,	"uintptr_t",
> +  }
> +end
>   
> -checktypes{
> -  1,	8,	"char __attribute__((aligned(8)))",
> -  1,	8,	"char __attribute((aligned(8)))",
> -  1,	8,	"char __attribute__((__aligned__(8)))",
> -  1,	8,	"__attribute__((aligned(8))) char",
> -  1,	8,	"char __declspec(align(8))",
> -  1,	8,	"__declspec(align(8)) char",
> -  1,	2,	"char __attribute__((aligned(8))) const __attribute__((aligned(2)))",
> -  1,	16,	"char __attribute__((aligned(8))) const __attribute__((aligned(16)))",
> -}
> +do --- attributes
> +  checktypes{
> +    1,	8,	"char __attribute__((aligned(8)))",
> +    1,	8,	"char __attribute((aligned(8)))",
> +    1,	8,	"char __attribute__((__aligned__(8)))",
> +    1,	8,	"__attribute__((aligned(8))) char",
> +    1,	8,	"char __declspec(align(8))",
> +    1,	8,	"__declspec(align(8)) char",
> +    1,	2,	"char __attribute__((aligned(8))) const __attribute__((aligned(2)))",
> +    1,	16,	"char __attribute__((aligned(8))) const __attribute__((aligned(16)))",
> +  }
> +end
>   
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 89773c0c..a805bdd0 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -17,6 +17,7 @@ ffi_lex_number.lua
>   ffi_metatype.lua
>   ffi_new.lua
>   ffi_parse_array.lua
> +ffi_parse_basic.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:05   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:11   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:11 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua | 141 ++++++++++---------
>   test/LuaJIT-tests/lib/ffi/index              |   1 +
>   2 files changed, 77 insertions(+), 65 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> index 4bb5d903..cc123808 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
> @@ -1,77 +1,88 @@
>   local ffi = require("ffi")
>   
> -dofile("../common/ffi_util.inc")
> +local checkfail = require("common.ffi.checkfail")
> +local checktypes = require("common.ffi.checktypes")
>   
> -checkfail({
> -  "int",
> -  "int aa1; int aa2 ",
> -  "static int x;",
> -  "static const long long x = 1;", -- NYI
> -  "static const double x = 1;",	   -- NYI
> -  "static const bool x = 1;",	   -- NYI (intentional, need true/false)
> -  "struct { static int x = 1; };",
> -  ";;static int y"
> -}, ffi.cdef)
> +do --- checkfail
> +  checkfail({
> +    "int",
> +    "int aa1; int aa2 ",
> +    "static int x;",
> +    "static const long long x = 1;", -- NYI
> +    "static const double x = 1;",	   -- NYI
> +    "static const bool x = 1;",	   -- NYI (intentional, need true/false)
> +    "struct { static int x = 1; };",
> +    ";;static int y"
> +  }, ffi.cdef)
> +end
>   
> -ffi.cdef[[
> -static const int K_42a = 42;
> -static const char K_42b = 42+256;
> -static const short K_M1a = 65535;
> -static const unsigned short K_65535a = 65535;
> -static const int K_1b = 0xffffffff >> 31;
> -static const int K_1c = 0xffffffffu >> 31;
> -static const int K_M1b = (int)0xffffffff >> 31;
> -]]
> +do --- constants declarations
> +   ffi.cdef[[
> +   static const int K_42a = 42;
> +   static const char K_42b = 42+256;
> +   static const short K_M1a = 65535;
> +   static const unsigned short K_65535a = 65535;
> +   static const int K_1b = 0xffffffff >> 31;
> +   static const int K_1c = 0xffffffffu >> 31;
> +   static const int K_M1b = (int)0xffffffff >> 31;
> +   ]]
>   
> -checktypes{
> -  42,	1,	"char[K_42a]",
> -  42,	1,	"char[K_42b]",
> -  1,	1,	"char[-K_M1a]",
> -  65535, 1,	"char[K_65535a]",
> -  1,	1,	"char[K_1b]",
> -  1,	1,	"char[K_1c]",
> -  1,	1,	"char[-K_M1b]",
> -}
> +   checktypes{
> +     42,	1,	"char[K_42a]",
> +     42,	1,	"char[K_42b]",
> +     1,	1,	"char[-K_M1a]",
> +     65535, 1,	"char[K_65535a]",
> +     1,	1,	"char[K_1b]",
> +     1,	1,	"char[K_1c]",
> +     1,	1,	"char[-K_M1b]",
> +   }
> +end
>   
> -ffi.cdef[[
> -struct str1 {
> -  enum {
> -    K_99 = 99
> -  };
> -  static const int K_55 = 55;
> -} extk;
> -]]
> +do --- constant struct
> +  ffi.cdef[[
> +  struct str1 {
> +    enum {
> +      K_99 = 99
> +    };
> +    static const int K_55 = 55;
> +  } extk;
> +  ]]
>   
> -checktypes{
> -  99,	1,	"char[K_99]",
> -  99,	1,	"char[extk.K_99]",
> -  99,	1,	"char[((struct str1)0).K_99]",
> -  99,	1,	"char[((struct str1 *)0)->K_99]",
> -  55,	1,	"char[extk.K_55]",
> -}
> +  checktypes{
> +    99,	1,	"char[K_99]",
> +    99,	1,	"char[extk.K_99]",
> +    99,	1,	"char[((struct str1)0).K_99]",
> +    99,	1,	"char[((struct str1 *)0)->K_99]",
> +    55,	1,	"char[extk.K_55]",
> +  }
>   
> -checkfail{
> -  "char[K_55]",
> -}
> +  checkfail{
> +    "char[K_55]",
> +  }
> +end
>   
> -ffi.cdef[[
> -extern int func1(void);
> -extern int func2();
> -static int func3();
> -static inline int func4(int n)
> -{
> -  int i, k = 0;
> -  float x = 1.0f;
> -  for (i = 0; i < n; i++) {
> -    k += i;
> +do --- parse functions declaration
> +  ffi.cdef[[
> +  extern int func1(void);
> +  extern int func2();
> +  static int func3();
> +  static inline int func4(int n)
> +  {
> +    int i, k = 0;
> +    float x = 1.0f;
> +    for (i = 0; i < n; i++) {
> +      k += i;
> +    }
> +    return k;
>     }
> -  return k;
> -}
> -;;;
> -]]
> +  ;;;
> +  ]]
> +end
>   
> -ffi.cdef[[
> -int ext1;
> -extern int ext2;
> -]]
> +do --- parse extern
> +  ffi.cdef[[
> +  int ext1;
> +  extern int ext2;
> +  ]]
> +end
>   
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index a805bdd0..12b6387f 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -18,6 +18,7 @@ ffi_metatype.lua
>   ffi_new.lua
>   ffi_parse_array.lua
>   ffi_parse_basic.lua
> +ffi_parse_cdef.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
  2024-02-01  9:16   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:14   ` Sergey Bronnikov via Tarantool-patches
  2024-02-06 14:25     ` Sergey Kaplun via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:14 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM with a minor comment

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes `dofile()` (which uses an unreliable relative file
> path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` of the helper functions. It adds groups with
> the names of subtests and enables the test in <index>.
>
> Part of tarantool/tarantool#9398
> ---
>   .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
>   test/LuaJIT-tests/lib/ffi/index               |   1 +
>   2 files changed, 176 insertions(+), 160 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> index 16a3d053..cb231c33 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
<snipped>
>   
> -do
> +do --- pragma pack aligment
typo: alignment
>     ffi.cdef[[
>       #pragma pack(2)
>       struct foo_packalign8 {
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 12b6387f..e3a34e30 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -19,6 +19,7 @@ ffi_new.lua
>   ffi_parse_array.lua
>   ffi_parse_basic.lua
>   ffi_parse_cdef.lua
> +ffi_parse_struct.lua
>   istype.lua
>   jit_array.lua
>   jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:19   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:20   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:20 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey!

thanks for the patch! LGTM after fixing comments from Max.

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <ffi_tabov.lua> test from the LuaJIT-tests suite to
> the tarantool-tests suite, because this test should be run separately to
> avoid overflow of the table with ctypes for other tests from
> LuaJIT-tests suite.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lib/ffi/ffi_tabov.lua | 12 -----------
>   test/tarantool-tests/ffi-tabov.test.lua | 27 +++++++++++++++++++++++++
>   2 files changed, 27 insertions(+), 12 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
>   create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua b/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> deleted file mode 100644
> index ba621960..00000000
> --- a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -local ffi = require("ffi")
> -
> -local last = 0
> -
> -assert(pcall(function()
> -  for i=1,65536 do
> -    last = i
> -    ffi.typeof"struct {}"
> -  end
> -end) == false)
> -
> -assert(last > 20000)
> diff --git a/test/tarantool-tests/ffi-tabov.test.lua b/test/tarantool-tests/ffi-tabov.test.lua
> new file mode 100644
> index 00000000..7ea8b24b
> --- /dev/null
> +++ b/test/tarantool-tests/ffi-tabov.test.lua
> @@ -0,0 +1,27 @@
> +local tap = require('tap')
> +local ffi = require('ffi')
> +
> +-- This test is moved here from the LuaJIT-tests suite since it
> +-- should be run separately because it exhausts the ctype table.
> +local test = tap.test('ffi-tabov')
> +
> +test:plan(3)
> +
> +-- XXX: Amount of ctypes available to the user of a platform.
> +local MIN_AVAILABLE_CTYPES = 20000
> +
> +local last = 0
> +
> +local res, errmsg = pcall(function()
> +  for i = 1, 2^16 do
> +    last = i
> +    ffi.typeof('struct {}')
> +  end
> +end)
> +
> +test:ok(res == false, 'correct status')
> +test:like(errmsg, 'table overflow', 'correct error message')
> +
> +test:ok(last > MIN_AVAILABLE_CTYPES, 'huge enough amount of free ctypes')
> +
> +test:done(true)

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:23   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:27   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:27 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <lightud.lua> test from the <misc> to <lang>
> directory, includes it in <index>, and names subtests. Also, it enables
> tests for all arches and fixes tests for 47-bit lightuserdata because it
> is available since the commit
> 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64
> bit lightuserdata.")
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/index       |  1 +
>   test/LuaJIT-tests/lang/lightud.lua | 89 ++++++++++++++++++++++++++++++
>   test/LuaJIT-tests/misc/lightud.lua | 88 -----------------------------
>   3 files changed, 90 insertions(+), 88 deletions(-)
>   create mode 100644 test/LuaJIT-tests/lang/lightud.lua
>   delete mode 100644 test/LuaJIT-tests/misc/lightud.lua
>
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 88e2edfa..60cbecfb 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -5,6 +5,7 @@ compare_nan.lua
>   constant
>   for.lua
>   length.lua
> +lightud.lua
>   modulo.lua
>   concat.lua
>   self.lua
> diff --git a/test/LuaJIT-tests/lang/lightud.lua b/test/LuaJIT-tests/lang/lightud.lua
> new file mode 100644
> index 00000000..aee9e85c
> --- /dev/null
> +++ b/test/LuaJIT-tests/lang/lightud.lua
> @@ -0,0 +1,89 @@
> +local ctest = require("libctest")
> +
> +local lightud = ctest.lightud
> +local assert = assert
> +
> +-- x64 lightud tests
> +do --- light userdata comparison and tostring +x64
> +  local ud1 = lightud(0x12345678)
> +  local ud2 = lightud(0x12345678)
> +  assert(ud1 == ud2)
> +  assert(tostring(ud1) == "userdata: 0x12345678")
> +end
> +
> +do --- unequal light userdata comparison +x64
> +  local ud1 = lightud(1)
> +  local ud2 = lightud(2)
> +  assert(ud1 ~= ud2)
> +end
> +
> +do --- big light userdata comparison and tostring +x64
> +  local ud1 = lightud(2^47-1)
> +  local ud2 = lightud(2^47-1)
> +  assert(ud1 == ud2)
> +  assert(tostring(ud1) == "userdata: 0x7fffffffffff")
> +end
> +
> +do --- unequal light userdata comparison JIT +x64
> +  local ud1 = lightud(0x12345678+123*2^32)
> +  local ud2 = lightud(0x12345678+456*2^32)
> +  for i=1,100 do assert(ud1 ~= ud2) end
> +end
> +
> +do --- 47 bits light userdata +x64
> +  assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234")
> +  -- Now more than 47 bits are available.
> +  assert(pcall(lightud, 2^47) == true)
> +  assert(pcall(lightud, 2^64-2048) == true)
> +end
> +
> +do --- metatable check
> +  assert(getmetatable(lightud(1)) == nil)
> +end
> +
> +do --- lightuserdata SLOAD value and HREF key
> +  local ud = lightud(12345)
> +  local t = {[ud] = 42}
> +  for i=1,100 do
> +    assert(t[ud] == 42)
> +  end
> +end
> +
> +do --- lightuserdata NEWREF key
> +  local ud = lightud(12345)
> +  for i=1,100 do
> +    local t = {[ud] = 42}
> +    assert(t[ud] == 42)
> +  end
> +end
> +
> +do --- lightuserdata ASTORE/HSTORE value
> +  local ud = lightud(12345)
> +  local t = {}
> +  for i=1,100 do
> +    t[i] = ud
> +  end
> +  assert(t[100] == ud)
> +end
> +
> +do --- lightuserdata sync to stack
> +  local ud = lightud(12345)
> +  local x = nil
> +  for j=1,20 do
> +    for i=1,50 do
> +      x = ud
> +    end
> +    assert(x == ud)
> +  end
> +end
> +
> +do --- lightuserdata vs. number type check
> +  local t = {}
> +  for i=1,200 do t[i] = i end
> +  t[180] = lightud(12345)
> +  local x = 0
> +  assert(not pcall(function(t)
> +    for i=1,200 do x = x + t[i] end
> +  end, t))
> +  assert(x == 16110)
> +end
> diff --git a/test/LuaJIT-tests/misc/lightud.lua b/test/LuaJIT-tests/misc/lightud.lua
> deleted file mode 100644
> index 4974d50f..00000000
> --- a/test/LuaJIT-tests/misc/lightud.lua
> +++ /dev/null
> @@ -1,88 +0,0 @@
> -local ctest = require("ctest")
> -
> -local lightud = ctest.lightud
> -local assert = assert
> -
> --- x64 lightud tests
> -if jit and jit.arch == "x64" then
> -  do
> -    local ud1 = lightud(0x12345678)
> -    local ud2 = lightud(0x12345678)
> -    assert(ud1 == ud2)
> -    assert(tostring(ud1) == "userdata: 0x12345678")
> -  end
> -  do
> -    local ud1 = lightud(1)
> -    local ud2 = lightud(2)
> -    assert(ud1 ~= ud2)
> -  end
> -  do
> -    local ud1 = lightud(2^47-1)
> -    local ud2 = lightud(2^47-1)
> -    assert(ud1 == ud2)
> -    assert(tostring(ud1) == "userdata: 0x7fffffffffff")
> -  end
> -  do
> -    local ud1 = lightud(0x12345678+123*2^32)
> -    local ud2 = lightud(0x12345678+456*2^32)
> -    for i=1,100 do assert(ud1 ~= ud2) end
> -  end
> -  assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234")
> -  assert(pcall(lightud, 2^47) == false)
> -  assert(pcall(lightud, 2^64-2048) == false)
> -end
> -
> -assert(getmetatable(lightud(1)) == nil)
> -
> --- lightuserdata SLOAD value and HREF key
> -do
> -  local ud = lightud(12345)
> -  local t = {[ud] = 42}
> -  for i=1,100 do
> -    assert(t[ud] == 42)
> -  end
> -end
> -
> --- lightuserdata NEWREF key
> -do
> -  local ud = lightud(12345)
> -  for i=1,100 do
> -    local t = {[ud] = 42}
> -    assert(t[ud] == 42)
> -  end
> -end
> -
> --- lightuserdata ASTORE/HSTORE value
> -do
> -  local ud = lightud(12345)
> -  local t = {}
> -  for i=1,100 do
> -    t[i] = ud
> -  end
> -  assert(t[100] == ud)
> -end
> -
> --- lightuserdata sync to stack
> -do
> -  local ud = lightud(12345)
> -  local x = nil
> -  for j=1,20 do
> -    for i=1,50 do
> -      x = ud
> -    end
> -    assert(x == ud)
> -  end
> -end
> -
> --- lightuserdata vs. number type check
> -do
> -  local t = {}
> -  for i=1,200 do t[i] = i end
> -  t[180] = lightud(12345)
> -  local x = 0
> -  assert(not pcall(function(t)
> -    for i=1,200 do x = x + t[i] end
> -  end, t))
> -  assert(x == 16110)
> -end
> -

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:25   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:28   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:28 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <api_call.lua> test from the <misc> to <lang>
> directory, includes it in <index>, and names subtests.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/{misc => lang}/api_call.lua | 32 +++++++++++--------
>   test/LuaJIT-tests/lang/index                  |  1 +
>   2 files changed, 19 insertions(+), 14 deletions(-)
>   rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)
>
> diff --git a/test/LuaJIT-tests/misc/api_call.lua b/test/LuaJIT-tests/lang/api_call.lua
> similarity index 79%
> rename from test/LuaJIT-tests/misc/api_call.lua
> rename to test/LuaJIT-tests/lang/api_call.lua
> index 7dbd5e40..142959c5 100644
> --- a/test/LuaJIT-tests/misc/api_call.lua
> +++ b/test/LuaJIT-tests/lang/api_call.lua
> @@ -1,4 +1,4 @@
> -local ctest = require("ctest")
> +local ctest = require("libctest")
>   
>   local function ret0() end
>   local function ret1() return 1 end
> @@ -57,19 +57,10 @@ local function test_adjust_results(testfunc)
>     ck(cc(-1, retva, 1, 2), 1, 2)
>   end
>   
> -test_adjust_results(ctest.call)
> -test_adjust_results(ctest.pcall_err)
> -
> -
>   local function gcshrink()
>     for i=1,10 do collectgarbage() end
>   end
>   
> -assert(select('#', ctest.call(2000, gcshrink)) == 2000)
> -gcshrink()
> -assert(select('#', ctest.call(7000, gcshrink)) == 7000)
> -gcshrink()
> -
>   local function test_yield(resume, yield)
>     local function inpcall()
>       ck(pack(yield(6, 7)), 18, 19)
> @@ -91,8 +82,21 @@ local function test_yield(resume, yield)
>     assert(resume(co) == false)
>   end
>   
> -test_yield(coroutine.resume, coroutine.yield)
> -test_yield(ctest.resume, coroutine.yield)
> -test_yield(coroutine.resume, ctest.yield)
> -test_yield(ctest.resume, ctest.yield)
> +do --- adjust results
> +  test_adjust_results(ctest.call)
> +  test_adjust_results(ctest.pcall_err)
> +end
>   
> +do --- GC shrink
> +  assert(select('#', ctest.call(2000, gcshrink)) == 2000)
> +  gcshrink()
> +  assert(select('#', ctest.call(7000, gcshrink)) == 7000)
> +  gcshrink()
> +end
> +
> +do --- yield
> +  test_yield(coroutine.resume, coroutine.yield)
> +  test_yield(ctest.resume, coroutine.yield)
> +  test_yield(coroutine.resume, ctest.yield)
> +  test_yield(ctest.resume, ctest.yield)
> +end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 60cbecfb..dc0c2e14 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -1,4 +1,5 @@
>   andor.lua
> +api_call.lua
>   assignment.lua
>   compare.lua
>   compare_nan.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:31   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:32 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <catch_wrap.lua> test from the <misc> to <lang>
> directory, includes it in <index>, and names subtests. Also, since the
> tests may be shuffled, `cp.wrapon()` and `cp.wrapoff()` are used for
> each test separately. Also, this patch adds a workaround for the
> internal ASAN bug, see details in the comment in the <CMakeLists.txt>.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/CMakeLists.txt              | 16 ++++++++++
>   .../{misc => lang}/catch_wrap.lua             | 29 +++++++++++++------
>   test/LuaJIT-tests/lang/index                  |  1 +
>   3 files changed, 37 insertions(+), 9 deletions(-)
>   rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)
>
> diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
> index c52bcc71..8ecfe3f6 100644
> --- a/test/LuaJIT-tests/CMakeLists.txt
> +++ b/test/LuaJIT-tests/CMakeLists.txt
> @@ -24,6 +24,22 @@ else()
>     list(APPEND LUAJIT_TESTS_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
>   endif()
>   
> +if(LUAJIT_USE_ASAN)
> +  # When running LuaJIT-tests under ASAN, the internal ASAN check
> +  # failed:
> +  # AddressSanitizer: CHECK failed: asan_interceptors.cpp:356
> +  # "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
> +  # This is a workaround suggested at
> +  # https://github.com/google/sanitizers/issues/934.
> +  execute_process(
> +    COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.so
> +    OUTPUT_VARIABLE LIB_STDCPP
> +    OUTPUT_STRIP_TRAILING_WHITESPACE
> +  )
> +  # Fortunately, we are not interested in macOS here.
> +  list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_STDCPP}")
> +endif()
> +
>   add_custom_command(TARGET LuaJIT-tests
>     COMMENT "Running LuaJIT-tests"
>     COMMAND
> diff --git a/test/LuaJIT-tests/misc/catch_wrap.lua b/test/LuaJIT-tests/lang/catch_wrap.lua
> similarity index 71%
> rename from test/LuaJIT-tests/misc/catch_wrap.lua
> rename to test/LuaJIT-tests/lang/catch_wrap.lua
> index 7f656bcc..9d1e3478 100644
> --- a/test/LuaJIT-tests/misc/catch_wrap.lua
> +++ b/test/LuaJIT-tests/lang/catch_wrap.lua
> @@ -1,45 +1,56 @@
> +local cp = require("libcpptest")
>   
> -local cp = require("cpptest")
> -cp.wrapon()
> +local unwind
>   
> -do
> +do --- catch, no error
> +  cp.wrapon()
>     local a, b = pcall(cp.catch, function() return "x" end)
>     assert(a == true and b == "x")
> +  cp.wrapoff()
>   end
>   
> -do
> +do --- pcall throw
> +  cp.wrapon()
>     local a, b = pcall(function() cp.throw("foo") end)
>     assert(a == false and b == "foo")
> +  cp.wrapoff()
>   end
>   
> -local unwind
> -do
> +do --- catch throw
> +  cp.wrapon()
>     local a, b = pcall(cp.catch, function() cp.throw("foo") end)
>     unwind = a
>     assert((a == false and b == "foo") or (a == true and b == "catch ..."))
> +  cp.wrapoff()
>   end
>   
> -do
> +do --- alloc, no error
> +  cp.wrapon()
>     local st = cp.alloc(function() return cp.isalloc() end)
>     assert(st == true)
>     assert(cp.isalloc() == false)
> +  cp.wrapoff()
>   end
>   
> -do
> +do --- throw in alloc
> +  cp.wrapon()
>     local a, b = pcall(cp.alloc, function()
>       assert(cp.isalloc() == true)
>       return "foo", cp.throw
>     end)
>     assert(a == false and b == "foo")
>     assert(cp.isalloc() == false)
> +  cp.wrapoff()
>   end
>   
> -do
> +do --- error in alloc
> +  cp.wrapon()
>     local a, b = pcall(cp.alloc, function()
>       assert(cp.isalloc() == true)
>       return "foo", error
>     end)
>     assert(a == false and b == "foo")
>     if unwind then assert(cp.isalloc() == false) end
> +  cp.wrapoff()
>   end
>   
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index dc0c2e14..87b0c5a0 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -1,6 +1,7 @@
>   andor.lua
>   api_call.lua
>   assignment.lua
> +catch_wrap.lua
>   compare.lua
>   compare_nan.lua
>   constant

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> LuaJIT test
  2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches
  2024-02-01  9:32   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-05 13:32 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <catch_cpp.lua> test from the <sysdep> to <lang>
> directory, includes it in <index>, and names subtests.
>
> Resolves of tarantool/tarantool#7834
> Part of tarantool/tarantool#9398
> ---
>   .../{sysdep => lang}/catch_cpp.lua            | 36 ++++++++++---------
>   test/LuaJIT-tests/lang/index                  |  1 +
>   2 files changed, 20 insertions(+), 17 deletions(-)
>   rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
>
> diff --git a/test/LuaJIT-tests/sysdep/catch_cpp.lua b/test/LuaJIT-tests/lang/catch_cpp.lua
> similarity index 75%
> rename from test/LuaJIT-tests/sysdep/catch_cpp.lua
> rename to test/LuaJIT-tests/lang/catch_cpp.lua
> index b2251009..6c52c78c 100644
> --- a/test/LuaJIT-tests/sysdep/catch_cpp.lua
> +++ b/test/LuaJIT-tests/lang/catch_cpp.lua
> @@ -1,30 +1,30 @@
> +local cp = require("libcpptest")
>   
> -local cp = require("cpptest")
> +local unwind
>   
> -do
> +do --- catch, no error
>     local a, b = pcall(cp.catch, function() return "x" end)
>     assert(a == true and b == "x")
>   end
>   
> -do
> +do --- pcall throw
>     local a, b = pcall(function() cp.throw("foo") end)
>     assert(a == false and b == "C++ exception")
>   end
>   
> -local unwind
> -do
> +do --- catch throw
>     local a, b = pcall(cp.catch, function() cp.throw("foo") end)
>     unwind = a
>     assert((a == false and b == "C++ exception") or (a == true and b == "foo"))
>   end
>   
> -do
> +do --- alloc, no error
>     local st = cp.alloc(function() return cp.isalloc() end)
>     assert(st == true)
>     assert(cp.isalloc() == false)
>   end
>   
> -do
> +do --- throw in alloc
>     local a, b = pcall(cp.alloc, function()
>       assert(cp.isalloc() == true)
>       return "foo", cp.throw
> @@ -33,21 +33,23 @@ do
>     assert(cp.isalloc() == false)
>   end
>   
> -if unwind then
> -  local a, b = pcall(cp.alloc, function()
> -    assert(cp.isalloc() == true)
> -    return "foo", error
> -  end)
> -  assert(a == false and b == "foo")
> -  assert(cp.isalloc() == false)
> +do --- error in alloc
> +  if unwind then
> +    local a, b = pcall(cp.alloc, function()
> +      assert(cp.isalloc() == true)
> +      return "foo", error
> +    end)
> +    assert(a == false and b == "foo")
> +    assert(cp.isalloc() == false)
> +  end
>   end
>   
> -do
> +do --- usereg nop
>     local a,b,c,d,e,f = cp.usereg(100, 50, function() end, false)
>     assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
>   end
>   
> -do
> +do --- usereg error
>     local function test()
>       cp.usereg(100, 40, error, "foo")
>     end
> @@ -55,7 +57,7 @@ do
>     assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
>   end
>   
> -do
> +do --- usereg trace with self table lookup
>     local t = {};
>     t.t = t;
>     local function foo()
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 87b0c5a0..41f7e7db 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -1,6 +1,7 @@
>   andor.lua
>   api_call.lua
>   assignment.lua
> +catch_cpp.lua
>   catch_wrap.lua
>   compare.lua
>   compare_nan.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro
  2024-01-31 11:25   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 11:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:48       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:23 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comments and force-pushed the branch.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:01PM +0300, Sergey Kaplun wrote:
> > This patch removes copy-pasting in macros used to add a new library for
> > testing and places this in the include test file.
> >
> > Needed for tarantool/tarantool#9398
> > ---
> >  test/CMakeLists.txt                           |  3 ++
> >  .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 25 +----------------
> >  test/cmake/AddTestLib.cmake                   | 28 +++++++++++++++++++
> >  test/tarantool-tests/CMakeLists.txt           | 27 +-----------------
> >  4 files changed, 33 insertions(+), 50 deletions(-)
> >  create mode 100644 test/cmake/AddTestLib.cmake
> >
> > diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
> > index 8afc42df..3ad5d15f 100644
> > --- a/test/CMakeLists.txt
> > +++ b/test/CMakeLists.txt
> > @@ -74,6 +74,9 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS
> >  set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
> >  separate_arguments(LUAJIT_TEST_COMMAND)
> >
> > +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
> > +include(AddTestLib)
> > +
> >  add_subdirectory(LuaJIT-tests)
> >  add_subdirectory(PUC-Rio-Lua-5.1-tests)
> >  add_subdirectory(lua-Harness-tests)
> > diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> > index 8501b767..e68e6aef 100644
> > --- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> > +++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
> > @@ -6,30 +6,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
> >
> >  # Build additional C libraries for tests.
> >  macro(BuildTestCLib lib sources)
> > -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> > -  target_include_directories(${lib} PRIVATE
> > -    ${LUAJIT_SOURCE_DIR}
> > -  )
> > -  set_target_properties(${lib} PROPERTIES
> > -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> > -    PREFIX ""
> > -  )
> > -  # XXX: The dynamic libraries are loaded with LuaJIT binary and
> > -  # use symbols from it. So it is totally OK to have unresolved
> > -  # symbols at build time.
> > -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> > -    set_target_properties(${lib} PROPERTIES
> > -      LINK_FLAGS "-undefined dynamic_lookup"
> > -    )
> > -  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> > -    # XXX: This is necessary mostly for openSUSE builds, see also
> > -    # https://bugzilla.suse.com/show_bug.cgi?id=1012388.
> > -    # Just strip out the linker flag to suppress this linker
> > -    # option.
> > -    string(REPLACE "-Wl,--no-undefined" ""
> > -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> > -    )
> > -  endif()
> > +  AddTestLib(${lib} ${sources})
> >    list(APPEND TESTLIBS ${lib})
> >  endmacro()
> This macro now seems redundant, maybe we should get rid of it.

Fixed with the following patch:

===================================================================
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
index e68e6aef..b496cbab 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
@@ -5,15 +5,10 @@
 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
 # Build additional C libraries for tests.
-macro(BuildTestCLib lib sources)
-  AddTestLib(${lib} ${sources})
-  list(APPEND TESTLIBS ${lib})
-endmacro()
-
-BuildTestCLib(lib1 lib1.c)
-BuildTestCLib(lib11 lib1.c lib11.c)
-BuildTestCLib(lib2 lib2.c)
-BuildTestCLib(lib21 lib2.c lib21.c)
+AddTestLib(lib1 lib1.c)
+AddTestLib(lib11 lib1.c lib11.c)
+AddTestLib(lib2 lib2.c)
+AddTestLib(lib21 lib2.c lib21.c)
 
 # Create the exact copy of the lib2 library for tests
 # in <attrib.lua>.
diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
index a31f632c..c5733d99 100644
--- a/test/cmake/AddTestLib.cmake
+++ b/test/cmake/AddTestLib.cmake
@@ -1,3 +1,5 @@
+# Add a test library to build and add it to the `TESTLIBS`
+# variable.
 macro(AddTestLib lib sources)
   add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
   target_include_directories(${lib} PRIVATE
@@ -25,4 +27,5 @@ macro(AddTestLib lib sources)
       CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
     )
   endif()
+  list(APPEND TESTLIBS ${lib})
 endmacro()
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 80d94a78..8c7c3ae8 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -12,12 +12,7 @@ endif()
 
 macro(BuildTestCLib lib sources)
   AddTestLib(${lib} ${sources})
-  # XXX: Append the lib to be built to the dependency list.
-  # Unfortunately, there is no convenient way in CMake to extend
-  # the list in parent scope other than join two strings with
-  # semicolon. If one finds the normal way to make it work, feel
-  # free to reach me.
-  set(TESTLIBS "${lib};${TESTLIBS}" PARENT_SCOPE)
+  set(TESTLIBS "${TESTLIBS}" PARENT_SCOPE)
   # 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
===================================================================

> >
> > diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
> > new file mode 100644
> > index 00000000..3764ee5c
> > --- /dev/null
> > +++ b/test/cmake/AddTestLib.cmake
> > @@ -0,0 +1,28 @@
> > +macro(AddTestLib lib sources)
> > +  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> > +  target_include_directories(${lib} PRIVATE
> > +    ${LUAJIT_SOURCE_DIR}
> > +    ${CMAKE_CURRENT_SOURCE_DIR}
> > +  )
> > +  set_target_properties(${lib} PROPERTIES
> > +    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> > +    PREFIX ""
> > +  )
> > +
> > +  # XXX: This change affects the current cmake variable scope and
> Typo: s/cmake/CMake/
> Typo: s/scope and/scope,/
> > +  # so a user should care to don't use it in a top level scope.
> Typo: s/should care to don't use/shouldn't use/
> Typo: s/top level/top-level/

Fixed:

===================================================================
diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
index 4450a950..a31f632c 100644
--- a/test/cmake/AddTestLib.cmake
+++ b/test/cmake/AddTestLib.cmake
@@ -9,8 +9,8 @@ macro(AddTestLib lib sources)
     PREFIX ""
   )
 
-  # XXX: This change affects the current cmake variable scope and
-  # so a user should care to don't use it in a top level scope.
+  # XXX: This change affects the current CMake variable scope, so
+  # a user shouldn't use it in a top-level scope.
   # The dynamic libraries are loaded with LuaJIT binary and use
   # symbols from it. So it is totally OK to have unresolved
   # symbols at build time.
===================================================================

> > +  # The dynamic libraries are loaded with LuaJIT binary and use
> > +  # symbols from it. So it is totally OK to have unresolved
> > +  # symbols at build time.
> > +  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> > +    set_target_properties(${lib} PROPERTIES
> > +      LINK_FLAGS "-undefined dynamic_lookup"
> > +    )
> > +  else()
> > +    # FIXME: Unfortunately, there is no another way to suppress
> > +    # this linker option, so just strip it out from the flags.
> > +    string(REPLACE "-Wl,--no-undefined" ""
> > +      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> > +    )
> I wonder why you've omitted the condition along with the comment here.

Added the condition.

===================================================================
diff --git a/test/cmake/AddTestLib.cmake b/test/cmake/AddTestLib.cmake
index 3764ee5c..4450a950 100644
--- a/test/cmake/AddTestLib.cmake
+++ b/test/cmake/AddTestLib.cmake
@@ -18,7 +18,7 @@ macro(AddTestLib lib sources)
     set_target_properties(${lib} PROPERTIES
       LINK_FLAGS "-undefined dynamic_lookup"
     )
-  else()
+  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     # FIXME: Unfortunately, there is no another way to suppress
     # this linker option, so just strip it out from the flags.
     string(REPLACE "-Wl,--no-undefined" ""
===================================================================

> > +  endif()
> > +endmacro()
> > diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
> > index 6d686876..80d94a78 100644
> > --- a/test/tarantool-tests/CMakeLists.txt
> > +++ b/test/tarantool-tests/CMakeLists.txt
> > @@ -11,32 +11,7 @@ if(NOT PROVE)
> >  endif()
> >
> >  macro(BuildTestCLib lib sources)
> > -  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
> > -  target_include_directories(${lib} PRIVATE
> > -    ${LUAJIT_SOURCE_DIR}
> > -    ${CMAKE_CURRENT_SOURCE_DIR}
> > -  )
> > -  set_target_properties(${lib} PROPERTIES
> > -    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
> > -    PREFIX ""
> > -  )
> > -
> > -  # XXX: This change affects the current cmake variable scope and
> > -  # so a user should care to don't use it in a top level scope.
> > -  # The dynamic libraries are loaded with LuaJIT binary and use
> > -  # symbols from it. So it is totally OK to have unresolved
> > -  # symbols at build time.
> > -  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> > -    set_target_properties(${lib} PROPERTIES
> > -      LINK_FLAGS "-undefined dynamic_lookup"
> > -    )
> > -  else()
> > -    # FIXME: Unfortunately, there is no another way to suppress
> > -    # this linker option, so just strip it out from the flags.
> > -    string(REPLACE "-Wl,--no-undefined" ""
> > -      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
> > -    )
> > -  endif()
> > +  AddTestLib(${lib} ${sources})
> Same comments as for the above section.

See the patch above.

> >    # XXX: Append the lib to be built to the dependency list.
> >    # Unfortunately, there is no convenient way in CMake to extend
> >    # the list in parent scope other than join two strings with
> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests
  2024-01-31 11:48   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 11:24     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:50       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:24 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comments and force-pushed the branch.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> On Mon, Jan 29, 2024 at 01:45:02PM +0300, Sergey Kaplun wrote:
> > This patch adds rules to build C and C++ libs from the
> > <LuaJIT-tests/src/> 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
> I think something like `LuaJIT-tests-libs` is better name for the
> target.

Renamed.

===================================================================
diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index 8ecfe3f6..2c933a11 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 add_subdirectory(src)
 
 add_custom_target(LuaJIT-tests
-  DEPENDS ${LUAJIT_TEST_BINARY} LuaJIT-tests-prepare
+  DEPENDS ${LUAJIT_TEST_BINARY} LuaJIT-tests-libs
 )
 
 make_lua_path(LUA_CPATH
diff --git a/test/LuaJIT-tests/src/CMakeLists.txt b/test/LuaJIT-tests/src/CMakeLists.txt
index 0855088f..2f90da86 100644
--- a/test/LuaJIT-tests/src/CMakeLists.txt
+++ b/test/LuaJIT-tests/src/CMakeLists.txt
@@ -6,4 +6,4 @@ AddTestLib(libctest libctest.c)
 enable_language(CXX)
 AddTestLib(libcpptest libcpptest.cpp)
 
-add_custom_target(LuaJIT-tests-prepare DEPENDS ${TESTLIBS})
+add_custom_target(LuaJIT-tests-libs DEPENDS ${TESTLIBS})
===================================================================

> > +)
> > +
> > +make_lua_path(LUA_CPATH
> > +  PATHS
> > +  ${CMAKE_CURRENT_BINARY_DIR}/src/?${CMAKE_SHARED_LIBRARY_SUFFIX}
> > +)
> > +
> > +set(LUAJIT_TESTS_ENV
> > +  "LUA_CPATH=\"${LUA_CPATH}\""
> IINM, outer quotes are redundant here.

Without them, CMake just add ${LUA_CPATH} as a string (without internal
quotes). Hence, they are needed.

> > +)
> > +

<snipped>

> > 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()
> See the comment about this macro in the previous patch.

Fixed within the patch below.

> > +
> > +# 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
> Editor configuration should not be there.

Fixed: see the iterative patch below.

===================================================================
diff --git a/test/LuaJIT-tests/src/CMakeLists.txt b/test/LuaJIT-tests/src/CMakeLists.txt
index fb14d6d9..0855088f 100644
--- a/test/LuaJIT-tests/src/CMakeLists.txt
+++ b/test/LuaJIT-tests/src/CMakeLists.txt
@@ -1,17 +1,9 @@
 # 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)
+AddTestLib(libctest libctest.c)
 enable_language(CXX)
-BuildTestLib(libcpptest libcpptest.cpp)
+AddTestLib(libcpptest libcpptest.cpp)
 
 add_custom_target(LuaJIT-tests-prepare DEPENDS ${TESTLIBS})
-
-# vim: expandtab tabstop=2 shiftwidth=2
===================================================================

> 

<snipped>

> >
> >  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
> Let's change the `k` here to a more clear name.

Changed to the `key`:

===================================================================
diff --git a/test/LuaJIT-tests/test.lua b/test/LuaJIT-tests/test.lua
index f2450222..ab178331 100644
--- a/test/LuaJIT-tests/test.lua
+++ b/test/LuaJIT-tests/test.lua
@@ -297,9 +297,9 @@ local function append_tree_to_plan(test_tree, opts, plan, prefix)
 end
 
 local function seal_globals()
-  local sealed_mt = {__newindex = function(_, k)
+  local sealed_mt = {__newindex = function(_, key)
     -- Allow to load C/C++ libraries for the test.
-    if k ~= "libctest" and k ~= "libcpptest" then
+    if key ~= "libctest" and key ~= "libcpptest" then
       error("Tests should not mutate global state", 3)
     end
   end}
===================================================================

> > +      error("Tests should not mutate global state", 3)
> > +    end
> >    end}
> >    local function seal(t)
> >      if getmetatable(t) then return end
> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-01-31 11:58   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 11:47     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:51       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:47 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comments, see the iterative patch below.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for a few nits below.
> 
> On Mon, Jan 29, 2024 at 01:45:03PM +0300, Sergey Kaplun wrote:
> > This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>

<snipped>

> > --- /dev/null
> > +++ b/test/LuaJIT-tests/common/ffi/checktypes.lua
> > @@ -0,0 +1,15 @@
> > +local ffi = require("ffi")
> > +
> > +-- Checker that takes an array with the following each 3 elements:
> Typo: s/each 3 elements/triplets/

Fixed thanks!

> > +-- 1) Sizeof for the given C type to be checked.
> > +-- 2) Alignof for the given C type to be checked.
> Nit: `sizeof()` and `alignof()` or something like that? Feel free to
> ignore.

Renamed.

===================================================================
diff --git a/test/LuaJIT-tests/common/ffi/checktypes.lua b/test/LuaJIT-tests/common/ffi/checktypes.lua
index c995d667..b5e04480 100644
--- a/test/LuaJIT-tests/common/ffi/checktypes.lua
+++ b/test/LuaJIT-tests/common/ffi/checktypes.lua
@@ -1,8 +1,8 @@
 local ffi = require("ffi")
 
--- Checker that takes an array with the following each 3 elements:
--- 1) Sizeof for the given C type to be checked.
--- 2) Alignof for the given C type to be checked.
+-- Checker that takes an array with the following triplets:
+-- 1) `sizeof()` for the given C type to be checked.
+-- 2) `alignof()` for the given C type to be checked.
 -- 3) String representing the C type.
 return function(t)
   for i=1,1e9,3 do
===================================================================

> > +-- 3) String representing the C type.

<snipped>

> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-02-01 15:45   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 11:48     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  6:49       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:48 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
Fixed your comment.

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with a minor comment below
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>
> > into separate files by analogy with <common/expect_error.lua>. The
> > `include()` helper isn't touched since it is used in system dependend
> typo: dependent?

Fixed, thanks!

> > tests, which won't be modified for now.
> >
> > Part of tarantool/tarantool#9398
> > ---

<snipped>

> >   

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-01-31 12:26   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 11:54     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:54 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment and force-pushed the branch.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for the single nit below.
> 
> On Mon, Jan 29, 2024 at 01:45:05PM +0300, Sergey Kaplun wrote:
> > This patch removes unused `dofile()`. Also, it names the only one test
> > as "misc" and includes the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---

| test: enable <ffi_bitfield.lua> in LuaJIT-tests
|
| This patch removes unused `dofile()`. Also, it splits the test case into
| several and includes the test in <index>.
|
| Part of tarantool/tarantool#9398

> >  test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua | 4 +---
> >  test/LuaJIT-tests/lib/ffi/index            | 1 +
> >  2 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> > index cd0b1815..fa74e45d 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
> > @@ -1,8 +1,6 @@
> >  local ffi = require("ffi")
> >
> > -dofile("../common/ffi_util.inc")
> > -
> > -do
> > +do --- misc
> Nit: Maybe `misc bitfield tests` then for it to be more elaborate?
> Or maybe it should be spplitted according to the sections inside the
> test.

I've prefered to split this test into several. See the iterative patch
below.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
index fa74e45d..e8efc82c 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua
@@ -1,17 +1,16 @@
 local ffi = require("ffi")
 
-do --- misc
-  local x = ffi.new([[
-    union {
-      uint32_t u;
-      struct { int a:10,b:10,c:11,d:1; };
-      struct { unsigned int e:10,f:10,g:11,h:1; };
-      struct { int8_t i:4,j:5,k:5,l:3; };
-      struct { _Bool b0:1,b1:1,b2:1,b3:1; };
-    }
-  ]])
+local x = ffi.new([[
+  union {
+    uint32_t u;
+    struct { int a:10,b:10,c:11,d:1; };
+    struct { unsigned int e:10,f:10,g:11,h:1; };
+    struct { int8_t i:4,j:5,k:5,l:3; };
+    struct { _Bool b0:1,b1:1,b2:1,b3:1; };
+  }
+]])
 
-  -- bitfield access
+do --- bitfield access
   x.u = 0xffffffff
   assert(x.a == -1 and x.b == -1 and x.c == -1 and x.d == -1)
   assert(x.e == 1023 and x.f == 1023 and x.g == 2047 and x.h == 1)
@@ -41,8 +40,9 @@ do --- misc
     assert(x.i == -2 and x.j == -6 and x.k == 1 and x.l == -2)
     assert(x.b0 == true and x.b1 == true and x.b2 == true and x.b3 == false)
   end
+end
 
-  -- bitfield insert
+do --- bitfield insert
   x.u = 0xffffffff
   x.a = 0
   if ffi.abi("le") then
@@ -71,8 +71,9 @@ do --- misc
   else
     assert(x.u == 0x003ff000)
   end
+end
 
-  -- cumulative bitfield insert
+do --- cumulative bitfield insert
   x.u = 0xffffffff
   if ffi.abi("le") then
     x.a = -392; x.b = 277; x.c = 291; x.d = 0
@@ -101,6 +102,4 @@ do --- misc
   else
     assert(x.u == 0xa0000000)
   end
-
 end
-
===================================================================

> >    local x = ffi.new([[
> >      union {
> >        uint32_t u;
> > diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> > index 7e046908..8d833107 100644
> > --- a/test/LuaJIT-tests/lib/ffi/index
> > +++ b/test/LuaJIT-tests/lib/ffi/index
> > @@ -3,6 +3,7 @@ cdata_var.lua
> >  copy_fill.lua
> >  err.lua
> >  ffi_arith_ptr.lua
> > +ffi_bitfield.lua
> >  istype.lua
> >  jit_array.lua
> >  jit_complex.lua
> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-02-01 15:52   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 11:55     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 11:55 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed the test and force-pushed the branch.

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM after renaming testcase (I'm agree with Maxim).
> 
> BTW don't forget to update commit description after renaming.

Split the test into several.
The new commit message is the following:

| test: enable <ffi_bitfield.lua> in LuaJIT-tests
|
| This patch removes unused `dofile()`. Also, it splits the test case into
| several and includes the test in <index>.
|
| Part of tarantool/tarantool#9398

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> in LuaJIT-tests
  2024-02-01 15:58   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 12:01     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 12:01 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment.

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with minor comment below
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patch removes unused `dofile()`. Also, it uses the basename of the
> > ctest library to be loaded via ffi. It adds groups with names of
> > subtests and enables the test in <index>. Complex type is undefined on
> > Windows, so the correponding tests are not enabled for this platform.
> > Fastcalls are enabled only for the x86 architecture. Stdcalls are
> > enabled only for Windows on x86. Tests with calls with 10 arguments with
> > sizes less than 8 bits are dummy for M1. This suite lacks a mechanism to
> 
> too much "with" for my taste :) feel free to ignore

Replaced the first "with" with:) containing. See the new commit message
below:

| test: enable <ffi_call.lua> in LuaJIT-tests
|
| This patch removes unused `dofile()`. Also, it uses the basename of the
| ctest library to be loaded via ffi. It adds groups with names of
| subtests and enables the test in <index>. Complex type is undefined on
| Windows, so the correponding tests are not enabled for this platform.
| Fastcalls are enabled only for the x86 architecture. Stdcalls are
| enabled only for Windows on x86. Tests containing calls with 10
| arguments with sizes less than 8 bits are dummy for M1. This suite lacks
| a mechanism to skip subtests satisfying complicated conditions, so it is
| done manually by the corresponding `if` check.
|
| Part of tarantool/tarantool#9398

> 
> Thanks for reformatting testcases, much more readable now.

It's a pleasure :).


-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 12:09     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 12:09 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment and force-pushed the branch.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for the question below.
> On Mon, Jan 29, 2024 at 01:45:08PM +0300, Sergey Kaplun wrote:
> > This patch changes the `dofile()` (which uses an unreliable relative
> > file path and mutates `_G` with global functions to be defined) to the
> > corresponding `require()`.  Also, it names the only one test as "misc"
> > and includes the test in <index>.
> >
> > Part of tarantool/tarantool#9398

The new commit message is the following:

| test: enable <ffi_const.lua> in LuaJIT-tests
|
| This patch changes the `dofile()` (which uses an unreliable relative
| file path and mutates `_G` with global functions to be defined) to the
| corresponding `require()`. Also, it splits the test case into several
| and includes the test in <index>.
|
| Part of tarantool/tarantool#9398

> > ---
> >  test/LuaJIT-tests/lib/ffi/ffi_const.lua | 4 ++--
> >  test/LuaJIT-tests/lib/ffi/index         | 1 +
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> > index d42133ad..3213156d 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
> > @@ -1,6 +1,6 @@
> >  local ffi = require("ffi")
> >
> > -dofile("../common/ffi_util.inc")
> > +local fails = require("common.fails")
> >
> >  ffi.cdef[[
> >  typedef struct s_t {
> > @@ -41,7 +41,7 @@ typedef struct foo_t {
> >  } foo_t;
> >  ]]
> >
> > -do
> > +do --- misc
> Again, maybe it is worth splitting into the subcategories that are
> mentioned below.

Fixed within the following patch:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_const.lua b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
index 3213156d..01db9881 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_const.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_const.lua
@@ -41,27 +41,29 @@ typedef struct foo_t {
 } foo_t;
 ]]
 
-do --- misc
-  local foo_t = ffi.typeof("foo_t")
-  local x = foo_t()
+local foo_t = ffi.typeof("foo_t")
+local x = foo_t()
 
-  -- constval
+do --- constval
   assert(x.cc == 17)
   fails(function(x) x.cc = 1 end, x)
   assert(x.CC == -37)
   fails(function(x) x.CC = 1 end, x)
+end
 
-  -- fields
+do --- fields
   x.i = 1
   fails(function(x) x.ci = 1 end, x)
   x.e = 1
   fails(function(x) x.ce = 1 end, x)
+end
 
-  -- bitfields
+do --- bitfields
   x.bi = 1
   fails(function(x) x.cbi = 1 end, x)
+end
 
-  -- arrays
+do --- arrays
   do
     local a = ffi.new("int[10]")
     a[0] = 1
@@ -74,8 +76,9 @@ do --- misc
   fails(function(x) x.ca = x.a end, x)
   fails(function(x) x.ca = {} end, x)
   fails(function(x) x.cac = "abc" end, x)
+end
 
-  -- structs
+do --- structs
   do
     local s = ffi.new("s_t")
     s.v = 1
@@ -87,18 +90,21 @@ do --- misc
   x.s = x.cs
   fails(function(x) x.cs = x.s end, x)
   fails(function(x) x.cs = {} end, x)
+end
 
-  -- pseudo-const structs
+do --- pseudo-const structs
   x.pcs1.v = 1
   fails(function(x) x.pcs1.w = 1 end, x)
   fails(function(x) x.pcs1 = x.pcs2 end, x)
   fails(function(x) x.pcs1 = {} end, x)
+end
 
-  -- transparent structs
+do --- transparent structs
   local y = x.ni
   fails(function(x) x.ni = 1 end, x)
+end
 
-  -- complex subtype is implicitly const and doesn't inherit const attribute
+do --- complex subtype is implicitly const and doesn't inherit const attribute
   x.cx = 1
   fails(function(x) x.ccx = 1 end, x)
   do
@@ -110,4 +116,3 @@ do --- misc
     x.ccp = ccxa
   end
 end
-
===================================================================

> >    local foo_t = ffi.typeof("foo_t")
> >    local x = foo_t()
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> > index 9a22104a..0a72daed 100644
> > --- a/test/LuaJIT-tests/lib/ffi/index
> > +++ b/test/LuaJIT-tests/lib/ffi/index
> > @@ -6,6 +6,7 @@ ffi_arith_ptr.lua
> >  ffi_bitfield.lua
> >  ffi_call.lua
> >  ffi_callback.lua
> > +ffi_const.lua
> >  istype.lua
> >  jit_array.lua
> >  jit_complex.lua
> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-02-01 14:32   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 12:10     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  6:52       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 12:10 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comments and force-pushed the branch.

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with a minor comment below
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patch changes the `dofile()` (which uses an unreliable relative
> > file path and mutates `_G` with global functions to be defined) to the
> > corresponding `require()`.  Also, it names the only one test as "misc"
> extra whitespace before "Also"

Fixed, thanks!

> > and includes the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---

The new commit message is the following:

| test: enable <ffi_const.lua> in LuaJIT-tests
|
| This patch changes the `dofile()` (which uses an unreliable relative
| file path and mutates `_G` with global functions to be defined) to the
| corresponding `require()`. Also, it splits the test case into several
| and includes the test in <index>.
|
| Part of tarantool/tarantool#9398

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 13:11     ` Sergey Kaplun via Tarantool-patches
  2024-02-06 14:03       ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:11 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comments and force-pushed the branch.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:09PM +0300, Sergey Kaplun wrote:
> > This patch changes `dofile()` (which uses an unreliable relative file
> > path and mutates `_G` with global functions to be defined) to the
> > corresponding require and renames the C library in the `require()` call.
> > It adds groups with the names of subtests and enables the test in
> > <index>. It renames structure and enum typedefs to avoid conflicts with
> > cdef in other tests. The GC threshold is increased since all tests run
> > in a single process, so the number of GC objects is greater.
> >
> > Part of tarantool/tarantool#9398
> > ---

The new commit message is the following:

| test: enable <ffi_convert.lua> in LuaJIT-tests
|
| This patch changes `dofile()` (which uses an unreliable relative file
| path and mutates `_G` with global functions to be defined) to the
| corresponding require and renames the C library in the `require()` call.
| It adds groups with the names of subtests and enables the test in
| <index>. It renames structure and enum typedefs to avoid conflicts with
| cdef in other tests. The GC threshold is increased since all tests run
| in a single process, so the number of GC objects is greater. Also, the
| one test case is splitted into several.
|
| Part of tarantool/tarantool#9398

> >  test/LuaJIT-tests/lib/ffi/ffi_convert.lua | 35 +++++++++++------------
> >  test/LuaJIT-tests/lib/ffi/index           |  1 +
> >  2 files changed, 18 insertions(+), 18 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> > index bd3fb1f9..284f2b53 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> > @@ -1,8 +1,7 @@
> >  local ffi = require("ffi")
> >
> > -local ctest = require("ctest")
> > -
> > -dofile("../common/ffi_util.inc")
> > +local ctest = require("libctest")
> > +local fails = require("common.fails")
> >
> >  local tonumber = tonumber
> >
> > @@ -32,15 +31,15 @@ typedef struct arrinc_t {
> >    int a[];
> >  } arrinc_t;
> >
> > -typedef enum uenum_t {
> > +typedef enum uenum_convert_t {
> >    UE0, UE71 = 71, UE72
> > -} uenum_t;
> > +} uenum_convert_t;
> `convert` acts as a namespace here, and those are usually used as a
> prefix. Here and below.

Renamed. See the iterative patch below.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
index 284f2b53..3d1b0064 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
@@ -31,15 +31,15 @@ typedef struct arrinc_t {
   int a[];
 } arrinc_t;
 
-typedef enum uenum_convert_t {
+typedef enum convert_uenum_t {
   UE0, UE71 = 71, UE72
-} uenum_convert_t;
+} convert_uenum_t;
 
 typedef enum ienum_convert_t {
   IE0, IEM12 = -12, IEM11
 } ienum_convert_t;
 
-typedef struct foo_convert_t {
+typedef struct convert_foo_t {
   bool b;
   int8_t i8;
   uint8_t u8;
@@ -78,9 +78,9 @@ typedef struct foo_convert_t {
   int si_guard;
   nest_t sn;
   uni_t ui;
-  uenum_convert_t ue;
+  convert_uenum_t ue;
   ienum_convert_t ie;
-} foo_convert_t;
+} convert_foo_t;
 
 char *strcpy(char *dest, const char *src);
 typedef struct FILE FILE;
@@ -89,10 +89,10 @@ int _fileno(FILE *stream);
 ]]
 
 do --- misc
-  local foo_convert_t = ffi.typeof("foo_convert_t")
-  local sz = ffi.sizeof(foo_convert_t)
-  local x = foo_convert_t()
-  local y = foo_convert_t()
+  local convert_foo_t = ffi.typeof("convert_foo_t")
+  local sz = ffi.sizeof(convert_foo_t)
+  local x = convert_foo_t()
+  local y = convert_foo_t()
   ffi.fill(x, sz, 0xff)
   ffi.fill(y, sz, 0xee)
 
===================================================================

> >
> > -typedef enum ienum_t {
> > +typedef enum ienum_convert_t {

<snipped>

> >
> > -do
> > -  local foo_t = ffi.typeof("foo_t")
> > -  local sz = ffi.sizeof(foo_t)
> > -  local x = foo_t()
> > -  local y = foo_t()
> > +do --- misc
> Is there any chance to split it up?

Splitted. See the iterative patch below.
Branch is force-pushed.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
index 3d1b0064..2d530f90 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
@@ -88,21 +88,23 @@ int fileno(FILE *stream);
 int _fileno(FILE *stream);
 ]]
 
-do --- misc
-  local convert_foo_t = ffi.typeof("convert_foo_t")
-  local sz = ffi.sizeof(convert_foo_t)
-  local x = convert_foo_t()
-  local y = convert_foo_t()
-  ffi.fill(x, sz, 0xff)
-  ffi.fill(y, sz, 0xee)
-
-  -- unknown member
+local convert_foo_t = ffi.typeof("convert_foo_t")
+local sz = ffi.sizeof(convert_foo_t)
+local x = convert_foo_t()
+local y = convert_foo_t()
+ffi.fill(x, sz, 0xff)
+ffi.fill(y, sz, 0xee)
+
+do --- unknown member
   fails(function(x) local a = x.bad end, x)
   fails(function(x) x.bad = 1 end, x)
-  -- too many initializers
+end
+
+do --- too many initializers, double
   fails(function(x) x.d = ffi.new("double", 1,2) end, x)
+end
 
-  -- conversions to bool
+do --- conversions to bool
   x.b = false
   assert(x.b == false)
   x.b = true
@@ -122,8 +124,9 @@ do --- misc
   assert(x.b == true)
   x.b = ffi.new("int32_t", 0)
   assert(x.b == false)
+end
 
-  -- conversions from bool
+do --- conversions from bool
   x.i32 = true
   assert(x.i32 == 1)
   x.i32 = false
@@ -136,13 +139,16 @@ do --- misc
   assert(x.d == 1)
   x.d = ffi.new("bool", false)
   assert(x.d == 0)
-  -- assignment of bool to other types is not allowed
+end
+
+do --- assignment of bool to other types is not allowed
   fails(function(x) x.cd = true end, x)
   fails(function(x) x.v4si = true end, x)
   fails(function(x) x.ai = true end, x)
   fails(function(x) x.s = true end, x)
+end
 
-  -- int to int conversions
+do --- int to int conversions
   x.i8 = 99
   assert(x.i8 == 99)
   x.i8 = -99
@@ -298,8 +304,9 @@ do --- misc
   assert(tonumber(x.u64) == 0xffeeddcc)
   x.u64 = ffi.new("int64_t", -0x7feeddcc*2^32)
   assert(tonumber(x.u64) == 2^64-0x7feeddcc*2^32)
+end
 
-  -- FP to int conversions, test for truncation
+do --- FP to int conversions, test for truncation
   x.i32 = 1.9
   assert(x.i32 == 1)
   x.i32 = 2.9
@@ -320,8 +327,9 @@ do --- misc
   assert(x.u32 == 1)
   x.u64 = 1.9
   assert(tonumber(x.u64) == 1)
+end
 
-  -- int to FP conversions (most tested above)
+do --- int to FP conversions (most tested above)
   x.f = ffi.new("int32_t", -17)
   assert(x.f == -17)
   x.d = ffi.new("int32_t", -17)
@@ -334,16 +342,20 @@ do --- misc
   x.d = ffi.new("union { uint32_t u32[2]; uint64_t u64; }",
 		{{ 0x77777777, 0x77777777}}).u64
   assert(x.d == 0x77777777*2^32 + 0x77777800)
+end
 
-  -- complex initialization
+do --- complex initialization
   x.cd = ffi.new("complex", 9.125, -78.5)
   assert(x.cd.re == 9.125 and x.cd.im == -78.5)
   x.cd = ffi.new("complex", {9.125, -78.5})
   assert(x.cd.re == 9.125 and x.cd.im == -78.5)
-  -- too many initializers
+end
+
+do --- too many initializers, complex
   fails(function(x) x.cd = ffi.new("complex", 1,2,3) end, x)
+end
 
-  -- conversions between FP and complex
+do --- conversions between FP and complex
   x.cf = -17.25
   assert(x.cf.re == -17.25 and x.cf.im == 0)
   x.cf = ffi.new("complex float", -57.5) -- missing initializer
@@ -371,25 +383,30 @@ do --- misc
   assert(x.d == 9.125)
   x.d = ffi.new("complex double", 9.125, -78.5)
   assert(x.d == 9.125)
+end
 
-  -- conversions between int and complex
+do --- conversions between int and complex
   x.cd = ffi.new("int32_t", -138)
   assert(x.cd.re == -138 and x.cd.im == 0)
   x.i32 = ffi.new("complex", 9.125, -78.5)
   assert(x.i32 == 9)
+end
 
-  -- vector initialization
+do --- vector initialization
   x.v4si = ffi.new("int __attribute__((mode(__V4SI__)))", 1, 2, 3, 4)
   assert(x.v4si[0] == 1 and x.v4si[1] == 2 and
 	 x.v4si[2] == 3 and x.v4si[3] == 4)
   x.v2df = ffi.new("double __attribute__((mode(__V2DF__)))", {3.5, -6.75})
   assert(x.v2df[0] == 3.5 and x.v2df[1] == -6.75)
-  -- too many initializers
+end
+
+do --- too many initializers, vector
   fails(function(x)
     x.v4si = ffi.new("int __attribute__((mode(__V4SI__)))", 1,2,3,4,5)
   end, x)
+end
 
-  -- conversions to vectors
+do --- conversions to vectors
   x.v4si = -17
   assert(x.v4si[0] == -17 and x.v4si[1] == -17 and
 	 x.v4si[2] == -17 and x.v4si[3] == -17)
@@ -400,14 +417,16 @@ do --- misc
   assert(x.v2df[0] == 12.5 and x.v2df[1] == 12.5)
   x.v2df = ffi.new("complex", 9.125, -78.5)
   assert(x.v2df[0] == 9.125 and x.v2df[1] == 9.125)
+end
 
-  -- assignment of same-sized but differently-typed vectors
+do --- assignment of same-sized but differently-typed vectors
   x.v16qi = 99
   x.v4si = 0x33333333
   x.v16qi = x.v4si
   assert(x.v16qi[0] == 0x33 and x.v16qi[15] == 0x33)
+end
 
-  -- string converted to enum
+do --- string converted to enum
   -- x.ue = -1 -- this is undefined on some architectures
   -- assert(x.ue == 0xffffffff)
   x.ue = "UE0"
@@ -420,58 +439,74 @@ do --- misc
   assert(x.ie == 0)
   x.ie = "IEM11"
   assert(x.ie == -11)
+end
 
+do --- self assignment is ok
   x.pi = x.pi
-  -- assignment to pointer with higher qualifiers is ok
+end
+
+do --- assignment to pointer with higher qualifiers is ok
   x.pci = x.pi
   x.pvi = x.pi
-  -- assignment to pointer with lower qualifiers is not ok
+end
+
+do --- assignment to pointer with lower qualifiers is not ok
   fails(function(x) x.pi = x.pci end, x)
   fails(function(x) x.pi = x.pvi end, x)
   fails(function(x) x.pci = x.pvi end, x)
   fails(function(x) x.pvi = x.pci end, x)
-  -- assignment of pointers with incompatible child types is not ok
+end
+
+do --- assignment of pointers with incompatible child types is not ok
   fails(function(x) x.ppi = x.ai end, x)
   fails(function(x) x.ppi = x.pi end, x)
   fails(function(x) x.ppv = x.ppi end, x)
-  -- qualifiers of child types must match, higher qualifiers not ok
+end
+
+do --- qualifiers of child types must match, higher qualifiers not ok
   fails(function(x) x.ppci = x.ppi end, x)
   fails(function(x) x.ppi = x.ppci end, x)
+end
 
-  -- pointer/int conversions are not allowed by default
+do --- pointer/int conversions are not allowed by default
   fails(function(x) x.pi = 1 end, x)
   fails(function(x) x.i32 = x.pi end, x)
   assert(tonumber(x.pi) == nil)
   assert(tonumber(x.ai) == nil)
   assert(tonumber(x.si) == nil)
+end
 
-  -- but pointer/int casts are allowed
+do --- pointer/int casts are allowed
   x.pi = ffi.cast("int *", ffi.new("int32_t", 0x12345678))
   x.i32 = ffi.cast("int32_t", x.pi)
   assert(x.i32 == 0x12345678)
   x.pi = ffi.cast("int *", 1234560.3)
   x.i32 = ffi.cast("int32_t", x.pi)
   assert(x.i32 == 1234560)
-  -- bad cast from non-TValue double to pointer
+end
+
+do --- bad cast from non-TValue double to pointer
   fails(function(x)
     ffi.cast("int *", ffi.new("double", 1.5))
   end, x)
+end
 
-  -- nil sets a pointer to NULL
+do --- nil sets a pointer to NULL
   x.pi = nil
   assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 0)
+end
 
-  -- userdata and lightuserdata are treated as void *
-  do
-    local u = newproxy()
-    local uaddr = _G.tonumber(string.match(tostring(u), "(0x.*)"))
-    x.pi = u
-    assert(tonumber(ffi.cast("uintptr_t", x.pi)) == uaddr)
-    x.pi = ctest.lightud(12345678)
-    assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 12345678)
-  end
 
-  -- io.* file converts to file handle (as a void *)
+do --- userdata and lightuserdata are treated as void *
+  local u = newproxy()
+  local uaddr = _G.tonumber(string.match(tostring(u), "(0x.*)"))
+  x.pi = u
+  assert(tonumber(ffi.cast("uintptr_t", x.pi)) == uaddr)
+  x.pi = ctest.lightud(12345678)
+  assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 12345678)
+end
+
+do --- io.* file converts to file handle (as a void *)
   if ffi.abi("win") then
     assert(ffi.C._fileno(io.stdout) == 1)
     assert(ffi.C._fileno(io.stderr) == 2)
@@ -485,44 +520,47 @@ do --- misc
     for i=1,100 do x = ffi.C.fileno(io.stderr) end
     assert(x == 2)
   end
+end
 
-  -- truncation/extension of __ptr32
-  if ffi.abi("64bit") then
-    x.pi = ffi.cast("int *", 15*2^32+0x12345678)
-    assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 15*2^32+0x12345678)
-    x.p32i = x.pi
-    assert(tonumber(ffi.cast("uintptr_t", x.p32i)) == 0x12345678)
-    x.pi = ffi.cast("int *", 0x1234*2^32+0x56780000)
-    x.pi = x.p32i
-    assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 0x12345678)
-  end
+do --- truncation/extension of __ptr32 +abi64
+  x.pi = ffi.cast("int *", 15*2^32+0x12345678)
+  assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 15*2^32+0x12345678)
+  x.p32i = x.pi
+  assert(tonumber(ffi.cast("uintptr_t", x.p32i)) == 0x12345678)
+  x.pi = ffi.cast("int *", 0x1234*2^32+0x56780000)
+  x.pi = x.p32i
+  assert(tonumber(ffi.cast("uintptr_t", x.pi)) == 0x12345678)
+end
 
-  -- reference initialization
-  do
-    x.ai[0] = 712
-    local ri = ffi.new("int &", x.ai)
-    assert(tonumber(ri) == 712)
-    local ra = ffi.new("int (&)[10]", ffi.cast("int (*)[10]", x.ai))
-    assert(ra[0] == 712)
-  end
+do --- reference initialization
+  x.ai[0] = 712
+  local ri = ffi.new("int &", x.ai)
+  assert(tonumber(ri) == 712)
+  local ra = ffi.new("int (&)[10]", ffi.cast("int (*)[10]", x.ai))
+  assert(ra[0] == 712)
+end
 
-  -- ffi.sizeof follows references
+do --- ffi.sizeof follows references
   assert(ffi.sizeof(x.ai) == 4*10)
   -- ffi.offsetof follows references
   assert(ffi.offsetof(x.s, "v") == 0)
   assert(ffi.offsetof(x.s, "w") == 4)
+end
 
-  -- ffi.fill writes the right amount
+do --- ffi.fill writes the right amount
   ffi.fill(x.ai2, ffi.sizeof(x.ai2), 0x72)
   ffi.fill(x.ai, ffi.sizeof(x.ai), 0x13)
   assert(x.ai[0] == 0x13131313)
   assert(x.ai[9] == 0x13131313)
   assert(x.ai2[0] == 0x72727272)
   assert(x.ai2[9] == 0x72727272)
+end
 
-  -- array cannot be assigned a pointer
+do --- array cannot be assigned a pointer
   fails(function(x) x.ai = x.pi end, x)
-  -- but pointer can be assigned the address of an array
+end
+
+do --- pointer can be assigned the address of an array
   x.pi = x.ai2
   assert(x.pi[0] == 0x72727272)
   assert(x.pi[9] == 0x72727272)
@@ -535,21 +573,28 @@ do --- misc
   -- reflected via pointer, too
   assert(x.pi[0] == 0x72727272)
   assert(x.pi[9] == 0x72727272)
-  -- mismatched type or size in array copy
+end
+
+do --- mismatched type or size in array copy
   fails(function(x) x.ai = x.ac end, x)
   fails(function(x) x.ai = ffi.new("int[20]") end, x)
   fails(function(x) x.ai = ffi.new("arrinc_t").a end, x)
   fails(function(x) ffi.new("arrinc_t").a = x.ai end, x)
+end
 
+do --- assignment follows references
   ffi.fill(x.s2, ffi.sizeof(x.s2), 0x59)
   x.s.v = 0x12345678
   x.s.w = 0x789abcde
   assert(x.s.v == 0x12345678)
   assert(x.s.w == 0x789abcde)
+end
 
-  -- struct cannot be assigned a pointer
+do --- struct cannot be assigned a pointer
   fails(function(x) x.s = x.ps end, x)
-  -- but pointer can be assigned the address of a struct
+end
+
+do --- pointer can be assigned the address of a struct
   x.ps = x.s
   assert(x.ps.v == 0x12345678)
   assert(x.ps.w == 0x789abcde)
@@ -562,12 +607,14 @@ do --- misc
   -- reflected via pointer, too
   assert(x.ps.v == 0x59595959)
   assert(x.ps.w == 0x59595959)
+end
 
-  -- structs must be identical, structural equivalence is not enough
+do --- structs must be identical, structural equivalence is not enough
   fails(function(x) x.ps = x.sx end, x)
   fails(function(x) x.s = x.sx end, x)
+end
 
-  -- string copy to arrays
+do --- string copy to arrays
   x.ac_guard = 99
   ffi.fill(x.ac, 10, 0x37)
   x.ac = "ABCD"
@@ -584,26 +631,31 @@ do --- misc
   x.ac = "ABCDEFGHIJKLM"
   assert(x.ac[8] == 65+8)
   assert(x.ac[9] == 65+9)
-  do -- copy to a[?]
-    local vx = ffi.new("struct { char ac[?]; }", 20)
-    ffi.fill(vx.ac, 20, 0x37)
-    vx.ac = "ABCDEFGHI"
-    assert(vx.ac[8] == 65+8)
-    assert(vx.ac[9] == 0)
-  end
-  do -- copy to a[0]
-    local vx = ffi.new("union { char ac[0]; char c[20]; }")
-    ffi.fill(vx.ac, 20, 0x37)
-    vx.ac = "ABCDEFGHI"
-    assert(vx.ac[8] == 65+8)
-    assert(vx.ac[9] == 0)
-  end
-  -- mismatched type or size in string copy
+end
+
+do --- copy to a[?]
+  local vx = ffi.new("struct { char ac[?]; }", 20)
+  ffi.fill(vx.ac, 20, 0x37)
+  vx.ac = "ABCDEFGHI"
+  assert(vx.ac[8] == 65+8)
+  assert(vx.ac[9] == 0)
+end
+
+do --- copy to a[0]
+  local vx = ffi.new("union { char ac[0]; char c[20]; }")
+  ffi.fill(vx.ac, 20, 0x37)
+  vx.ac = "ABCDEFGHI"
+  assert(vx.ac[8] == 65+8)
+  assert(vx.ac[9] == 0)
+end
+
+do --- mismatched type or size in string copy
   fails(function(x) x.i32 = "ABCD" end, x)
   fails(function(x) x.ai = "ABCD" end, x)
   assert(x.ac_guard == 99) -- Check guard
+end
 
-  -- array initialization
+do --- array initialization
   x.ai = ffi.new("int[10]") -- zero fill
   for i=0,9 do assert(x.ai[i] == 0) end
   x.ai = ffi.new("int[10]", -67) -- replicate first element
@@ -616,25 +668,28 @@ do --- misc
   for i=0,9 do assert(x.ai[i] == i+1) end
   x.ai = ffi.new("int[10]", {1,2,3,4,5,6,7,8,9,10})
   for i=0,9 do assert(x.ai[i] == i+1) end
-  -- VLA initialization
-  do
-    local v = ffi.new("int[?]", 4)
-    for i=0,3 do assert(v[i] == 0) end
-    local v = ffi.new("int[?]", 4, 833)
-    for i=0,3 do assert(v[i] == 833) end
-    local v = ffi.new("int[?]", 4, 12, -9)
-    assert(v[0] == 12 and v[1] == -9 and v[2] == 0 and v[3] == 0)
-    local v = ffi.new("int[?]", 4, 1,2,3,4)
-    assert(v[0] == 1 and v[1] == 2 and v[2] == 3 and v[3] == 4)
-  end
-  -- too many initializers
+end
+
+do --- VLA initialization
+  local v = ffi.new("int[?]", 4)
+  for i=0,3 do assert(v[i] == 0) end
+  local v = ffi.new("int[?]", 4, 833)
+  for i=0,3 do assert(v[i] == 833) end
+  local v = ffi.new("int[?]", 4, 12, -9)
+  assert(v[0] == 12 and v[1] == -9 and v[2] == 0 and v[3] == 0)
+  local v = ffi.new("int[?]", 4, 1,2,3,4)
+  assert(v[0] == 1 and v[1] == 2 and v[2] == 3 and v[3] == 4)
+end
+
+do --- too many initializers, array
   fails(function(x) x.ai = {1,2,3,4,5,6,7,8,9,10,11} end, x)
   for i=0,9 do assert(x.ai[i] == i+1) end -- but it's partially executed
   fails(function(x)
     local v = ffi.new("int[?]", 4, 1,2,3,4,5)
   end, x)
+end
 
-  -- struct initialization
+do --- struct initialization
   x.sn = ffi.new("nest_t") -- zero fill
   assert(x.sn.e.e2 == 0)
   x.sn = ffi.new("nest_t", 1,2) -- remainder filled with zero
@@ -649,27 +704,32 @@ do --- misc
   assert(x.sn.a == 1 and x.sn.b == 2 and x.sn.c == 3 and x.sn.d == 4)
   assert(x.sn.e.e1 == 5 and x.sn.e.e2 == 6)
   assert(x.sn.f[0] == 7 and x.sn.f[1] == 8)
-  -- VLS initialization
-  do
-    local v = ffi.new("struct { int x; int a[?]; }", 4)
-    assert(v.x == 0)
-    for i=0,3 do assert(v.a[i] == 0) end
-    local v = ffi.new("struct { int x; int a[?]; }", 4, 9, {833})
-    assert(v.x == 9)
-    -- NYI: fill up VLA in VLS. currently seen as indefinite length
-    -- for i=0,3 do assert(v.a[i] == 833) end
-    assert(v.a[0] == 833 and v.a[1] == 0 and v.a[2] == 0 and v.a[3] == 0)
-  end
-  -- no multi-value init beyond first level
+end
+
+do --- VLS initialization
+  local v = ffi.new("struct { int x; int a[?]; }", 4)
+  assert(v.x == 0)
+  for i=0,3 do assert(v.a[i] == 0) end
+  local v = ffi.new("struct { int x; int a[?]; }", 4, 9, {833})
+  assert(v.x == 9)
+  -- NYI: fill up VLA in VLS. currently seen as indefinite length
+  -- for i=0,3 do assert(v.a[i] == 833) end
+  assert(v.a[0] == 833 and v.a[1] == 0 and v.a[2] == 0 and v.a[3] == 0)
+end
+
+do --- no multi-value init beyond first level
   fails(function(x)
     x.sn = ffi.new("nest_t", 1,2,3,4,5,6,7,8)
   end, x)
-  -- too many initializers
+end
+
+do --- too many initializers, nested structure
   fails(function(x)
     x.sn = ffi.new("nest_t", 1,2,3,4,{5,6},{7,8}, 9)
   end, x)
+end
 
-  -- union initialization
+do --- union initialization
   x.ui = ffi.new("uni_t") -- zero fill
   assert(x.ui.a == 0 and x.ui.b == 0 and x.ui.c == 0)
   x.ui = ffi.new("uni_t", 255) -- initialize first field, remainder is zero
@@ -678,15 +738,18 @@ do --- misc
   else
     assert(x.ui.a == -1 and x.ui.b == -256 and x.ui.c == -16777216)
   end
-  -- too many initializers
+end
+
+do --- too many initializers, union
   fails(function(x)
     x.sn = ffi.new("uni_t", 1,2)
   end, x)
   fails(function()
     ffi.new("union { struct { int x; }; int y; }", 1,2)
   end)
+end
 
-  -- table converted to array
+do --- table converted to array
   ffi.fill(x.ai, ffi.sizeof(x.ai), 0x13)
   x.ai_guard = 99
   x.ai = {} -- zero fill
@@ -700,8 +763,9 @@ do --- misc
   assert(x.ai[1] == -27)
   for i=2,9 do assert(x.ai[i] == 0) end
   assert(x.ai_guard == 99) -- Check guard
+end
 
-  -- table converted to struct
+do --- table converted to struct
   ffi.fill(x.si, ffi.sizeof(x.si), 0x74)
   x.si_guard = 97
   -- convert from array part
@@ -723,8 +787,9 @@ do --- misc
   x.si = {b = 12, 5, 6, 7} -- hash part ignored if array part exists
   assert(x.si.a == 5 and x.si.b == 6 and x.si.c == 7)
   assert(x.si_guard == 97) -- Check guard
+end
 
-  -- table converted to struct with transparent/nested structs and arrays
+do --- table converted to struct with transparent/nested structs and arrays
   ffi.fill(x.sn, ffi.sizeof(x.sn), 0x74)
   x.sn = {} -- zero fill
   assert(x.sn.e.e2 == 0)
@@ -736,8 +801,9 @@ do --- misc
   assert(x.sn.a == 0 and x.sn.b == 0 and x.sn.c == 10 and x.sn.d == 0)
   assert(x.sn.e.e1 == 11 and x.sn.e.e2 == 12)
   assert(x.sn.f[0] == 13 and x.sn.f[1] == 14)
+end
 
-  -- table converted to union
+do --- table converted to union
   ffi.fill(x.ui, ffi.sizeof(x.ui), 0x58)
   x.ui = {} -- zero fill
   assert(x.ui.a == 0 and x.ui.b == 0 and x.ui.c == 0)
@@ -753,18 +819,18 @@ do --- misc
   else
     assert(x.ui.a == -1 and x.ui.b == -1 and x.ui.c == -65536)
   end
+end
 
-  -- copy constructor
-  do
-    x.s.v = 1; x.s.w = 2
-    local s = ffi.new("bar_t", x.s)
-    assert(s.v == 1 and s.w == 2)
-    for i=0,9 do x.ai[i] = i end
-    local a = ffi.new("int[10]", x.ai)
-    for i=0,9 do assert(a[i] == i) end
-  end
+do --- copy constructor
+  x.s.v = 1; x.s.w = 2
+  local s = ffi.new("bar_t", x.s)
+  assert(s.v == 1 and s.w == 2)
+  for i=0,9 do x.ai[i] = i end
+  local a = ffi.new("int[10]", x.ai)
+  for i=0,9 do assert(a[i] == i) end
+end
 
-  -- assignment to function pointer
+do --- assignment to function pointer
   x.ppf = ffi.C.strcpy
 end
 
===================================================================

> > +  local foo_convert_t = ffi.typeof("foo_convert_t")
> > +  local sz = ffi.sizeof(foo_convert_t)
> > +  local x = foo_convert_t()
> > +  local y = foo_convert_t()
> >    ffi.fill(x, sz, 0xff)
> >    ffi.fill(y, sz, 0xee)
> >
> > @@ -769,7 +768,7 @@ do
> >    x.ppf = ffi.C.strcpy
> >  end
> >
> > -do
> > +do --- GC cdata __index
> >    collectgarbage()
> >    local oc = collectgarbage("count")
> >    local cd = ffi.new"struct { struct { int a; } x;}"
> > @@ -780,7 +779,7 @@ do
> >    for i=1,2 do
> >      f(cd)
> >      local nc = collectgarbage("count")
> > -    assert(nc < oc + 200, "GC step missing for cdata __index")
> Are you sure it is the lower bound threshold?

For big platforms, yes. But more importantly, this is a relative
threshold, so it is unreliable from platform memory usage.

> > +    assert(nc < oc * 3, "GC step missing for cdata __index")

<snipped>

> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-02-01 16:06   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 13:13     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:13 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment and force-pushed the branch.

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM after renaming test

I've prefered to split the test into several.
See here [1].

[1]: https://lists.tarantool.org/tarantool-patches/c3645f13-b8d9-44c2-88af-4ff9565d1a13@tarantool.org/T/#me92605dd888b6473372d3cb34c149ff48c789e4c

> 
> On 1/29/24 13:45, Sergey Kaplun wrote:

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>
  2024-01-31 15:07   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 13:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:23 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the revew.
Fixed your comment see the iterative patch below.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for the single nit below.
> 
> On Mon, Jan 29, 2024 at 01:45:11PM +0300, Sergey Kaplun wrote:
> > This patch declares functions as local to avoid pollution of the global
> > environment. It separates the body of the test in the `do` `while` block
> > and includes the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---
> >  .../lib/ffi/ffi_gcstep_recursive.lua          | 27 ++++++++++---------
> >  test/LuaJIT-tests/lib/ffi/index               |  1 +
> >  2 files changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> > index cb19df11..f6e0b009 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
> > @@ -1,6 +1,6 @@
> >  -- From Robert G. Jakabosky, 2012-03-20
> >
> > -local N=tonumber(arg[1] or 10000)
> > +local N= 10000
> Something wrong with formatting here.

Fixed.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
index f6e0b009..3029defd 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
@@ -1,6 +1,6 @@
 -- From Robert G. Jakabosky, 2012-03-20
 
-local N= 10000
+local N = 10000
 
 local ffi=require"ffi"

===================================================================

> 
> <snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  2024-01-31 15:15   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 13:29     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:59       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:29 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment below.

On 31.01.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for the single minor comment below.
> On Mon, Jan 29, 2024 at 01:45:12PM +0300, Sergey Kaplun wrote:
> > This patch names all subtests and includes the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---

<snipped>

> >
> > --- ra_destpair
> > -do
> > +
> > +do --- ra_destpair
> Does `ra` means `register allocator`?

Yes, renamed the test case as the following.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
index efe83cfd..2c866b87 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua
@@ -143,7 +143,7 @@ do --- char and 0LL base comparisons
 end
 
 
-do --- ra_destpair
+do --- destination register pair (ra_destpair)
   local x, y = 0, 0
   for i=1,100 do
     x = x + i/3LL
===================================================================

> >    local x, y = 0, 0

<snipped>

> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  2024-02-05 12:51   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 13:33     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  6:53       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:33 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment below.

On 05.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch. LGTM with a minor comment
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:

<snipped>

> > +do --- ligud to pointer
> typo: ligud -> lightud

Fixed as the following (since the test name should be verbose):

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
index 0e64fe75..9edf67de 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
@@ -259,7 +259,7 @@ do --- int16_t array arithmetic
   assert(a[99] == 100)
 end
 
-do --- ligud to pointer
+do --- lightuserdata to pointer
   local ud = ctest.lightud(12345678)
   local s = ffi.new("struct { void *p; }")
   for i=1,100 do
===================================================================

> <snipped>


-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> in LuaJIT-tests
  2024-02-01  8:38   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 13:39     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:03       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:39 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider two comments below.

Renamed the test cases as the following:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
index ca6c65c5..87ec2722 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
@@ -14,7 +14,7 @@ local function checklex(t)
   end
 end
 
-do --- checklex
+do --- correct 64-bit integers and complex numbers parsing
   checklex{
     "0LL",                      "0ll",
     "0LL",                      "0LL",
@@ -39,7 +39,7 @@ do --- checklex
   }
 end
 
-do --- checkfail
+do --- incorrect format for 64-bit integers and complex numbers
   checkfail({
     "0l",
     "0lll",
===================================================================

> 
> On Mon, Jan 29, 2024 at 01:45:15PM +0300, Sergey Kaplun wrote:
> > This patch changes the `dofile()` (which uses an unreliable relative
> > file path and mutates `_G` with global functions to be defined) to the
> > corresponding `require()`. Also, it adds groups with the names of
> > subtests and enables the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---
> >  test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua | 72 +++++++++++---------
> >  test/LuaJIT-tests/lib/ffi/index              |  1 +
> >  2 files changed, 39 insertions(+), 34 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> > index e26650ef..ca6c65c5 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua
> > @@ -1,6 +1,6 @@
> >  local ffi = require("ffi")
> >
> > -dofile("../common/ffi_util.inc")
> > +local checkfail = require("common.ffi.checkfail")
> >
> >  local function checklex(t)
> >    for i=1,1e9,2 do
> > @@ -14,38 +14,42 @@ local function checklex(t)
> >    end
> >  end
> >
> > -checklex{
> > -  "0LL",			"0ll",
> > -  "0LL",			"0LL",
> > -  "0ULL",			"0ull",
> > -  "0ULL",			"0ULl",
> > -  "18446744073709551615ULL",	"18446744073709551615llu",
> > -  "9223372036854775807LL",	"0x7fffffffffffffffll",
> > -  "9223372036854775808ULL",	"0x8000000000000000ull",
> > -  "1311768467463790320LL",	"0x123456789abcdef0ll",
> > -  "-1LL",			"-1ll",
> > -  "18446744073709551615ULL",	"-1ull",
> > -  "-9223372036854775807LL",	"-0x7fffffffffffffffll",
> > -  "9223372036854775808ULL",	"-0x8000000000000000ull",
> > -  "0+0i",			"0i",
> > -  "0+0i",			"0I",
> > -  "0+12.5i",			"12.5i",
> > -  "0+4660i",			"0x1234i",
> > -  "0+infI",			"1e400i",
> > -  "0-infI",			"-1e400i",
> > -  "0-12.5i",			"-12.5i",
> > -  "0-0i",			"-0i",
> > -}
> > +do --- checklex
> Maybe we can come up with a more elaborate name?
> > +  checklex{
> > +    "0LL",			"0ll",
> > +    "0LL",			"0LL",
> > +    "0ULL",			"0ull",
> > +    "0ULL",			"0ULl",
> > +    "18446744073709551615ULL",	"18446744073709551615llu",
> > +    "9223372036854775807LL",	"0x7fffffffffffffffll",
> > +    "9223372036854775808ULL",	"0x8000000000000000ull",
> > +    "1311768467463790320LL",	"0x123456789abcdef0ll",
> > +    "-1LL",			"-1ll",
> > +    "18446744073709551615ULL",	"-1ull",
> > +    "-9223372036854775807LL",	"-0x7fffffffffffffffll",
> > +    "9223372036854775808ULL",	"-0x8000000000000000ull",
> > +    "0+0i",			"0i",
> > +    "0+0i",			"0I",
> > +    "0+12.5i",			"12.5i",
> > +    "0+4660i",			"0x1234i",
> > +    "0+infI",			"1e400i",
> > +    "0-infI",			"-1e400i",
> > +    "0-12.5i",			"-12.5i",
> > +    "0-0i",			"-0i",
> > +  }
> > +end
> >
> > -checkfail({
> > -  "0l",
> > -  "0lll",
> > -  "0u",
> > -  "0ul",
> > -  "0ulll",
> > -  "0wll",
> > -  "0xll",
> > -  ".0ll",
> > -  "0ii",
> > -}, function(s) assert(loadstring("return "..s)) end)
> > +do --- checkfail
> Same here.
> > +  checkfail({
> > +    "0l",
> > +    "0lll",
> > +    "0u",
> > +    "0ul",
> > +    "0ulll",
> > +    "0wll",
> > +    "0xll",
> > +    ".0ll",
> > +    "0ii",
> > +  }, function(s) assert(loadstring("return "..s)) end)
> > +end
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> > index 71def57b..833c31e3 100644
> > --- a/test/LuaJIT-tests/lib/ffi/index
> > +++ b/test/LuaJIT-tests/lib/ffi/index
> > @@ -13,6 +13,7 @@ ffi_gcstep_recursive.lua
> >  ffi_jit_arith.lua
> >  ffi_jit_call.lua
> >  ffi_jit_conv.lua
> > +ffi_lex_number.lua
> >  istype.lua
> >  jit_array.lua
> >  jit_complex.lua
> > --
> > 2.43.0
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> in LuaJIT-tests
  2024-02-05 12:58   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 13:48     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  7:01       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:48 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment below.

On 05.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with a minor comment
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:

<snipped>

> > @@ -14,7 +14,7 @@ local function ptreq(a, b)
> >     return ffi.cast("void *", a) == ffi.cast("void *", b)
> >   end
> >   
> > -do
> > +do --- metatype index newindex
> 
> isn't better: "metatype with index and newindex metamethods" or smthing 
> like this?
> 
> This descriptions are for humans mostly and would be better to convert 
> these keywords to readable sentence.
> 
> same for test names below

Fixed. See the iterative patch below:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
index b0054b1a..3fea5341 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
@@ -14,7 +14,7 @@ local function ptreq(a, b)
   return ffi.cast("void *", a) == ffi.cast("void *", b)
 end
 
-do --- metatype index newindex
+do --- metatype with index and newindex metamethods
   local nidx = {}
   local tp = ffi.metatype("idx1_t", {
     __index = { foo = 99, method = function(c, v) return v end },
@@ -45,7 +45,7 @@ do --- metatype index newindex
   fails(function(cp) cp.bar = 42 end, cp)
 end
 
-do --- metatype index newindex with upvalues
+do --- index and newindex metamethods use upvalues
   local uc, uk, uv
   local tp = ffi.metatype("idx2_t", {
     __index = function(c, k, x, y)
@@ -78,7 +78,7 @@ do --- metatype index newindex with upvalues
   fails(function(p) p[0] = 11 end, p)
 end
 
-do --- metatype index newindex with upvalues via setmetatable
+do --- index and newindex metamethods as metaobjects use upvalues
   local uc, uk, uv
   local ti, tn = {}, {}
   local tp = ffi.metatype("idx3_t", {
===================================================================

> 

<snipped>

> >   jit_complex.lua

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-02-01  8:43   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 13:55     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:09       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
See the iterative patch below. Branch is force-pushed.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> On Mon, Jan 29, 2024 at 01:45:17PM +0300, Sergey Kaplun wrote:

<snipped>

> > +local fails = require("common.fails")
> >
> >  ffi.cdef([[
> > -typedef struct { int a,b,c; } foo1_t;
> > -typedef int foo2_t[?];
> > +typedef struct { int a,b,c; } foo1_new_t;
> > +typedef int foo2_new_t[?];
> `new` acts as a namespace here, which are conventionally go at the
> beginning. Here and below.

Renamed, see the iterative patch below.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
index e5b19053..17578995 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
@@ -4,30 +4,30 @@ local bit = require("bit")
 local fails = require("common.fails")
 
 ffi.cdef([[
-typedef struct { int a,b,c; } foo1_new_t;
-typedef int foo2_new_t[?];
+typedef struct { int a,b,c; } new_foo1_t;
+typedef int new_foo2_t[?];
 void *malloc(size_t size);
 void free(void *ptr);
 ]])
 
-do --- foo1_new_t
-  assert(ffi.sizeof("foo1_new_t") == 12)
-  local cd = ffi.new("foo1_new_t")
+do --- new_foo1_t
+  assert(ffi.sizeof("new_foo1_t") == 12)
+  local cd = ffi.new("new_foo1_t")
   assert(ffi.sizeof(cd) == 12)
-  local foo1_new_t = ffi.typeof("foo1_new_t")
-  assert(ffi.sizeof(foo1_new_t) == 12)
-  cd = foo1_new_t()
+  local new_foo1_t = ffi.typeof("new_foo1_t")
+  assert(ffi.sizeof(new_foo1_t) == 12)
+  cd = new_foo1_t()
   assert(ffi.sizeof(cd) == 12)
 end
 
-do --- foo2_new_t
-  assert(ffi.sizeof("foo2_new_t", 3) == 12)
-  local cd = ffi.new("foo2_new_t", 3)
+do --- new_foo2_t
+  assert(ffi.sizeof("new_foo2_t", 3) == 12)
+  local cd = ffi.new("new_foo2_t", 3)
   assert(ffi.sizeof(cd) == 12)
-  local foo2_new_t = ffi.typeof("foo2_new_t")
-  fails(ffi.sizeof, foo2_new_t)
-  assert(ffi.sizeof(foo2_new_t, 3) == 12)
-  cd = foo2_new_t(3)
+  local new_foo2_t = ffi.typeof("new_foo2_t")
+  fails(ffi.sizeof, new_foo2_t)
+  assert(ffi.sizeof(new_foo2_t, 3) == 12)
+  cd = new_foo2_t(3)
   assert(ffi.sizeof(cd) == 12)
 end
 
===================================================================

> >  void *malloc(size_t size);
> >  void free(void *ptr);
> >  ]])
> >

<snipped>

> >
> > -do
> > +do --- aligned structure GC
> >    local oc = collectgarbage("count")
> >    for al=0,15 do
> >      local align = 2^al -- 1, 2, 4, ..., 32768
> > @@ -54,17 +54,17 @@ do
> >      end
> >    end
> >    local nc = collectgarbage("count")
> > -  assert(nc < oc + 3000, "GC step missing for ffi.new")
> > +  assert(nc < oc * 10, "GC step missing for ffi.new")
> Are you sure that this is the lower bound of the GC threshold?

For big platforms, yes. But more importantly, this is a relative
threshold, so it is unreliable from platform memory usage.

> >  end

<snipped>

> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-02-05 13:03   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 13:58     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  7:51       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 13:58 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comments below.

On 05.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with minor comments
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:

<snipped>

> > -do
> > -  assert(ffi.sizeof("foo1_t") == 12)
> > -  local cd = ffi.new("foo1_t")
> > +do --- foo1_new_t
> 
> test desc says nothing about what test tests.
> 
> I would rename to something like "ffi.sizeof with custom struct"

Renamed as the following:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
index 17578995..ec18e324 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
@@ -10,7 +10,7 @@ void *malloc(size_t size);
 void free(void *ptr);
 ]])
 
-do --- new_foo1_t
+do --- ffi.sizeof with custom struct new_foo1_t
   assert(ffi.sizeof("new_foo1_t") == 12)
   local cd = ffi.new("new_foo1_t")
   assert(ffi.sizeof(cd) == 12)
@@ -20,7 +20,7 @@ do --- new_foo1_t
   assert(ffi.sizeof(cd) == 12)
 end
 
-do --- new_foo2_t
+do --- ffi.sizeof with custom struct new_foo2_t
   assert(ffi.sizeof("new_foo2_t", 3) == 12)
   local cd = ffi.new("new_foo2_t", 3)
   assert(ffi.sizeof(cd) == 12)
@@ -57,14 +57,14 @@ do --- aligned structure GC
   assert(nc < oc * 10, "GC step missing for ffi.new")
 end
 
-do --- VLA
+do --- VLA initialization
   local t = {}
   for i=1,100 do t[i] = ffi.new("int[?]", i) end
   assert(ffi.sizeof(t[100]) == 400)
   for i=0,99 do assert(t[100][i] == 0) end
 end
 
-do --- VLS
+do --- VLS initialization
   local t = {}
   local ct = ffi.typeof("struct { double x; int y[?];}")
   for i=1,100 do t[i] = ct(i) end
===================================================================

> 
> same below
> 
> > +  assert(ffi.sizeof("foo1_new_t") == 12)

<snipped>

> >   jit_complex.lua

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-02-06 13:11     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-06 14:03       ` Sergey Kaplun via Tarantool-patches
  2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:03 UTC (permalink / raw)
  To: Maxim Kokryashkin, tarantool-patches

Sorry, some fixups:).

On 06.02.24, Sergey Kaplun via Tarantool-patches wrote:

<snipped>

> > > -typedef enum uenum_t {
> > > +typedef enum uenum_convert_t {
> > >    UE0, UE71 = 71, UE72
> > > -} uenum_t;
> > > +} uenum_convert_t;
> > `convert` acts as a namespace here, and those are usually used as a
> > prefix. Here and below.
> 
> Renamed. See the iterative patch below.
> 
> ===================================================================
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> index 284f2b53..3d1b0064 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
> @@ -31,15 +31,15 @@ typedef struct arrinc_t {
>    int a[];
>  } arrinc_t;
>  
> -typedef enum uenum_convert_t {
> +typedef enum convert_uenum_t {
>    UE0, UE71 = 71, UE72
> -} uenum_convert_t;
> +} convert_uenum_t;
>  
>  typedef enum ienum_convert_t {
>    IE0, IEM12 = -12, IEM11
>  } ienum_convert_t;
>  
> -typedef struct foo_convert_t {
> +typedef struct convert_foo_t {
>    bool b;
>    int8_t i8;
>    uint8_t u8;
> @@ -78,9 +78,9 @@ typedef struct foo_convert_t {
>    int si_guard;
>    nest_t sn;
>    uni_t ui;
> -  uenum_convert_t ue;
> +  convert_uenum_t ue;
>    ienum_convert_t ie;
> -} foo_convert_t;
> +} convert_foo_t;
>  
>  char *strcpy(char *dest, const char *src);
>  typedef struct FILE FILE;
> @@ -89,10 +89,10 @@ int _fileno(FILE *stream);
>  ]]
>  
>  do --- misc
> -  local foo_convert_t = ffi.typeof("foo_convert_t")
> -  local sz = ffi.sizeof(foo_convert_t)
> -  local x = foo_convert_t()
> -  local y = foo_convert_t()
> +  local convert_foo_t = ffi.typeof("convert_foo_t")
> +  local sz = ffi.sizeof(convert_foo_t)
> +  local x = convert_foo_t()
> +  local y = convert_foo_t()
>    ffi.fill(x, sz, 0xff)
>    ffi.fill(y, sz, 0xee)
>  
> ===================================================================

`ienum_convert_t` is renamed too.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
index 2d530f90..e577001e 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_convert.lua
@@ -35,9 +35,9 @@ typedef enum convert_uenum_t {
   UE0, UE71 = 71, UE72
 } convert_uenum_t;
 
-typedef enum ienum_convert_t {
+typedef enum convert_ienum_t {
   IE0, IEM12 = -12, IEM11
-} ienum_convert_t;
+} convert_ienum_t;
 
 typedef struct convert_foo_t {
   bool b;
@@ -79,7 +79,7 @@ typedef struct convert_foo_t {
   nest_t sn;
   uni_t ui;
   convert_uenum_t ue;
-  ienum_convert_t ie;
+  convert_ienum_t ie;
 } convert_foo_t;
 
 char *strcpy(char *dest, const char *src);
===================================================================

<snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-02-01  9:01   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:11     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:11       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:11 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Renamed test cases as you suggested:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
index d3b02759..ce82f5da 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
@@ -4,7 +4,7 @@ local checkfail = require("common.ffi.checkfail")
 local checktypes = require("common.ffi.checktypes")
 local fails = require("common.fails")
 
-do --- checkfail
+do --- incorrect declarations
   checkfail{
     "int [",
     "int [-1]",
@@ -33,8 +33,7 @@ do --- sizeof of arrays
   assert(ffi.sizeof("foo2_array_t") == 200)
 end
 
-
-do --- checktypes
+do --- array declarations, sizeof() and alignof()
   local P = ffi.sizeof("void *")
   checktypes{
     10, 1,      "char [10]",
@@ -60,7 +59,7 @@ do --- checktypes
   }
 end
 
-do --- sizeof VLA
+do --- VLA sizeof
   assert(ffi.sizeof("int [?]", 10) == 4*10)
   local id = ffi.typeof("const short [?]")
   assert(ffi.sizeof(id, 10) == 2*10)
@@ -72,7 +71,7 @@ do --- sizeof VLA
   assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
 end
 
-do --- sizeof VLS
+do --- VLS sizeof
   assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
   local id = ffi.typeof("struct { int x; short a[?]; }")
   assert(ffi.sizeof(id, 10) == 4+2*10)
===================================================================

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> On Mon, Jan 29, 2024 at 01:45:18PM +0300, Sergey Kaplun wrote:

<snipped>

> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-02-05 13:08   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 14:12     ` Sergey Kaplun via Tarantool-patches
  2024-02-07  8:04       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:12 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment below.

On 05.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM wit a minor comment
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patch changes `dofile()` (which uses an unreliable relative file
> > path and mutates `_G` with global functions to be defined) to the
> > corresponding `require()` of the helper functions. It adds groups with
> > the names of subtests and enables the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---
> >   test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 ++++++++++--------
> >   test/LuaJIT-tests/lib/ffi/index               |   1 +
> >   2 files changed, 58 insertions(+), 49 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> > index 3a9616d7..d3b02759 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> > @@ -1,58 +1,66 @@
> >   local ffi = require("ffi")
> <snipped>
> >   
> > -do
> > +do --- sizeof VLA
> 
> it is inconsistent with test name at least in a previous patch.
> 
> Here: "sizeof VLA", in a previous patch "VLA".
> 
> Feel free to ignore.

Renamed as the following:

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
index d3b02759..ce82f5da 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
@@ -4,7 +4,7 @@ local checkfail = require("common.ffi.checkfail")
 local checktypes = require("common.ffi.checktypes")
 local fails = require("common.fails")
 
-do --- checkfail
+do --- incorrect declarations
   checkfail{
     "int [",
     "int [-1]",
@@ -33,8 +33,7 @@ do --- sizeof of arrays
   assert(ffi.sizeof("foo2_array_t") == 200)
 end
 
-
-do --- checktypes
+do --- array declarations, sizeof() and alignof()
   local P = ffi.sizeof("void *")
   checktypes{
     10, 1,      "char [10]",
@@ -60,7 +59,7 @@ do --- checktypes
   }
 end
 
-do --- sizeof VLA
+do --- VLA sizeof
   assert(ffi.sizeof("int [?]", 10) == 4*10)
   local id = ffi.typeof("const short [?]")
   assert(ffi.sizeof(id, 10) == 2*10)
@@ -72,7 +71,7 @@ do --- sizeof VLA
   assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
 end
 
-do --- sizeof VLS
+do --- VLS sizeof
   assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
   local id = ffi.typeof("struct { int x; short a[?]; }")
   assert(ffi.sizeof(id, 10) == 4+2*10)
===================================================================

> 

<snipped>

> >   jit_complex.lua

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  2024-02-01  9:03   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:15     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:15 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:19PM +0300, Sergey Kaplun wrote:

<snipped>

> > +do --- checkfail
> I would prefer a more elaborate name here.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
index 3b49648c..b072cefb 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua
@@ -3,7 +3,7 @@ local ffi = require("ffi")
 local checkfail = require("common.ffi.checkfail")
 local checktypes = require("common.ffi.checktypes")
 
-do --- checkfail
+do --- incorrect declarations
   checkfail{
     "",
     " ",
===================================================================

> > +  checkfail{

<snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  2024-02-01  9:05   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:21     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:21 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:20PM +0300, Sergey Kaplun wrote:

<snipped>

> > +do --- checkfail
> More elaborate name would be nice.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
index cc123808..c095ff46 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua
@@ -3,7 +3,7 @@ local ffi = require("ffi")
 local checkfail = require("common.ffi.checkfail")
 local checktypes = require("common.ffi.checktypes")
 
-do --- checkfail
+do --- incorrect or unsupported declarations
   checkfail({
     "int",
     "int aa1; int aa2 ",
===================================================================

> > +  checkfail({
> > +    "int",
> > +    "int aa1; int aa2 ",
> > +    "static int x;",
> > +    "static const long long x = 1;", -- NYI
> > +    "static const double x = 1;",	   -- NYI
> > +    "static const bool x = 1;",	   -- NYI (intentional, need true/false)
> > +    "struct { static int x = 1; };",
> > +    ";;static int y"
> > +  }, ffi.cdef)
> > +end
> <snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-02-01  9:16   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:23     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:23 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comment below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:21PM +0300, Sergey Kaplun wrote:

<snipped>

> > +do --- checkfail
> A more elaborate name would be nice.

Fixed.

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
index cb231c33..60385810 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
@@ -7,7 +7,7 @@ local fails = require("common.fails")
 local P = ffi.sizeof("void *")
 local A = (ffi.arch == "x86" and not ffi.abi("win")) and 4 or 8
 
-do --- checkfail
+do --- incorrect declarations
   checkfail{
     "struct",
     "struct {",
===================================================================

> > +  checkfail{
> > +    "struct",
> > +    "struct {",
> > +    "struct xx xx {}",
> > +    "struct { int x  }",
> > +    "struct { int x,  }",
> > +    "struct { int x,y  }",
> > +    "struct { void x; }",
> <snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-02-05 13:14   ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 14:25     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:25 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!
Fixed your comment below.

On 05.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch! LGTM with a minor comment
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patch changes `dofile()` (which uses an unreliable relative file
> > path and mutates `_G` with global functions to be defined) to the
> > corresponding `require()` of the helper functions. It adds groups with
> > the names of subtests and enables the test in <index>.
> >
> > Part of tarantool/tarantool#9398
> > ---
> >   .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
> >   test/LuaJIT-tests/lib/ffi/index               |   1 +
> >   2 files changed, 176 insertions(+), 160 deletions(-)
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> > index 16a3d053..cb231c33 100644
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> > +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
> <snipped>
> >   
> > -do
> > +do --- pragma pack aligment
> typo: alignment

Fixed, thanks!

===================================================================
diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
index 60385810..17ed19fd 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_struct.lua
@@ -251,7 +251,7 @@ do --- pragma pack pop
   assert(ffi.sizeof("struct foo_packpop2") == 12)
 end
 
-do --- pragma pack aligment
+do --- pragma pack alignment
   ffi.cdef[[
     #pragma pack(2)
     struct foo_packalign8 {
===================================================================

> >     ffi.cdef[[
> >       #pragma pack(2)
> >       struct foo_packalign8 {
> > diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> > index 12b6387f..e3a34e30 100644
> > --- a/test/LuaJIT-tests/lib/ffi/index
> > +++ b/test/LuaJIT-tests/lib/ffi/index
> > @@ -19,6 +19,7 @@ ffi_new.lua
> >   ffi_parse_array.lua
> >   ffi_parse_basic.lua
> >   ffi_parse_cdef.lua
> > +ffi_parse_struct.lua
> >   istype.lua
> >   jit_array.lua
> >   jit_complex.lua

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test
  2024-02-01  9:19   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:37     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:37 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
Fixed your comments below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> Please consider my comments below.
> 
> On Mon, Jan 29, 2024 at 01:45:22PM +0300, Sergey Kaplun wrote:
> > This patch moves the <ffi_tabov.lua> test from the LuaJIT-tests suite to
> > the tarantool-tests suite, because this test should be run separately to
> > avoid overflow of the table with ctypes for other tests from
> > LuaJIT-tests suite.
> >
> > Part of tarantool/tarantool#9398
> > ---
> >  test/LuaJIT-tests/lib/ffi/ffi_tabov.lua | 12 -----------
> >  test/tarantool-tests/ffi-tabov.test.lua | 27 +++++++++++++++++++++++++
> >  2 files changed, 27 insertions(+), 12 deletions(-)
> >  delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> >  create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
> >
> > diff --git a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua b/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> > deleted file mode 100644
> > index ba621960..00000000
> > --- a/test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> > +++ /dev/null
> > @@ -1,12 +0,0 @@
> > -local ffi = require("ffi")
> > -
> > -local last = 0
> > -
> > -assert(pcall(function()
> > -  for i=1,65536 do
> > -    last = i
> > -    ffi.typeof"struct {}"
> > -  end
> > -end) == false)
> > -
> > -assert(last > 20000)
> > diff --git a/test/tarantool-tests/ffi-tabov.test.lua b/test/tarantool-tests/ffi-tabov.test.lua
> > new file mode 100644
> > index 00000000..7ea8b24b
> > --- /dev/null
> > +++ b/test/tarantool-tests/ffi-tabov.test.lua
> > @@ -0,0 +1,27 @@
> > +local tap = require('tap')
> > +local ffi = require('ffi')
> > +
> > +-- This test is moved here from the LuaJIT-tests suite since it
> > +-- should be run separately because it exhausts the ctype table.
> > +local test = tap.test('ffi-tabov')
> > +
> > +test:plan(3)
> > +
> > +-- XXX: Amount of ctypes available to the user of a platform.
> Where does this number comes from? Drop a comment.

As you can see it was declared in the suite. I suppose this number is
something empirical. So, I've mentioned that this was declared in the
previous suite.

> > +local MIN_AVAILABLE_CTYPES = 20000
> > +
> > +local last = 0
> > +
> > +local res, errmsg = pcall(function()
> > +  for i = 1, 2^16 do
> Drop a comment explaining the number of iterations.

Added, good suggestion! See the iterative patch below.

===================================================================
diff --git a/test/tarantool-tests/ffi-tabov.test.lua b/test/tarantool-tests/ffi-tabov.test.lua
index 7ea8b24b..7de7794d 100644
--- a/test/tarantool-tests/ffi-tabov.test.lua
+++ b/test/tarantool-tests/ffi-tabov.test.lua
@@ -8,12 +8,15 @@ local test = tap.test('ffi-tabov')
 test:plan(3)
 
 -- XXX: Amount of ctypes available to the user of a platform.
+-- Was declared in the LuaJIT-tests suite.
 local MIN_AVAILABLE_CTYPES = 20000
+-- Maximum available amount of ctypes.
+local CTID_MAX = 2^16
 
 local last = 0
 
 local res, errmsg = pcall(function()
-  for i = 1, 2^16 do
+  for i = 1, CTID_MAX do
     last = i
     ffi.typeof('struct {}')
   end
===================================================================

> > +    last = i

<snipped>

> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> LuaJIT test
  2024-02-01  9:23   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:43     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:14       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:43 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
See my answer below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, with a question below.
> On Mon, Jan 29, 2024 at 01:45:23PM +0300, Sergey Kaplun wrote:
> > This patch moves the <lightud.lua> test from the <misc> to <lang>
> What is the rationale for that?

I suppose that the `misc` name is some stash directory name for orphan
tests. This directory contains tests related to the JIT engine
(<jit_flush.lua>, <loop_unroll.lua>).
But tests like <stackov.lua>, <api_call.lua> or <lightud.lua> are
related to the language itself, so I suppose it will be better to move
them there.

> > directory, includes it in <index>, and names subtests. Also, it enables
> > tests for all arches and fixes tests for 47-bit lightuserdata because it
> > is available since the commit
> > 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64
> > bit lightuserdata.")
> <snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> LuaJIT test
  2024-02-01  9:25   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-06 14:44     ` Sergey Kaplun via Tarantool-patches
  2024-02-09 16:15       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 14:44 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!
Thanks for the review!
See my answer below.

On 01.02.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, with the same question about moving from <misc> to <lang>.

I suppose that the `misc` name is some stash directory name for orphan
tests. This directory contains tests related to the JIT engine
(<jit_flush.lua>, <loop_unroll.lua>).
But tests like <stackov.lua>, <api_call.lua> or <lightud.lua> are
related to the language itself, so I suppose it will be better to move
them there.

> On Mon, Jan 29, 2024 at 01:45:24PM +0300, Sergey Kaplun wrote:
> > This patch moves the <api_call.lua> test from the <misc> to <lang>
> > directory, includes it in <index>, and names subtests.
> >
> > Part of tarantool/tarantool#9398
> <snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-01 16:32 ` [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
@ 2024-02-06 17:03   ` Sergey Kaplun via Tarantool-patches
  2024-02-07  8:06     ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-06 17:03 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!

On 01.02.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> there is a problem with running under ASAN:
> 
> 
> cmake -S . -B build -DLUAJIT_USE_ASAN=ON
> 
> <snipped>
> 
> cmake --build build/ -t LuaJIT-tests
> 
> <snipped>
> 
> [100%] Linking C executable luajit
> [100%] Built target luajit_static
> Running LuaJIT-tests
> ==320737==ASan runtime does not come first in initial library list; you 
> should either link runtime to your application or manually preload it 
> with LD_PRELOAD.
> gmake[3]: *** 
> [test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/build.make:74: 
> LuaJIT-tests] Error 1
> gmake[2]: *** [CMakeFiles/Makefile2:1193: 
> test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/all] Error 2
> gmake[1]: *** [CMakeFiles/Makefile2:1200: 
> test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/rule] Error 2
> gmake: *** [Makefile:455: LuaJIT-tests] Error 2
> 
> cannot reproduce on tarantool/master

Good catch!
I've been tricked by the CMake again...

The new patch is the following:

===================================================================
diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index 96981e32..e91e3d4a 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -24,6 +24,39 @@ else()
   list(APPEND LUAJIT_TESTS_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
 endif()
 
+if(LUAJIT_USE_ASAN)
+  # When running LuaJIT-tests under ASAN, the internal ASAN check
+  # failed:
+  # AddressSanitizer: CHECK failed: asan_interceptors.cpp:356
+  # "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
+  # This is a workaround suggested at
+  # https://github.com/google/sanitizers/issues/934.
+  macro(LibRealPath output lib)
+    execute_process(
+      COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=${lib}
+      OUTPUT_VARIABLE LIB_LINK
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    # Fortunately, we are not interested in macOS here, so we can
+    # use realpath.
+    execute_process(
+      COMMAND realpath ${LIB_LINK}
+      OUTPUT_VARIABLE ${output}
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+  endmacro()
+  LibRealPath(LIB_STDCPP libstdc++.so)
+  # XXX: GCC requires both. Clang requires only libstdc++.
+  if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+    LibRealPath(LIB_ASAN libasan.so)
+    # XXX: Don't use " " (separator in LD_PRELOAD) in `list()`.
+    # ";" will expand to " " as we want.
+    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_ASAN};${LIB_STDCPP}")
+  else()
+    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_STDCPP}")
+  endif()
+endif()
+
 add_custom_command(TARGET LuaJIT-tests
   COMMENT "Running LuaJIT-tests"
   COMMAND
===================================================================

> 
> 
> On 1/29/24 13:45, Sergey Kaplun wrote:
> > This patchset enables most of the LuaJIT-tests related to FFI and
> > testing of C libraries (cpptest, ctest). More tests (from the <misc>
> > directory) will be enabled in the future series.
> >
> > FFI tests from the <unportable> directory aren't enabled because of their
> > inconsistency, see also [1].
> >
> > This increases coverage up to 92.5%, see here [2].
> >
> > Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-9398-more-luajit-tests
> > Tarantool PR: https://github.com/tarantool/tarantool/pull/9603
> > Related issues:
> > * https://github.com/tarantool/tarantool/issues/9398
> > * https://github.com/tarantool/tarantool/issues/7834
> >
> > [1]: https://github.com/LuaJIT/LuaJIT/pull/415
> > [2]: https://coveralls.io/github/tarantool/luajit?branch=skaplun/gh-9398-more-luajit-tests
> >
> > Changes in the v2:
> > * Introduce the AddTestLib macro to avoid copy-pasting. It only adds a
> >    target with necessary flags without setting any variables.
> > * <cpptest.cpp> is renamed to <libcpptest.cpp> for consistency with
> >    <libctest.c>
> > * Rename some tests with uninformative naming (like `call_10i` ->
> >    `10 int args`)
> > * Add adjusments of arguments for long calls (~10 arguments) to make them
> >    comparable without changing test semantics.
> > * Fix some typos
> >
> > Sergey Kaplun (26):
> >    cmake: introduce AddTestLib macro
> >    test: prepare lauxilarily libs for LuaJIT-tests
> >    test: separate LuaJIT helpers from ffi_util.inc
> >    test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
> >    test: enable <ffi_bitfield.lua> in LuaJIT-tests
> >    test: enable <ffi_call.lua> in LuaJIT-tests
> >    test: enable <ffi_callback.lua> in LuaJIT-tests
> >    test: enable <ffi_const.lua> in LuaJIT-tests
> >    test: enable <ffi_convert.lua> in LuaJIT-tests
> >    test: enable <ffi_enum.lua> in LuaJIT-tests
> >    test: enable <ffi_gcstep_recursive.lua>
> >    test: enable <ffi_jit_arith.lua> in LuaJIT-tests
> >    test: enable <ffi_jit_call.lua> in LuaJIT-tests
> >    test: enable <ffi_jit_conv.lua> in LuaJIT-tests
> >    test: enable <ffi_lex_number.lua> in LuaJIT-tests
> >    test: enable <ffi_metatype.lua> in LuaJIT-tests
> >    test: enable <ffi_new.lua> in LuaJIT-tests
> >    test: enable <ffi_parse_array.lua> in LuaJIT-tests
> >    test: enable <ffi_parse_basic.lua> in LuaJIT-tests
> >    test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
> >    test: enable <ffi_parse_struct.lua> LuaJIT test
> >    test: enable <ffi_tabov.lua> LuaJIT test
> >    test: enable <lightud.lua> LuaJIT test
> >    test: enable <api_call.lua> LuaJIT test
> >    test: enable <catch_wrap.lua> LuaJIT test
> >    test: enable <catch_cpp.lua> LuaJIT test
> >
> >   test/CMakeLists.txt                           |   3 +
> >   test/LuaJIT-tests/CMakeLists.txt              |  45 ++-
> >   test/LuaJIT-tests/common/fails.lua            |   3 +
> >   test/LuaJIT-tests/common/ffi/checkfail.lua    |  14 +
> >   test/LuaJIT-tests/common/ffi/checktypes.lua   |  15 +
> >   test/LuaJIT-tests/common/ffi_util.inc         |  23 --
> >   test/LuaJIT-tests/{misc => lang}/api_call.lua |  32 +-
> >   .../{sysdep => lang}/catch_cpp.lua            |  36 +-
> >   .../{misc => lang}/catch_wrap.lua             |  29 +-
> >   test/LuaJIT-tests/lang/index                  |   4 +
> >   test/LuaJIT-tests/lang/lightud.lua            |  89 +++++
> >   test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua   |  13 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua    |   4 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_call.lua        | 185 +++++-----
> >   test/LuaJIT-tests/lib/ffi/ffi_callback.lua    |  45 +--
> >   test/LuaJIT-tests/lib/ffi/ffi_const.lua       |   4 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_convert.lua     |  35 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_enum.lua        |  11 +-
> >   .../lib/ffi/ffi_gcstep_recursive.lua          |  27 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua   |  22 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua    |  70 ++--
> >   test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua    |  70 ++--
> >   test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua  |  72 ++--
> >   test/LuaJIT-tests/lib/ffi/ffi_metatype.lua    |  16 +-
> >   test/LuaJIT-tests/lib/ffi/ffi_new.lua         |  50 +--
> >   test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 +++---
> >   test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 ++++++-------
> >   test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua  | 141 ++++----
> >   .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
> >   test/LuaJIT-tests/lib/ffi/ffi_tabov.lua       |  12 -
> >   test/LuaJIT-tests/lib/ffi/index               |  18 +
> >   test/LuaJIT-tests/misc/lightud.lua            |  88 -----
> >   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 +-
> >   .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt |  25 +-
> >   test/cmake/AddTestLib.cmake                   |  28 ++
> >   test/tarantool-tests/CMakeLists.txt           |  27 +-
> >   test/tarantool-tests/ffi-tabov.test.lua       |  27 ++
> >   40 files changed, 1086 insertions(+), 921 deletions(-)
> >   create mode 100644 test/LuaJIT-tests/common/fails.lua
> >   create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
> >   create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
> >   rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)
> >   rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
> >   rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)
> >   create mode 100644 test/LuaJIT-tests/lang/lightud.lua
> >   delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
> >   delete mode 100644 test/LuaJIT-tests/misc/lightud.lua
> >   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%)
> >   create mode 100644 test/cmake/AddTestLib.cmake
> >   create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
> >

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-02-06 11:48     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  6:49       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  6:49 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches


On 2/6/24 14:48, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the patch!
> Fixed your comment.
>
> On 01.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM with a minor comment below
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
>>> This patch moves common helpers from <LuaJIT-tests/common/ffi_util.inc>
>>> into separate files by analogy with <common/expect_error.lua>. The
>>> `include()` helper isn't touched since it is used in system dependend
>> typo: dependent?
> Fixed, thanks!

Thanks!

<snipped>



^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-02-06 11:55     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  6:50 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches


On 2/6/24 14:55, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed the test and force-pushed the branch.
>
> On 01.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM after renaming testcase (I'm agree with Maxim).
>>
>> BTW don't forget to update commit description after renaming.
> Split the test into several.
> The new commit message is the following:
>
> | test: enable <ffi_bitfield.lua> in LuaJIT-tests
> |
> | This patch removes unused `dofile()`. Also, it splits the test case into
> | several and includes the test in <index>.
> |
> | Part of tarantool/tarantool#9398
>
Thanks!

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> in LuaJIT-tests
  2024-02-06 12:01     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  6:50 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey

thanks for fixes! LGTM as I said before.

On 2/6/24 15:01, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comment.
>
> On 01.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM with minor comment below
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
>>> This patch removes unused `dofile()`. Also, it uses the basename of the
>>> ctest library to be loaded via ffi. It adds groups with names of
>>> subtests and enables the test in <index>. Complex type is undefined on
>>> Windows, so the correponding tests are not enabled for this platform.
>>> Fastcalls are enabled only for the x86 architecture. Stdcalls are
>>> enabled only for Windows on x86. Tests with calls with 10 arguments with
>>> sizes less than 8 bits are dummy for M1. This suite lacks a mechanism to
>> too much "with" for my taste :) feel free to ignore
> Replaced the first "with" with:) containing. See the new commit message
> below:
>
> | test: enable <ffi_call.lua> in LuaJIT-tests
> |
> | This patch removes unused `dofile()`. Also, it uses the basename of the
> | ctest library to be loaded via ffi. It adds groups with names of
> | subtests and enables the test in <index>. Complex type is undefined on
> | Windows, so the correponding tests are not enabled for this platform.
> | Fastcalls are enabled only for the x86 architecture. Stdcalls are
> | enabled only for Windows on x86. Tests containing calls with 10
> | arguments with sizes less than 8 bits are dummy for M1. This suite lacks
> | a mechanism to skip subtests satisfying complicated conditions, so it is
> | done manually by the corresponding `if` check.
> |
> | Part of tarantool/tarantool#9398
>
>> Thanks for reformatting testcases, much more readable now.
> It's a pleasure :).
>
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-02-06 12:10     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  6:52       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  6:52 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey

thanks for fixes. LGTM

On 2/6/24 15:10, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comments and force-pushed the branch.
>
> On 01.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM with a minor comment below
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
>>> This patch changes the `dofile()` (which uses an unreliable relative
>>> file path and mutates `_G` with global functions to be defined) to the
>>> corresponding `require()`.  Also, it names the only one test as "misc"
>> extra whitespace before "Also"
> Fixed, thanks!
>
>>> and includes the test in <index>.
>>>
>>> Part of tarantool/tarantool#9398
>>> ---
> The new commit message is the following:
>
> | test: enable <ffi_const.lua> in LuaJIT-tests
> |
> | This patch changes the `dofile()` (which uses an unreliable relative
> | file path and mutates `_G` with global functions to be defined) to the
> | corresponding `require()`. Also, it splits the test case into several
> | and includes the test in <index>.
> |
> | Part of tarantool/tarantool#9398
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> in LuaJIT-tests
  2024-02-06 13:33     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  6:53       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  6:53 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey


thanks for the fix! LGTM

On 2/6/24 16:33, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comment below.
>
> On 05.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch. LGTM with a minor comment
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
> <snipped>
>
>>> +do --- ligud to pointer
>> typo: ligud -> lightud
> Fixed as the following (since the test name should be verbose):
>
> ===================================================================
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> index 0e64fe75..9edf67de 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua
> @@ -259,7 +259,7 @@ do --- int16_t array arithmetic
>     assert(a[99] == 100)
>   end
>   
> -do --- ligud to pointer
> +do --- lightuserdata to pointer
>     local ud = ctest.lightud(12345678)
>     local s = ffi.new("struct { void *p; }")
>     for i=1,100 do
> ===================================================================
>
>> <snipped>
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> in LuaJIT-tests
  2024-02-06 13:48     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  7:01       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  7:01 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey

thanks for the fix! LGTM

On 2/6/24 16:48, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comment below.
>
> On 05.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM with a minor comment
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
> <snipped>
>
>>> @@ -14,7 +14,7 @@ local function ptreq(a, b)
>>>      return ffi.cast("void *", a) == ffi.cast("void *", b)
>>>    end
>>>    
>>> -do
>>> +do --- metatype index newindex
>> isn't better: "metatype with index and newindex metamethods" or smthing
>> like this?
>>
>> This descriptions are for humans mostly and would be better to convert
>> these keywords to readable sentence.
>>
>> same for test names below
> Fixed. See the iterative patch below:
>
> ===================================================================
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> index b0054b1a..3fea5341 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_metatype.lua
> @@ -14,7 +14,7 @@ local function ptreq(a, b)
>     return ffi.cast("void *", a) == ffi.cast("void *", b)
>   end
>   
> -do --- metatype index newindex
> +do --- metatype with index and newindex metamethods
>     local nidx = {}
>     local tp = ffi.metatype("idx1_t", {
>       __index = { foo = 99, method = function(c, v) return v end },
> @@ -45,7 +45,7 @@ do --- metatype index newindex
>     fails(function(cp) cp.bar = 42 end, cp)
>   end
>   
> -do --- metatype index newindex with upvalues
> +do --- index and newindex metamethods use upvalues
>     local uc, uk, uv
>     local tp = ffi.metatype("idx2_t", {
>       __index = function(c, k, x, y)
> @@ -78,7 +78,7 @@ do --- metatype index newindex with upvalues
>     fails(function(p) p[0] = 11 end, p)
>   end
>   
> -do --- metatype index newindex with upvalues via setmetatable
> +do --- index and newindex metamethods as metaobjects use upvalues
>     local uc, uk, uv
>     local ti, tn = {}, {}
>     local tp = ffi.metatype("idx3_t", {
> ===================================================================
>
> <snipped>
>
>>>    jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-02-06 13:58     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  7:51       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  7:51 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!

much better now, thanks! LGTM

On 2/6/24 16:58, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comments below.
>
> On 05.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM with minor comments
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
> <snipped>
>
>>> -do
>>> -  assert(ffi.sizeof("foo1_t") == 12)
>>> -  local cd = ffi.new("foo1_t")
>>> +do --- foo1_new_t
>> test desc says nothing about what test tests.
>>
>> I would rename to something like "ffi.sizeof with custom struct"
> Renamed as the following:
>
> ===================================================================
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_new.lua b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> index 17578995..ec18e324 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_new.lua
> @@ -10,7 +10,7 @@ void *malloc(size_t size);
>   void free(void *ptr);
>   ]])
>   
> -do --- new_foo1_t
> +do --- ffi.sizeof with custom struct new_foo1_t
>     assert(ffi.sizeof("new_foo1_t") == 12)
>     local cd = ffi.new("new_foo1_t")
>     assert(ffi.sizeof(cd) == 12)
> @@ -20,7 +20,7 @@ do --- new_foo1_t
>     assert(ffi.sizeof(cd) == 12)
>   end
>   
> -do --- new_foo2_t
> +do --- ffi.sizeof with custom struct new_foo2_t
>     assert(ffi.sizeof("new_foo2_t", 3) == 12)
>     local cd = ffi.new("new_foo2_t", 3)
>     assert(ffi.sizeof(cd) == 12)
> @@ -57,14 +57,14 @@ do --- aligned structure GC
>     assert(nc < oc * 10, "GC step missing for ffi.new")
>   end
>   
> -do --- VLA
> +do --- VLA initialization
>     local t = {}
>     for i=1,100 do t[i] = ffi.new("int[?]", i) end
>     assert(ffi.sizeof(t[100]) == 400)
>     for i=0,99 do assert(t[100][i] == 0) end
>   end
>   
> -do --- VLS
> +do --- VLS initialization
>     local t = {}
>     local ct = ffi.typeof("struct { double x; int y[?];}")
>     for i=1,100 do t[i] = ct(i) end
> ===================================================================
>
>> same below
>>
>>> +  assert(ffi.sizeof("foo1_new_t") == 12)
> <snipped>
>
>>>    jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-02-06 14:12     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  8:04       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  8:04 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!

thanks! LGTM

On 2/6/24 17:12, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
> Fixed your comment below.
>
> On 05.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> thanks for the patch! LGTM wit a minor comment
>>
>> On 1/29/24 13:45, Sergey Kaplun wrote:
>>> This patch changes `dofile()` (which uses an unreliable relative file
>>> path and mutates `_G` with global functions to be defined) to the
>>> corresponding `require()` of the helper functions. It adds groups with
>>> the names of subtests and enables the test in <index>.
>>>
>>> Part of tarantool/tarantool#9398
>>> ---
>>>    test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 ++++++++++--------
>>>    test/LuaJIT-tests/lib/ffi/index               |   1 +
>>>    2 files changed, 58 insertions(+), 49 deletions(-)
>>>
>>> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
>>> index 3a9616d7..d3b02759 100644
>>> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
>>> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
>>> @@ -1,58 +1,66 @@
>>>    local ffi = require("ffi")
>> <snipped>
>>>    
>>> -do
>>> +do --- sizeof VLA
>> it is inconsistent with test name at least in a previous patch.
>>
>> Here: "sizeof VLA", in a previous patch "VLA".
>>
>> Feel free to ignore.
> Renamed as the following:
>
> ===================================================================
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> index d3b02759..ce82f5da 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua
> @@ -4,7 +4,7 @@ local checkfail = require("common.ffi.checkfail")
>   local checktypes = require("common.ffi.checktypes")
>   local fails = require("common.fails")
>   
> -do --- checkfail
> +do --- incorrect declarations
>     checkfail{
>       "int [",
>       "int [-1]",
> @@ -33,8 +33,7 @@ do --- sizeof of arrays
>     assert(ffi.sizeof("foo2_array_t") == 200)
>   end
>   
> -
> -do --- checktypes
> +do --- array declarations, sizeof() and alignof()
>     local P = ffi.sizeof("void *")
>     checktypes{
>       10, 1,      "char [10]",
> @@ -60,7 +59,7 @@ do --- checktypes
>     }
>   end
>   
> -do --- sizeof VLA
> +do --- VLA sizeof
>     assert(ffi.sizeof("int [?]", 10) == 4*10)
>     local id = ffi.typeof("const short [?]")
>     assert(ffi.sizeof(id, 10) == 2*10)
> @@ -72,7 +71,7 @@ do --- sizeof VLA
>     assert(ffi.sizeof(id, 0x3fffffff) == 2*0x3fffffff)
>   end
>   
> -do --- sizeof VLS
> +do --- VLS sizeof
>     assert(ffi.sizeof("struct { double x; int a[?]; }", 10) == 8+4*10)
>     local id = ffi.typeof("struct { int x; short a[?]; }")
>     assert(ffi.sizeof(id, 10) == 4+2*10)
> ===================================================================
>
> <snipped>
>
>>>    jit_complex.lua

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-06 17:03   ` Sergey Kaplun via Tarantool-patches
@ 2024-02-07  8:06     ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  8:06 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!


On 2/6/24 20:03, Sergey Kaplun wrote:
> Hi, Sergey!
> Thanks for the review!
>
> On 01.02.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> there is a problem with running under ASAN:
>>
>>
>> cmake -S . -B build -DLUAJIT_USE_ASAN=ON
>>
>> <snipped>
>>
>> cmake --build build/ -t LuaJIT-tests
>>
>> <snipped>
>>
>> [100%] Linking C executable luajit
>> [100%] Built target luajit_static
>> Running LuaJIT-tests
>> ==320737==ASan runtime does not come first in initial library list; you
>> should either link runtime to your application or manually preload it
>> with LD_PRELOAD.
>> gmake[3]: ***
>> [test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/build.make:74:
>> LuaJIT-tests] Error 1
>> gmake[2]: *** [CMakeFiles/Makefile2:1193:
>> test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/all] Error 2
>> gmake[1]: *** [CMakeFiles/Makefile2:1200:
>> test/LuaJIT-tests/CMakeFiles/LuaJIT-tests.dir/rule] Error 2
>> gmake: *** [Makefile:455: LuaJIT-tests] Error 2
>>
>> cannot reproduce on tarantool/master
> Good catch!
> I've been tricked by the CMake again...
>
> The new patch is the following:

this fix works for me, thanks!

<snipped>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (26 preceding siblings ...)
  2024-02-01 16:32 ` [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
@ 2024-02-07  8:14 ` Sergey Bronnikov via Tarantool-patches
  2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
  2024-02-28 18:25 ` Sergey Kaplun via Tarantool-patches
  29 siblings, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-07  8:14 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey!

thanks for the patch series again! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patchset enables most of the LuaJIT-tests related to FFI and
> testing of C libraries (cpptest, ctest). More tests (from the <misc>
> directory) will be enabled in the future series.
>
> FFI tests from the <unportable> directory aren't enabled because of their
> inconsistency, see also [1].
>
> This increases coverage up to 92.5%, see here [2].
>
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-9398-more-luajit-tests
> Tarantool PR: https://github.com/tarantool/tarantool/pull/9603
> Related issues:
> * https://github.com/tarantool/tarantool/issues/9398
> * https://github.com/tarantool/tarantool/issues/7834
>
> [1]: https://github.com/LuaJIT/LuaJIT/pull/415
> [2]: https://coveralls.io/github/tarantool/luajit?branch=skaplun/gh-9398-more-luajit-tests
>
> Changes in the v2:
> * Introduce the AddTestLib macro to avoid copy-pasting. It only adds a
>    target with necessary flags without setting any variables.
> * <cpptest.cpp> is renamed to <libcpptest.cpp> for consistency with
>    <libctest.c>
> * Rename some tests with uninformative naming (like `call_10i` ->
>    `10 int args`)
> * Add adjusments of arguments for long calls (~10 arguments) to make them
>    comparable without changing test semantics.
> * Fix some typos
>
> Sergey Kaplun (26):
>    cmake: introduce AddTestLib macro
>    test: prepare lauxilarily libs for LuaJIT-tests
>    test: separate LuaJIT helpers from ffi_util.inc
>    test: enable <ffi_arith_ptr.lua> in LuaJIT-tests
>    test: enable <ffi_bitfield.lua> in LuaJIT-tests
>    test: enable <ffi_call.lua> in LuaJIT-tests
>    test: enable <ffi_callback.lua> in LuaJIT-tests
>    test: enable <ffi_const.lua> in LuaJIT-tests
>    test: enable <ffi_convert.lua> in LuaJIT-tests
>    test: enable <ffi_enum.lua> in LuaJIT-tests
>    test: enable <ffi_gcstep_recursive.lua>
>    test: enable <ffi_jit_arith.lua> in LuaJIT-tests
>    test: enable <ffi_jit_call.lua> in LuaJIT-tests
>    test: enable <ffi_jit_conv.lua> in LuaJIT-tests
>    test: enable <ffi_lex_number.lua> in LuaJIT-tests
>    test: enable <ffi_metatype.lua> in LuaJIT-tests
>    test: enable <ffi_new.lua> in LuaJIT-tests
>    test: enable <ffi_parse_array.lua> in LuaJIT-tests
>    test: enable <ffi_parse_basic.lua> in LuaJIT-tests
>    test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
>    test: enable <ffi_parse_struct.lua> LuaJIT test
>    test: enable <ffi_tabov.lua> LuaJIT test
>    test: enable <lightud.lua> LuaJIT test
>    test: enable <api_call.lua> LuaJIT test
>    test: enable <catch_wrap.lua> LuaJIT test
>    test: enable <catch_cpp.lua> LuaJIT test
>
>   test/CMakeLists.txt                           |   3 +
>   test/LuaJIT-tests/CMakeLists.txt              |  45 ++-
>   test/LuaJIT-tests/common/fails.lua            |   3 +
>   test/LuaJIT-tests/common/ffi/checkfail.lua    |  14 +
>   test/LuaJIT-tests/common/ffi/checktypes.lua   |  15 +
>   test/LuaJIT-tests/common/ffi_util.inc         |  23 --
>   test/LuaJIT-tests/{misc => lang}/api_call.lua |  32 +-
>   .../{sysdep => lang}/catch_cpp.lua            |  36 +-
>   .../{misc => lang}/catch_wrap.lua             |  29 +-
>   test/LuaJIT-tests/lang/index                  |   4 +
>   test/LuaJIT-tests/lang/lightud.lua            |  89 +++++
>   test/LuaJIT-tests/lib/ffi/ffi_arith_ptr.lua   |  13 +-
>   test/LuaJIT-tests/lib/ffi/ffi_bitfield.lua    |   4 +-
>   test/LuaJIT-tests/lib/ffi/ffi_call.lua        | 185 +++++-----
>   test/LuaJIT-tests/lib/ffi/ffi_callback.lua    |  45 +--
>   test/LuaJIT-tests/lib/ffi/ffi_const.lua       |   4 +-
>   test/LuaJIT-tests/lib/ffi/ffi_convert.lua     |  35 +-
>   test/LuaJIT-tests/lib/ffi/ffi_enum.lua        |  11 +-
>   .../lib/ffi/ffi_gcstep_recursive.lua          |  27 +-
>   test/LuaJIT-tests/lib/ffi/ffi_jit_arith.lua   |  22 +-
>   test/LuaJIT-tests/lib/ffi/ffi_jit_call.lua    |  70 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua    |  70 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_lex_number.lua  |  72 ++--
>   test/LuaJIT-tests/lib/ffi/ffi_metatype.lua    |  16 +-
>   test/LuaJIT-tests/lib/ffi/ffi_new.lua         |  50 +--
>   test/LuaJIT-tests/lib/ffi/ffi_parse_array.lua | 106 +++---
>   test/LuaJIT-tests/lib/ffi/ffi_parse_basic.lua | 251 ++++++-------
>   test/LuaJIT-tests/lib/ffi/ffi_parse_cdef.lua  | 141 ++++----
>   .../LuaJIT-tests/lib/ffi/ffi_parse_struct.lua | 335 +++++++++---------
>   test/LuaJIT-tests/lib/ffi/ffi_tabov.lua       |  12 -
>   test/LuaJIT-tests/lib/ffi/index               |  18 +
>   test/LuaJIT-tests/misc/lightud.lua            |  88 -----
>   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 +-
>   .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt |  25 +-
>   test/cmake/AddTestLib.cmake                   |  28 ++
>   test/tarantool-tests/CMakeLists.txt           |  27 +-
>   test/tarantool-tests/ffi-tabov.test.lua       |  27 ++
>   40 files changed, 1086 insertions(+), 921 deletions(-)
>   create mode 100644 test/LuaJIT-tests/common/fails.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checkfail.lua
>   create mode 100644 test/LuaJIT-tests/common/ffi/checktypes.lua
>   rename test/LuaJIT-tests/{misc => lang}/api_call.lua (79%)
>   rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
>   rename test/LuaJIT-tests/{misc => lang}/catch_wrap.lua (71%)
>   create mode 100644 test/LuaJIT-tests/lang/lightud.lua
>   delete mode 100644 test/LuaJIT-tests/lib/ffi/ffi_tabov.lua
>   delete mode 100644 test/LuaJIT-tests/misc/lightud.lua
>   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%)
>   create mode 100644 test/cmake/AddTestLib.cmake
>   create mode 100644 test/tarantool-tests/ffi-tabov.test.lua
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro
  2024-02-06 11:23     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:48       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:48 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests
  2024-02-06 11:24     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:50       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:50 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc
  2024-02-06 11:47     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:51       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:51 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, as I've already said.

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> in LuaJIT-tests
  2024-02-06 11:54     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:52 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, as I've already said.

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests
  2024-02-06 12:09     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:52 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, as I've already said.

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> in LuaJIT-tests
  2024-02-06 13:11     ` Sergey Kaplun via Tarantool-patches
  2024-02-06 14:03       ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:58 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>
  2024-02-06 13:23     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:58 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, as I've already said.

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests
  2024-02-06 13:29     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 14:59       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 14:59 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM, as I've already said.

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> in LuaJIT-tests
  2024-02-06 13:39     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:03       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:03 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
  2024-02-06 13:55     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:09       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:09 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> in LuaJIT-tests
  2024-02-06 14:11     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:11       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:11 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the patch!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> in LuaJIT-tests
  2024-02-06 14:15     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:12 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> in LuaJIT-tests
  2024-02-06 14:21     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:12 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test
  2024-02-06 14:23     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:13 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM


^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test
  2024-02-06 14:37     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:13 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the fixes!
LGTM


^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> LuaJIT test
  2024-02-06 14:43     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:14       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:14 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the clarification!
On Tue, Feb 06, 2024 at 05:43:24PM +0300, Sergey Kaplun wrote:
> Hi, Maxim!
> Thanks for the review!
> See my answer below.
>
> On 01.02.24, Maxim Kokryashkin wrote:
> > Hi, Sergey!
> > Thanks for the patch!
> > LGTM, with a question below.
> > On Mon, Jan 29, 2024 at 01:45:23PM +0300, Sergey Kaplun wrote:
> > > This patch moves the <lightud.lua> test from the <misc> to <lang>
> > What is the rationale for that?
>
> I suppose that the `misc` name is some stash directory name for orphan
> tests. This directory contains tests related to the JIT engine
> (<jit_flush.lua>, <loop_unroll.lua>).
> But tests like <stackov.lua>, <api_call.lua> or <lightud.lua> are
> related to the language itself, so I suppose it will be better to move
> them there.
>
> > > directory, includes it in <index>, and names subtests. Also, it enables
> > > tests for all arches and fixes tests for 47-bit lightuserdata because it
> > > is available since the commit
> > > 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64
> > > bit lightuserdata.")
> > <snipped>
>
> --
> Best regards,
> Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> LuaJIT test
  2024-02-06 14:44     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-09 16:15       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-09 16:15 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the clarification!
On Tue, Feb 06, 2024 at 05:44:16PM +0300, Sergey Kaplun wrote:
> Hi, Maxim!
> Thanks for the review!
> See my answer below.
>
> On 01.02.24, Maxim Kokryashkin wrote:
> > Hi, Sergey!
> > Thanks for the patch!
> > LGTM, with the same question about moving from <misc> to <lang>.
>
> I suppose that the `misc` name is some stash directory name for orphan
> tests. This directory contains tests related to the JIT engine
> (<jit_flush.lua>, <loop_unroll.lua>).
> But tests like <stackov.lua>, <api_call.lua> or <lightud.lua> are
> related to the language itself, so I suppose it will be better to move
> them there.
>
> > On Mon, Jan 29, 2024 at 01:45:24PM +0300, Sergey Kaplun wrote:
> > > This patch moves the <api_call.lua> test from the <misc> to <lang>
> > > directory, includes it in <index>, and names subtests.
> > >
> > > Part of tarantool/tarantool#9398
> > <snipped>
>
> --
> Best regards,
> Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (27 preceding siblings ...)
  2024-02-07  8:14 ` Sergey Bronnikov via Tarantool-patches
@ 2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
  2024-02-18 11:48   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-20  8:10   ` Sergey Bronnikov via Tarantool-patches
  2024-02-28 18:25 ` Sergey Kaplun via Tarantool-patches
  29 siblings, 2 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-15 12:49 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

Hi, folks!

I found that with disabled external unwinding, the <catch_cpp.lua> fails
(predictably). The following patch fixes it (squashed it with the
corresponding commit).
===================================================================
diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index e91e3d4a..a0fb5440 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -57,12 +57,19 @@ if(LUAJIT_USE_ASAN)
   endif()
 endif()
 
+if(LUAJIT_NO_UNWIND)
+  # Test <catch_cpp.lua> verifies the interoperability with C++
+  # ABI exceptions, so it requires external unwinding enabled.
+  # Hence, skip them otherwise.
+  set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
+endif()
+
 add_custom_command(TARGET LuaJIT-tests
   COMMENT "Running LuaJIT-tests"
   COMMAND
     env
       ${LUAJIT_TESTS_ENV}
       ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
-      +slow +ffi +bit +jit
+      +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
 )
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 41f7e7db..4ff7a297 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -1,7 +1,7 @@
 andor.lua
 api_call.lua
 assignment.lua
-catch_cpp.lua
+catch_cpp.lua -internal_unwinder
 catch_wrap.lua
 compare.lua
 compare_nan.lua
===================================================================

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches]  [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
@ 2024-02-18 11:48   ` Maxim Kokryashkin via Tarantool-patches
  2024-02-18 11:54     ` Sergey Kaplun via Tarantool-patches
  2024-02-20  8:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-18 11:48 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]


Hi, thanks for the fixup!
IINM, the LUAJIT_NO_UNWIND flag means that there is no
external unwinding, and internal unwinding is used instead,
without any additional configuration. Do we really need to add
this extra flag?
 
 
--
Best regards,
Maxim Kokryashkin
 
 
> 
>>Hi, folks!
>>
>>I found that with disabled external unwinding, the <catch_cpp.lua> fails
>>(predictably). The following patch fixes it (squashed it with the
>>corresponding commit).
>>===================================================================
>>diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
>>index e91e3d4a..a0fb5440 100644
>>--- a/test/LuaJIT-tests/CMakeLists.txt
>>+++ b/test/LuaJIT-tests/CMakeLists.txt
>>@@ -57,12 +57,19 @@ if(LUAJIT_USE_ASAN)
>>   endif()
>> endif()
>> 
>>+if(LUAJIT_NO_UNWIND)
>>+ # Test <catch_cpp.lua> verifies the interoperability with C++
>>+ # ABI exceptions, so it requires external unwinding enabled.
>>+ # Hence, skip them otherwise.
>>+ set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
>>+endif()
>>+
>> add_custom_command(TARGET LuaJIT-tests
>>   COMMENT "Running LuaJIT-tests"
>>   COMMAND
>>     env
>>       ${LUAJIT_TESTS_ENV}
>>       ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
>>- +slow +ffi +bit +jit
>>+ +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
>>   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> )
>>diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
>>index 41f7e7db..4ff7a297 100644
>>--- a/test/LuaJIT-tests/lang/index
>>+++ b/test/LuaJIT-tests/lang/index
>>@@ -1,7 +1,7 @@
>> andor.lua
>> api_call.lua
>> assignment.lua
>>-catch_cpp.lua
>>+catch_cpp.lua -internal_unwinder
>> catch_wrap.lua
>> compare.lua
>> compare_nan.lua
>>===================================================================
>>
>>--
>>Best regards,
>>Sergey Kaplun
> 

[-- Attachment #2: Type: text/html, Size: 2696 bytes --]

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-18 11:48   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-18 11:54     ` Sergey Kaplun via Tarantool-patches
  2024-02-19  8:56       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 1 reply; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-18 11:54 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!

On 18.02.24, Maxim Kokryashkin wrote:
> 
> Hi, thanks for the fixup!
> IINM, the LUAJIT_NO_UNWIND flag means that there is no
> external unwinding, and internal unwinding is used instead,
> without any additional configuration. Do we really need to add
> this extra flag?

This is a tag for the testing suite. As you can see, it adds the
additional flag to index the file to skip. Option LUAJIT_NO_UNWIND is
already used, see <CMakeLists.txt>:
| option(LUAJIT_NO_UNWIND "Disable external unwinding.")
With internal unwinder, there is no interoperability with C++ ABI
exceptions, so exeptions from this <catch.cpp.lua> are not catched
(predictable), and this aborts the process.

>  
>  
> --
> Best regards,
> Maxim Kokryashkin
>  
>  
> > 
> >>Hi, folks!
> >>
> >>I found that with disabled external unwinding, the <catch_cpp.lua> fails
> >>(predictably). The following patch fixes it (squashed it with the
> >>corresponding commit).
> >>===================================================================
> >>diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
> >>index e91e3d4a..a0fb5440 100644
> >>--- a/test/LuaJIT-tests/CMakeLists.txt
> >>+++ b/test/LuaJIT-tests/CMakeLists.txt
> >>@@ -57,12 +57,19 @@ if(LUAJIT_USE_ASAN)
> >>   endif()
> >> endif()
> >> 
> >>+if(LUAJIT_NO_UNWIND)
> >>+ # Test <catch_cpp.lua> verifies the interoperability with C++
> >>+ # ABI exceptions, so it requires external unwinding enabled.
> >>+ # Hence, skip them otherwise.
> >>+ set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
> >>+endif()
> >>+
> >> add_custom_command(TARGET LuaJIT-tests
> >>   COMMENT "Running LuaJIT-tests"
> >>   COMMAND
> >>     env
> >>       ${LUAJIT_TESTS_ENV}
> >>       ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
> >>- +slow +ffi +bit +jit
> >>+ +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
> >>   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
> >> )
> >>diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> >>index 41f7e7db..4ff7a297 100644
> >>--- a/test/LuaJIT-tests/lang/index
> >>+++ b/test/LuaJIT-tests/lang/index
> >>@@ -1,7 +1,7 @@
> >> andor.lua
> >> api_call.lua
> >> assignment.lua
> >>-catch_cpp.lua
> >>+catch_cpp.lua -internal_unwinder
> >> catch_wrap.lua
> >> compare.lua
> >> compare_nan.lua
> >>===================================================================
> >>
> >>--
> >>Best regards,
> >>Sergey Kaplun
> > 

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches]  [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-18 11:54     ` Sergey Kaplun via Tarantool-patches
@ 2024-02-19  8:56       ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 0 replies; 144+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2024-02-19  8:56 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2787 bytes --]


Hi!
Thanks for the clarification!
LGTM
 
 
--
Best regards,
Maxim Kokryashkin
 
  
>Воскресенье, 18 февраля 2024, 14:58 +03:00 от Sergey Kaplun <skaplun@tarantool.org>:
> 
>Hi, Maxim!
>
>On 18.02.24, Maxim Kokryashkin wrote:
>>
>> Hi, thanks for the fixup!
>> IINM, the LUAJIT_NO_UNWIND flag means that there is no
>> external unwinding, and internal unwinding is used instead,
>> without any additional configuration. Do we really need to add
>> this extra flag?
>
>This is a tag for the testing suite. As you can see, it adds the
>additional flag to index the file to skip. Option LUAJIT_NO_UNWIND is
>already used, see <CMakeLists.txt>:
>| option(LUAJIT_NO_UNWIND "Disable external unwinding.")
>With internal unwinder, there is no interoperability with C++ ABI
>exceptions, so exeptions from this <catch.cpp.lua> are not catched
>(predictable), and this aborts the process.
>
>>  
>>  
>> --
>> Best regards,
>> Maxim Kokryashkin
>>  
>>  
>> > 
>> >>Hi, folks!
>> >>
>> >>I found that with disabled external unwinding, the <catch_cpp.lua> fails
>> >>(predictably). The following patch fixes it (squashed it with the
>> >>corresponding commit).
>> >>===================================================================
>> >>diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
>> >>index e91e3d4a..a0fb5440 100644
>> >>--- a/test/LuaJIT-tests/CMakeLists.txt
>> >>+++ b/test/LuaJIT-tests/CMakeLists.txt
>> >>@@ -57,12 +57,19 @@ if(LUAJIT_USE_ASAN)
>> >>   endif()
>> >> endif()
>> >> 
>> >>+if(LUAJIT_NO_UNWIND)
>> >>+ # Test <catch_cpp.lua> verifies the interoperability with C++
>> >>+ # ABI exceptions, so it requires external unwinding enabled.
>> >>+ # Hence, skip them otherwise.
>> >>+ set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
>> >>+endif()
>> >>+
>> >> add_custom_command(TARGET LuaJIT-tests
>> >>   COMMENT "Running LuaJIT-tests"
>> >>   COMMAND
>> >>     env
>> >>       ${LUAJIT_TESTS_ENV}
>> >>       ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
>> >>- +slow +ffi +bit +jit
>> >>+ +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
>> >>   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> >> )
>> >>diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
>> >>index 41f7e7db..4ff7a297 100644
>> >>--- a/test/LuaJIT-tests/lang/index
>> >>+++ b/test/LuaJIT-tests/lang/index
>> >>@@ -1,7 +1,7 @@
>> >> andor.lua
>> >> api_call.lua
>> >> assignment.lua
>> >>-catch_cpp.lua
>> >>+catch_cpp.lua -internal_unwinder
>> >> catch_wrap.lua
>> >> compare.lua
>> >> compare_nan.lua
>> >>===================================================================
>> >>
>> >>--
>> >>Best regards,
>> >>Sergey Kaplun
>> > 
>
>--
>Best regards,
>Sergey Kaplun
 

[-- Attachment #2: Type: text/html, Size: 4112 bytes --]

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
  2024-02-18 11:48   ` Maxim Kokryashkin via Tarantool-patches
@ 2024-02-20  8:10   ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 0 replies; 144+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-02-20  8:10 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Sergey

thanks for the patch! LGTM

On 2/15/24 15:49, Sergey Kaplun wrote:
> Hi, folks!
>
> I found that with disabled external unwinding, the <catch_cpp.lua> fails
> (predictably). The following patch fixes it (squashed it with the
> corresponding commit).
> ===================================================================
> diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
> index e91e3d4a..a0fb5440 100644
> --- a/test/LuaJIT-tests/CMakeLists.txt
> +++ b/test/LuaJIT-tests/CMakeLists.txt
> @@ -57,12 +57,19 @@ if(LUAJIT_USE_ASAN)
>     endif()
>   endif()
>   
> +if(LUAJIT_NO_UNWIND)
> +  # Test <catch_cpp.lua> verifies the interoperability with C++
> +  # ABI exceptions, so it requires external unwinding enabled.
> +  # Hence, skip them otherwise.
> +  set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
> +endif()
> +
>   add_custom_command(TARGET LuaJIT-tests
>     COMMENT "Running LuaJIT-tests"
>     COMMAND
>       env
>         ${LUAJIT_TESTS_ENV}
>         ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
> -      +slow +ffi +bit +jit
> +      +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
>     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>   )
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 41f7e7db..4ff7a297 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -1,7 +1,7 @@
>   andor.lua
>   api_call.lua
>   assignment.lua
> -catch_cpp.lua
> +catch_cpp.lua -internal_unwinder
>   catch_wrap.lua
>   compare.lua
>   compare_nan.lua
> ===================================================================
>

^ permalink raw reply	[flat|nested] 144+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1
  2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
                   ` (28 preceding siblings ...)
  2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
@ 2024-02-28 18:25 ` Sergey Kaplun via Tarantool-patches
  29 siblings, 0 replies; 144+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-02-28 18:25 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

Hi, Maxim, Sergey!

I've checked the patchset into all long-term branches in
tarantool/luajit and bumped a new version in master [1], release/3.0 [2]
and release/2.11 [3].

[1]: https://github.com/tarantool/tarantool/pull/9737
[2]: https://github.com/tarantool/tarantool/pull/9738
[3]: https://github.com/tarantool/tarantool/pull/9739

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 144+ messages in thread

end of thread, other threads:[~2024-02-28 18:29 UTC | newest]

Thread overview: 144+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches
2024-01-31 11:25   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 11:23     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:48       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 14:20   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches
2024-01-31 11:48   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 11:24     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:50       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 14:23   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches
2024-01-31 11:58   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 11:47     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:51       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 15:45   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 11:48     ` Sergey Kaplun via Tarantool-patches
2024-02-07  6:49       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
2024-01-31 12:21   ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 15:50   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 12:26   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 11:54     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 15:52   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 11:55     ` Sergey Kaplun via Tarantool-patches
2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 12:34   ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 15:58   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 12:01     ` Sergey Kaplun via Tarantool-patches
2024-02-07  6:50       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 13:02   ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:01   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 14:32   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 12:09     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:52       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 14:32   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 12:10     ` Sergey Kaplun via Tarantool-patches
2024-02-07  6:52       ` Sergey Bronnikov via Tarantool-patches
2024-02-01 16:02   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 14:55   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 13:11     ` Sergey Kaplun via Tarantool-patches
2024-02-06 14:03       ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:06   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 13:13     ` Sergey Kaplun via Tarantool-patches
2024-02-01 16:19   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches
2024-01-31 14:59   ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:07   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches
2024-01-31 15:07   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 13:23     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:58       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:10   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches
2024-01-31 15:15   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 13:29     ` Sergey Kaplun via Tarantool-patches
2024-02-09 14:59       ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:12   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  8:30   ` Maxim Kokryashkin via Tarantool-patches
2024-02-01 16:15   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  8:32   ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 12:51   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 13:33     ` Sergey Kaplun via Tarantool-patches
2024-02-07  6:53       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  8:38   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 13:39     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:03       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 12:53   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  8:40   ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 12:58   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 13:48     ` Sergey Kaplun via Tarantool-patches
2024-02-07  7:01       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  8:43   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 13:55     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:09       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:03   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 13:58     ` Sergey Kaplun via Tarantool-patches
2024-02-07  7:51       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:01   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:11     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:11       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:08   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 14:12     ` Sergey Kaplun via Tarantool-patches
2024-02-07  8:04       ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:03   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:15     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:10   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:05   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:21     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:12       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:11   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
2024-02-01  9:16   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:23     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:14   ` Sergey Bronnikov via Tarantool-patches
2024-02-06 14:25     ` Sergey Kaplun via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:19   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:37     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:13       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:20   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:23   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:43     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:14       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:27   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:25   ` Maxim Kokryashkin via Tarantool-patches
2024-02-06 14:44     ` Sergey Kaplun via Tarantool-patches
2024-02-09 16:15       ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:28   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:31   ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches
2024-02-01  9:32   ` Maxim Kokryashkin via Tarantool-patches
2024-02-05 13:32   ` Sergey Bronnikov via Tarantool-patches
2024-02-01 16:32 ` [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
2024-02-06 17:03   ` Sergey Kaplun via Tarantool-patches
2024-02-07  8:06     ` Sergey Bronnikov via Tarantool-patches
2024-02-07  8:14 ` Sergey Bronnikov via Tarantool-patches
2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches
2024-02-18 11:48   ` Maxim Kokryashkin via Tarantool-patches
2024-02-18 11:54     ` Sergey Kaplun via Tarantool-patches
2024-02-19  8:56       ` Maxim Kokryashkin via Tarantool-patches
2024-02-20  8:10   ` Sergey Bronnikov via Tarantool-patches
2024-02-28 18:25 ` Sergey Kaplun via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox