From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org,
Sergey Kaplun <skaplun@tarantool.org>,
Maxim Kokryashkin <m.kokryashkin@tarantool.org>
Subject: [Tarantool-patches] [PATCH luajit 3/6] test: move LibRealPath to the separate module
Date: Tue, 26 Mar 2024 11:33:29 +0300 [thread overview]
Message-ID: <1b5d9c264a39a35cb3d930ef78f4d4473c80d8bc.1711441864.git.sergeyb@tarantool.org> (raw)
In-Reply-To: <cover.1711441864.git.sergeyb@tarantool.org>
From: Sergey Kaplun <skaplun@tarantool.org>
This patch moves the `LibRealPath` macro to a separate module to be used
in other test suites.
Needed for tarantool/tarantool#9656
---
test/CMakeLists.txt | 1 +
test/LuaJIT-tests/CMakeLists.txt | 37 ----------------------------
test/cmake/LibRealPath.cmake | 41 ++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 37 deletions(-)
create mode 100644 test/cmake/LibRealPath.cmake
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3ad5d15f..62478441 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -76,6 +76,7 @@ separate_arguments(LUAJIT_TEST_COMMAND)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddTestLib)
+include(LibRealPath)
add_subdirectory(LuaJIT-tests)
add_subdirectory(PUC-Rio-Lua-5.1-tests)
diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index badec91d..e8361e97 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -31,43 +31,6 @@ if(LUAJIT_USE_ASAN)
# "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
# This is a workaround suggested at
# https://github.com/google/sanitizers/issues/934.
- macro(LibRealPath output lib)
- execute_process(
- # CMAKE_C_COMPILER is used because it has the same behaviour
- # as CMAKE_CXX_COMPILER, but CMAKE_CXX_COMPILER is not
- # required for building LuaJIT and can be missed in GH
- # Actions.
- COMMAND ${CMAKE_C_COMPILER} -print-file-name=${lib}
- OUTPUT_VARIABLE LIB_LINK
- OUTPUT_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE RES
- )
-
- if(NOT RES EQUAL 0)
- message(FATAL_ERROR
- "Executing '${CMAKE_C_COMPILER} -print-file-name=${lib}' has failed"
- )
- endif()
-
- # GCC and Clang return a passed filename when a library is
- # not found.
- if(LIB_LINK STREQUAL ${lib})
- message(FATAL_ERROR "Library '${lib}' is not found")
- endif()
-
- # Fortunately, we are not interested in macOS here, so we can
- # use realpath. Beware, `realpath` always returns an exit code
- # equal to 0, so we cannot check if it fails.
- execute_process(
- COMMAND realpath ${LIB_LINK}
- OUTPUT_VARIABLE ${output}
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
-
- unset(LIB_LINK)
- unset(RES)
- endmacro()
-
LibRealPath(LIB_STDCPP libstdc++.so)
# XXX: GCC requires both. Clang requires only libstdc++.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
diff --git a/test/cmake/LibRealPath.cmake b/test/cmake/LibRealPath.cmake
new file mode 100644
index 00000000..70d43c50
--- /dev/null
+++ b/test/cmake/LibRealPath.cmake
@@ -0,0 +1,41 @@
+# Find a full path of a library used by a compiler and set it to
+# the given variable.
+macro(LibRealPath output lib)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ message(FATAL_ERROR "LibRealPath macro is unsupported for OSX")
+ endif()
+ execute_process(
+ # CMAKE_C_COMPILER is used because it has the same behaviour
+ # as CMAKE_CXX_COMPILER, but CMAKE_CXX_COMPILER is not
+ # required for building LuaJIT and can be missed in GH
+ # Actions.
+ COMMAND ${CMAKE_C_COMPILER} -print-file-name=${lib}
+ OUTPUT_VARIABLE LIB_LINK
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE RES
+ )
+
+ if(NOT RES EQUAL 0)
+ message(FATAL_ERROR
+ "Executing '${CMAKE_C_COMPILER} -print-file-name=${lib}' has failed"
+ )
+ endif()
+
+ # GCC and Clang return a passed filename when a library is
+ # not found.
+ if(LIB_LINK STREQUAL ${lib})
+ message(FATAL_ERROR "Library '${lib}' is not found")
+ endif()
+
+ # Fortunately, we are not interested in macOS here, so we can
+ # use realpath. Beware, `realpath` always returns an exit code
+ # equal to 0, so we cannot check if it fails.
+ execute_process(
+ COMMAND realpath ${LIB_LINK}
+ OUTPUT_VARIABLE ${output}
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ unset(LIB_LINK)
+ unset(RES)
+endmacro()
--
2.34.1
next prev parent reply other threads:[~2024-03-26 8:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 8:33 [Tarantool-patches] [PATCH luajit 0/6][v5] cmake: replace prove with CTest Sergey Bronnikov via Tarantool-patches
2024-03-26 8:33 ` [Tarantool-patches] [PATCH luajit 1/6] ci: execute LuaJIT tests with GCC 10 and ASAN Sergey Bronnikov via Tarantool-patches
2024-03-26 9:51 ` Sergey Kaplun via Tarantool-patches
2024-03-26 8:33 ` [Tarantool-patches] [PATCH luajit 2/6] test: refactor CMake macro LibRealPath Sergey Bronnikov via Tarantool-patches
2024-03-26 9:57 ` Sergey Kaplun via Tarantool-patches
2024-03-26 8:33 ` Sergey Bronnikov via Tarantool-patches [this message]
2024-03-26 10:01 ` [Tarantool-patches] [PATCH luajit 3/6] test: move LibRealPath to the separate module Sergey Kaplun via Tarantool-patches
2024-03-26 8:33 ` [Tarantool-patches] [PATCH luajit 4/6] test: more cautious usage of LD_PRELOAD for ASan Sergey Bronnikov via Tarantool-patches
2024-03-26 10:04 ` Sergey Kaplun via Tarantool-patches
2024-03-26 8:33 ` [Tarantool-patches] [PATCH luajit 5/6] test: fix lj-802-panic-at-mcode-protfail GCC+ASan Sergey Bronnikov via Tarantool-patches
2024-03-26 10:08 ` Sergey Kaplun via Tarantool-patches
2024-03-26 15:22 ` Sergey Bronnikov via Tarantool-patches
2024-03-26 8:33 ` [Tarantool-patches] [PATCH luajit 6/6] cmake: replace prove with CTest Sergey Bronnikov via Tarantool-patches
2024-03-26 11:03 ` Sergey Kaplun via Tarantool-patches
2024-04-01 14:28 ` Sergey Bronnikov via Tarantool-patches
2024-04-01 18:46 ` Sergey Kaplun via Tarantool-patches
2024-04-11 16:47 ` [Tarantool-patches] [PATCH luajit 0/6][v5] " Sergey Kaplun 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=1b5d9c264a39a35cb3d930ef78f4d4473c80d8bc.1711441864.git.sergeyb@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=estetus@gmail.com \
--cc=m.kokryashkin@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit 3/6] test: move LibRealPath to the separate module' \
/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