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 6553921C253; Mon, 27 Feb 2023 12:12:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6553921C253 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1677489156; bh=2k014u6s+l1khD7AD/2w/bvsjvX6GApXct3KCA8Qu7k=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=xC/RwZGvxoVvRV7bhokIBOXplxIe1enOZUdgIOHcGaqfXN4rz3vVwsXf/VPMVNKzT dxej9QK7PlTIRikBj1dxf3EzyGTGNUTfsCtYAm2wIQul+i0WqPcdyjtwJW/lqfGtCq zhDl0t/wj7U4MQ974GTkm1aLVNiNswKGu5FyRQqk= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [95.163.41.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 335DF21C253 for ; Mon, 27 Feb 2023 12:10:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 335DF21C253 Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1pWZWH-002jL3-SQ; Mon, 27 Feb 2023 12:10:06 +0300 To: Sergey Kaplun , Maxim Kokryashkin Date: Mon, 27 Feb 2023 09:07:23 +0000 Message-Id: <4e6d8b43d8000a6439ef6a20505acaf2e8929332.1677236706.git.imun@tarantool.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9806C989EC2150E3345DC9DC7E492C5E84DDF5398DFCC3EF3182A05F538085040FDD13A4562D73DBFE25ADD04193815ED9FAA8C8C30F8F350F600E77B55AAB791 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73DDC6BBB7CD71318EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637013F392EFFCDE01C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D863713634D6CCEC123FD2D2B2336B0E6C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC6D77D8F98F67F34EA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520C65AC60A1F0286FE28451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE599709FD55CB46A6F206494F22AA87D6D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE36A1CB4668A9CA5FA6E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006371F24DFF1B2961425731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5E48487BB77A66C7AAB363DFE61A064F4625741F711566B904EAF44D9B582CE87C8A4C02DF684249CC203C45FEA855C8F X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343FB425EC7F4D4A4B0B83DA85E80E1A05518247630367AB98F8A57E5A18F8A77F02BF04F7B35867FC1D7E09C32AA3244CB711F127895E60C937AC5ADF1D2CC4963FD9C8CA1B0515E0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojY+HhiuGRi+rVkEHrjbkbQA== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D5312400532989988835FF6F1CFC567A4D38506B6831E712E9CA2326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 5/5] test: make skipcond helper more convenient 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch provides two enhancements for : 1. As a result of the patch, becomes multi-conditional, so there is no need to concatenate one huge and complex condition with one huge unreadable reason. Now skipcond receives the table with conditions and skips the test if one of the given conditions is met. 2. yields the test object, that allows to chain skipcond call right next to the test constructor. Finally as a result of the aforementioned changes is moved to tap.lua. Co-authored-by: Sergey Kaplun Signed-off-by: Igor Munkin --- .../gh-4199-gc64-fuse.test.lua | 11 ++++---- .../gh-4427-ffi-sandwich.test.lua | 11 +++----- .../gh-5813-resolving-of-c-symbols.test.lua | 19 ++++++------- ...4-add-proto-trace-sysprof-default.test.lua | 15 ++++------ .../lj-430-maxirconst.test.lua | 10 +++---- .../lj-603-err-snap-restore.test.lua | 19 ++++++++----- ...lj-672-cdata-allocation-recording.test.lua | 12 ++++---- .../lj-906-fix-err-mem.test.lua | 12 ++++---- .../lj-flush-on-trace.test.lua | 11 +++----- .../misclib-getmetrics-capi.test.lua | 17 +++++------ .../misclib-getmetrics-lapi.test.lua | 13 ++++----- .../misclib-memprof-lapi.test.lua | 28 ++++++++----------- .../misclib-sysprof-capi.test.lua | 19 ++++++------- .../misclib-sysprof-lapi.test.lua | 19 ++++++------- test/tarantool-tests/tap.lua | 11 ++++++++ test/tarantool-tests/utils.lua | 8 ------ 16 files changed, 107 insertions(+), 128 deletions(-) diff --git a/test/tarantool-tests/gh-4199-gc64-fuse.test.lua b/test/tarantool-tests/gh-4199-gc64-fuse.test.lua index 4d69250f..65f9faac 100644 --- a/test/tarantool-tests/gh-4199-gc64-fuse.test.lua +++ b/test/tarantool-tests/gh-4199-gc64-fuse.test.lua @@ -1,11 +1,12 @@ --- The test is GC64 only. -local ffi = require('ffi') -require('utils').skipcond(not ffi.abi('gc64'), 'test is GC64 only') - local tap = require('tap') -local test = tap.test('gh-4199-gc64-fuse') +local test = tap.test('gh-4199-gc64-fuse'):skipcond({ + ['Test requires GC64 mode enabled'] = not require('ffi').abi('gc64'), +}) + test:plan(1) +local ffi = require('ffi') + collectgarbage() -- Chomp memory in currently allocated GC space. collectgarbage('stop') diff --git a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua index 06985dcd..ed3f50d1 100644 --- a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua +++ b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua @@ -1,16 +1,13 @@ -local utils = require('utils') - --- Disabled on *BSD due to #4819. -utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819') - local tap = require('tap') +local test = tap.test('gh-4427-ffi-sandwich'):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) -local test = tap.test('gh-4427-ffi-sandwich') test:plan(2) -- runs %testname%/script.lua by -- with the given environment, launch options and CLI arguments. -local script = utils.makecmd(arg, { +local script = require('utils').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 e0b6d86d..3c6833fc 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 @@ -1,14 +1,10 @@ --- Memprof is implemented for x86 and x64 architectures only. -local utils = require("utils") - -utils.skipcond( - jit.arch ~= "x86" and jit.arch ~= "x64" or jit.os ~= "Linux", - jit.arch.." architecture or "..jit.os.. - " OS is NIY for memprof c symbols resolving" -) - local tap = require("tap") -local test = tap.test("gh-5813-resolving-of-c-symbols") +local test = tap.test("gh-5813-resolving-of-c-symbols"):skipcond({ + ["Memprof is implemented for x86_64 only"] = jit.arch ~= "x86" and + jit.arch ~= "x64", + ["Memprof is implemented for Linux only"] = jit.os ~= "Linux", +}) + test:plan(5) jit.off() @@ -19,8 +15,9 @@ local symtab = require "utils.symtab" local testboth = require "resboth" local testhash = require "reshash" local testgnuhash = require "resgnuhash" +local profilename = require("utils").profilename -local TMP_BINFILE = utils.profilename("memprofdata.tmp.bin") +local TMP_BINFILE = profilename("memprofdata.tmp.bin") local function tree_contains(node, name) if node == nil then 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 15bd0a8b..472bc2d1 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 @@ -1,13 +1,10 @@ --- Sysprof is implemented for x86 and x64 architectures only. -require('utils').skipcond( - jit.arch ~= 'x86' and jit.arch ~= 'x64' or jit.os ~= 'Linux' - or require('ffi').abi('gc64'), - jit.arch..' architecture or '..jit.os.. - ' OS is NIY for sysprof' -) - local tap = require('tap') -local test = tap.test('gh-7264-add-proto-trace-sysprof-default.test.lua') +local test = tap.test('gh-7264-add-proto-trace-sysprof-default'):skipcond({ + ['Sysprof is implemented for x86_64 only'] = jit.arch ~= 'x86' and + jit.arch ~= 'x64', + ['Sysprof is implemented for Linux only'] = jit.os ~= 'Linux', +}) + test:plan(2) local chunk = [[ diff --git a/test/tarantool-tests/lj-430-maxirconst.test.lua b/test/tarantool-tests/lj-430-maxirconst.test.lua index 8bc523c2..633ab676 100644 --- a/test/tarantool-tests/lj-430-maxirconst.test.lua +++ b/test/tarantool-tests/lj-430-maxirconst.test.lua @@ -1,12 +1,12 @@ --- Disabled on *BSD due to #4819. -require('utils').skipcond(jit.os == 'BSD', 'Disabled due to #4819') - local tap = require('tap') -local traceinfo = require('jit.util').traceinfo +local test = tap.test('lj-430-maxirconst'):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) -local test = tap.test('lj-430-maxirconst') test:plan(2) +local traceinfo = require('jit.util').traceinfo + -- This function has only 3 IR constant. local function irconst3() end 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 b5353e85..be54a5f3 100644 --- a/test/tarantool-tests/lj-603-err-snap-restore.test.lua +++ b/test/tarantool-tests/lj-603-err-snap-restore.test.lua @@ -1,9 +1,9 @@ local tap = require('tap') - -- Test to demonstrate the incorrect JIT behaviour when an error -- is raised on restoration from the snapshot. -- See also https://github.com/LuaJIT/LuaJIT/issues/603. -local test = tap.test('lj-603-err-snap-restore.test.lua') +local test = tap.test('lj-603-err-snap-restore') + test:plan(2) -- XXX: This is fragile. We need a specific amount of Lua stack @@ -38,11 +38,16 @@ end recursive_f() test:ok(true) --- Disabled on *BSD due to #4819. --- XXX: The different amount of stack slots is in-use for --- Tarantool at start, so just skip test for it. --- luacheck: no global -test:ok(jit.os == 'BSD' or _TARANTOOL or not handler_is_called) + +test:skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', + -- XXX: The different amount of stack slots is in-use for + -- Tarantool at start, so just skip test for it. + -- luacheck: no global + ['Disable test for Tarantool'] = _TARANTOOL, +}) + +test:ok(not handler_is_called) -- XXX: Don't use `os.exit()` here by intention. When error on -- snap restoration is raised, `err_unwind()` doesn't stop on 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 1dc741d8..2165afe3 100644 --- a/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua +++ b/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua @@ -1,13 +1,13 @@ --- Disabled on *BSD due to #4819. -require('utils').skipcond(jit.os == 'BSD', 'Disabled due to #4819') +local tap = require('tap') +local test = tap.test('lj-672-cdata-allocation-recording'):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) + +test:plan(1) local ffi = require('ffi') local traceinfo = require('jit.util').traceinfo -local tap = require('tap') -local test = tap.test('lj-672-cdata-allocation-recording') -test:plan(1) - -- Structure with array. ffi.cdef('struct my_struct {int a; char d[8];}') 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 450beeff..6c6df338 100644 --- a/test/tarantool-tests/lj-906-fix-err-mem.test.lua +++ b/test/tarantool-tests/lj-906-fix-err-mem.test.lua @@ -1,13 +1,13 @@ local tap = require('tap') -local ffi = require('ffi') -local table_new = require('table.new') - --- Avoid test to be killed. -require('utils').skipcond(ffi.abi('gc64'), 'test is not GC64 only') +local test = tap.test('lj-906-fix-err-mem'):skipcond({ + ['Test requires GC64 mode disabled'] = require('ffi').abi('gc64'), +}) -local test = tap.test('lj-906-fix-err-mem') test:plan(1) +local ffi = require('ffi') +local table_new = require('table.new') + local KB = 1024 local MB = 1024 * KB local sizes = {8 * MB, 8 * KB, 8} diff --git a/test/tarantool-tests/lj-flush-on-trace.test.lua b/test/tarantool-tests/lj-flush-on-trace.test.lua index 3351cc5a..099e9650 100644 --- a/test/tarantool-tests/lj-flush-on-trace.test.lua +++ b/test/tarantool-tests/lj-flush-on-trace.test.lua @@ -1,16 +1,13 @@ -local utils = require('utils') - --- Disabled on *BSD due to #4819. -utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819') - local tap = require('tap') +local test = tap.test('lj-flush-on-trace'):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) -local test = tap.test('lj-flush-on-trace') test:plan(2) -- runs %testname%/script.lua by -- with the given environment, launch options and CLI arguments. -local script = utils.makecmd(arg, { +local script = require('utils').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-capi.test.lua b/test/tarantool-tests/misclib-getmetrics-capi.test.lua index 42a9adf9..c5a91955 100644 --- a/test/tarantool-tests/misclib-getmetrics-capi.test.lua +++ b/test/tarantool-tests/misclib-getmetrics-capi.test.lua @@ -1,12 +1,15 @@ -local utils = require('utils') +local tap = require('tap') +local test = tap.test("clib-misc-getmetrics"):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) --- Disabled on *BSD due to #4819. -utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819') +test:plan(11) local path = arg[0]:gsub('%.test%.lua', '') local suffix = package.cpath:match('?.(%a+);') package.cpath = ('%s/?.%s;'):format(path, suffix)..package.cpath +local MAXNINS = require('utils').const.maxnins local jit_opt_default = { 3, -- level "hotloop=56", @@ -14,11 +17,6 @@ local jit_opt_default = { "minstitch=0", } -local tap = require('tap') - -local test = tap.test("clib-misc-getmetrics") -test:plan(11) - local testgetmetrics = require("testgetmetrics") test:ok(testgetmetrics.base()) @@ -96,8 +94,7 @@ end)) -- Compiled loop with a side exit which does not get compiled. test:ok(testgetmetrics.snap_restores(function() - jit.opt.start(0, "hotloop=1", "hotexit=2", - ("minstitch=%d"):format(utils.const.maxnins)) + jit.opt.start(0, "hotloop=1", "hotexit=2", ("minstitch=%d"):format(MAXNINS)) local function foo(i) -- math.fmod is not yet compiled! diff --git a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua index 0c170d0c..e71bc239 100644 --- a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua +++ b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua @@ -2,16 +2,14 @@ -- Major portions taken verbatim or adapted from the LuaVela testing suite. -- Copyright (C) 2015-2019 IPONWEB Ltd. -local utils = require('utils') - --- Disabled on *BSD due to #4819. -utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819') - local tap = require('tap') +local test = tap.test("lib-misc-getmetrics"):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) -local test = tap.test("lib-misc-getmetrics") test:plan(10) +local MAXNINS = require('utils').const.maxnins local jit_opt_default = { 3, -- level "hotloop=56", @@ -281,8 +279,7 @@ test:test("snap-restores-loop-side-exit-non-compiled", function(subtest) -- Compiled loop with a side exit which does not get compiled. subtest:plan(1) - jit.opt.start(0, "hotloop=1", "hotexit=2", - ("minstitch=%d"):format(utils.const.maxnins)) + jit.opt.start(0, "hotloop=1", "hotexit=2", ("minstitch=%d"):format(MAXNINS)) local function foo(i) -- math.fmod is not yet compiled! diff --git a/test/tarantool-tests/misclib-memprof-lapi.test.lua b/test/tarantool-tests/misclib-memprof-lapi.test.lua index bae0c27c..18c8aaab 100644 --- a/test/tarantool-tests/misclib-memprof-lapi.test.lua +++ b/test/tarantool-tests/misclib-memprof-lapi.test.lua @@ -1,14 +1,13 @@ --- Memprof is implemented for x86 and x64 architectures only. -local utils = require("utils") - -utils.skipcond( - jit.arch ~= "x86" and jit.arch ~= "x64", - jit.arch.." architecture is NIY for memprof" -) - +-- XXX: This comment is a reminder to reimplement memprof tests +-- assertions to make them more indepentent to the changes made. +-- Now I just leave this 3 lines comment to preserve line numbers. local tap = require("tap") +local test = tap.test("misc-memprof-lapi"):skipcond({ + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', + ["Memprof is implemented for x86_64 only"] = jit.arch ~= "x86" and + jit.arch ~= "x64", +}) -local test = tap.test("misc-memprof-lapi") test:plan(5) local jit_opt_default = { @@ -27,9 +26,10 @@ 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 TMP_BINFILE = utils.profilename("memprofdata.tmp.bin") -local BAD_PATH = utils.profilename("memprofdata/tmp.bin") +local TMP_BINFILE = profilename("memprofdata.tmp.bin") +local BAD_PATH = profilename("memprofdata/tmp.bin") local SRC_PATH = "@"..arg[0] local function default_payload() @@ -267,12 +267,6 @@ end) jit.on() test:test("jit-output", function(subtest) - -- Disabled on *BSD due to #4819. - if jit.os == 'BSD' then - subtest:plan(1) - subtest:skip('Disabled due to #4819') - return - end subtest:plan(4) diff --git a/test/tarantool-tests/misclib-sysprof-capi.test.lua b/test/tarantool-tests/misclib-sysprof-capi.test.lua index dad0fe4a..a9b712a5 100644 --- a/test/tarantool-tests/misclib-sysprof-capi.test.lua +++ b/test/tarantool-tests/misclib-sysprof-capi.test.lua @@ -1,21 +1,18 @@ --- Sysprof is implemented for x86 and x64 architectures only. -local utils = require("utils") -utils.skipcond( - jit.arch ~= "x86" and jit.arch ~= "x64" or jit.os ~= "Linux", - jit.arch.." architecture or "..jit.os.. - " OS is NIY for sysprof" -) +local tap = require("tap") +local test = tap.test("clib-misc-sysprof"):skipcond({ + ["Sysprof is implemented for x86_64 only"] = jit.arch ~= "x86" and + jit.arch ~= "x64", + ["Sysprof is implemented for Linux only"] = jit.os ~= "Linux", +}) + +test:plan(2) local testsysprof = require("testsysprof") -local tap = require("tap") local jit = require('jit') jit.off() -local test = tap.test("clib-misc-sysprof") -test:plan(2) - test:ok(testsysprof.base()) test:ok(testsysprof.validation()) diff --git a/test/tarantool-tests/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/misclib-sysprof-lapi.test.lua index 4bf10e8d..fff89dfd 100644 --- a/test/tarantool-tests/misclib-sysprof-lapi.test.lua +++ b/test/tarantool-tests/misclib-sysprof-lapi.test.lua @@ -1,14 +1,10 @@ --- Sysprof is implemented for x86 and x64 architectures only. -local utils = require("utils") -utils.skipcond( - jit.arch ~= "x86" and jit.arch ~= "x64" or jit.os ~= "Linux", - jit.arch.." architecture or "..jit.os.. - " OS is NIY for sysprof" -) - local tap = require("tap") +local test = tap.test("misc-sysprof-lapi"):skipcond({ + ["Sysprof is implemented for x86_64 only"] = jit.arch ~= "x86" and + jit.arch ~= "x64", + ["Sysprof is implemented for Linux only"] = jit.os ~= "Linux", +}) -local test = tap.test("misc-sysprof-lapi") test:plan(19) jit.off() @@ -17,9 +13,10 @@ jit.flush() local bufread = require("utils.bufread") local symtab = require("utils.symtab") local sysprof = require("sysprof.parse") +local profilename = require("utils").profilename -local TMP_BINFILE = utils.profilename("sysprofdata.tmp.bin") -local BAD_PATH = utils.profilename("sysprofdata/tmp.bin") +local TMP_BINFILE = profilename("sysprofdata.tmp.bin") +local BAD_PATH = profilename("sysprofdata/tmp.bin") local function payload() local function fib(n) diff --git a/test/tarantool-tests/tap.lua b/test/tarantool-tests/tap.lua index 343f97e3..47a8fe87 100644 --- a/test/tarantool-tests/tap.lua +++ b/test/tarantool-tests/tap.lua @@ -327,6 +327,16 @@ local function check(test) return test.planned == test.total and test.failed == 0 end +local function skipcond(test, conditions) + for reason, condition in pairs(conditions) do + if condition then + local skipfunc = test.planned and skiprest or skipall + skipfunc(test, reason) + end + end + return test +end + test_mt = { __index = { test = new, @@ -338,6 +348,7 @@ test_mt = { skip = skip, skipall = skipall, skiprest = skiprest, + skipcond = skipcond, is = is, isnt = isnt, isnil = isnil, diff --git a/test/tarantool-tests/utils.lua b/test/tarantool-tests/utils.lua index 8355149b..83716bb3 100644 --- a/test/tarantool-tests/utils.lua +++ b/test/tarantool-tests/utils.lua @@ -81,14 +81,6 @@ function M.makecmd(arg, opts) }) end -function M.skipcond(condition, message) - if not condition then return end - local test = tap.test(arg[0]:match('/?(.+)%.test%.lua')) - test:plan(1) - test:skip(message) - os.exit(test:check() and 0 or 1) -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') -- 2.30.2