[Tarantool-patches] [PATCH luajit v2 3/5] test: introduce test:done TAP helper

Igor Munkin imun at tarantool.org
Fri Jul 21 11:12:06 MSK 2023


Before the patch all tests (except <lj-603-err-snap-restore.test.lua>)
in tarantool-tests suite terminate their execution via <os.exit> with
the status depending on the test results. However, the second argument
of <os.exit> was omitted and Lua universe was not properly finalized as
a result. This behaviour becomes a problem, when LuaJIT is build with
LUAJIT_USE_SYSMALLOC option and AddressSanitizer support enabled, since
the sanitizer starts reporting false positive errors about the memory
allocations without the corresponding memory releases. To resolve these
errors, the second parameter to each <os.exit> call terminating the test
has to be added.

To avoid loss of the aforementioned parameter in future, <test:done>
helper has been added to the TAP module. Depending on the single
parameter, the new helper either properly finalize the test being run,
or simply checks all the test assertions and raises an error if any of
them fail. The latter case is added especially to handle the specifics
of <lj-603-err-snap-restore.test.lua> and still check that everything
works fine.

Needed for tarantool/tarantool#5878

Signed-off-by: Igor Munkin <imun at tarantool.org>
---
 .../arm64-ccall-fp-convention.test.lua            |  2 +-
 test/tarantool-tests/bc-jit-unpatching.test.lua   |  2 +-
 .../c-library-path-length.test.lua                |  2 +-
 .../fix-bit-shift-generation.test.lua             |  2 +-
 test/tarantool-tests/fix-cdata-concat.test.lua    |  2 +-
 test/tarantool-tests/fix-emit-rma.test.lua        |  2 +-
 .../fix-fold-simplify-conv-sext.test.lua          |  2 +-
 test/tarantool-tests/fix-gc-setupvalue.test.lua   |  2 +-
 .../fix-slot-check-for-mm-record.test.lua         |  2 +-
 .../gh-3196-incorrect-string-length.test.lua      |  2 +-
 test/tarantool-tests/gh-4199-gc64-fuse.test.lua   |  2 +-
 .../tarantool-tests/gh-4427-ffi-sandwich.test.lua |  2 +-
 .../gh-4476-fix-string-find-recording.test.lua    |  2 +-
 .../gh-4773-tonumber-fail-on-NUL-char.test.lua    |  2 +-
 .../gh-5813-resolving-of-c-symbols.test.lua       |  2 +-
 .../gh-6065-jit-library-smoke-tests.test.lua      |  2 +-
 ...6084-missed-carg1-in-bctsetr-fallback.test.lua |  2 +-
 .../gh-6096-external-unwinding-on-arm64.test.lua  |  2 +-
 ...-6098-fix-side-exit-patching-on-arm64.test.lua |  2 +-
 test/tarantool-tests/gh-6163-min-max.test.lua     |  2 +-
 test/tarantool-tests/gh-6189-cur_L.test.lua       |  2 +-
 ...27-bytecode-allocator-for-comparisons.test.lua |  2 +-
 .../gh-6371-string-char-no-arg.test.lua           |  2 +-
 .../gh-6782-stitching-in-vmevent-handler.test.lua |  2 +-
 .../gh-6976-narrowing-of-unary-minus.test.lua     |  2 +-
 ...-7264-add-proto-trace-sysprof-default.test.lua |  2 +-
 .../tarantool-tests/gh-7745-oom-on-trace.test.lua |  2 +-
 .../lj-350-sload-typecheck.test.lua               |  2 +-
 .../lj-351-print-tostring-number.test.lua         |  2 +-
 .../lj-356-ir-khash-non-string-obj.test.lua       |  2 +-
 test/tarantool-tests/lj-357-arm64-hrefk.test.lua  |  2 +-
 .../lj-366-strtab-correct-size.test.lua           |  2 +-
 .../lj-375-ir-bufput-signed-char.test.lua         |  2 +-
 .../lj-378-string-format-c-null-char.test.lua     |  2 +-
 .../lj-408-tonumber-cdata-record.test.lua         |  2 +-
 .../lj-416-xor-before-jcc.test.lua                |  2 +-
 .../lj-418-assert-any-type.test.lua               |  2 +-
 ...j-426-arm64-incorrect-check-closed-uv.test.lua |  2 +-
 test/tarantool-tests/lj-430-maxirconst.test.lua   |  2 +-
 ...-438-arm64-constant-rematerialization.test.lua |  2 +-
 .../lj-445-fix-memory-probing-allocator.test.lua  |  2 +-
 test/tarantool-tests/lj-463-os-date-oom.test.lua  |  2 +-
 .../lj-494-table-chain-infinite-loop.test.lua     |  2 +-
 .../lj-505-fold-no-strref-for-ptrdiff.test.lua    |  2 +-
 .../lj-512-profiler-hook-finalizers.test.lua      |  2 +-
 .../lj-524-fold-conv-respect-src-irt.test.lua     |  2 +-
 test/tarantool-tests/lj-528-tonumber-0.test.lua   |  2 +-
 .../lj-556-fix-loop-realignment.test.lua          |  2 +-
 .../lj-574-overflow-unpack.test.lua               |  2 +-
 .../lj-584-bad-renames-for-sunk-values.test.lua   |  2 +-
 .../lj-586-debug-non-string-error.test.lua        |  2 +-
 .../lj-601-fix-gc-finderrfunc.test.lua            |  2 +-
 .../lj-603-err-snap-restore.test.lua              | 15 ++++++++-------
 .../lj-671-arm64-assert-after-mremap.test.lua     |  2 +-
 .../lj-672-cdata-allocation-recording.test.lua    |  2 +-
 .../lj-688-snap-ir-rename.test.lua                |  2 +-
 .../lj-695-ffi-vararg-call.test.lua               |  2 +-
 .../lj-698-arm-pcall-panic.test.lua               |  2 +-
 .../lj-704-bc-varg-use-def.test.lua               |  2 +-
 .../lj-726-profile-flush-close.test.lua           |  2 +-
 .../lj-727-lightuserdata-itern.test.lua           |  2 +-
 .../lj-735-io-close-on-closed-file.test.lua       |  2 +-
 test/tarantool-tests/lj-762-pcall-no-arg.test.lua |  2 +-
 .../lj-819-fix-missing-uclo.test.lua              |  2 +-
 .../lj-864-varg-rec-base-offset.test.lua          |  2 +-
 test/tarantool-tests/lj-906-fix-err-mem.test.lua  |  2 +-
 test/tarantool-tests/lj-981-folding-0.test.lua    |  2 +-
 ...994-instable-types-during-loop-unroll.test.lua |  2 +-
 test/tarantool-tests/lj-flush-on-trace.test.lua   |  2 +-
 test/tarantool-tests/math-modf.test.lua           |  2 ++
 .../misclib-getmetrics-lapi.test.lua              |  2 +-
 .../tarantool-tests/misclib-memprof-lapi.test.lua |  2 +-
 .../tarantool-tests/misclib-sysprof-lapi.test.lua |  2 +-
 .../tarantool-tests/or-144-gc64-asmref-l.test.lua |  2 +-
 .../or-232-unsink-64-kptr.test.lua                |  2 +-
 .../or-94-arm64-ir-ahuvload-bool.test.lua         |  2 +-
 test/tarantool-tests/tap.lua                      | 14 +++++++++++++-
 .../tonumber-negative-non-decimal-base.test.lua   |  2 +-
 test/tarantool-tests/tools-utils-avl.test.lua     |  2 +-
 test/tarantool-tests/unit-jit-parse.test.lua      |  2 +-
 80 files changed, 100 insertions(+), 85 deletions(-)

