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 04EF5C6C776; Thu, 15 Aug 2024 16:38:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 04EF5C6C776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1723729104; bh=yKBaim62TfjMQq4x2X++8RHnrFwAVNKXq9HRxAdEEKg=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=HANElPVpHZTdooYNdETCvLrLNgi1CPnUsrfVC2xPdB+LPZ3sSk1Q3WX63wLNHHSYI bBdjFHwFksftYHYwOQE27j6Ytpt9spxN6J4uoeKhJWcnQ7u7m8eH7azL94RWcwvEBi BW/3rjmTzbKmCWWPBqFgCX0vmwKVOK3SlNe0S1gQ= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [95.163.41.82]) (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 ED524C6C772 for ; Thu, 15 Aug 2024 16:38:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org ED524C6C772 Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1seagH-00000007RYP-3bsK; Thu, 15 Aug 2024 16:38:22 +0300 Content-Type: multipart/alternative; boundary="------------579rNAyPnzzAqu0YHiJb2G4u" Message-ID: Date: Thu, 15 Aug 2024 16:38:21 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <39c68575a9675fac95f52bc2fc66253f1ede25e0.1723638851.git.skaplun@tarantool.org> In-Reply-To: <39c68575a9675fac95f52bc2fc66253f1ede25e0.1723638851.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9F97E3C14763C38E21D034174EA8ECC476D3C65BCD9935719182A05F538085040815F7F08E2C3A40B91417EB218679B827E045C3152075961680876344559C0AD4787F701E01DBF3D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BC08626EA5717D14EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AF78C68CB7D402738638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D878FE601013D7AC85229D09172E44115A32935A6F76B9911ECC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F79006372A3B24BF85B2E607389733CBF5DBD5E9B5C8C57E37DE458BD9DD9810294C998ED8FC6C240DEA76428AA50765F7900637B3B881E57936E120D81D268191BDAD3DBD4B6F7A4D31EC0BE2F48590F00D11D6D81D268191BDAD3D78DA827A17800CE7E8EDC39F4C7E04DDEC76A7562686271ED91E3A1F190DE8FD2E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C30A3B31C63366F72535872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A50286AD670B6259125002B1117B3ED6968387B35DC5959A24AD0703CEB2EF9A27823CB91A9FED034534781492E4B8EEADAE4FDBF11360AC9BBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF224028874FA1883FAB3C97EBF49DFF045DD5E833E2FEC1D83D84D5491425B02545CF0F9AF1251E13470327EB0AC8E693DD23636BC9D77FE08E1833661E1348261DEEF12AD5DBE27C5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojD5rM0r3KxnGOqkLo3XuRSA== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140C4D7CB3A1B67945B8E7FF402C01AF1B90E976F1E549384A20152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 12/36] 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------579rNAyPnzzAqu0YHiJb2G4u Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey thanks for the patch! Please see my comments below. On 14.08.2024 16:55, Sergey Kaplun wrote: > This patch moves the aforementioned test from the to the > directory, includes it in , and names the subtests. + changed formatting > > Part of tarantool/tarantool#9398 > --- > test/LuaJIT-tests/lang/hook_active.lua | 102 +++++++++++++++++++++++++ > test/LuaJIT-tests/lang/index | 1 + > test/LuaJIT-tests/misc/hook_active.lua | 95 ----------------------- > 3 files changed, 103 insertions(+), 95 deletions(-) > create mode 100644 test/LuaJIT-tests/lang/hook_active.lua > delete mode 100644 test/LuaJIT-tests/misc/hook_active.lua > > diff --git a/test/LuaJIT-tests/lang/hook_active.lua b/test/LuaJIT-tests/lang/hook_active.lua > new file mode 100644 > index 00000000..c82670f5 > --- /dev/null > +++ b/test/LuaJIT-tests/lang/hook_active.lua > @@ -0,0 +1,102 @@ > +local ctest = require("libctest") > + > +local called = 0 > +local function clearhook() debug.sethook(nil, "", 0) end > + > +do --- Return from pcall with active hook must prepend true. FF pcall. > + called = 0 > + debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1) add more spaces > + do local x = 1 end > + assert(called == 1) > +end > + > +do --- Hook with special caught error must not unblock hooks. FF pcall. > + called = 0 > + debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1) add more spaces > + do local x = 1 end > + assert(called == 1) > +end > + > +do --- Hook with caught error must not unblock hooks. FF pcall. > + called = 0 > + local function p2() error("") end > + debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1) add more spaces here and below > + do local x = 1 end > + assert(called == 1) > +end > + > +do --- Hook with special caught error must not unblock hooks. C pcall. > + called = 0 > + debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1) add more spaces > + do local x = 1 end > + assert(called == 1) > +end > + > +do --- Hook with caught error must not unblock hooks. C pcall missed dot at the end > + called = 0 > + local function p2() error("") end > + debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1) > + do local x = 1 end > + assert(called == 1) > +end > + > +do --- Regular pcall must not block hooks. > + debug.sethook(function() called=called+1 end, "", 1) add more spaces > + pcall(function() end) > + called = 0 > + do local x = 1 end > + assert(called > 0) > + pcall(function() error("") end) > + called = 0 > + do local x = 1 end > + assert(called > 0) > + ctest.pcall(function() end) > + called = 0 > + do local x = 1 end > + assert(called > 0) > + ctest.pcall(function() error("") end) > + called = 0 > + do local x = 1 end > + assert(called > 0) > + clearhook() > +end > + > +do --- Hook with uncaught error must unblock hooks. FF pcall missed dot at the end > + called = 0 > + pcall(function() > + debug.sethook(function() > + local old = called > + called = 1 > + if old == 0 then error("") end > + end, "", 1) > + do local x = 1 end > + end) > + assert(called == 1) > + called = 2 > + do local x = 1 end > + assert(called == 1, "hook not unblocked after uncaught error") > + clearhook() > + called = 2 > + do local x = 1 end > + assert(called == 2) > +end > + > +do --- Hook with uncaught error must unblock hooks. C pcall missed dot at the end > + called = 0 > + ctest.pcall(function() > + debug.sethook(function() > + local old = called > + called = 1 > + if old == 0 then error("") end > + end, "", 1) > + do local x = 1 end > + end) > + assert(called == 1) > + called = 2 > + do local x = 1 end > + assert(called == 1, "hook not unblocked after uncaught error") > + clearhook() > + called = 2 > + do local x = 1 end > + assert(called == 2) > +end > diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index > index 274425bf..8cecfa08 100644 > --- a/test/LuaJIT-tests/lang/index > +++ b/test/LuaJIT-tests/lang/index > @@ -8,6 +8,7 @@ compare_nan.lua > constant > dualnum.lua > for.lua > +hook_active.lua > length.lua > lightud.lua > modulo.lua > diff --git a/test/LuaJIT-tests/misc/hook_active.lua b/test/LuaJIT-tests/misc/hook_active.lua > deleted file mode 100644 > index 37dfc379..00000000 > --- a/test/LuaJIT-tests/misc/hook_active.lua > +++ /dev/null > @@ -1,95 +0,0 @@ > -local ctest = require("ctest") > - > -local called = 0 > -local function clearhook() debug.sethook(nil, "", 0) end > - > --- Return from pcall with active hook must prepend true. FF pcall. > -called = 0 > -debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1) > -do local x = 1 end > -assert(called == 1) > - > --- Hook with special caught error must not unblock hooks. FF pcall. > -called = 0 > -debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1) > -do local x = 1 end > -assert(called == 1) > - > --- Hook with caught error must not unblock hooks. FF pcall. > -called = 0 > -local function p2() error("") end > -debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1) > -do local x = 1 end > -assert(called == 1) > - > --- Hook with special caught error must not unblock hooks. C pcall. > -called = 0 > -debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1) > -do local x = 1 end > -assert(called == 1) > - > --- Hook with caught error must not unblock hooks. C pcall > -called = 0 > -local function p2() error("") end > -debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1) > -do local x = 1 end > -assert(called == 1) > - > --- Regular pcall must not block hooks. > -debug.sethook(function() called=called+1 end, "", 1) > -pcall(function() end) > -called = 0 > -do local x = 1 end > -assert(called > 0) > -pcall(function() error("") end) > -called = 0 > -do local x = 1 end > -assert(called > 0) > -ctest.pcall(function() end) > -called = 0 > -do local x = 1 end > -assert(called > 0) > -ctest.pcall(function() error("") end) > -called = 0 > -do local x = 1 end > -assert(called > 0) > -clearhook() > - > --- Hook with uncaught error must unblock hooks. FF pcall > -called = 0 > -pcall(function() > - debug.sethook(function() > - local old = called > - called = 1 > - if old == 0 then error("") end > - end, "", 1) > - do local x = 1 end > -end) > -assert(called == 1) > -called = 2 > -do local x = 1 end > -assert(called == 1, "hook not unblocked after uncaught error") > -clearhook() > -called = 2 > -do local x = 1 end > -assert(called == 2) > - > --- Hook with uncaught error must unblock hooks. C pcall > -called = 0 > -ctest.pcall(function() > - debug.sethook(function() > - local old = called > - called = 1 > - if old == 0 then error("") end > - end, "", 1) > - do local x = 1 end > -end) > -assert(called == 1) > -called = 2 > -do local x = 1 end > -assert(called == 1, "hook not unblocked after uncaught error") > -clearhook() > -called = 2 > -do local x = 1 end > -assert(called == 2) > - --------------579rNAyPnzzAqu0YHiJb2G4u Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey

