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 09A4FE4FB76; Wed, 11 Dec 2024 16:23:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09A4FE4FB76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1733923388; bh=M2EbFyDbd1x8fW80LAV06CosEXt4RxhopIvgN3mtcCU=; 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=F7vIAN/QJKYRXfi2Z3rPhYaWmm7qYLeY8QEDE+KqxWpFJxQv2SjApU9evuDtvsQCW XEtONY0GMu117vgWYD3x9iMnXyBg3vQ04jLSwKpXGoTb+CaYjdFkQgsZ7G4Ope007F u1eQQxeoAdu6CLmvaNCSlSNVy78Jb6YADMp4t3fg= Received: from send83.i.mail.ru (send83.i.mail.ru [89.221.237.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 79B88E4FB77 for ; Wed, 11 Dec 2024 16:22:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 79B88E4FB77 Received: by exim-smtp-598667c6b5-5zbpn with esmtpa (envelope-from ) id 1tLMfG-00000000FHh-1II1; Wed, 11 Dec 2024 16:22:06 +0300 To: Maksim Tiushev , Sergey Bronnikov Date: Wed, 11 Dec 2024 16:21:07 +0300 Message-ID: <7f8dea571105b6780b05d633df0d75b8c1a8a3c1.1733909411.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9B739379E53DE709505C39FBBBB723F94F87A505A23DBA096182A05F53808504028C2DA46892DF39F3DE06ABAFEAF6705B9B1A8F0C4D09DF73AAC8CF8E4B5DCE0CDF3F5685B32E1CC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7607B8778E2C6A697EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637129C704593A46970EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BC08E230531AC9C90A6C2F4FD996FF7B205783AEFFEDAFCAE55D3244A6BC317D4A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7BEE62E5629C982429FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E97D2AE7161E217F117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C2FFDA4F57982C5F42E808ACE2090B5E1725E5C173C3A84C3ED8438A78DFE0A9E089D37D7C0E48F6C8AA50765F7900637427B078F297B269AEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5CB8509F2F8CAC2785002B1117B3ED6961F13C1A83CA955A5F09842853758E9E5823CB91A9FED034534781492E4B8EEAD4ADCFBF7921B375DC79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFC8733ACC93B6560C7A4F97B48A99F3EA8541FF273888DAA98628C8CB2D65DA40C7C5EACBE3BE5B47A0626FDB23E8EA707D8EBA433065F7541E1DEA007741E9D7A9F2990160E0DBB9C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojlzf/Y03FLloIGTlFQjLsnA== X-DA7885C5: 7BA7C8DDD7C02351F255D290C0D534F90BF2896073488C9F6AB8ED1C5BABA21C7D934456E88B99A05B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F739381B31377CF4CA219A45F2EBF2591F3907C8D3F15B84920A00A208F6A3E222249E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v5 luajit 2/3] cmake: run tests with Valgrind 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Maksim Tiushev This patch enables running tests with Valgrind. There is a `VALGRIND_OPTS` variable [1] that we can set -- it makes the usage of valgrind more flexible -- we can define any necessary flags in the command line (not at the building stage). By default, the suppression files are set to (original suppression file in LuaJIT) and an additional one (maintained by us). Also, this patch disables the following tests when running with Valgrind due to failures: Disabled due tarantool/tarantool#10803: - tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua - tarantool-tests/lj-512-profiler-hook-finalizers.test.lua - tarantool-tests/lj-726-profile-flush-close.test.lua - tarantool-tests/misclib-sysprof-lapi.test.lua - tarantool-tests/profilers/gh-5688-tool-cli-flag.test.lua Timed out due to running under Valgrind: - tarantool-tests/gh-7745-oom-on-trace.test.lua - tarantool-tests/lj-1034-tabov-error-frame.test.lua - tarantool-c-tests/gh-8594-sysprof-ffunc-crash.c_test [1]: https://valgrind.org/docs/manual/manual-core.html#manual-core.defopts Part of tarantool/tarantool#3705 --- CMakeLists.txt | 5 +++++ src/lj_extra.supp | 19 +++++++++++++++++++ test/CMakeLists.txt | 19 +++++++++++++++++++ test/tarantool-c-tests/CMakeLists.txt | 11 ++++++++++- .../gh-8594-sysprof-ffunc-crash.test.c | 9 +++++++++ test/tarantool-tests/CMakeLists.txt | 6 ++++++ .../gh-7745-oom-on-trace.test.lua | 1 + .../lj-1034-tabov-error-frame.test.lua | 1 + .../lj-512-profiler-hook-finalizers.test.lua | 5 ++++- .../lj-726-profile-flush-close.test.lua | 5 ++++- .../profilers/gh-5688-tool-cli-flag.test.lua | 2 ++ ...4-add-proto-trace-sysprof-default.test.lua | 2 ++ .../profilers/misclib-sysprof-lapi.test.lua | 2 ++ 13 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 src/lj_extra.supp diff --git a/CMakeLists.txt b/CMakeLists.txt index aa2103b3..854b3613 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,11 @@ endif() # ASan enabled. option(LUAJIT_USE_ASAN "Build LuaJIT with AddressSanitizer" OFF) if(LUAJIT_USE_ASAN) + if(LUAJIT_USE_VALGRIND) + message(FATAL_ERROR + "AddressSanitizer and Valgrind cannot be used simultaneously." + ) + endif() if(NOT LUAJIT_USE_SYSMALLOC) message(WARNING "Unfortunately, internal LuaJIT memory allocator is not instrumented yet," diff --git a/src/lj_extra.supp b/src/lj_extra.supp new file mode 100644 index 00000000..ac205f03 --- /dev/null +++ b/src/lj_extra.supp @@ -0,0 +1,19 @@ +# Valgrind suppression file maintained by the Tarantool team. + +# Missed from the original suppression file. +# Unaligned access to the string, see for the details. +{ + Optimized string compare + Memcheck:Addr4 + fun:lj_getu32 + fun:str_fastcmp +} + +# Missed from the original suppression file. +# `lj_str_cmp()` may read up to 3 extra bytes from the end of the +# string. It is OK due to the aligned allocations. +{ + Optimized string compare + Memcheck:Cond + fun:lj_str_cmp +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0db2dd8b..bda85ec1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -69,6 +69,25 @@ add_custom_target(${PROJECT_NAME}-lint DEPENDS ) set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]") + +if(LUAJIT_USE_VALGRIND) + if (NOT LUAJIT_USE_SYSMALLOC) + message(WARNING + "LUAJIT_USE_SYSMALLOC option is mandatory for Valgrind's memcheck tool" + " on x64 and the only way to get useful results from it for all other" + " architectures.") + endif() + + find_program(VALGRIND valgrind) + list(APPEND LUAJIT_TEST_VALGRIND_SUPP + --suppressions=${LUAJIT_SOURCE_DIR}/lj.supp + --suppressions=${LUAJIT_SOURCE_DIR}/lj_extra.supp + ) + set(LUAJIT_TEST_COMMAND + "${VALGRIND} --error-exitcode=1 " + "${LUAJIT_TEST_VALGRIND_SUPP} ${LUAJIT_TEST_COMMAND}") +endif() + separate_arguments(LUAJIT_TEST_COMMAND) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/test/tarantool-c-tests/CMakeLists.txt b/test/tarantool-c-tests/CMakeLists.txt index 30d174bb..5f6c45da 100644 --- a/test/tarantool-c-tests/CMakeLists.txt +++ b/test/tarantool-c-tests/CMakeLists.txt @@ -56,10 +56,19 @@ foreach(test_source ${tests}) # Generate CMake tests. set(test_title "test/${TEST_SUITE_NAME}/${exe}${C_TEST_SUFFIX}") + set(test_command ${CMAKE_CURRENT_BINARY_DIR}/${exe}${C_TEST_SUFFIX}) + + if(LUAJIT_USE_VALGRIND) + set(test_command ${VALGRIND} --error-exitcode=1 ${LUAJIT_TEST_VALGRIND_SUPP} + ${test_command} + ) + endif() + add_test(NAME ${test_title} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${exe}${C_TEST_SUFFIX} + COMMAND ${test_command} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) + set_tests_properties(${test_title} PROPERTIES LABELS ${TEST_SUITE_NAME} DEPENDS tarantool-c-tests-deps diff --git a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c index cf1d815a..35108e77 100644 --- a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c +++ b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c @@ -46,6 +46,8 @@ * * https://github.com/tarantool/tarantool/issues/9387 */ +#define UNUSED(x) ((void)(x)) + #define MESSAGE "Canary is alive" #define LUACALL "local a = tostring('" MESSAGE "') return a" @@ -248,6 +250,12 @@ static int tracer(pid_t chpid) static int test_tostring_call(void *ctx) { +#if LUAJIT_USE_VALGRIND + UNUSED(ctx); + UNUSED(tracer); + UNUSED(tracee); + return skip("Disabled with Valgrind (Timeout)"); +#else pid_t chpid = fork(); switch(chpid) { case -1: @@ -264,6 +272,7 @@ static int test_tostring_call(void *ctx) default: return tracer(chpid); } +#endif } #else /* LUAJIT_OS == LUAJIT_OS_LINUX && LUAJIT_TARGET == LUAJIT_ARCH_X64 */ diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt index 8bdb2cf3..848c4cab 100644 --- a/test/tarantool-tests/CMakeLists.txt +++ b/test/tarantool-tests/CMakeLists.txt @@ -89,6 +89,12 @@ if(LUAJIT_ENABLE_TABLE_BUMP) list(APPEND LUA_TEST_ENV_MORE LUAJIT_TABLE_BUMP=1) endif() +# Needed to skip some long tests or tests using signals. +# See also https://github.com/tarantool/tarantool/issues/10803. +if(LUAJIT_USE_VALGRIND) + list(APPEND LUA_TEST_ENV_MORE LUAJIT_TEST_USE_VALGRIND=1) +endif() + set(TEST_SUITE_NAME "tarantool-tests") # XXX: The call produces both test and target 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 fe320251..c481da24 100644 --- a/test/tarantool-tests/gh-7745-oom-on-trace.test.lua +++ b/test/tarantool-tests/gh-7745-oom-on-trace.test.lua @@ -6,6 +6,7 @@ local test = tap.test('OOM on trace'):skipcond({ (jit.os == 'OSX'), ['Disabled on MacOS due to #8652'] = jit.os == 'OSX', ['Test requires JIT enabled'] = not jit.status(), + ['Disabled with Valgrind (Timeout)'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) test:plan(1) diff --git a/test/tarantool-tests/lj-1034-tabov-error-frame.test.lua b/test/tarantool-tests/lj-1034-tabov-error-frame.test.lua index 0e23fdb2..de63b6d2 100644 --- a/test/tarantool-tests/lj-1034-tabov-error-frame.test.lua +++ b/test/tarantool-tests/lj-1034-tabov-error-frame.test.lua @@ -4,6 +4,7 @@ local test = tap.test('lj-1034-tabov-error-frame'):skipcond({ ['Test requires JIT enabled'] = not jit.status(), ['Test requires GC64 mode enabled'] = not ffi.abi('gc64'), ['Disabled on MacOS due to #8652'] = jit.os == 'OSX', + ['Disabled with Valgrind (Timeout)'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) -- XXX: The test for the problem uses the table of GC 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 f02bd05f..32b12c65 100644 --- a/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua +++ b/test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua @@ -1,7 +1,10 @@ local tap = require('tap') local profile = require('jit.profile') -local test = tap.test('lj-512-profiler-hook-finalizers') +local test = tap.test('lj-512-profiler-hook-finalizers'):skipcond({ + -- See also https://github.com/tarantool/tarantool/issues/10803. + ['Disabled due to #10803'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), +}) test:plan(1) -- Sampling interval in ms. 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 36cca43d..b26f0603 100644 --- a/test/tarantool-tests/lj-726-profile-flush-close.test.lua +++ b/test/tarantool-tests/lj-726-profile-flush-close.test.lua @@ -1,6 +1,9 @@ local tap = require('tap') -local test = tap.test('lj-726-profile-flush-close') +local test = tap.test('lj-726-profile-flush-close'):skipcond({ + -- See also https://github.com/tarantool/tarantool/issues/10803. + ['Disabled due to #10803'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), +}) test:plan(1) local TEST_FILE = 'lj-726-profile-flush-close.profile' diff --git a/test/tarantool-tests/profilers/gh-5688-tool-cli-flag.test.lua b/test/tarantool-tests/profilers/gh-5688-tool-cli-flag.test.lua index f935dc5b..ad0d6caf 100644 --- a/test/tarantool-tests/profilers/gh-5688-tool-cli-flag.test.lua +++ b/test/tarantool-tests/profilers/gh-5688-tool-cli-flag.test.lua @@ -7,6 +7,8 @@ local test = tap.test('gh-5688-tool-cli-flag'):skipcond({ ['No profile tools CLI option integration'] = _TARANTOOL, -- See also https://github.com/LuaJIT/LuaJIT/issues/606. ['Disabled due to LuaJIT/LuaJIT#606'] = os.getenv('LUAJIT_TABLE_BUMP'), + -- See also https://github.com/tarantool/tarantool/issues/10803. + ['Disabled due to #10803'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) test:plan(3) diff --git a/test/tarantool-tests/profilers/gh-7264-add-proto-trace-sysprof-default.test.lua b/test/tarantool-tests/profilers/gh-7264-add-proto-trace-sysprof-default.test.lua index 176c1a15..d9a3080e 100644 --- a/test/tarantool-tests/profilers/gh-7264-add-proto-trace-sysprof-default.test.lua +++ b/test/tarantool-tests/profilers/gh-7264-add-proto-trace-sysprof-default.test.lua @@ -6,6 +6,8 @@ local test = tap.test('gh-7264-add-proto-trace-sysprof-default'):skipcond({ ['Sysprof is implemented for Linux only'] = jit.os ~= 'Linux', -- See also https://github.com/LuaJIT/LuaJIT/issues/606. ['Disabled due to LuaJIT/LuaJIT#606'] = os.getenv('LUAJIT_TABLE_BUMP'), + -- See also https://github.com/tarantool/tarantool/issues/10803. + ['Disabled due to #10803'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) test:plan(2) diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua index 26c277cd..605ff91c 100644 --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua @@ -5,6 +5,8 @@ local test = tap.test("misc-sysprof-lapi"):skipcond({ ["Sysprof is implemented for Linux only"] = jit.os ~= "Linux", -- See also https://github.com/LuaJIT/LuaJIT/issues/606. ["Disabled due to LuaJIT/LuaJIT#606"] = os.getenv("LUAJIT_TABLE_BUMP"), + -- See also https://github.com/tarantool/tarantool/issues/10803. + ['Disabled due to #10803'] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) test:plan(19) -- 2.47.0