diff --git a/test/tarantool-tests/arm64-ccall-fp-convention.test.lua b/test/tarantool-tests/arm64-ccall-fp-convention.test.lua
index 8307e8b1..c58ba697 100644
--- a/test/tarantool-tests/arm64-ccall-fp-convention.test.lua
+++ b/test/tarantool-tests/arm64-ccall-fp-convention.test.lua
@@ -62,4 +62,4 @@ test:ok(assert_sz12(sz12_222, {2, 2, 2}), '2 structures as args')
 local sz12_333 = ffi_ccall.sum3sz12(sz12_111, sz12_111, sz12_111)
 test:ok(assert_sz12(sz12_333, {3, 3, 3}), '3 structures as args')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/bc-jit-unpatching.test.lua b/test/tarantool-tests/bc-jit-unpatching.test.lua
index f4f148c9..752fafac 100644
--- a/test/tarantool-tests/bc-jit-unpatching.test.lua
+++ b/test/tarantool-tests/bc-jit-unpatching.test.lua
@@ -22,4 +22,4 @@ f(5)
 test:ok(utils.frontend.hasbc(load(string.dump(f)), ret1bc),
         'bytecode unpatching is OK')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/c-library-path-length.test.lua b/test/tarantool-tests/c-library-path-length.test.lua
index 4f1e6602..63f3b695 100644
--- a/test/tarantool-tests/c-library-path-length.test.lua
+++ b/test/tarantool-tests/c-library-path-length.test.lua
@@ -11,4 +11,4 @@ local res, err = package.loadlib(long_path, 'func')
 test:ok(res == nil, 'loaded library with a too large path')
 test:like(err, 'path too long', 'incorrect error')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-bit-shift-generation.test.lua b/test/tarantool-tests/fix-bit-shift-generation.test.lua
index d8e8a9b4..9704f32c 100644
--- a/test/tarantool-tests/fix-bit-shift-generation.test.lua
+++ b/test/tarantool-tests/fix-bit-shift-generation.test.lua
@@ -44,4 +44,4 @@ for i = 1, NTESTS do
   test:ok(result[i] == shl(1ULL, i + 32), 'valid rol')
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-cdata-concat.test.lua b/test/tarantool-tests/fix-cdata-concat.test.lua
index df069e58..2ea37b02 100644
--- a/test/tarantool-tests/fix-cdata-concat.test.lua
+++ b/test/tarantool-tests/fix-cdata-concat.test.lua
@@ -18,4 +18,4 @@ debug.getmetatable(1LL).__concat = function(a, b)
 end
 test:ok(1LL .. 2LL == '1LL2LL', 'cdata concatenation with defined metamethod')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-emit-rma.test.lua b/test/tarantool-tests/fix-emit-rma.test.lua
index 1f8e66f4..42804447 100644
--- a/test/tarantool-tests/fix-emit-rma.test.lua
+++ b/test/tarantool-tests/fix-emit-rma.test.lua
@@ -101,4 +101,4 @@ end
 -- trace.
 test:ok(true, 'IR_OBAR emit_rma check correctness')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-fold-simplify-conv-sext.test.lua b/test/tarantool-tests/fix-fold-simplify-conv-sext.test.lua
index 60eb3e7c..d5356816 100644
--- a/test/tarantool-tests/fix-fold-simplify-conv-sext.test.lua
+++ b/test/tarantool-tests/fix-fold-simplify-conv-sext.test.lua
@@ -32,4 +32,4 @@ for i = 1, NTEST do
   test:ok(results[i] == expected[i], 'correct cdata indexing')
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-gc-setupvalue.test.lua b/test/tarantool-tests/fix-gc-setupvalue.test.lua
index 21acc9bf..6b57283f 100644
--- a/test/tarantool-tests/fix-gc-setupvalue.test.lua
+++ b/test/tarantool-tests/fix-gc-setupvalue.test.lua
@@ -58,4 +58,4 @@ for i = 1, 1e2 do local _ = {string.rep('0', i)} end
 
 test:ok(_G.parent() == 42, 'correct set up of upvalue')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/fix-slot-check-for-mm-record.test.lua b/test/tarantool-tests/fix-slot-check-for-mm-record.test.lua
