[Tarantool-patches] [PATCH 4/4] test: enable luajit-tap:lj-flush-on-trace tests

Igor Munkin imun at tarantool.org
Fri Mar 27 16:23:38 MSK 2020


The test is added as a CMake subdirectory and the runner executes
tarantool test.lua command via io.popen to check whether the platform
successfully finishes the execution or platform panic occurs.

Signed-off-by: Igor Munkin <imun at tarantool.org>
---
 test/CMakeLists.txt                     |  1 +
 test/app-tap/lj-flush-on-trace.test.lua | 30 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100755 test/app-tap/lj-flush-on-trace.test.lua

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index bceea4567..0ae3843e3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -60,6 +60,7 @@ add_subdirectory(app-tap)
 add_subdirectory(box)
 add_subdirectory(unit)
 add_subdirectory(luajit-tap/gh-4427-ffi-sandwich)
+add_subdirectory(luajit-tap/lj-flush-on-trace)
 
 # Move tarantoolctl config
 if (NOT ${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
diff --git a/test/app-tap/lj-flush-on-trace.test.lua b/test/app-tap/lj-flush-on-trace.test.lua
new file mode 100755
index 000000000..70b7bd9a2
--- /dev/null
+++ b/test/app-tap/lj-flush-on-trace.test.lua
@@ -0,0 +1,30 @@
+#!/usr/bin/env tarantool
+
+local tap = require('tap')
+
+local test = tap.test('lj-flush-on-trace')
+
+local cmd = string.gsub(
+  'LUA_CPATH=$/?.so LD_LIBRARY_PATH=$ tarantool 2>&1 $/test.lua %d %d',
+  '%$', os.getenv('BUILDDIR') .. '/test/luajit-tap/lj-flush-on-trace')
+
+local checks = {
+  { hotloop = 1, trigger = 1, success = true  },
+  { hotloop = 1, trigger = 2, success = false },
+}
+
+test:plan(#checks)
+
+for _, ch in pairs(checks) do
+  local res
+  local proc = io.popen(cmd:format(ch.hotloop, ch.trigger))
+  for s in proc:lines('*l') do res = s end
+  assert(res, 'proc:lines failed')
+  if ch.success then
+    test:is(res, 'OK')
+  else
+    test:is(res, 'JIT mode change is detected while executing the trace')
+  end
+end
+
+os.exit(test:check() and 0 or 1)
-- 
2.25.0



More information about the Tarantool-patches mailing list