From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <m.kokryashkin@tarantool.org>, Sergey Bronnikov <sergeyb@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH luajit 13/25] test: enable <ffi_jit_conv.lua> in LuaJIT-tests Date: Fri, 19 Jan 2024 14:32:36 +0300 [thread overview] Message-ID: <cb44ad4a99c6b287e1a5eba7fa56d3478a4c8bba.1705661401.git.skaplun@tarantool.org> (raw) In-Reply-To: <cover.1705661401.git.skaplun@tarantool.org> This patch renames the C library in the `require()` call. It adds groups with the names of subtests and enables the test in <index>. It renames enum definitions to avoid conflicts with cdef in other tests. Part of tarantool/tarantool#9398 --- test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua | 70 +++++++++++----------- test/LuaJIT-tests/lib/ffi/index | 1 + 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua index d4707db7..0e64fe75 100644 --- a/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua +++ b/test/LuaJIT-tests/lib/ffi/ffi_jit_conv.lua @@ -1,8 +1,8 @@ local ffi = require("ffi") -local ctest = require("ctest") +local ctest = require("libctest") -do +do --- int32_t, narrowed local s = ffi.new("struct { int32_t x; }") s.x = -0x12345678 for i=1,100 do @@ -11,7 +11,7 @@ do assert(s.x == -0x12345678+100) end -do +do --- uint32_t, CONV num.u32 u32.num local s = ffi.new("struct { uint32_t x; }") s.x = 0x81234567 for i=1,100 do @@ -20,7 +20,7 @@ do assert(s.x == 0x81234567+100) end -do +do --- int8_t, CONV.int.i8 forwarding local s = ffi.new("struct { int8_t x; }") s.x = 42 for i=1,100 do @@ -30,7 +30,7 @@ do assert(s.x == 142-256) end -do +do --- uint8_t, CONV.int.u8 forwarding local s = ffi.new("struct { uint8_t x; }") s.x = 200 for i=1,100 do @@ -40,7 +40,7 @@ do assert(s.x == 300-256) end -do +do --- int16_t, CONV.int.i16 forwarding local s = ffi.new("struct { int16_t x; }") s.x = 32700 for i=1,100 do @@ -50,7 +50,7 @@ do assert(s.x == 32800-65536) end -do +do --- uint16_t, CONV.int.u16 forwarding local s = ffi.new("struct { uint16_t x; }") s.x = 65450 for i=1,100 do @@ -60,7 +60,7 @@ do assert(s.x == 65550-65536) end -do +do --- union i32 u32, forwarding num.int num.u32 local s = ffi.new("union { int32_t x; uint32_t y; }") s.x = 0x7fffffff - 60 local x,y = 0,0 @@ -75,7 +75,7 @@ do assert(x == y - 40*2^32) end -do +do --- union i32 u32, forwarding CONV.int.u32 local s = ffi.new("union { int32_t x; uint32_t y; }") local x, z = 0, 2^31 + 42 for i=1,100 do @@ -85,7 +85,7 @@ do assert(x == 100*(-2^31 + 42)) end -do +do --- union i8 u8, forwarding CONV.int.i8 CONV.num.int local s = ffi.new("union { int8_t x; uint8_t y; }") s.x = 42 local x,y = 0,0 @@ -100,7 +100,7 @@ do assert(x == y - (100-(127-42))*256) end -do +do --- tobit + CONV.num.u32, 1 local a = ffi.new("uint32_t[?]", 101) for i=1,100 do a[i] = 0x80000000+i end local x = 0 @@ -110,7 +110,7 @@ do assert(x == 100) end -do +do --- tobit + CONV.num.u32, 2 local a = ffi.new("uint32_t[?]", 101) for i=1,100 do a[i] = 0x80000000+i end local x = 0 @@ -120,7 +120,7 @@ do assert(x == -0x80000000+100) end -do +do --- CONV.num.flt local v = ffi.new("float", 12.5) local x = 0 for i=1,100 do @@ -129,7 +129,7 @@ do assert(x == 100*12.5) end -do +do --- CONV.num.u32 local v = ffi.new("uint32_t", 0x80000000) local x = 0 for i=1,100 do @@ -138,7 +138,7 @@ do assert(x == 100*0x80000000) end -do +do --- CONV.num.i64 local v = ffi.new("int64_t", 0x1234567800000000ll) local x = 0 for i=1,100 do @@ -147,7 +147,7 @@ do assert(x == 100*0x12345678*2^32) end -do +do --- CONV.num.u64 local v = ffi.new("uint64_t", 0x89abcdef00000000ull) local x = 0 for i=1,100 do @@ -156,7 +156,7 @@ do assert(x == 100*0x89abcdef*2^32) end -do +do --- CONV.num.i64, overflow local a = ffi.new("int64_t[?]", 101) for i=1,100 do a[i] = -i end local x = 0 @@ -166,7 +166,7 @@ do assert(x == -5050) end -do +do --- CONV.num.u64, overflow local a = ffi.new("uint64_t[?]", 101) for i=1,100 do a[i] = 2^63+2^32*i end local x = 0 @@ -176,7 +176,7 @@ do assert(x == 2^63*100+2^32*5050) end -do +do --- tonumber(complex) local v = ffi.new("complex", 12.5, -3.25) local x = 0 for i=1,100 do @@ -185,7 +185,7 @@ do assert(x == 100*12.5) end -do +do --- const on trace i64 local s = ffi.new("struct { int64_t x;}") for i=1,100 do s.x = 0x123456789abcdef0LL @@ -193,7 +193,7 @@ do assert(tonumber(s.x) == tonumber(0x123456789abcdef0LL)) end -do +do --- const on trace u64 local s = ffi.new("struct { uint64_t x;}") for i=1,100 do s.x = 0x823456789abcdef0ULL @@ -201,27 +201,27 @@ do assert(tonumber(s.x) == tonumber(0x823456789abcdef0ULL)) end -do +do --- enum recording ffi.cdef[[ - typedef enum { AA, BB, CC = -42 } foo_i; - typedef enum { DD, EE, FF = 0x80000000u } foo_u; + typedef enum { AAA, BBB, CCC = -42 } foo_i; + typedef enum { DDD, EEE, FFF = 0x80000000u } foo_u; ]] local s = ffi.new("struct { foo_i x; foo_u y;}") for i=1,100 do - s.x = "CC" + s.x = "CCC" assert(s.x == -42) - s.x = "BB" + s.x = "BBB" assert(s.x == 1) - s.y = "FF" + s.y = "FFF" assert(s.y == 0x80000000) end local st = ffi.typeof(s) for i=1,100 do s = st() end assert(s.x == 0 and s.y == 0) - for i=1,100 do s = st("CC", "EE") end + for i=1,100 do s = st("CCC", "EEE") end assert(s.x == -42 and s.y == 1) - local ei = ffi.new("foo_i", "CC") - local eu = ffi.new("foo_u", "EE") + local ei = ffi.new("foo_i", "CCC") + local eu = ffi.new("foo_u", "EEE") for i=1,100 do s = st(ei, eu) end assert(s.x == -42 and s.y == 1) local x @@ -229,7 +229,7 @@ do assert(x == -42) end -do +do --- const char* recording local s = ffi.new("struct { const char *x; const char *y;}") local a, tmp = "abcd", "ab" for i=1,100 do @@ -240,7 +240,7 @@ do assert(ffi.string(s.y) == "ab") end -do +do --- bool int double recording local s = ffi.new("struct { bool b[200]; int i[200]; double d[200];}") for i=0,199 do s.i[i] = i-100; s.d[i] = i-100 end for i=0,99 do s.b[i] = 0 end @@ -253,13 +253,13 @@ do for i=0,199 do assert(s.b[i] == (i ~= 100)) end end -do +do --- int16_t array arithmetic local a = ffi.new("int16_t[100]", 1) for i=1,99 do a[i] = a[i] + a[i-1] end assert(a[99] == 100) end -do +do --- ligud to pointer local ud = ctest.lightud(12345678) local s = ffi.new("struct { void *p; }") for i=1,100 do @@ -269,7 +269,7 @@ do assert(ffi.cast("uintptr_t", s.p) == 12345678) end -do +do --- reference type initialization local x = ffi.new("struct { int & x;}", ffi.new("int[1]", 42)) local z for i=1,100 do z = x.x end diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index index d6e2b64a..71def57b 100644 --- a/test/LuaJIT-tests/lib/ffi/index +++ b/test/LuaJIT-tests/lib/ffi/index @@ -12,6 +12,7 @@ ffi_enum.lua ffi_gcstep_recursive.lua ffi_jit_arith.lua ffi_jit_call.lua +ffi_jit_conv.lua istype.lua jit_array.lua jit_complex.lua -- 2.43.0
next prev parent reply other threads:[~2024-01-19 11:43 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-19 11:32 [Tarantool-patches] [PATCH luajit 00/25] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 01/25] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-23 9:10 ` Sergey Bronnikov via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 02/25] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches 2024-01-23 9:17 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:35 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 03/25] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-23 9:21 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 13:10 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 04/25] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 05/25] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:32 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:46 ` Sergey Kaplun via Tarantool-patches 2024-01-24 11:05 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 06/25] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:36 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:01 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:58 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 07/25] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:38 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 11:59 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:52 ` Sergey Kaplun via Tarantool-patches 2024-01-23 12:49 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 08/25] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:39 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:51 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 09/25] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 10/25] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 11/25] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 12/25] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-24 14:43 ` Sergey Bronnikov via Tarantool-patches 2024-01-19 11:32 ` Sergey Kaplun via Tarantool-patches [this message] 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 14/25] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 15/25] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 16/25] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 17/25] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 18/25] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 19/25] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 20/25] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 21/25] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 22/25] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 23/25] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 24/25] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 25/25] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:01 ` [Tarantool-patches] [PATCH luajit 00/25] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=cb44ad4a99c6b287e1a5eba7fa56d3478a4c8bba.1705661401.git.skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit 13/25] test: enable <ffi_jit_conv.lua> in LuaJIT-tests' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox