From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] test: fix LuaJIT-tests for old libc version Date: Fri, 6 Dec 2024 14:25:31 +0300 [thread overview] Message-ID: <Z1LfK3jCBUfbw6ae@pony> (raw) In-Reply-To: <8fb12a94cdf48fb1475dbe374dc91a86be74bdbc.1733405666.git.skaplun@tarantool.org> Hi, Sergey, thanks for the patch! On 16:42 Thu 05 Dec , Sergey Kaplun wrote: >The `strtod parsing` subtest in the <lib/base/tonumber_scan.lua> checks >the results yielded by the `strtod()` via FFI call. In versions before s/versions/GLibc versions/ >2.19 it returns an incorrect result for "0x1p-2075" [1]. This patch >skips this test for a smaller version of the libc installed. > >[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=16151 >--- > test/CMakeLists.txt | 1 + > test/LuaJIT-tests/CMakeLists.txt | 9 +++++ > test/LuaJIT-tests/lib/base/tonumber_scan.lua | 4 ++- > test/cmake/GetLibCVersion.cmake | 35 ++++++++++++++++++++ > 4 files changed, 48 insertions(+), 1 deletion(-) > create mode 100644 test/cmake/GetLibCVersion.cmake > >diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt >index 0db2dd8b..be02d2e4 100644 >--- a/test/CMakeLists.txt >+++ b/test/CMakeLists.txt >@@ -73,6 +73,7 @@ separate_arguments(LUAJIT_TEST_COMMAND) > > set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") > include(AddTestLib) >+include(GetLibCVersion) > include(LibRealPath) > > # CTEST_FLAGS is used by CMake targets in test suites. >diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt >index 019762e0..d0771e14 100644 >--- a/test/LuaJIT-tests/CMakeLists.txt >+++ b/test/LuaJIT-tests/CMakeLists.txt >@@ -62,6 +62,15 @@ if(CMAKE_C_FLAGS MATCHES "-march=skylake-avx512") > list(APPEND LUAJIT_TEST_TAGS_EXTRA +avx512) > endif() > >+if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") >+ GetLibCVersion(LIBC_VERSION) >+ # XXX: <tonumber_scan.lua> uses `strtod()`, old versions of >+ # which have the bug [1] for "0x1p-2075" parsing. Add the skip >+ # check for it. >+ # [1]: https://sourceware.org/bugzilla/show_bug.cgi?id=16151 >+ list(APPEND LUAJIT_TEST_TAGS_EXTRA +libc=${LIBC_VERSION}) >+endif() >+ > set(TEST_SUITE_NAME "LuaJIT-tests") > > # XXX: The call produces both test and target <LuaJIT-tests-deps> >diff --git a/test/LuaJIT-tests/lib/base/tonumber_scan.lua b/test/LuaJIT-tests/lib/base/tonumber_scan.lua >index e2dcd4d0..ac7d68a4 100644 >--- a/test/LuaJIT-tests/lib/base/tonumber_scan.lua >+++ b/test/LuaJIT-tests/lib/base/tonumber_scan.lua >@@ -186,7 +186,9 @@ do --- tonumber parsing > test_conv(tonumber) > end > >-do --- strtod parsing >+-- Skip for the old libc version with the bug in the `strtod()`. >+-- See also https://sourceware.org/bugzilla/show_bug.cgi?id=16151. >+do --- strtod parsing -libc<2.19 > test_conv(function(s) > local d = ffi.C.strtod(s, e) > return (e[0][0] == 0 and #s ~= 0) and d or nil >diff --git a/test/cmake/GetLibCVersion.cmake b/test/cmake/GetLibCVersion.cmake >new file mode 100644 >index 00000000..fd05fa6d >--- /dev/null >+++ b/test/cmake/GetLibCVersion.cmake >@@ -0,0 +1,35 @@ >+# Get the libc version installed in the system. >+# XXX: uses `LibRealPath`, so unsupported for OSX. >+macro(GetLibCVersion output) >+ LibRealPath(libcpath "libc.so.6") I don't get why shared lib filename is hardcoded. Version (6) can be changed and our test will fail. We can use gcc: [1] ~/sources/MRG/tarantool/third_party/luajit $ gcc -Wl,--trace main.c | grep libc /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libc.so /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib/x86_64-linux-gnu/libc_nonshared.a or ldd: [1] ~/sources/MRG/tarantool/third_party/luajit $ ldd build/src/luajit linux-vdso.so.1 (0x00007ffd161fd000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f272b6ac000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f272b68c000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f272b400000) /lib64/ld-linux-x86-64.so.2 (0x00007f272b88a000) >+ >+ # Get the version from the library name. >+ if(libcpath MATCHES "libc-([0-9]+\.[0-9]+)\.so") >+ set(${output} ${CMAKE_MATCH_1}) >+ else() >+ # Try to directly run the library and parse the version from >+ # the output message. >+ execute_process( >+ COMMAND ${libcpath} >+ OUTPUT_VARIABLE LIB_C_INFO >+ ERROR_VARIABLE ERROR_MSG >+ OUTPUT_STRIP_TRAILING_WHITESPACE >+ RESULT_VARIABLE RES >+ ) >+ >+ if(NOT RES EQUAL 0) >+ message(FATAL_ERROR "Executing '${libcpath}' has failed: '${ERROR_MSG}'") >+ endif() >+ >+ if(LIB_C_INFO MATCHES "^.*stable release version ([0-9]+\.[0-9]+)") >+ set(${output} ${CMAKE_MATCH_1}) >+ else() >+ message(FATAL_ERROR "Can't determine libc version") >+ endif() >+ >+ unset(RES) >+ unset(ERROR_MSG) >+ unset(LIB_C_INFO) >+ endif() >+ unset(CMAKE_MATCH_1) >+endmacro() >-- >2.47.0 > -- sergeyb@
next prev parent reply other threads:[~2024-12-06 11:25 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-12-05 13:42 [Tarantool-patches] [PATCH luajit 0/2] Fix LuaJIT tests for old libc versions Sergey Kaplun via Tarantool-patches 2024-12-05 13:42 ` [Tarantool-patches] [PATCH luajit 1/2] test: support number value of tag in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-12-06 11:09 ` Sergey Bronnikov via Tarantool-patches 2024-12-06 11:17 ` Sergey Kaplun via Tarantool-patches 2024-12-06 13:42 ` Sergey Bronnikov via Tarantool-patches 2024-12-11 15:40 ` Maxim Kokryashkin via Tarantool-patches 2024-12-05 13:42 ` [Tarantool-patches] [PATCH luajit 2/2] test: fix LuaJIT-tests for old libc version Sergey Kaplun via Tarantool-patches 2024-12-06 11:25 ` Sergey Bronnikov via Tarantool-patches [this message] 2024-12-11 15:40 ` Maxim Kokryashkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Z1LfK3jCBUfbw6ae@pony \ --to=tarantool-patches@dev.tarantool.org \ --cc=estetus@gmail.com \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit 2/2] test: fix LuaJIT-tests for old libc version' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox