Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
	Maxim Kokryashkin <m.kokryashkin@tarantool.org>,
	Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 1/3] test: split utils.lua into several modules
Date: Tue, 27 Jun 2023 13:28:48 +0000	[thread overview]
Message-ID: <b0d79e9b118f9a8444c9ff3dad6175519b0d5b86.1687872015.git.imun@tarantool.org> (raw)
In-Reply-To: <cover.1683720396.git.skaplun@tarantool.org>

The next patch introduces a separate JIT-related module with convenient
utils for JIT engine testing. Considering this change it looks vital to
make a structured utils distributed module instead of "all in one" Lua
chunk. As a result the original utils.lua is split into the several
modules per subsystem to be tested (e.g. GC, frontend, profilers, etc.).

Lazy loading of the introduced submodules allows to use this utils in
all test chunks regardless LuaJIT configuration (e.g. with JIT engine
disabled, without FFI support, etc) and do not spoil utils table with
the excess helpers.

Signed-off-by: Igor Munkin <imun@tarantool.org>
---

Sergey, considering the changes you've made in the second patch, I
propose to finally split utils.lua into submodules that loads lazily.
I've pushed my commit on your branch prior to your patchset. If you have
some notes regarding this, please share them. Otherwise, I'll push this
into the LuaJIT long-term branches.


You can also find the trivial changes made within your commits below:

================================================================================