index 6161747f..602426ac 100644
--- a/test/tarantool-tests/fix-slot-check-for-mm-record.test.lua
+++ b/test/tarantool-tests/fix-slot-check-for-mm-record.test.lua
@@ -79,4 +79,4 @@ end
 jit.opt.start('hotloop=1', 'maxrecord=2048')
 
 test:ok(try(require('ffi').abi('gc64')))
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-3196-incorrect-string-length.test.lua b/test/tarantool-tests/gh-3196-incorrect-string-length.test.lua
index 0342c832..b82029f6 100644
--- a/test/tarantool-tests/gh-3196-incorrect-string-length.test.lua
+++ b/test/tarantool-tests/gh-3196-incorrect-string-length.test.lua
@@ -12,4 +12,4 @@ test:is(h:len(), 20)
 h = "\x0F\x93\xE2\x1C\xCA\xDE\x28\x08\x26\x01\xED\x0A\x2F\xE4\x21\x02\x97\x77\xD9\x3E"
 test:is(h:len(), 20)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-4199-gc64-fuse.test.lua b/test/tarantool-tests/gh-4199-gc64-fuse.test.lua
index 4513d43b..ca050cf0 100644
--- a/test/tarantool-tests/gh-4199-gc64-fuse.test.lua
+++ b/test/tarantool-tests/gh-4199-gc64-fuse.test.lua
@@ -83,4 +83,4 @@ for n = 1, 100 do
 end
 
 test:ok(ok, 'IR constant fusion')
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
index 677a6085..34139d86 100644
--- a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
+++ b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
@@ -59,4 +59,4 @@ for _, subtest in pairs(cases) do
   test[subtest.test](test, output, subtest.expected, subtest.message)
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-4476-fix-string-find-recording.test.lua b/test/tarantool-tests/gh-4476-fix-string-find-recording.test.lua
index 56776192..c4acdd3d 100644
--- a/test/tarantool-tests/gh-4476-fix-string-find-recording.test.lua
+++ b/test/tarantool-tests/gh-4476-fix-string-find-recording.test.lua
@@ -76,4 +76,4 @@ until not e
 
 test:is(count_vm, count_jit)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-4773-tonumber-fail-on-NUL-char.test.lua b/test/tarantool-tests/gh-4773-tonumber-fail-on-NUL-char.test.lua
index 112c491e..7bacc0f9 100644
--- a/test/tarantool-tests/gh-4773-tonumber-fail-on-NUL-char.test.lua
+++ b/test/tarantool-tests/gh-4773-tonumber-fail-on-NUL-char.test.lua
@@ -19,4 +19,4 @@ test:is(tonumber(t.zero), 0)
 test:is(tonumber(t.zero .. t.tail), nil)
 test:is(tonumber(t.zero .. t.null .. t.tail), nil)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
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 1209d288..30b8a3ca 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
@@ -95,4 +95,4 @@ test:ok(tree_contains(symbols.cfunc, "allocate_string"))
 -- perform a test in that case, since it is impossible to load Lua module
 -- written in C if it doesn't have a .dynsym segment.
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6065-jit-library-smoke-tests.test.lua b/test/tarantool-tests/gh-6065-jit-library-smoke-tests.test.lua
index 5d7fd7e2..8105c3ba 100644
--- a/test/tarantool-tests/gh-6065-jit-library-smoke-tests.test.lua
+++ b/test/tarantool-tests/gh-6065-jit-library-smoke-tests.test.lua
@@ -10,4 +10,4 @@ test:plan(1)
 -- as a second argument to the assertion.
 test:ok(pcall(jit.on))
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
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 10db7603..5cc9416a 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
@@ -24,4 +24,4 @@ local res = table.move(t, 1, 1, 2)
 test:ok(t == res, 'table.move returns the same table')
 test:ok(t[1] == t[2], 'table.move is correct')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6096-external-unwinding-on-arm64.test.lua b/test/tarantool-tests/gh-6096-external-unwinding-on-arm64.test.lua
index cdeea441..097e771c 100644
--- a/test/tarantool-tests/gh-6096-external-unwinding-on-arm64.test.lua
+++ b/test/tarantool-tests/gh-6096-external-unwinding-on-arm64.test.lua
@@ -10,4 +10,4 @@ test:plan(1)
 local res = pcall(require, 'not-existing-module')
 test:ok(res == false, 'successful unwinding in pcall')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64.test.lua b/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64.test.lua
index cfcc6adb..93db3041 100644
--- a/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64.test.lua
+++ b/test/tarantool-tests/gh-6098-fix-side-exit-patching-on-arm64.test.lua
@@ -129,4 +129,4 @@ pxcall(cbool, false)
 cbool(false)
 
 test:ok(true)
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6163-min-max.test.lua b/test/tarantool-tests/gh-6163-min-max.test.lua
index 882cb1a0..63437955 100644
--- a/test/tarantool-tests/gh-6163-min-max.test.lua
+++ b/test/tarantool-tests/gh-6163-min-max.test.lua
@@ -262,4 +262,4 @@ end
 -- expected: 1.1 1.1 1.1 1.1
 test:ok(array_is_consistent(result), 'max: fold_kfold_numarith')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6189-cur_L.test.lua b/test/tarantool-tests/gh-6189-cur_L.test.lua
