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 0102FE0C2AE; Mon, 9 Dec 2024 14:18:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0102FE0C2AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1733743083; bh=GGdxYnvZLG3kV5pTqpNudh+188qIJtMNlKH4U6H+KBc=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=bH7Xi88wMyPTS+79/ThBXgd4W03vb94wHCqEqhkhvKL7hRLjUspk2dZ/4IOTTP0mG uTddTdcLZ71dEcFJJJ2Fi3bdodq0aLuY/EJNc1Cq2uekQZkC/k0uvqQDLGAjKxVTYG eaOhn3Vt6ge2TloOAYDaTtEdJS5xexEf1573ODxE= Received: from send151.i.mail.ru (send151.i.mail.ru [89.221.237.246]) (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 D4F58E0C2AC for ; Mon, 9 Dec 2024 14:18:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D4F58E0C2AC Received: by exim-smtp-fb95f984f-fwvnx with esmtpa (envelope-from ) id 1tKbm3-000000001SR-32fw; Mon, 09 Dec 2024 14:18:00 +0300 Content-Type: multipart/alternative; boundary="------------RhYl5kZb0HG8cVOdIKhRU3dW" Message-ID: <9763bdee-230a-4a09-95bd-15333ef1b3d6@tarantool.org> Date: Mon, 9 Dec 2024 14:17:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <616560a5fc0131d0f6c5358cebbc267025444334.1733739230.git.skaplun@tarantool.org> In-Reply-To: <616560a5fc0131d0f6c5358cebbc267025444334.1733739230.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9008082F162C50007A53896C97B9A26DB40BCDA7E413CB9A7182A05F53808504001080E9307AB85163DE06ABAFEAF6705773059847C1F7A1456F150D7326021D37AE8E57E538EEBEE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73B2A9F8A35432468EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063768D6DD405B71470F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DD3658C62C9B0DF3FCB2DC6714572DF15175A0479B65BE51CC7F00164DA146DAFE8445B8C89999728AA50765F790063741F7343E26298569389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8989FD0BDF65E50FBF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C5E3BF8C76DC23F74BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B6F4758F8EC3E027ED3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FCF1175FABE1C0F9B6E2021AF6380DFAD18AA50765F7900637F09814068C508CC822CA9DD8327EE4930A3850AC1BE2E73526B9191E2D567F0EC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5D020E04FA859F9885002B1117B3ED6967B37FF036D51E74430E4A65F242F5898823CB91A9FED034534781492E4B8EEADB05233B9BC4759D3 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFB000DE31C4AC968105CF51635220E66E493C3AFC2CE4BCDDB860795FB240BCD1711F655CCE117FA35C69F0120C2109DFCE6A19F54D777ABA67935D730988900F7FB1D67AE2EA164B5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojBv0bg8QSzYQJR/F1+e6jIw== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140D83D38ACDF2E6D9B9487ABAC94A94B5439108CB697AD21050152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 2/2] test: fix LuaJIT-tests for old libc version 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------RhYl5kZb0HG8cVOdIKhRU3dW Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey! thanks for the patch! LGTM after fix a comment below On 09.12.2024 13:16, Sergey Kaplun wrote: > The `strtod parsing` subtest in the checks > the results yielded by the `strtod()` via FFI call. In GLibc versions > before 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 | 41 ++++++++++++++++++++ > 4 files changed, 54 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: 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 > 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 alsohttps://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..d87e8b70 > --- /dev/null > +++ b/test/cmake/GetLibCVersion.cmake > @@ -0,0 +1,41 @@ > +# Get the libc version installed in the system. > +macro(GetLibCVersion output) > + # Try to directly parse the version. > + execute_process( > + COMMAND echo "#include " I propose to replace "echo" with a variable set by `find_program()`: diff --git a/test/cmake/GetLibCVersion.cmake b/test/cmake/GetLibCVersion.cmake index d87e8b70..15a8b440 100644 --- a/test/cmake/GetLibCVersion.cmake +++ b/test/cmake/GetLibCVersion.cmake @@ -1,8 +1,14 @@  # Get the libc version installed in the system.  macro(GetLibCVersion output) +  find_program(ECHO echo) +  if(NOT ECHO) +    message(FATAL_ERROR "`echo` is not found'") +    return() +  endif() +    # Try to directly parse the version.    execute_process( -    COMMAND echo "#include " +    COMMAND ${ECHO} "#include "      COMMAND ${CMAKE_C_COMPILER} -E -dM -      OUTPUT_VARIABLE LIB_C_INFO      ERROR_VARIABLE ERROR_MSG @@ -31,6 +37,7 @@ macro(GetLibCVersion output)    set(${output} "${GLIBC_MAJOR}.${GLIBC_MINOR}") +  unset(ECHO)    unset(CMAKE_MATCH_1)    unset(GLIBC_MAJOR)    unset(GLIBC_MINOR) > + COMMAND ${CMAKE_C_COMPILER} -E -dM - > + OUTPUT_VARIABLE LIB_C_INFO > + ERROR_VARIABLE ERROR_MSG > + OUTPUT_STRIP_TRAILING_WHITESPACE > + RESULT_VARIABLE RES > + ) > + > + if(NOT RES EQUAL 0) > + message(FATAL_ERROR > + "gnu/libc-version preprocessing has failed: '${ERROR_MSG}'") > + endif() > + > + string(REGEX MATCH "__GLIBC__ ([0-9]+)" MATCH ${LIB_C_INFO}) > + if(MATCH) > + set(GLIBC_MAJOR ${CMAKE_MATCH_1}) > + else() > + message(FATAL_ERROR "Can't determine GLIBC_MAJOR version.") > + endif() > + > + string(REGEX MATCH "__GLIBC_MINOR__ ([0-9]+)" MATCH ${LIB_C_INFO}) > + if(MATCH) > + set(GLIBC_MINOR ${CMAKE_MATCH_1}) > + else() > + message(FATAL_ERROR "Can't determine GLIBC_MINOR version.") > + endif() > + > + set(${output} "${GLIBC_MAJOR}.${GLIBC_MINOR}") > + > + unset(CMAKE_MATCH_1) > + unset(GLIBC_MAJOR) > + unset(GLIBC_MINOR) > + unset(MATCH) > + unset(RES) > + unset(ERROR_MSG) > + unset(LIB_C_INFO) > +endmacro() --------------RhYl5kZb0HG8cVOdIKhRU3dW Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey!

