[Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc

Maxim Kokryashkin m.kokryashkin at tarantool.org
Wed Jan 31 14:58:04 MSK 2024


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
>


More information about the Tarantool-patches mailing list