index a5096a7c..d6b8eef0 100644
--- a/test/tarantool-tests/gh-6189-cur_L.test.lua
+++ b/test/tarantool-tests/gh-6189-cur_L.test.lua
@@ -28,4 +28,4 @@ assert(pcall(libcur_L.error_from_other_thread) == false, "return from error")
 cbool(false)
 
 test:ok(true)
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua b/test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua
index da399bcf..07152744 100644
--- a/test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua
+++ b/test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua
@@ -54,4 +54,4 @@ for _ = 1, 3 do
 end
 
 test:ok(true)
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
index 90121860..48a5857d 100644
--- a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
+++ b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
@@ -27,4 +27,4 @@ for i = 1, NTEST do
   test:ok(results[i] == '', 'correct recording of string.char() without args')
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6782-stitching-in-vmevent-handler.test.lua b/test/tarantool-tests/gh-6782-stitching-in-vmevent-handler.test.lua
index 385e7648..afca6c40 100644
--- a/test/tarantool-tests/gh-6782-stitching-in-vmevent-handler.test.lua
+++ b/test/tarantool-tests/gh-6782-stitching-in-vmevent-handler.test.lua
@@ -32,4 +32,4 @@ require('jit.bc').dump(loadstring(string.dump(fibb)), {
 -- `jit.bc` functions inside.
 test:ok(fibb(2) == 1, 'run compiled function inside vmevent handler')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-6976-narrowing-of-unary-minus.test.lua b/test/tarantool-tests/gh-6976-narrowing-of-unary-minus.test.lua
index 40387cca..31890965 100644
--- a/test/tarantool-tests/gh-6976-narrowing-of-unary-minus.test.lua
+++ b/test/tarantool-tests/gh-6976-narrowing-of-unary-minus.test.lua
@@ -48,4 +48,4 @@ test:ok(check(function()
   return res
 end), 'assertion guard fail')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua b/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua
index 9cce32cb..c1d68e3c 100644
--- a/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua
+++ b/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua
@@ -44,4 +44,4 @@ assert(misc.sysprof.start({ mode = 'D' }))
 allocate()
 test:ok(misc.sysprof.stop(), 'trace record in sysprof runtime')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/gh-7745-oom-on-trace.test.lua b/test/tarantool-tests/gh-7745-oom-on-trace.test.lua
index 81be445d..9ac41ac7 100644
--- a/test/tarantool-tests/gh-7745-oom-on-trace.test.lua
+++ b/test/tarantool-tests/gh-7745-oom-on-trace.test.lua
@@ -38,4 +38,4 @@ collectgarbage()
 
 test:ok(res == false)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-350-sload-typecheck.test.lua b/test/tarantool-tests/lj-350-sload-typecheck.test.lua
index 5b25864d..33380170 100644
--- a/test/tarantool-tests/lj-350-sload-typecheck.test.lua
+++ b/test/tarantool-tests/lj-350-sload-typecheck.test.lua
@@ -41,4 +41,4 @@ jit.off()
 
 test:ok(not traceinfo(2), 'the second trace should not be compiled')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
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 b7041f2a..c67c6859 100644
--- a/test/tarantool-tests/lj-351-print-tostring-number.test.lua
+++ b/test/tarantool-tests/lj-351-print-tostring-number.test.lua
@@ -26,4 +26,4 @@ for _, subtest in pairs(cases) do
           ('subtest is OK for %s type'):format(subtest.typename))
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua b/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua
index 9977205d..5159ac32 100644
--- a/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua
+++ b/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua
@@ -90,4 +90,4 @@ for i = 1, N_ITERATIONS do
   test:ok(result_tab[i] == MAGIC, 'correct hash lookup from the table')
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-357-arm64-hrefk.test.lua b/test/tarantool-tests/lj-357-arm64-hrefk.test.lua
index d7e9c85e..8db8bbfc 100644
--- a/test/tarantool-tests/lj-357-arm64-hrefk.test.lua
+++ b/test/tarantool-tests/lj-357-arm64-hrefk.test.lua
@@ -29,4 +29,4 @@ end
 test:is(t.hrefk, -START)
 test:is(t[t.hrefk], STOP)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-366-strtab-correct-size.test.lua b/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
index aa4e72e7..8a97a441 100644
--- a/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
+++ b/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
@@ -202,4 +202,4 @@ test:ok(sym_is_found == true, 'symbol is found')
 local ret = os.remove(elf_filename)
 assert(ret == true, 'cannot remove an object file')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua b/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua
index f600d898..9f913eba 100644
--- a/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua
+++ b/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua
@@ -29,4 +29,4 @@ for i = 1, NTEST do
   test:ok(results[i] == 0xff, 'correct 0xff signed char assembling')
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-378-string-format-c-null-char.test.lua b/test/tarantool-tests/lj-378-string-format-c-null-char.test.lua
index 15cefadf..7632c7fd 100644
--- a/test/tarantool-tests/lj-378-string-format-c-null-char.test.lua
+++ b/test/tarantool-tests/lj-378-string-format-c-null-char.test.lua
@@ -8,4 +8,4 @@ test:plan(1)
 -- See also https://github.com/LuaJIT/LuaJIT/issues/378.
 
 test:is(string.format('%c', 0), '\0', 'string.format %c on null char')
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-408-tonumber-cdata-record.test.lua b/test/tarantool-tests/lj-408-tonumber-cdata-record.test.lua
index bdd0aaaa..3a7e1f28 100644
--- a/test/tarantool-tests/lj-408-tonumber-cdata-record.test.lua
+++ b/test/tarantool-tests/lj-408-tonumber-cdata-record.test.lua
@@ -41,4 +41,4 @@ check(0LL)
 test:ok(check(0LL), 'recorded with 0LL and converted for 0LL')
 test:ok(not check(NULL), 'recorded with 0LL and not converted for NULL')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-416-xor-before-jcc.test.lua b/test/tarantool-tests/lj-416-xor-before-jcc.test.lua
index 861114e8..605bb92a 100644
--- a/test/tarantool-tests/lj-416-xor-before-jcc.test.lua
+++ b/test/tarantool-tests/lj-416-xor-before-jcc.test.lua
@@ -97,4 +97,4 @@ for _ = 1, 3 do
 end
 test:ok(true, 'impossible branch is not taken')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-418-assert-any-type.test.lua b/test/tarantool-tests/lj-418-assert-any-type.test.lua
index 24683554..51b21ed8 100644
--- a/test/tarantool-tests/lj-418-assert-any-type.test.lua
+++ b/test/tarantool-tests/lj-418-assert-any-type.test.lua
@@ -15,4 +15,4 @@ xpcall(assert, function(obj)
   test:ok(obj == retv, 'xpcall error handler function get non-string argument')
 end, false, retv)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-426-arm64-incorrect-check-closed-uv.test.lua b/test/tarantool-tests/lj-426-arm64-incorrect-check-closed-uv.test.lua
index 4cdf1211..a689ed60 100644
--- a/test/tarantool-tests/lj-426-arm64-incorrect-check-closed-uv.test.lua
+++ b/test/tarantool-tests/lj-426-arm64-incorrect-check-closed-uv.test.lua
@@ -36,4 +36,4 @@ while (misc.getmetrics().gc_steps_atomic == old_steps_atomic) do
 end
 
 test:ok(true)
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-430-maxirconst.test.lua b/test/tarantool-tests/lj-430-maxirconst.test.lua
index 531acd7d..903fad8e 100644
--- a/test/tarantool-tests/lj-430-maxirconst.test.lua
+++ b/test/tarantool-tests/lj-430-maxirconst.test.lua
@@ -44,4 +44,4 @@ irconst4()
 jit.off()
 test:ok(not traceinfo(2), 'trace should not appear due to maxirconst limit')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-438-arm64-constant-rematerialization.test.lua b/test/tarantool-tests/lj-438-arm64-constant-rematerialization.test.lua
index 0a59209c..9886fe09 100644
--- a/test/tarantool-tests/lj-438-arm64-constant-rematerialization.test.lua
+++ b/test/tarantool-tests/lj-438-arm64-constant-rematerialization.test.lua
@@ -102,4 +102,4 @@ wrap()
 
 test:ok(true, 'the resulting trace is correct')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-445-fix-memory-probing-allocator.test.lua b/test/tarantool-tests/lj-445-fix-memory-probing-allocator.test.lua
index a228651b..da924bb0 100644
--- a/test/tarantool-tests/lj-445-fix-memory-probing-allocator.test.lua
+++ b/test/tarantool-tests/lj-445-fix-memory-probing-allocator.test.lua
@@ -47,4 +47,4 @@ for _ = 1, MAX_GB do
   end
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-463-os-date-oom.test.lua b/test/tarantool-tests/lj-463-os-date-oom.test.lua
index 0861ce14..e431d19d 100644
--- a/test/tarantool-tests/lj-463-os-date-oom.test.lua
+++ b/test/tarantool-tests/lj-463-os-date-oom.test.lua
@@ -14,4 +14,4 @@ end
 
 test:ok(true, 'os.date() finished without OOM')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-494-table-chain-infinite-loop.test.lua b/test/tarantool-tests/lj-494-table-chain-infinite-loop.test.lua
index aae90e8a..3dd17e7a 100644
--- a/test/tarantool-tests/lj-494-table-chain-infinite-loop.test.lua
+++ b/test/tarantool-tests/lj-494-table-chain-infinite-loop.test.lua
@@ -174,4 +174,4 @@ for c, v in pairs(victims) do
 end
 test:ok(true, "table keys collisions are resolved properly (no assertions failed)")
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-505-fold-no-strref-for-ptrdiff.test.lua b/test/tarantool-tests/lj-505-fold-no-strref-for-ptrdiff.test.lua
index fec08b30..a40e7796 100644
--- a/test/tarantool-tests/lj-505-fold-no-strref-for-ptrdiff.test.lua
+++ b/test/tarantool-tests/lj-505-fold-no-strref-for-ptrdiff.test.lua
@@ -18,4 +18,4 @@ for _ = 1, 20 do
 end
 test:ok(true, "string.find offset aritmetics wasn't broken while recording")
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua b/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua
index f7ee344f..a282a10f 100644
--- a/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua
+++ b/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua
@@ -28,4 +28,4 @@ profile.stop()
 test:ok(nsamples >= 0.5 * (finish - start) * 1e3 / INTERVAL,
         'profiler sampling')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-524-fold-conv-respect-src-irt.test.lua b/test/tarantool-tests/lj-524-fold-conv-respect-src-irt.test.lua
index a13e5d55..70d330ac 100644
--- a/test/tarantool-tests/lj-524-fold-conv-respect-src-irt.test.lua
+++ b/test/tarantool-tests/lj-524-fold-conv-respect-src-irt.test.lua
@@ -21,4 +21,4 @@ end
 
 test:is(tonumber(sq), math.fmod(math.pow(42, 8), math.pow(2, 32)))
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-528-tonumber-0.test.lua b/test/tarantool-tests/lj-528-tonumber-0.test.lua
index 27f17e54..8b4c0832 100644
--- a/test/tarantool-tests/lj-528-tonumber-0.test.lua
+++ b/test/tarantool-tests/lj-528-tonumber-0.test.lua
@@ -10,4 +10,4 @@ test:plan(1)
 -- As numbers -0 equals to 0, so convert it back to string.
 test:ok(tostring(tonumber('-0')) == '-0', 'correct "-0" string parsing')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-556-fix-loop-realignment.test.lua b/test/tarantool-tests/lj-556-fix-loop-realignment.test.lua
index b94bd3e9..89f70693 100644
--- a/test/tarantool-tests/lj-556-fix-loop-realignment.test.lua
+++ b/test/tarantool-tests/lj-556-fix-loop-realignment.test.lua
@@ -17,4 +17,4 @@ while s > 0 do
 end
 
 test:ok(true, 'loop is compiled and ran successfully')
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-574-overflow-unpack.test.lua b/test/tarantool-tests/lj-574-overflow-unpack.test.lua
index 6715d947..671ccddd 100644
--- a/test/tarantool-tests/lj-574-overflow-unpack.test.lua
+++ b/test/tarantool-tests/lj-574-overflow-unpack.test.lua
@@ -9,4 +9,4 @@ test:plan(1)
 local r, e = pcall(unpack, {}, 0, 2^31 - 1)
 test:ok(not r and e == 'too many results to unpack', 'overflow check in unpack')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-584-bad-renames-for-sunk-values.test.lua b/test/tarantool-tests/lj-584-bad-renames-for-sunk-values.test.lua
index e0c3e577..cb0623b1 100644
--- a/test/tarantool-tests/lj-584-bad-renames-for-sunk-values.test.lua
+++ b/test/tarantool-tests/lj-584-bad-renames-for-sunk-values.test.lua
@@ -96,4 +96,4 @@ end, function()
   test:fail('Invalid Lua stack has been restored')
 end)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
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 c00301a1..67869708 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
@@ -44,4 +44,4 @@ EOF]]):format(luabin, magic)
 
 local res = io.popen(cmd):read('*all'):gsub('%s+$', '')
 test:ok(res == expected, 'handle non-string error in debug.debug()')
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-601-fix-gc-finderrfunc.test.lua b/test/tarantool-tests/lj-601-fix-gc-finderrfunc.test.lua
index 2122c7a0..1549257d 100644
--- a/test/tarantool-tests/lj-601-fix-gc-finderrfunc.test.lua
+++ b/test/tarantool-tests/lj-601-fix-gc-finderrfunc.test.lua
@@ -35,4 +35,4 @@ a = nil
 -- frame. As a result, error is raised in __gc metamethod above.
 test:ok(mixcframe.test_handle_err(), 'error in __gc is successfully handled')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-603-err-snap-restore.test.lua b/test/tarantool-tests/lj-603-err-snap-restore.test.lua
