From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 47BB7988E48; Fri, 19 Jan 2024 14:39:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47BB7988E48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1705664374; bh=ji+3VmEQ2rVpY1tubwnVffjKT9H+TpMUattKnHd9YSc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Vcref5N5bAcjZ1cNb4HLurXxPq2Z50XD/Z/8t+f94AUBR2yFGd7bckDMd/lLG1YxX eBZPi+we0EHqQDRZsWzah2wl73jAgSB83E16GKXSHUSURNPCh98L9nHdyiot927iOk cFV1shzQ6RlR6pvofO8dm7SD2Y1pKBt/rl6FdUaM= Received: from smtp16.i.mail.ru (smtp16.i.mail.ru [95.163.41.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8DB7E9885F2 for ; Fri, 19 Jan 2024 14:37:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8DB7E9885F2 Received: by smtp16.i.mail.ru with esmtpa (envelope-from ) id 1rQnBI-00FDC7-2D; Fri, 19 Jan 2024 14:37:05 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Fri, 19 Jan 2024 14:32:28 +0300 Message-ID: <6785a95ee05ea262eff6226bc7867c9280ea37ea.1705661401.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9C4CE30293DC53173C6572E29AED1347C5733A4CF546C45731313CFAB8367EF908E2BE116634AD74DFC19D315265A8FF4C5B57E2F45E6057D88687216CC303E0C83CBAA0A329D8B6B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73230F712CF4B3924EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A6C16C7015BEC7F48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D88C3AE413B0004C9BE0277D3041D3612F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCA9BB761A57C26B8FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10F618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0FE3A47D6FA29121068655334FD4449CB33AC447995A7AD1857739F23D657EF2BD5E8D9A59859A8B68A0907C648FB30DE089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A59171742187B72B723DE3FD803DF40A2F07362B2D0A160375F87CCE6106E1FC07E67D4AC08A07B9B0F254576263B31EA99C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF590254F41FE3F1F7D18E11F612527ACBE27A17094F986C2B1DAEA584E54AB84CBE0296D7E8D7E7C6197189FEE4B1C7A2AF4B41CA53A3FB196262DA0730D5D49A74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojJsr4kcGAUCMO2w7pK23BBg== X-DA7885C5: 02302927491435EC22358C9D20223E7B8B1754574E25848A9583D20D7060D830262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE33BE383BA7380A7B379D1BD157AEBC4F930FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 05/25] test: enable in LuaJIT-tests X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch removes unused `dofile()`. Also, it uses the basename of the ctest library to be loaded via ffi. It adds groups with names of subtests and enables the test in . Complex type is undefined on Windows, so the correponding tests are not enabled for this platform. Fastcalls are enabled only for the x86 architecture. Stdcalls are enabled only for Windows on x86. Tests with calls with 10 arguments with sizes less than 8 bits are dummy for M1. This suite lacks a mechanism to skip subtests satisfying complicated conditions, so it is done manually by the corresponding `if` check. Part of tarantool/tarantool#9398 --- test/LuaJIT-tests/lib/ffi/ffi_call.lua | 180 +++++++++++++------------ test/LuaJIT-tests/lib/ffi/index | 1 + 2 files changed, 92 insertions(+), 89 deletions(-) diff --git a/test/LuaJIT-tests/lib/ffi/ffi_call.lua b/test/LuaJIT-tests/lib/ffi/ffi_call.lua index 1eb5e906..c362f3e0 100644 --- a/test/LuaJIT-tests/lib/ffi/ffi_call.lua +++ b/test/LuaJIT-tests/lib/ffi/ffi_call.lua @@ -1,8 +1,5 @@ - local ffi = require("ffi") -dofile("../common/ffi_util.inc") - local tonumber = tonumber ffi.cdef[[ @@ -73,81 +70,87 @@ double __stdcall stdcall_dd(double a, double b); float __stdcall stdcall_ff(float a, float b); ]] -local C = ffi.load("../clib/ctest") +local C = ffi.load("ctest") -assert(C.call_i(-42) == -41) -assert(C.call_ii(-42, 17) == -42+17) -assert(C.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) == -42+17+12345+9987-100+11+51+0x12345678+338-78901234) +do --- call int enum double float args + assert(C.call_i(-42) == -41) + assert(C.call_ii(-42, 17) == -42+17) -assert(C.call_ie(123) == 124) + assert(C.call_ie(123) == 124) -assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17)) -assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17)) -assert(tonumber(C.call_jj(-42, 17)) == -42+17) -assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) == tonumber(0x123456789abcdef0LL-0x789abcde99887766LL)) + assert(tonumber(C.call_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17)) + assert(tonumber(C.call_ij(-17, 0x123456789LL)) == tonumber(0x123456789LL-17)) + assert(tonumber(C.call_jj(-42, 17)) == -42+17) + assert(tonumber(C.call_jj(0x123456789abcdef0LL, -0x789abcde99887766LL)) == tonumber(0x123456789abcdef0LL-0x789abcde99887766LL)) -assert(C.call_dd(12.5, -3.25) == 12.5-3.25) -assert(C.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75) + assert(C.call_dd(12.5, -3.25) == 12.5-3.25) -assert(C.call_ff(12.5, -3.25) == 12.5-3.25) -assert(C.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75) + assert(C.call_ff(12.5, -3.25) == 12.5-3.25) -assert(C.call_idifjd(-42, 17.125, 0x12345, -100.625, 12345678901234, -789012.75) == -42+17.125+0x12345-100.625+12345678901234-789012.75) + assert(C.call_idifjd(-42, 17.125, 0x12345, -100.625, 12345678901234, -789012.75) == -42+17.125+0x12345-100.625+12345678901234-789012.75) +end + +do --- call 10 args + if not (jit.os == "OSX" and jit.arch == "arm64") then -- NYI + assert(C.call_10i(-42, 17, 12345, 9987, -100, 11, 51, 0x12345678, 338, -78901234) == -42+17+12345+9987-100+11+51+0x12345678+338-78901234) + assert(C.call_10f(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x123456, 338, -789012.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x123456+338-789012.75) + end + assert(C.call_10d(-42.5, 17.125, 12345.5, 9987, -100.625, 11, 51, 0x12345678, 338, -78901234.75) == -42.5+17.125+12345.5+9987-100.625+11+51+0x12345678+338-78901234.75) +end -do +do --- call pointer arg local a = ffi.new("int[10]", -42) assert(C.call_p_i(a) == -42+1) assert(tonumber(ffi.cast("intptr_t", C.call_p_p(a+3))) == tonumber(ffi.cast("intptr_t", a+4))) assert(C.call_pp_i(a+8, a+5) == 3) end --- vararg -assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131) +do --- vararg + assert(C.call_ividi(-42, ffi.new("int", 17), 12.5, ffi.new("int", 131)) == -42+17+12.5+131) +end -- complex -if pcall(function() return C.call_dd_cd end) then - do - local c = C.call_dd_cd(12.5, -3.25) - assert(c.re == 12.5 and c.im == -3.25*2) - end - do - local c1 = ffi.new("complex", 12.5, -3.25) - local cz = C.call_cd(c1) - assert(cz.re == 12.5+1 and cz.im == -3.25-2) - end - do - local c1 = ffi.new("complex", 12.5, -3.25) - local c2 = ffi.new("complex", -17.125, 100.625) - local cz = C.call_cdcd(c1, c2) - assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625) - end +do --- dd_cd -windows + local c = C.call_dd_cd(12.5, -3.25) + assert(c.re == 12.5 and c.im == -3.25*2) +end +do --- cd -windows + local c1 = ffi.new("complex", 12.5, -3.25) + local cz = C.call_cd(c1) + assert(cz.re == 12.5+1 and cz.im == -3.25-2) +end +do --- cdcd -windows + local c1 = ffi.new("complex", 12.5, -3.25) + local c2 = ffi.new("complex", -17.125, 100.625) + local cz = C.call_cdcd(c1, c2) + assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625) +end - do - local c = C.call_ff_cf(12.5, -3.25) - assert(c.re == 12.5 and c.im == -3.25*2) - end - do - local c1 = ffi.new("complex float", 12.5, -3.25) - local cz = C.call_cf(c1) - assert(cz.re == 12.5+1 and cz.im == -3.25-2) - end - do - local c1 = ffi.new("complex float", 12.5, -3.25) - local c2 = ffi.new("complex float", -17.125, 100.625) - local cz = C.call_cfcf(c1, c2) - assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625) - end +do --- ff_cf -windows + local c = C.call_ff_cf(12.5, -3.25) + assert(c.re == 12.5 and c.im == -3.25*2) +end +do --- cf -windows + local c1 = ffi.new("complex float", 12.5, -3.25) + local cz = C.call_cf(c1) + assert(cz.re == 12.5+1 and cz.im == -3.25-2) +end +do --- cfcf -windows + local c1 = ffi.new("complex float", 12.5, -3.25) + local c2 = ffi.new("complex float", -17.125, 100.625) + local cz = C.call_cfcf(c1, c2) + assert(cz.re == 12.5-17.125 and cz.im == -3.25+100.625) end -- structs -do +do --- s_ii local s1 = ffi.new("s_ii", -42, 17) local sz = C.call_sii(s1) assert(s1.x == -42 and s1.y == 17) assert(sz.x == -42 and sz.y == 17) end -do +do --- s_jj local s1 = ffi.new("s_jj", 0x123456789abcdef0LL, -0x789abcde99887766LL) local sz = C.call_sjj(s1) assert(s1.x == 0x123456789abcdef0LL) @@ -156,28 +159,28 @@ do assert(sz.y == -0x789abcde99887766LL) end -do +do --- s_ff local s1 = ffi.new("s_ff", 12.5, -3.25) local sz = C.call_sff(s1) assert(s1.x == 12.5 and s1.y == -3.25) assert(sz.x == 12.5 and sz.y == -3.25) end -do +do --- s_dd local s1 = ffi.new("s_dd", 12.5, -3.25) local sz = C.call_sdd(s1) assert(s1.x == 12.5 and s1.y == -3.25) assert(sz.x == 12.5 and sz.y == -3.25) end -do +do --- s_8i local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678) local sz = C.call_s8i(s1) assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678) assert(sz.a+sz.b+sz.c+sz.d+sz.e+sz.f+sz.g+sz.h == -42+17+12345+9987-100+11+51+0x12345678) end -do +do --- s_ii s_ii local s1 = ffi.new("s_ii", -42, 17) local s2 = ffi.new("s_ii", 0x12345, -98765) local sz = C.call_siisii(s1, s2) @@ -186,7 +189,7 @@ do assert(sz.x == -42+0x12345 and sz.y == 17-98765) end -do +do --- s_ff s_ff local s1 = ffi.new("s_ff", 12.5, -3.25) local s2 = ffi.new("s_ff", -17.125, 100.625) local sz = C.call_sffsff(s1, s2) @@ -195,7 +198,7 @@ do assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625) end -do +do --- s_dd s_dd local s1 = ffi.new("s_dd", 12.5, -3.25) local s2 = ffi.new("s_dd", -17.125, 100.625) local sz = C.call_sddsdd(s1, s2) @@ -204,7 +207,7 @@ do assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625) end -do +do --- s_8i s_8i local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678) local s2 = ffi.new("s_8i", 99, 311, 98765, -51, 312, 97, 17, 0x44332211) local sz = C.call_s8is8i(s1, s2) @@ -215,7 +218,7 @@ do assert(sz.h == 0x12345678+0x44332211) end -do +do --- is8ii local s1 = ffi.new("s_8i", -42, 17, 12345, 9987, -100, 11, 51, 0x12345678) local sz = C.call_is8ii(19, s1, -51) assert(s1.a+s1.b+s1.c+s1.d+s1.e+s1.f+s1.g+s1.h == -42+17+12345+9987-100+11+51+0x12345678) @@ -225,42 +228,41 @@ do end -- target-specific -if jit.arch == "x86" then +do --- fastcall void int double +x86 assert(C.fastcall_void() == 1) assert(C.fastcall_i(-42) == -41) assert(C.fastcall_ii(-42, 17) == -42+17) assert(C.fastcall_iii(-42, 17, 139) == -42+17+139) assert(tonumber(C.fastcall_ji(0x123456789LL, -17)) == tonumber(0x123456789LL-17)) assert(C.fastcall_dd(12.5, -3.25) == 12.5-3.25) +end - do - local a = ffi.new("int[10]", -42) - assert(C.fastcall_pp_i(a+8, a+5) == 3) - end - - do - local s1 = ffi.new("s_ii", -42, 17) - local s2 = ffi.new("s_ii", 0x12345, -98765) - local sz = C.fastcall_siisii(s1, s2) - assert(s1.x == -42 and s1.y == 17) - assert(s2.x == 0x12345 and s2.y == -98765) - assert(sz.x == -42+0x12345 and sz.y == 17-98765) - end +do --- fastcall pp_i +x86 + local a = ffi.new("int[10]", -42) + assert(C.fastcall_pp_i(a+8, a+5) == 3) +end - do - local s1 = ffi.new("s_dd", 12.5, -3.25) - local s2 = ffi.new("s_dd", -17.125, 100.625) - local sz = C.fastcall_sddsdd(s1, s2) - assert(s1.x == 12.5 and s1.y == -3.25) - assert(s2.x == -17.125 and s2.y == 100.625) - assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625) - end +do --- fastcall s_ii s_ii +x86 + local s1 = ffi.new("s_ii", -42, 17) + local s2 = ffi.new("s_ii", 0x12345, -98765) + local sz = C.fastcall_siisii(s1, s2) + assert(s1.x == -42 and s1.y == 17) + assert(s2.x == 0x12345 and s2.y == -98765) + assert(sz.x == -42+0x12345 and sz.y == 17-98765) +end - if jit.os == "Windows" then - assert(C.stdcall_i(-42) == -41) - assert(C.stdcall_ii(-42, 17) == -42+17) - assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25) - assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25) - end +do --- fastcall s_dd s_dd +x86 + local s1 = ffi.new("s_dd", 12.5, -3.25) + local s2 = ffi.new("s_dd", -17.125, 100.625) + local sz = C.fastcall_sddsdd(s1, s2) + assert(s1.x == 12.5 and s1.y == -3.25) + assert(s2.x == -17.125 and s2.y == 100.625) + assert(sz.x == 12.5-17.125 and sz.y == -3.25+100.625) end +do --- stdcall +x86 +windows + assert(C.stdcall_i(-42) == -41) + assert(C.stdcall_ii(-42, 17) == -42+17) + assert(C.stdcall_dd(12.5, -3.25) == 12.5-3.25) + assert(C.stdcall_ff(12.5, -3.25) == 12.5-3.25) +end diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index index 8d833107..599a0182 100644 --- a/test/LuaJIT-tests/lib/ffi/index +++ b/test/LuaJIT-tests/lib/ffi/index @@ -4,6 +4,7 @@ copy_fill.lua err.lua ffi_arith_ptr.lua ffi_bitfield.lua +ffi_call.lua istype.lua jit_array.lua jit_complex.lua -- 2.43.0