Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin <imun@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	Sergey Ostanevich <sergos@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 luajit 1/3] test: add auxillary module for testing
Date: Wed, 15 Apr 2020 03:34:25 +0300	[thread overview]
Message-ID: <72c427cc218d5f9d7d62ef752cbcf89a69fd1665.1586906667.git.imun@tarantool.org> (raw)
In-Reply-To: <cover.1586906667.git.imun@tarantool.org>

The introduced Lua module provides the <selfrun> routine for testing the
platform behaviour in some cases e.g. when test case leads to panic and
error message need to be checked after the platform failure.

Signed-off-by: Igor Munkin <imun@tarantool.org>
---
 test/suite.ini |  1 +
 test/utils.lua | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 test/utils.lua

diff --git a/test/suite.ini b/test/suite.ini
index 3e860c9..0b9d5e2 100644
--- a/test/suite.ini
+++ b/test/suite.ini
@@ -1,5 +1,6 @@
 [default]
 core = app
 description = Luajit tests
+lua_libs = utils.lua
 is_parallel = True
 pretest_clean = True
diff --git a/test/utils.lua b/test/utils.lua
new file mode 100644
index 0000000..5e6f8d9
--- /dev/null
+++ b/test/utils.lua
@@ -0,0 +1,33 @@
+local M = { }
+
+local tap = require('tap')
+
+function M.selfrun(arg, checks)
+  local test = tap.test(arg[0]:match('/?(.+)%.test%.lua'))
+
+  test:plan(#checks)
+
+  local vars = {
+    LUABIN = arg[-1],
+    SCRIPT = arg[0],
+    PATH   = arg[0]:gsub('%.test%.lua', ''),
+    SUFFIX = package.cpath:match('?.(%a+);'),
+  }
+
+  local cmd = string.gsub('LUA_CPATH="$LUA_CPATH;<PATH>/?.<SUFFIX>" ' ..
+                          'LUA_PATH="$LUA_PATH;<PATH>/?.lua" ' ..
+                          'LD_LIBRARY_PATH=<PATH> ' ..
+                          '<LUABIN> 2>&1 <SCRIPT>', '%<(%w+)>', vars)
+
+  for _, ch in pairs(checks) do
+    local res
+    local proc = io.popen((cmd .. (' %s'):rep(#ch.arg)):format(unpack(ch.arg)))
+    for s in proc:lines() do res = s end
+    assert(res, 'proc:lines failed')
+    test:is(res, ch.res, ch.msg)
+  end
+
+  os.exit(test:check() and 0 or 1)
+end
+
+return M
-- 
2.25.0

  reply	other threads:[~2020-04-15  0:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  0:34 [Tarantool-patches] [PATCH v2 luajit 0/3] Trace abort on FFI sandwich or mode change Igor Munkin
2020-04-15  0:34 ` Igor Munkin [this message]
2020-04-15  0:34 ` [Tarantool-patches] [PATCH v2 luajit 2/3] jit: abort trace recording and execution for C API Igor Munkin
2020-04-15  0:34 ` [Tarantool-patches] [PATCH v2 luajit 3/3] jit: abort trace execution on JIT mode change Igor Munkin
2020-04-19 16:16 ` [Tarantool-patches] [PATCH v2 luajit 0/3] Trace abort on FFI sandwich or " Vladislav Shpilevoy
2020-04-19 17:51   ` Igor Munkin
2020-04-19 20:16 ` Igor Munkin
2020-04-20  7:09 ` Kirill Yukhin

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=72c427cc218d5f9d7d62ef752cbcf89a69fd1665.1586906667.git.imun@tarantool.org \
    --to=imun@tarantool.org \
    --cc=sergos@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 luajit 1/3] test: add auxillary module for testing' \
    /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