index a6c831ed..791107ba 100644
--- a/test/tarantool-tests/lj-603-err-snap-restore.test.lua
+++ b/test/tarantool-tests/lj-603-err-snap-restore.test.lua
@@ -55,16 +55,17 @@ end
 -- restoration from the snapshot.
 if require('ffi').abi('gc64') then
   -- luacheck: no unused
-  local _, _, _, _, _, _
+  local _, _, _, _, _
   do_test()
 else
   -- luacheck: no unused
-  local _, _, _, _
+  local _, _, _, _, _, _, _, _, _, _, _, _, _
   do_test()
 end
 
--- XXX: Don't use `os.exit()` here by intention. When error on
--- snap restoration is raised, `err_unwind()` doesn't stop on
--- correct cframe. So later, on exit from VM this corrupted cframe
--- chain shows itself. `os.exit()` literally calls `exit()` and
--- doesn't show the issue.
+-- XXX: Don't force `test:done()` finish test with `os.exit()` by
+-- intention. When error on snapshot restoration is raised,
+-- `err_unwind()` doesn't stop on the correct cframe. So later, on
+-- exit from VM this corrupted cframe chain shows itself.
+-- `os.exit()` just calls `exit()` and doesn't show the issue.
+test:done(false)
diff --git a/test/tarantool-tests/lj-671-arm64-assert-after-mremap.test.lua b/test/tarantool-tests/lj-671-arm64-assert-after-mremap.test.lua
index 0558cbe3..74ade1db 100644
--- a/test/tarantool-tests/lj-671-arm64-assert-after-mremap.test.lua
+++ b/test/tarantool-tests/lj-671-arm64-assert-after-mremap.test.lua
@@ -21,4 +21,4 @@ local DEFAULT_MMAP_THRESHOLD = 128 * 1024
 local s = string.rep('x', DEFAULT_MMAP_THRESHOLD)..'x'
 test:ok(s)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua b/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua
