[Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> LuaJIT test

Maxim Kokryashkin m.kokryashkin at tarantool.org
Thu Feb 1 12:19:38 MSK 2024


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
>


More information about the Tarantool-patches mailing list