From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (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 AB16E441875 for ; Fri, 20 Mar 2020 15:50:49 +0300 (MSK) From: "Alexander V. Tikhonov" Date: Fri, 20 Mar 2020 15:50:43 +0300 Message-Id: <1a00fc69881893cc376e78815fdfee12b9e038b3.1584708367.git.avtikhon@tarantool.org> In-Reply-To: References: In-Reply-To: References: Subject: [Tarantool-patches] [PATCH v3 1/2] test: cleanup tests code List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Cleaned up the tests code according to the Lua style guide: - made scoped variables local - added os.exit call at the end of the test chunk - adjusted the messages in test:ok calls Part of #4655 --- test/fix_string_find_recording.test.lua | 6 +++--- test/fold_bug_LuaJIT_505.test.lua | 7 ++++--- test/fold_bug_LuaJIT_524.test.lua | 4 ++-- test/gh.test.lua | 8 ++++---- test/table_chain_bug_LuaJIT_494.test.lua | 23 ++++++++++++----------- test/unsink_64_kptr.test.lua | 7 ++++--- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/test/fix_string_find_recording.test.lua b/test/fix_string_find_recording.test.lua index d3fc9e1..209090a 100755 --- a/test/fix_string_find_recording.test.lua +++ b/test/fix_string_find_recording.test.lua @@ -1,8 +1,8 @@ #!/usr/bin/env tarantool -tap = require('tap') +local tap = require('tap') -test = tap.test("fix-string-find-recording") +local test = tap.test("gh-4476-fix-string-find-recording") test:plan(1) local err = [[module 'kit.1.10.3-136' not found: @@ -76,4 +76,4 @@ until not e test:is(count_vm, count_jit) -test:check() +os.exit(test:check() and 0 or 1) diff --git a/test/fold_bug_LuaJIT_505.test.lua b/test/fold_bug_LuaJIT_505.test.lua index 2fee069..15d6533 100755 --- a/test/fold_bug_LuaJIT_505.test.lua +++ b/test/fold_bug_LuaJIT_505.test.lua @@ -1,8 +1,8 @@ #!/usr/bin/env tarantool -tap = require('tap') +local tap = require('tap') -test = tap.test("505") +local test = tap.test("lj-505-fold-icorrect-behavior") test:plan(1) -- Test file to demonstrate Lua fold machinery icorrect behavior, details: @@ -16,5 +16,6 @@ for _ = 1, 20 do local pos_b = string.find(value2, "b", 2, true) assert(pos_b == 2, "FAIL: position of 'b' is " .. pos_b) end +test:ok(true, "LuaJIT/LuaJIT gh-505 string.find offset aritmetics wasn't broken while recording") -test:ok("PASS") +os.exit(test:check() and 0 or 1) diff --git a/test/fold_bug_LuaJIT_524.test.lua b/test/fold_bug_LuaJIT_524.test.lua index b056684..a232eea 100755 --- a/test/fold_bug_LuaJIT_524.test.lua +++ b/test/fold_bug_LuaJIT_524.test.lua @@ -3,7 +3,7 @@ local tap = require('tap') local ffi = require('ffi') -local test = tap.test("LuaJIT 524") +local test = tap.test("or-524-fold-icorrect-behavior") test:plan(1) -- Test file to demonstrate LuaJIT folding machinery incorrect behaviour, @@ -21,4 +21,4 @@ end test:is(tonumber(sq), math.fmod(math.pow(42, 8), math.pow(2, 32))) -test:check() +os.exit(test:check() and 0 or 1) diff --git a/test/gh.test.lua b/test/gh.test.lua index 00b71a6..f135de7 100755 --- a/test/gh.test.lua +++ b/test/gh.test.lua @@ -1,17 +1,17 @@ #!/usr/bin/env tarantool -- Miscellaneous test for LuaJIT bugs -tap = require('tap') +local tap = require('tap') -test = tap.test("gh") +local test = tap.test("gh-3196-incorrect-string-length") test:plan(2) -- -- gh-3196: incorrect string length if Lua hash returns 0 -- -h = "\x1F\x93\xE2\x1C\xCA\xDE\x28\x08\x26\x01\xED\x0A\x2F\xE4\x21\x02\x97\x77\xD9\x3E" +local h = "\x1F\x93\xE2\x1C\xCA\xDE\x28\x08\x26\x01\xED\x0A\x2F\xE4\x21\x02\x97\x77\xD9\x3E" 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) -test:check() +os.exit(test:check() and 0 or 1) diff --git a/test/table_chain_bug_LuaJIT_494.test.lua b/test/table_chain_bug_LuaJIT_494.test.lua index 06c0f0d..55968dd 100755 --- a/test/table_chain_bug_LuaJIT_494.test.lua +++ b/test/table_chain_bug_LuaJIT_494.test.lua @@ -1,8 +1,8 @@ #!/usr/bin/env tarantool -tap = require('tap') +local tap = require('tap') -test = tap.test("494") +local test = tap.test("lj-494-table-chain-infinite-loop") test:plan(1) -- Test file to demonstrate Lua table hash chain bugs discussed in @@ -11,19 +11,19 @@ test:plan(1) -- https://gist.github.com/corsix/1fc9b13a2dd5f3659417b62dd54d4500 --- Plumbing -ffi = require"ffi" -ffi.cdef"char* strstr(const char*, const char*)" -strstr = ffi.C.strstr -cast = ffi.cast -str_hash_offset = cast("uint32_t*", strstr("*", ""))[-2] == 1 and 3 or 2 +local ffi = require("ffi") +ffi.cdef("char* strstr(const char*, const char*)") +local strstr = ffi.C.strstr +local cast = ffi.cast +local str_hash_offset = cast("uint32_t*", strstr("*", ""))[-2] == 1 and 3 or 2 function str_hash(s) return cast("uint32_t*", strstr(s, "")) - str_hash_offset end -table_new = require"table.new" +local table_new = require("table.new") --- Prepare some objects -victims = {} -orig_hash = {} +local victims = {} +local orig_hash = {} for c in ("abcdef"):gmatch"." do v = c .. "{09add58a-13a4-44e0-a52c-d44d0f9b2b95}" victims[c] = v @@ -174,5 +174,6 @@ collectgarbage() for c, v in pairs(victims) do str_hash(v)[0] = orig_hash[c] end +test:ok(true, "LuaJIT/LuaJIT gh-494 table keys collisions are resolved properly (no assertions failed)") -test:ok("PASS") +os.exit(test:check() and 0 or 1) diff --git a/test/unsink_64_kptr.test.lua b/test/unsink_64_kptr.test.lua index 8995763..d1123c5 100755 --- a/test/unsink_64_kptr.test.lua +++ b/test/unsink_64_kptr.test.lua @@ -1,8 +1,8 @@ #!/usr/bin/env tarantool -tap = require('tap') +local tap = require('tap') -test = tap.test("232") +local test = tap.test("or-232-unsink-64-kptr") test:plan(1) --- From: Thibault Charbonnier @@ -40,5 +40,6 @@ end for i = 1, 1000 do fn(i) end +test:ok(true, "openresty-lua/resty-core gh-232 allocation is unsunk at the trace exit (no platform failures)") -test:ok("PASS") +os.exit(test:check() and 0 or 1) -- 2.17.1