index 1d6b19ba..22deac5d 100644
--- a/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua
+++ b/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua
@@ -28,4 +28,4 @@ end
 
 test:ok(traceinfo(1), 'new trace created')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-688-snap-ir-rename.test.lua b/test/tarantool-tests/lj-688-snap-ir-rename.test.lua
index 46bddd9f..807e0811 100644
--- a/test/tarantool-tests/lj-688-snap-ir-rename.test.lua
+++ b/test/tarantool-tests/lj-688-snap-ir-rename.test.lua
@@ -57,4 +57,4 @@ end
 test:ok(true, 'IR_RENAME is fine')
 -- `test:check() and 0 or 1` is replaced with just test:check()
 -- here, because otherwise, it affects the renaming process.
-os.exit(test:check())
+test:done(true)
diff --git a/test/tarantool-tests/lj-695-ffi-vararg-call.test.lua b/test/tarantool-tests/lj-695-ffi-vararg-call.test.lua
index 04be1998..496a4c0d 100644
--- a/test/tarantool-tests/lj-695-ffi-vararg-call.test.lua
+++ b/test/tarantool-tests/lj-695-ffi-vararg-call.test.lua
@@ -13,4 +13,4 @@ local result = ffi.string(str)
 test:is(#result, strlen)
 test:is(result, 'try vararg function: imun:9.00(9) - 18446744073709551615')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-698-arm-pcall-panic.test.lua b/test/tarantool-tests/lj-698-arm-pcall-panic.test.lua
index 88476d3e..5f9d193a 100644
--- a/test/tarantool-tests/lj-698-arm-pcall-panic.test.lua
+++ b/test/tarantool-tests/lj-698-arm-pcall-panic.test.lua
@@ -15,4 +15,4 @@ local runner = ffi.cast("int (*)(int, int, int, int, int, int, int, int, int)",
 local st = pcall(runner, 1, 1, 1, 1, 1, 1, 1, 1, 1)
 test:ok(not st, 'error handling completed correctly')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
index e6a0973b..93455e3c 100644
--- a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
+++ b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
@@ -90,4 +90,4 @@ wrap_ret_bc(ON_TRACE_VALUE)
 
 test:ok(result ~= 0, 'use-def analysis for FUNCV with jump before BC_VARG')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-726-profile-flush-close.test.lua b/test/tarantool-tests/lj-726-profile-flush-close.test.lua
index a3f8def9..36cca43d 100644
--- a/test/tarantool-tests/lj-726-profile-flush-close.test.lua
+++ b/test/tarantool-tests/lj-726-profile-flush-close.test.lua
@@ -26,4 +26,4 @@ test:ok(f:read(0), 'profile output was flushed and closed')
 
 assert(os.remove(TEST_FILE))
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-727-lightuserdata-itern.test.lua b/test/tarantool-tests/lj-727-lightuserdata-itern.test.lua
index 3e459f43..bb01f122 100644
--- a/test/tarantool-tests/lj-727-lightuserdata-itern.test.lua
+++ b/test/tarantool-tests/lj-727-lightuserdata-itern.test.lua
@@ -42,4 +42,4 @@ end)
 test.strict = true
 test:is_deeply(visited, t, 'userdata node is visited')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-735-io-close-on-closed-file.test.lua b/test/tarantool-tests/lj-735-io-close-on-closed-file.test.lua
index 2a590df0..a23aa0d4 100644
--- a/test/tarantool-tests/lj-735-io-close-on-closed-file.test.lua
+++ b/test/tarantool-tests/lj-735-io-close-on-closed-file.test.lua
@@ -21,4 +21,4 @@ test:ok(err:match('attempt to use a closed file'), 'correct error message')
 
 assert(os.remove(TEST_FILE))
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-762-pcall-no-arg.test.lua b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua
index 6cbfe707..db16c3dd 100644
--- a/test/tarantool-tests/lj-762-pcall-no-arg.test.lua
+++ b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua
@@ -12,4 +12,4 @@ local result, err = pcall(pcall)
 test:ok(not result, 'pcall() without args: bad status')
 test:like(err, 'value expected', 'pcall() without args: error message')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua b/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua
index 942c22b2..e2352c92 100644
--- a/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua
+++ b/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua
@@ -112,4 +112,4 @@ local _
 _, res = pcall(f)
 test:ok(type(res) == 'function', 'consistency on compilation: type of returned value is correct')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-864-varg-rec-base-offset.test.lua b/test/tarantool-tests/lj-864-varg-rec-base-offset.test.lua
index d41e33ff..02864e44 100644
--- a/test/tarantool-tests/lj-864-varg-rec-base-offset.test.lua
+++ b/test/tarantool-tests/lj-864-varg-rec-base-offset.test.lua
@@ -24,4 +24,4 @@ end
 -- due to failing assertion guard for type of loaded vararg slot.
 test:ok(test_rec_varg(42, 0), 'correct BC_VARG recording')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-906-fix-err-mem.test.lua b/test/tarantool-tests/lj-906-fix-err-mem.test.lua
index 6c6df338..7235e829 100644
--- a/test/tarantool-tests/lj-906-fix-err-mem.test.lua
+++ b/test/tarantool-tests/lj-906-fix-err-mem.test.lua
@@ -100,4 +100,4 @@ collectgarbage()
 
 test:ok(true, 'correctly throw memory error')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-981-folding-0.test.lua b/test/tarantool-tests/lj-981-folding-0.test.lua
index d156f53d..608cb2cd 100644
--- a/test/tarantool-tests/lj-981-folding-0.test.lua
+++ b/test/tarantool-tests/lj-981-folding-0.test.lua
@@ -60,4 +60,4 @@ test:ok(result == expected, 'TDUP and -0 folding')
 -- Test that there is no NEWREF -0 IR.
 test:ok(not traces[1]:has_ir('NEWREF.*-0'), '-0 is canonized for TDUP tab')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua b/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
index 78c04f21..730b0e61 100644
--- a/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
+++ b/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
@@ -50,4 +50,4 @@ end
 test:is(result, true, 'TDUP load forwarding was successful')
 ]]
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/lj-flush-on-trace.test.lua b/test/tarantool-tests/lj-flush-on-trace.test.lua
index fe740087..a64fac4d 100644
--- a/test/tarantool-tests/lj-flush-on-trace.test.lua
+++ b/test/tarantool-tests/lj-flush-on-trace.test.lua
@@ -59,4 +59,4 @@ for _, subtest in pairs(cases) do
   test[subtest.test](test, output, subtest.expected, subtest.message)
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/math-modf.test.lua b/test/tarantool-tests/math-modf.test.lua
index d8421db9..20a3bb16 100644
--- a/test/tarantool-tests/math-modf.test.lua
+++ b/test/tarantool-tests/math-modf.test.lua
@@ -32,3 +32,5 @@ for i = 1, 3 do
 end
 
 test:ok(array_is_consistent(r1) and array_is_consistent(r2), 'wrong modf')
