[Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> in LuaJIT-tests

Sergey Kaplun skaplun at tarantool.org
Tue Feb 6 15:09:14 MSK 2024


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


More information about the Tarantool-patches mailing list