thanks for the patch!

LGTM after fix a comment below

On 09.12.2024 13:16, 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 GLibc versions
before 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              | 41 ++++++++++++++++++++
 4 files changed, 54 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..d87e8b70
--- /dev/null
+++ b/test/cmake/GetLibCVersion.cmake
@@ -0,0 +1,41 @@
+# Get the libc version installed in the system.
+macro(GetLibCVersion output)
+  # Try to directly parse the version.
+  execute_process(
+    COMMAND echo "#include <gnu/libc-version.h>"

I propose to replace "echo" with a variable set by `find_program()`:


diff --git a/test/cmake/GetLibCVersion.cmake b/test/cmake/GetLibCVersion.cmake
index d87e8b70..15a8b440 100644
--- a/test/cmake/GetLibCVersion.cmake
+++ b/test/cmake/GetLibCVersion.cmake
@@ -1,8 +1,14 @@
 # Get the libc version installed in the system.
 macro(GetLibCVersion output)
+  find_program(ECHO echo)
+  if(NOT ECHO)
+    message(FATAL_ERROR "`echo` is not found'")
+    return()
+  endif()
+
   # Try to directly parse the version.
   execute_process(
-    COMMAND echo "#include <gnu/libc-version.h>"
+    COMMAND ${ECHO} "#include <gnu/libc-version.h>"
     COMMAND ${CMAKE_C_COMPILER} -E -dM -
     OUTPUT_VARIABLE LIB_C_INFO
     ERROR_VARIABLE ERROR_MSG
@@ -31,6 +37,7 @@ macro(GetLibCVersion output)
 
   set(${output} "${GLIBC_MAJOR}.${GLIBC_MINOR}")
 
+  unset(ECHO)
   unset(CMAKE_MATCH_1)
   unset(GLIBC_MAJOR)
   unset(GLIBC_MINOR)

+    COMMAND ${CMAKE_C_COMPILER} -E -dM -
+    OUTPUT_VARIABLE LIB_C_INFO
+    ERROR_VARIABLE ERROR_MSG
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE RES
+  )
+
+  if(NOT RES EQUAL 0)
+    message(FATAL_ERROR
+            "gnu/libc-version preprocessing has failed: '${ERROR_MSG}'")
+  endif()
+
+  string(REGEX MATCH "__GLIBC__ ([0-9]+)" MATCH ${LIB_C_INFO})
+  if(MATCH)
+    set(GLIBC_MAJOR ${CMAKE_MATCH_1})
+  else()
+    message(FATAL_ERROR "Can't determine GLIBC_MAJOR version.")
+  endif()
+
+  string(REGEX MATCH "__GLIBC_MINOR__ ([0-9]+)" MATCH ${LIB_C_INFO})
+  if(MATCH)
+    set(GLIBC_MINOR ${CMAKE_MATCH_1})
+  else()
+    message(FATAL_ERROR "Can't determine GLIBC_MINOR version.")
+  endif()
+
+  set(${output} "${GLIBC_MAJOR}.${GLIBC_MINOR}")
+
+  unset(CMAKE_MATCH_1)
+  unset(GLIBC_MAJOR)
+  unset(GLIBC_MINOR)
+  unset(MATCH)
+  unset(RES)
+  unset(ERROR_MSG)
+  unset(LIB_C_INFO)
+endmacro()
--------------RhYl5kZb0HG8cVOdIKhRU3dW--