[Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> in LuaJIT-tests
Sergey Kaplun
skaplun at tarantool.org
Tue Feb 6 16:55:20 MSK 2024
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
More information about the Tarantool-patches
mailing list