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

Sergey Kaplun skaplun at tarantool.org
Mon Jan 29 13:45:04 MSK 2024


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



More information about the Tarantool-patches mailing list