+
+test:done(true)
diff --git a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
index 0ee71499..741900b6 100644
--- a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
+++ b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
@@ -430,4 +430,4 @@ test:test("tracenum-base", function(subtest)
     subtest:is(metrics.jit_trace_num, 0)
 end)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/misclib-memprof-lapi.test.lua b/test/tarantool-tests/misclib-memprof-lapi.test.lua
index eae20893..3cb5c8be 100644
--- a/test/tarantool-tests/misclib-memprof-lapi.test.lua
+++ b/test/tarantool-tests/misclib-memprof-lapi.test.lua
@@ -296,4 +296,4 @@ test:test("jit-output", function(subtest)
   jit.opt.start(unpack(jit_opt_default))
 end)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/misclib-sysprof-lapi.test.lua
index 2f0635db..fdaed46a 100644
--- a/test/tarantool-tests/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/misclib-sysprof-lapi.test.lua
@@ -129,4 +129,4 @@ check_mode("C", 100)
 
 os.remove(TMP_BINFILE)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/or-144-gc64-asmref-l.test.lua b/test/tarantool-tests/or-144-gc64-asmref-l.test.lua
index 0c352c29..18c6efb2 100644
--- a/test/tarantool-tests/or-144-gc64-asmref-l.test.lua
+++ b/test/tarantool-tests/or-144-gc64-asmref-l.test.lua
@@ -25,4 +25,4 @@ end
 
 test:ok(global_env == getfenv(0), 'IR_LREF assembling correctness')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/or-232-unsink-64-kptr.test.lua b/test/tarantool-tests/or-232-unsink-64-kptr.test.lua