thanks for the patch! Please see my comments below.


On 14.08.2024 16:55, Sergey Kaplun wrote:
This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtests.
+ changed formatting

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/hook_active.lua | 102 +++++++++++++++++++++++++
 test/LuaJIT-tests/lang/index           |   1 +
 test/LuaJIT-tests/misc/hook_active.lua |  95 -----------------------
 3 files changed, 103 insertions(+), 95 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/hook_active.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_active.lua

diff --git a/test/LuaJIT-tests/lang/hook_active.lua b/test/LuaJIT-tests/lang/hook_active.lua
new file mode 100644
index 00000000..c82670f5
--- /dev/null
+++ b/test/LuaJIT-tests/lang/hook_active.lua
@@ -0,0 +1,102 @@
+local ctest = require("libctest")
+
+local called = 0
+local function clearhook() debug.sethook(nil, "", 0) end
+
+do --- Return from pcall with active hook must prepend true. FF pcall.
+  called = 0
+  debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
add more spaces
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with special caught error must not unblock hooks. FF pcall.
+  called = 0
+  debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
add more spaces
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with caught error must not unblock hooks. FF pcall.
+  called = 0
+  local function p2() error("") end
+  debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
add more spaces here and below
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with special caught error must not unblock hooks. C pcall.
+  called = 0
+  debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
add more spaces
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with caught error must not unblock hooks. C pcall
missed dot at the end
+  called = 0
+  local function p2() error("") end
+  debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Regular pcall must not block hooks.
+  debug.sethook(function() called=called+1 end, "", 1)
add more spaces
+  pcall(function() end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  pcall(function() error("") end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  ctest.pcall(function() end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  ctest.pcall(function() error("") end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  clearhook()
+end
+
+do --- Hook with uncaught error must unblock hooks. FF pcall
missed dot at the end
+  called = 0
+  pcall(function()
+    debug.sethook(function()
+      local old = called
+      called = 1
+      if old == 0 then error("") end
+    end, "", 1)
+    do local x = 1 end
+  end)
+  assert(called == 1)
+  called = 2
+  do local x = 1 end
+  assert(called == 1, "hook not unblocked after uncaught error")
+  clearhook()
+  called = 2
+  do local x = 1 end
+  assert(called == 2)
+end
+
+do --- Hook with uncaught error must unblock hooks. C pcall
missed dot at the end
+  called = 0
+  ctest.pcall(function()
+    debug.sethook(function()
+      local old = called
+      called = 1
+      if old == 0 then error("") end
+    end, "", 1)
+    do local x = 1 end
+  end)
+  assert(called == 1)
+  called = 2
+  do local x = 1 end
+  assert(called == 1, "hook not unblocked after uncaught error")
+  clearhook()
+  called = 2
+  do local x = 1 end
+  assert(called == 2)
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 274425bf..8cecfa08 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -8,6 +8,7 @@ compare_nan.lua
 constant
 dualnum.lua
 for.lua
+hook_active.lua
 length.lua
 lightud.lua
 modulo.lua
diff --git a/test/LuaJIT-tests/misc/hook_active.lua b/test/LuaJIT-tests/misc/hook_active.lua
deleted file mode 100644
index 37dfc379..00000000
--- a/test/LuaJIT-tests/misc/hook_active.lua
+++ /dev/null
@@ -1,95 +0,0 @@
-local ctest = require("ctest")
-
-local called = 0
-local function clearhook() debug.sethook(nil, "", 0) end
-
--- Return from pcall with active hook must prepend true. FF pcall.
-called = 0
-debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with special caught error must not unblock hooks. FF pcall.
-called = 0
-debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with caught error must not unblock hooks. FF pcall.
-called = 0
-local function p2() error("") end
-debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with special caught error must not unblock hooks. C pcall.
-called = 0
-debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with caught error must not unblock hooks. C pcall
-called = 0
-local function p2() error("") end
-debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Regular pcall must not block hooks.
-debug.sethook(function() called=called+1 end, "", 1)
-pcall(function() end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-pcall(function() error("") end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-ctest.pcall(function() end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-ctest.pcall(function() error("") end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-clearhook()
-
--- Hook with uncaught error must unblock hooks. FF pcall
-called = 0
-pcall(function()
-  debug.sethook(function()
-    local old = called
-    called = 1
-    if old == 0 then error("") end
-  end, "", 1)
-  do local x = 1 end
-end)
-assert(called == 1)
-called = 2
-do local x = 1 end
-assert(called == 1, "hook not unblocked after uncaught error")
-clearhook()
-called = 2
-do local x = 1 end
-assert(called == 2)
-
--- Hook with uncaught error must unblock hooks. C pcall
-called = 0
-ctest.pcall(function()
-  debug.sethook(function()
-    local old = called
-    called = 1
-    if old == 0 then error("") end
-  end, "", 1)
-  do local x = 1 end
-end)
-assert(called == 1)
-called = 2
-do local x = 1 end
-assert(called == 1, "hook not unblocked after uncaught error")
-clearhook()
-called = 2
-do local x = 1 end
-assert(called == 2)
-
--------------579rNAyPnzzAqu0YHiJb2G4u--