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 8F22298C133; Fri, 19 Jan 2024 14:48:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8F22298C133 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1705664883; bh=Hbx3PW4+4NTJDiiqmiwZrFSchkqoEmc0lFGaoDf5vPM=; 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=lLxONlxg5X82pR8d+c8uOze/HLWFwJ9E2KuSIQPagkEUr/T+U3dVfsTTQC6T3fFcc dBnaElSVZGvxtbpeH2/EAXl1onhMUvAvBVlXhGgjAOkCvMqx7C9M6pSqo0dkkTo5LB y9BJd1Cw2c69O4W6JZcovsxc4Nb3C6RiqcJMFHR8= 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 166CE988E4A for ; Fri, 19 Jan 2024 14:37:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 166CE988E4A Received: by smtp16.i.mail.ru with esmtpa (envelope-from ) id 1rQnBo-00FDC7-1n; Fri, 19 Jan 2024 14:37:37 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Fri, 19 Jan 2024 14:32:45 +0300 Message-ID: <75e5f1cc7b525ed7d46affc17107792c85091384.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AE5B4AFB3AE2A59092FCB11211B72126BE62AE7BFAEAA27F182A05F5380850409BDA6420D29D37E777CA480E2D39EF6FAF9CE47BF0D913AE38F7F05869BE000F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72A64CB3BE381ABE4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372FCE560095E3DFB88638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86590DD218E975DA9261ECAA631925BC8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC1F8789D36234D406A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C088D2E8BEBF93D4B068655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C1156E5889A6D309143847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5B96AA67C2F73BE2F3DE3FD803DF40A2F7EF99FC0F73872F6F87CCE6106E1FC07E67D4AC08A07B9B0AD0E433DBF1FBFA39C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF8802192653B6504A1C65A8C71FB905A44CF6A3C5B15B57E879B7471AB6F716688926F27D50C27B5D6197189FEE4B1C7AEE44044BCF36C09206B77838FC6A7D2CA74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojJsr4kcGAUCPUqCPonOr5dg== X-DA7885C5: D2A0E7C3A918662A22358C9D20223E7B71CD93BCA5597A3DFACEAF27CCCDF64FD8288D6B1992AB67EF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE33EF5BA94D64B13D7F4907EE48715D9B530FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 22/25] test: enable LuaJIT test 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 moves the test from the to directory, includes it in , and names subtests. Also, it enables tests for all arches and fixes tests for 47-bit lightuserdata because it is available since the commit 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64 bit lightuserdata.") Part of tarantool/tarantool#9398 --- test/LuaJIT-tests/lang/index | 1 + test/LuaJIT-tests/lang/lightud.lua | 89 ++++++++++++++++++++++++++++++ test/LuaJIT-tests/misc/lightud.lua | 88 ----------------------------- 3 files changed, 90 insertions(+), 88 deletions(-) create mode 100644 test/LuaJIT-tests/lang/lightud.lua delete mode 100644 test/LuaJIT-tests/misc/lightud.lua diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index index 88e2edfa..60cbecfb 100644 --- a/test/LuaJIT-tests/lang/index +++ b/test/LuaJIT-tests/lang/index @@ -5,6 +5,7 @@ compare_nan.lua constant for.lua length.lua +lightud.lua modulo.lua concat.lua self.lua diff --git a/test/LuaJIT-tests/lang/lightud.lua b/test/LuaJIT-tests/lang/lightud.lua new file mode 100644 index 00000000..aee9e85c --- /dev/null +++ b/test/LuaJIT-tests/lang/lightud.lua @@ -0,0 +1,89 @@ +local ctest = require("libctest") + +local lightud = ctest.lightud +local assert = assert + +-- x64 lightud tests +do --- light userdata comparison and tostring +x64 + local ud1 = lightud(0x12345678) + local ud2 = lightud(0x12345678) + assert(ud1 == ud2) + assert(tostring(ud1) == "userdata: 0x12345678") +end + +do --- unequal light userdata comparison +x64 + local ud1 = lightud(1) + local ud2 = lightud(2) + assert(ud1 ~= ud2) +end + +do --- big light userdata comparison and tostring +x64 + local ud1 = lightud(2^47-1) + local ud2 = lightud(2^47-1) + assert(ud1 == ud2) + assert(tostring(ud1) == "userdata: 0x7fffffffffff") +end + +do --- unequal light userdata comparison JIT +x64 + local ud1 = lightud(0x12345678+123*2^32) + local ud2 = lightud(0x12345678+456*2^32) + for i=1,100 do assert(ud1 ~= ud2) end +end + +do --- 47 bits light userdata +x64 + assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234") + -- Now more than 47 bits are available. + assert(pcall(lightud, 2^47) == true) + assert(pcall(lightud, 2^64-2048) == true) +end + +do --- metatable check + assert(getmetatable(lightud(1)) == nil) +end + +do --- lightuserdata SLOAD value and HREF key + local ud = lightud(12345) + local t = {[ud] = 42} + for i=1,100 do + assert(t[ud] == 42) + end +end + +do --- lightuserdata NEWREF key + local ud = lightud(12345) + for i=1,100 do + local t = {[ud] = 42} + assert(t[ud] == 42) + end +end + +do --- lightuserdata ASTORE/HSTORE value + local ud = lightud(12345) + local t = {} + for i=1,100 do + t[i] = ud + end + assert(t[100] == ud) +end + +do --- lightuserdata sync to stack + local ud = lightud(12345) + local x = nil + for j=1,20 do + for i=1,50 do + x = ud + end + assert(x == ud) + end +end + +do --- lightuserdata vs. number type check + local t = {} + for i=1,200 do t[i] = i end + t[180] = lightud(12345) + local x = 0 + assert(not pcall(function(t) + for i=1,200 do x = x + t[i] end + end, t)) + assert(x == 16110) +end diff --git a/test/LuaJIT-tests/misc/lightud.lua b/test/LuaJIT-tests/misc/lightud.lua deleted file mode 100644 index 4974d50f..00000000 --- a/test/LuaJIT-tests/misc/lightud.lua +++ /dev/null @@ -1,88 +0,0 @@ -local ctest = require("ctest") - -local lightud = ctest.lightud -local assert = assert - --- x64 lightud tests -if jit and jit.arch == "x64" then - do - local ud1 = lightud(0x12345678) - local ud2 = lightud(0x12345678) - assert(ud1 == ud2) - assert(tostring(ud1) == "userdata: 0x12345678") - end - do - local ud1 = lightud(1) - local ud2 = lightud(2) - assert(ud1 ~= ud2) - end - do - local ud1 = lightud(2^47-1) - local ud2 = lightud(2^47-1) - assert(ud1 == ud2) - assert(tostring(ud1) == "userdata: 0x7fffffffffff") - end - do - local ud1 = lightud(0x12345678+123*2^32) - local ud2 = lightud(0x12345678+456*2^32) - for i=1,100 do assert(ud1 ~= ud2) end - end - assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234") - assert(pcall(lightud, 2^47) == false) - assert(pcall(lightud, 2^64-2048) == false) -end - -assert(getmetatable(lightud(1)) == nil) - --- lightuserdata SLOAD value and HREF key -do - local ud = lightud(12345) - local t = {[ud] = 42} - for i=1,100 do - assert(t[ud] == 42) - end -end - --- lightuserdata NEWREF key -do - local ud = lightud(12345) - for i=1,100 do - local t = {[ud] = 42} - assert(t[ud] == 42) - end -end - --- lightuserdata ASTORE/HSTORE value -do - local ud = lightud(12345) - local t = {} - for i=1,100 do - t[i] = ud - end - assert(t[100] == ud) -end - --- lightuserdata sync to stack -do - local ud = lightud(12345) - local x = nil - for j=1,20 do - for i=1,50 do - x = ud - end - assert(x == ud) - end -end - --- lightuserdata vs. number type check -do - local t = {} - for i=1,200 do t[i] = i end - t[180] = lightud(12345) - local x = 0 - assert(not pcall(function(t) - for i=1,200 do x = x + t[i] end - end, t)) - assert(x == 16110) -end - -- 2.43.0