index fc8acaaf..4a0ece89 100644
--- a/test/tarantool-tests/or-232-unsink-64-kptr.test.lua
+++ b/test/tarantool-tests/or-232-unsink-64-kptr.test.lua
@@ -41,4 +41,4 @@ for i = 1, 1000 do
 end
 test:ok(true, "allocation is unsunk at the trace exit (no platform failures)")
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/or-94-arm64-ir-ahuvload-bool.test.lua b/test/tarantool-tests/or-94-arm64-ir-ahuvload-bool.test.lua
index 5418a058..990a3989 100644
--- a/test/tarantool-tests/or-94-arm64-ir-ahuvload-bool.test.lua
+++ b/test/tarantool-tests/or-94-arm64-ir-ahuvload-bool.test.lua
@@ -145,4 +145,4 @@ for i = 1, N_TESTS do
   jit.flush()
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/tap.lua b/test/tarantool-tests/tap.lua
index 47a8fe87..8559ee52 100644
--- a/test/tarantool-tests/tap.lua
+++ b/test/tarantool-tests/tap.lua
@@ -10,7 +10,7 @@ local NULL = ffi.new("void *")
 local function finalize(test)
   -- TODO: implement finalization for subtests too.
   assert(test.parent == nil, 'FIXME: There is no way to use finalize subtest')
-  os.exit(test:check() and 0 or 1)
+  test:done(true)
 end
 
 local function indent(level, size)
@@ -337,12 +337,24 @@ local function skipcond(test, conditions)
   return test
 end
 
+local function done(test, exit)
+  if exit then
+    -- XXX: The second argument is required to properly close Lua
+    -- universe (i.e. invoke <lua_close> before exiting).
+    -- XXX: return is added explicitly to force CALLT emitting.
+    return os.exit(test:check() and 0 or 1, true)
+  else
+    assert(test:check(), 'Test check failed')
+  end
+end
+
 test_mt = {
   __index = {
     test       = new,
     plan       = plan,
     check      = check,
     diag       = diag,
+    done       = done,
     ok         = ok,
     fail       = fail,
     skip       = skip,
diff --git a/test/tarantool-tests/tonumber-negative-non-decimal-base.test.lua b/test/tarantool-tests/tonumber-negative-non-decimal-base.test.lua
index 94df3b1f..c7ac6b6f 100644
--- a/test/tarantool-tests/tonumber-negative-non-decimal-base.test.lua
+++ b/test/tarantool-tests/tonumber-negative-non-decimal-base.test.lua
@@ -26,4 +26,4 @@ test:ok(tonumber('- 1010  ', 2) == nil, 'space between sign and value')
 test:ok(tonumber('-_1010  ', 2) == nil,
 	'invalid character between sign and value')
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/tools-utils-avl.test.lua b/test/tarantool-tests/tools-utils-avl.test.lua
index ebcfac2e..d7aa5011 100644
--- a/test/tarantool-tests/tools-utils-avl.test.lua
+++ b/test/tarantool-tests/tools-utils-avl.test.lua
@@ -38,4 +38,4 @@ test:is(avl.floor(root, -10), nil)
 -- Not exact upper bound.
 test:is(avl.floor(root, 2.75), 2)
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
diff --git a/test/tarantool-tests/unit-jit-parse.test.lua b/test/tarantool-tests/unit-jit-parse.test.lua
index 24216e87..2e6a2228 100644
--- a/test/tarantool-tests/unit-jit-parse.test.lua
+++ b/test/tarantool-tests/unit-jit-parse.test.lua
@@ -42,4 +42,4 @@ for irnum = 1, N_TESTS do
   test:ok(irref, 'find IR refernce by pattern: ' .. ir_pattern)
 end
 
-os.exit(test:check() and 0 or 1)
+test:done(true)
-- 
2.30.2



More information about the Tarantool-patches mailing list