diff --git a/test/tarantool-tests/lj-981-folding-0.test.lua b/test/tarantool-tests/lj-981-folding-0.test.lua
index 64473ba3..d156f53d 100644
--- a/test/tarantool-tests/lj-981-folding-0.test.lua
+++ b/test/tarantool-tests/lj-981-folding-0.test.lua
@@ -8,7 +8,7 @@ local test = tap.test('lj-981-folding-0'):skipcond({
 -- for -0 IR constant as table index.
 -- See also, https://github.com/LuaJIT/LuaJIT/issues/981.
 
-local jparse = require('utils.jit_parse')
+local jparse = require('utils').jit.parse
 
 -- XXX: Avoid any other traces compilation due to hotcount
 -- collisions for predictable results.
diff --git a/test/tarantool-tests/unit-jit-parse.test.lua b/test/tarantool-tests/unit-jit-parse.test.lua
index e9c0bb80..e4445bf4 100644
--- a/test/tarantool-tests/unit-jit-parse.test.lua
+++ b/test/tarantool-tests/unit-jit-parse.test.lua
@@ -4,7 +4,7 @@ local test = tap.test('unit-jit-parse'):skipcond({
   ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
 })
 
-local jparse = require('utils.jit_parse')
+local jparse = require('utils').jit.parse
 
 local expected_irs = {
   -- The different exotic builds may add different IR

================================================================================

 test/tarantool-tests/CMakeLists.txt           |   2 +-
 .../bc-jit-unpatching.test.lua                |   5 +-
 .../fix-gc-setupvalue.test.lua                |   4 +-
 .../gh-4427-ffi-sandwich.test.lua             |   2 +-
 .../gh-5813-resolving-of-c-symbols.test.lua   |   2 +-
 ...-missed-carg1-in-bctsetr-fallback.test.lua |   2 +-
 .../lj-351-print-tostring-number.test.lua     |   2 +-
 .../lj-586-debug-non-string-error.test.lua    |   2 +-
 .../lj-flush-on-trace.test.lua                |   2 +-
 .../misclib-getmetrics-lapi.test.lua          |   2 +-
 .../misclib-memprof-lapi.test.lua             |   2 +-
 .../misclib-sysprof-lapi.test.lua             |   2 +-
 test/tarantool-tests/utils.lua                | 125 ------------------
 test/tarantool-tests/utils/exec.lua           |  52 ++++++++
 test/tarantool-tests/utils/frontend.lua       |  25 ++++
 test/tarantool-tests/utils/gc.lua             |  33 +++++
 test/tarantool-tests/utils/init.lua           |   7 +
 test/tarantool-tests/utils/jit/const.lua      |   8 ++
 test/tarantool-tests/utils/jit/init.lua       |   7 +
 test/tarantool-tests/utils/tools.lua          |  15 +++
 20 files changed, 162 insertions(+), 139 deletions(-)
 delete mode 100644 test/tarantool-tests/utils.lua
 create mode 100644 test/tarantool-tests/utils/exec.lua
 create mode 100644 test/tarantool-tests/utils/frontend.lua
 create mode 100644 test/tarantool-tests/utils/gc.lua
 create mode 100644 test/tarantool-tests/utils/init.lua
 create mode 100644 test/tarantool-tests/utils/jit/const.lua
 create mode 100644 test/tarantool-tests/utils/jit/init.lua
 create mode 100644 test/tarantool-tests/utils/tools.lua

diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 527905b6..14a98cf2 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -75,7 +75,7 @@ add_subdirectory(lj-flush-on-trace)
 # directory), so LUA_PATH need to be updated.
 make_lua_path(LUA_PATH
   PATHS
-    ${CMAKE_CURRENT_SOURCE_DIR}/?.lua
+    ${CMAKE_CURRENT_SOURCE_DIR}/?/init.lua
     ${PROJECT_SOURCE_DIR}/tools/?.lua
     ${LUAJIT_SOURCE_DIR}/?.lua
     ${LUAJIT_BINARY_DIR}/?.lua
diff --git a/test/tarantool-tests/bc-jit-unpatching.test.lua b/test/tarantool-tests/bc-jit-unpatching.test.lua
index 2c3b7c9a..f4f148c9 100644
--- a/test/tarantool-tests/bc-jit-unpatching.test.lua
+++ b/test/tarantool-tests/bc-jit-unpatching.test.lua
@@ -13,12 +13,13 @@ end
 
 local ret1bc = 'RET1%s*1%s*2'
 -- Check that this bytecode still persists.
-assert(utils.hasbc(load(string.dump(f)), ret1bc))
+assert(utils.frontend.hasbc(load(string.dump(f)), ret1bc))
 
 jit.opt.start('hotloop=1', 'hotexit=1')
 -- Compile function to get JLOOP bytecode in recursion.
 f(5)
 
-test:ok(utils.hasbc(load(string.dump(f)), ret1bc), 'bytecode unpatching is OK ')
+test:ok(utils.frontend.hasbc(load(string.dump(f)), ret1bc),
+        'bytecode unpatching is OK')
 
 os.exit(test:check() and 0 or 1)
diff --git a/test/tarantool-tests/fix-gc-setupvalue.test.lua b/test/tarantool-tests/fix-gc-setupvalue.test.lua
index c94d5d85..21acc9bf 100644
--- a/test/tarantool-tests/fix-gc-setupvalue.test.lua
+++ b/test/tarantool-tests/fix-gc-setupvalue.test.lua
@@ -1,5 +1,5 @@
 local tap = require('tap')
-local utils = require('utils')
+local gcisblack = require('utils').gc.isblack
 
 local test = tap.test('fix-gc-setupvalue')
 test:plan(1)
@@ -40,7 +40,7 @@ local oldstepmul = collectgarbage('setstepmul', 1)
 
 -- `parent()` function is marked before `child()`, so wait until
 -- it becomes black and proceed with the test.
-while not utils.gcisblack(_G.parent) do
+while not gcisblack(_G.parent) do
   collectgarbage('step')
 end
 
diff --git a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
index 86544196..677a6085 100644
--- a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
+++ b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
@@ -8,7 +8,7 @@ test:plan(2)
 
 -- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY>
 -- with the given environment, launch options and CLI arguments.
-local script = require('utils').makecmd(arg, {
+local script = require('utils').exec.makecmd(arg, {
   -- XXX: Apple tries their best to "protect their users from
   -- malware". As a result SIP (see the link[1] below) has been
   -- designed and released. Now, Apple developers are so
diff --git a/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua b/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua
index 9f2c5f85..1209d288 100644
--- a/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua
+++ b/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua
@@ -17,7 +17,7 @@ local symtab = require "utils.symtab"
 local testboth = require "resboth"
 local testhash = require "reshash"
 local testgnuhash = require "resgnuhash"
-local profilename = require("utils").profilename
+local profilename = require("utils").tools.profilename
 
 local TMP_BINFILE = profilename("memprofdata.tmp.bin")
 
diff --git a/test/tarantool-tests/gh-6084-missed-carg1-in-bctsetr-fallback.test.lua b/test/tarantool-tests/gh-6084-missed-carg1-in-bctsetr-fallback.test.lua
index 86bbabe3..10db7603 100644
--- a/test/tarantool-tests/gh-6084-missed-carg1-in-bctsetr-fallback.test.lua
+++ b/test/tarantool-tests/gh-6084-missed-carg1-in-bctsetr-fallback.test.lua
@@ -15,7 +15,7 @@ test:plan(2)
 
 -- XXX: We need to make sure the bytecode is present in the chosen
 -- built-in to make sure our test is still valid.
-assert(utils.hasbc(table.move, 'TSETR'))
+assert(utils.frontend.hasbc(table.move, 'TSETR'))
 
 -- `t` table asize equals 1. Just copy its first element (1)
 -- to the field by index 2 > 1, to fallback inside TSETR.
diff --git a/test/tarantool-tests/lj-351-print-tostring-number.test.lua b/test/tarantool-tests/lj-351-print-tostring-number.test.lua
index 72a9ec2b..b7041f2a 100644
--- a/test/tarantool-tests/lj-351-print-tostring-number.test.lua
+++ b/test/tarantool-tests/lj-351-print-tostring-number.test.lua
@@ -3,7 +3,7 @@ local tap = require('tap')
 local test = tap.test('lj-351-print-tostring-number')
 test:plan(8)
 
-local script = require('utils').makecmd(arg)
+local script = require('utils').exec.makecmd(arg)
 
 local cases = {
   {typename = 'nil', value = 'nil'},
diff --git a/test/tarantool-tests/lj-586-debug-non-string-error.test.lua b/test/tarantool-tests/lj-586-debug-non-string-error.test.lua
index dcb730a2..c00301a1 100644
--- a/test/tarantool-tests/lj-586-debug-non-string-error.test.lua
+++ b/test/tarantool-tests/lj-586-debug-non-string-error.test.lua
@@ -21,7 +21,7 @@ test:plan(1)
 -- Debugger prompt.
 local ldb = 'lua_debug> '
 local magic = 42
-local luabin = utils.luacmd(arg)
+local luabin = utils.exec.luacmd(arg)
 local stderr = {
   -- XXX: The first debugger prompt printed at the start.
   ldb,
diff --git a/test/tarantool-tests/lj-flush-on-trace.test.lua b/test/tarantool-tests/lj-flush-on-trace.test.lua
index 46db4d2a..fe740087 100644
--- a/test/tarantool-tests/lj-flush-on-trace.test.lua
+++ b/test/tarantool-tests/lj-flush-on-trace.test.lua
@@ -8,7 +8,7 @@ test:plan(2)
 
 -- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY>
 -- with the given environment, launch options and CLI arguments.
-local script = require('utils').makecmd(arg, {
+local script = require('utils').exec.makecmd(arg, {
   -- XXX: Apple tries their best to "protect their users from
   -- malware". As a result SIP (see the link[1] below) has been
   -- designed and released. Now, Apple developers are so
diff --git a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
index 881e717b..0ee71499 100644
--- a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
+++ b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
@@ -10,7 +10,7 @@ local test = tap.test("lib-misc-getmetrics"):skipcond({
 
 test:plan(10)
 
-local MAXNINS = require('utils').const.maxnins
+local MAXNINS = require('utils').jit.const.maxnins
 local jit_opt_default = {
     3, -- level
     "hotloop=56",
diff --git a/test/tarantool-tests/misclib-memprof-lapi.test.lua b/test/tarantool-tests/misclib-memprof-lapi.test.lua
index 4e413c88..eae20893 100644
--- a/test/tarantool-tests/misclib-memprof-lapi.test.lua
+++ b/test/tarantool-tests/misclib-memprof-lapi.test.lua
@@ -26,7 +26,7 @@ local bufread = require "utils.bufread"
 local memprof = require "memprof.parse"
 local process = require "memprof.process"
 local symtab = require "utils.symtab"
-local profilename = require("utils").profilename
+local profilename = require("utils").tools.profilename
 
 local TMP_BINFILE = profilename("memprofdata.tmp.bin")
 local BAD_PATH = profilename("memprofdata/tmp.bin")
diff --git a/test/tarantool-tests/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/misclib-sysprof-lapi.test.lua
index 96eaaab6..2f0635db 100644
--- a/test/tarantool-tests/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/misclib-sysprof-lapi.test.lua
@@ -15,7 +15,7 @@ pcall(jit.flush)
 local bufread = require("utils.bufread")
 local symtab = require("utils.symtab")
 local sysprof = require("sysprof.parse")
-local profilename = require("utils").profilename
+local profilename = require("utils").tools.profilename
 
 local TMP_BINFILE = profilename("sysprofdata.tmp.bin")
 local BAD_PATH = profilename("sysprofdata/tmp.bin")
diff --git a/test/tarantool-tests/utils.lua b/test/tarantool-tests/utils.lua
deleted file mode 100644
index 8c1538d6..00000000
--- a/test/tarantool-tests/utils.lua
+++ /dev/null
@@ -1,125 +0,0 @@
-local M = {}
-
-local ffi = require('ffi')
-local bc = require('jit.bc')
-local bit = require('bit')
-
-local LJ_GC_BLACK = 0x04
-local LJ_STR_HASHLEN = 8
-local GCref = ffi.abi('gc64') and 'uint64_t' or 'uint32_t'
-
-ffi.cdef([[
-  typedef struct {
-]]..GCref..[[ nextgc;
-    uint8_t   marked;
-    uint8_t   gct;
-    /* Need this fields for correct alignment and sizeof. */
-    uint8_t   misc1;
-    uint8_t   misc2;
-  } GCHeader;
-]])
-
-function M.gcisblack(obj)
-  local objtype = type(obj)
-  local address = objtype == 'string'
-    -- XXX: get strdata first and go back to GCHeader.
-    and ffi.cast('char *', obj) - (ffi.sizeof('GCHeader') + LJ_STR_HASHLEN)
-    -- XXX: FFI ABI forbids to cast functions objects
-    -- to non-functional pointers, but we can get their address
-    -- via tostring.
-    or tonumber((tostring(obj):gsub(objtype .. ': ', '')))
-  local marked = ffi.cast('GCHeader *', address).marked
-  return bit.band(marked, LJ_GC_BLACK) == LJ_GC_BLACK
-end
-
-function M.luacmd(args)
-  -- arg[-1] is guaranteed to be not nil.
-  local idx = -2
-  while args[idx] do
-    assert(type(args[idx]) == 'string', 'Command part have to be a string')
-    idx = idx - 1
-  end
-  -- return the full command with flags.
-  return table.concat(args, ' ', idx + 1, -1)
-end
-
-local function makeenv(tabenv)
-  if tabenv == nil then return '' end
-  local flatenv = {}
-  for var, value in pairs(tabenv) do
-    table.insert(flatenv, ('%s=%s'):format(var, value))
-  end
-  return table.concat(flatenv, ' ')
-end
-
--- <makecmd> creates a command that runs %testname%/script.lua by
--- <LUAJIT_TEST_BINARY> with the given environment, launch options
--- and CLI arguments. The function yields an object (i.e. table)
--- with the aforementioned parameters. To launch the command just
--- call the object.
-function M.makecmd(arg, opts)
-  return setmetatable({
-    LUABIN = M.luacmd(arg),
-    SCRIPT = opts and opts.script or arg[0]:gsub('%.test%.lua$', '/script.lua'),
-    ENV = opts and makeenv(opts.env) or '',
-    REDIRECT = opts and opts.redirect or '',
-  }, {
-    __call = function(self, ...)
-      -- This line just makes the command for <io.popen> by the
-      -- following steps:
-      -- 1. Replace the placeholders with the corresponding values
-      --    given to the command constructor (e.g. script, env).
-      -- 2. Join all CLI arguments given to the __call metamethod.
-      -- 3. Concatenate the results of step 1 and step 2 to obtain
-      --    the resulting command.
-      local cmd = ('<ENV> <LUABIN> <REDIRECT> <SCRIPT>'):gsub('%<(%w+)>', self)
-                  .. (' %s'):rep(select('#', ...)):format(...)
-      -- Trim both leading and trailing whitespace from the output
-      -- produced by the child process.
-      return io.popen(cmd):read('*all'):gsub('^%s+', ''):gsub('%s+$', '')
-    end
-  })
-end
-
-function M.hasbc(f, bytecode)
-  assert(type(f) == 'function', 'argument #1 should be a function')
-  assert(type(bytecode) == 'string', 'argument #2 should be a string')
-  local function empty() end
-  local hasbc = false
-  -- Check the bytecode entry line by line.
-  local out = {
-    write = function(out, line)
-      if line:match(bytecode) then
-        hasbc = true
-        out.write = empty
-      end
-    end,
-    flush = empty,
-    close = empty,
-  }
-  bc.dump(f, out)
-  return hasbc
-end
-
-function M.profilename(name)
-  local vardir = os.getenv('LUAJIT_TEST_VARDIR')
-  -- Replace pattern will change directory name of the generated
-  -- profile to LUAJIT_TEST_VARDIR if it is set in the process
-  -- environment. Otherwise, the original dirname is left intact.
-  -- As a basename for this profile the test name is concatenated
-  -- with the name given as an argument.
-  local replacepattern = ('%s/%s-%s'):format(vardir or '%1', '%2', name)
-  -- XXX: return only the resulting string.
-  return (arg[0]:gsub('^(.+)/([^/]+)%.test%.lua$', replacepattern))
-end
-
-M.const = {
-  -- XXX: Max nins is limited by max IRRef, that equals to
-  -- REF_DROP - REF_BIAS. Unfortunately, these constants are not
-  -- provided to Lua space, so we ought to make some math:
-  -- * REF_DROP = 0xffff
-  -- * REF_BIAS = 0x8000
-  maxnins = 0xffff - 0x8000,
-}
-
-return M
diff --git a/test/tarantool-tests/utils/exec.lua b/test/tarantool-tests/utils/exec.lua
new file mode 100644
index 00000000..a56ca2dc
--- /dev/null
+++ b/test/tarantool-tests/utils/exec.lua
@@ -0,0 +1,52 @@
+local M = {}
+
+function M.luacmd(args)
+  -- arg[-1] is guaranteed to be not nil.
+  local idx = -2
+  while args[idx] do
+    assert(type(args[idx]) == 'string', 'Command part have to be a string')
+    idx = idx - 1
+  end
+  -- return the full command with flags.
+  return table.concat(args, ' ', idx + 1, -1)
+end
+
+local function makeenv(tabenv)
+  if tabenv == nil then return '' end
+  local flatenv = {}
+  for var, value in pairs(tabenv) do
+    table.insert(flatenv, ('%s=%s'):format(var, value))
+  end
+  return table.concat(flatenv, ' ')
+end
+
+-- <makecmd> creates a command that runs %testname%/script.lua by
+-- <LUAJIT_TEST_BINARY> with the given environment, launch options
+-- and CLI arguments. The function yields an object (i.e. table)
+-- with the aforementioned parameters. To launch the command just
+-- call the object.
+function M.makecmd(arg, opts)
+  return setmetatable({
+    LUABIN = M.luacmd(arg),
+    SCRIPT = opts and opts.script or arg[0]:gsub('%.test%.lua$', '/script.lua'),
+    ENV = opts and makeenv(opts.env) or '',
+    REDIRECT = opts and opts.redirect or '',
+  }, {
+    __call = function(self, ...)
+      -- This line just makes the command for <io.popen> by the
+      -- following steps:
+      -- 1. Replace the placeholders with the corresponding values
+      --    given to the command constructor (e.g. script, env).
+      -- 2. Join all CLI arguments given to the __call metamethod.
+      -- 3. Concatenate the results of step 1 and step 2 to obtain
+      --    the resulting command.
+      local cmd = ('<ENV> <LUABIN> <REDIRECT> <SCRIPT>'):gsub('%<(%w+)>', self)
+                  .. (' %s'):rep(select('#', ...)):format(...)
+      -- Trim both leading and trailing whitespace from the output
+      -- produced by the child process.
+      return io.popen(cmd):read('*all'):gsub('^%s+', ''):gsub('%s+$', '')
+    end
+  })
+end
+
+return M
diff --git a/test/tarantool-tests/utils/frontend.lua b/test/tarantool-tests/utils/frontend.lua
new file mode 100644
index 00000000..2afebbb2
--- /dev/null
+++ b/test/tarantool-tests/utils/frontend.lua
@@ -0,0 +1,25 @@
+local M = {}
+
+local bc = require('jit.bc')
+
+function M.hasbc(f, bytecode)
+  assert(type(f) == 'function', 'argument #1 should be a function')
+  assert(type(bytecode) == 'string', 'argument #2 should be a string')
+  local function empty() end
+  local hasbc = false
+  -- Check the bytecode entry line by line.
+  local out = {
+    write = function(out, line)
+      if line:match(bytecode) then
+        hasbc = true
+        out.write = empty
+      end
+    end,
+    flush = empty,
+    close = empty,
+  }
+  bc.dump(f, out)
+  return hasbc
+end
+
+return M
diff --git a/test/tarantool-tests/utils/gc.lua b/test/tarantool-tests/utils/gc.lua
new file mode 100644
index 00000000..22094f51
--- /dev/null
+++ b/test/tarantool-tests/utils/gc.lua
@@ -0,0 +1,33 @@
+local M = {}
+
+local ffi = require('ffi')
+
+local LJ_GC_BLACK = 0x04
+local LJ_STR_HASHLEN = 8
+local GCref = ffi.abi('gc64') and 'uint64_t' or 'uint32_t'
+
+ffi.cdef([[
+  typedef struct {
+]]..GCref..[[ nextgc;
+    uint8_t   marked;
+    uint8_t   gct;
+    /* Need this fields for correct alignment and sizeof. */
+    uint8_t   misc1;
+    uint8_t   misc2;
+  } GCHeader;
+]])
+
+function M.isblack(obj)
+  local objtype = type(obj)
+  local address = objtype == 'string'
+    -- XXX: get strdata first and go back to GCHeader.
+    and ffi.cast('char *', obj) - (ffi.sizeof('GCHeader') + LJ_STR_HASHLEN)
+    -- XXX: FFI ABI forbids to cast functions objects
+    -- to non-functional pointers, but we can get their address
+    -- via tostring.
+    or tonumber((tostring(obj):gsub(objtype .. ': ', '')))
+  local marked = ffi.cast('GCHeader *', address).marked
+  return bit.band(marked, LJ_GC_BLACK) == LJ_GC_BLACK
+end
+
+return M
diff --git a/test/tarantool-tests/utils/init.lua b/test/tarantool-tests/utils/init.lua
new file mode 100644
index 00000000..ecf55ee7
--- /dev/null
+++ b/test/tarantool-tests/utils/init.lua
@@ -0,0 +1,7 @@
+return setmetatable({}, {
+  __index = function(self, k)
+    assert(type(k) == 'string', "The name of `utils' submodule is required")
+    rawset(self, k, require(('utils.%s'):format(k)))
+    return rawget(self, k)
+  end,
+})
diff --git a/test/tarantool-tests/utils/jit/const.lua b/test/tarantool-tests/utils/jit/const.lua
new file mode 100644
index 00000000..13e58830
--- /dev/null
+++ b/test/tarantool-tests/utils/jit/const.lua
@@ -0,0 +1,8 @@
+return {
+  -- XXX: Max nins is limited by max IRRef, that equals to
+  -- REF_DROP - REF_BIAS. Unfortunately, these constants are not
+  -- provided to Lua space, so we ought to make some math:
+  -- * REF_DROP = 0xffff
+  -- * REF_BIAS = 0x8000
+  maxnins = 0xffff - 0x8000,
+}
diff --git a/test/tarantool-tests/utils/jit/init.lua b/test/tarantool-tests/utils/jit/init.lua
new file mode 100644
index 00000000..56662214
--- /dev/null
+++ b/test/tarantool-tests/utils/jit/init.lua
@@ -0,0 +1,7 @@
+return setmetatable({}, {
+  __index = function(self, k)
+    assert(type(k) == 'string', "The name of `utils.jit' submodule is required")
+    rawset(self, k, require(('utils.jit.%s'):format(k)))
+    return rawget(self, k)
+  end,
+})
diff --git a/test/tarantool-tests/utils/tools.lua b/test/tarantool-tests/utils/tools.lua
new file mode 100644
index 00000000..f35c6922
--- /dev/null
+++ b/test/tarantool-tests/utils/tools.lua
@@ -0,0 +1,15 @@
+local M = {}
+
+function M.profilename(name)
+  local vardir = os.getenv('LUAJIT_TEST_VARDIR')
+  -- Replace pattern will change directory name of the generated
+  -- profile to LUAJIT_TEST_VARDIR if it is set in the process
+  -- environment. Otherwise, the original dirname is left intact.
+  -- As a basename for this profile the test name is concatenated
+  -- with the name given as an argument.
+  local replacepattern = ('%s/%s-%s'):format(vardir or '%1', '%2', name)
+  -- XXX: return only the resulting string.
+  return (arg[0]:gsub('^(.+)/([^/]+)%.test%.lua$', replacepattern))
+end
+
+return M
-- 
2.30.2


  parent reply	other threads:[~2023-06-27 13:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10 12:34 [Tarantool-patches] [PATCH luajit 0/2] Fix canonicalization of +-0.0 keys for IR_NEWREF Sergey Kaplun via Tarantool-patches
2023-05-10 12:34 ` [Tarantool-patches] [PATCH luajit 1/2] test: add utility for parsing `jit.dump` Sergey Kaplun via Tarantool-patches
2023-05-15 11:11   ` Maxim Kokryashkin via Tarantool-patches
2023-05-15 12:00     ` Maxim Kokryashkin via Tarantool-patches
2023-05-21  7:47       ` Sergey Kaplun via Tarantool-patches
2023-05-21  7:39     ` Sergey Kaplun via Tarantool-patches
2023-05-22  7:04       ` Sergey Kaplun via Tarantool-patches
2023-05-29 13:55       ` Maxim Kokryashkin via Tarantool-patches
2023-05-16 10:55   ` Sergey Bronnikov via Tarantool-patches
2023-05-22  7:02     ` Sergey Kaplun via Tarantool-patches
2023-05-22  9:14       ` Sergey Kaplun via Tarantool-patches
2023-05-10 12:34 ` [Tarantool-patches] [PATCH luajit 2/2] Fix canonicalization of +-0.0 keys for IR_NEWREF Sergey Kaplun via Tarantool-patches
2023-05-15 12:05   ` Maxim Kokryashkin via Tarantool-patches
2023-05-20 15:03     ` Sergey Kaplun via Tarantool-patches
2023-05-16 12:17   ` Sergey Bronnikov via Tarantool-patches
2023-05-20 14:54     ` Sergey Kaplun via Tarantool-patches
2023-05-22  7:55       ` Sergey Bronnikov via Tarantool-patches
2023-06-27 13:28 ` Igor Munkin via Tarantool-patches [this message]
2023-06-27 13:35   ` [Tarantool-patches] [PATCH luajit 1/3] test: split utils.lua into several modules Igor Munkin via Tarantool-patches
2023-06-28 11:36   ` Sergey Kaplun via Tarantool-patches
2023-06-28 16:07     ` Igor Munkin via Tarantool-patches
2023-07-04 17:10 ` [Tarantool-patches] [PATCH luajit 0/2] Fix canonicalization of +-0.0 keys for IR_NEWREF Igor Munkin 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=b0d79e9b118f9a8444c9ff3dad6175519b0d5b86.1687872015.git.imun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 1/3] test: split utils.lua into several modules' \
    /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