Tarantool development patches archive
 help / color / mirror / Atom feed
From: sergos 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 1/2] test: set DYLD_LIBRARY_PATH environment variable
Date: Thu, 2 Jun 2022 11:51:46 +0300	[thread overview]
Message-ID: <FA4E1862-B413-434C-9177-92B062AB6560@tarantool.org> (raw)
In-Reply-To: <db4e327a9600ec4dda425c26b420cff6238145aa.1639039919.git.skaplun@tarantool.org>

Hi!

Thanks for the patch, I can’t find any problems in it, although I couldn’t
apply it on the latest luajit.

Sergos.


> On 9 Dec 2021, at 13:24, Sergey Kaplun <skaplun@tarantool.org> wrote:
> 
> This patch allows to use tests with `ffi.load()` without usage of
> `utils.selfrun()` by setting the DYLD_LIBRARY_PATH variable for the
> process directly via additional env command. Also, this commit "reverts"
> part of the commit fae1681dd1c117a913f99cbeed0ca2b87cf581a1 ('test: fix
> dynamic modules loading on MacOS') since there is no need to tweak
> environment while running those tests.
> 
> Needed for tarantool/tarantool#6548
> ---
> test/tarantool-tests/CMakeLists.txt           | 19 +++++++++++--------
> .../gh-4427-ffi-sandwich.test.lua             |  4 ----
> .../lj-flush-on-trace.test.lua                |  4 ----
> test/tarantool-tests/utils.lua                | 17 -----------------
> 4 files changed, 11 insertions(+), 33 deletions(-)
> 
> diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
> index a872fa5e..992556d9 100644
> --- a/test/tarantool-tests/CMakeLists.txt
> +++ b/test/tarantool-tests/CMakeLists.txt
> @@ -94,22 +94,21 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
>   # since some programs sanitize the environment before they start
>   # child processes. Specifically, environment variables starting
>   # with DYLD_ and LD_ are unset for child process started by
> -  # system programs (like /usr/bin/env used for preparing testing
> -  # environment). For more info, see the docs[2] below.
> +  # other programs (like /usr/bin/prove --exec using for launching
> +  # test suite). For more info, see the docs[2] below.
>   #
>   # These environment variables are used by FFI machinery to find
>   # the proper shared library, hence we can still tweak testing
>   # environment before calling <ffi.load>. However, the value
>   # can't be passed via the standard environment variable, so we
> -  # prepend TEST_ prefix to its name to get around SIP magic
> -  # tricks. Finally, to set the variable required by FFI machinery
> -  # the introduced <utils.tweakenv> routine is used.
> +  # use env call in prove's --exec flag value to get around SIP
> +  # magic tricks.
>   #
>   # [1]: https://support.apple.com/en-us/HT204899
>   # [2]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html
> -  list(APPEND LUA_TEST_ENV TEST_DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
> +  list(APPEND LUA_TEST_ENV_MORE DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
> else()
> -  list(APPEND LUA_TEST_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
> +  list(APPEND LUA_TEST_ENV_MORE LD_LIBRARY_PATH="${LD_LIBRARY_PATH}")
> endif()
> 
> # LUA_CPATH and LD_LIBRARY_PATH variables and also TESTLIBS list
> @@ -120,10 +119,14 @@ add_custom_target(tarantool-tests
> add_custom_command(TARGET tarantool-tests
>   COMMENT "Running Tarantool tests"
>   COMMAND
> +  # XXX: We can't move everything to the "inner" env, since there
> +  # are some issues with escaping ';' for different shells. As
> +  # a result LUA_PATH/LUA_CPATH variables are set via the "outer"
> +  # env, since they are not stripped by SIP like LD_*/DYLD_* are.
>   env
>     ${LUA_TEST_ENV}
>     ${PROVE} ${CMAKE_CURRENT_SOURCE_DIR}
> -      --exec '${LUAJIT_TEST_COMMAND}'
> +      --exec 'env ${LUA_TEST_ENV_MORE} ${LUAJIT_TEST_COMMAND}'
>       --ext ${LUA_TEST_SUFFIX}
>       ${LUA_TEST_FLAGS}
>   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> diff --git a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
> index 3e6801a5..dd02130c 100644
> --- a/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
> +++ b/test/tarantool-tests/gh-4427-ffi-sandwich.test.lua
> @@ -3,10 +3,6 @@ local utils = require('utils')
> -- Disabled on *BSD due to #4819.
> utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819')
> 
> --- XXX: Tweak the process environment to get around SIP.
> --- See the comment in suite CMakeLists.txt for more info.
> -utils.tweakenv(jit.os == 'OSX', 'DYLD_LIBRARY_PATH')
> -
> utils.selfrun(arg, {
>   {
>     arg = {
> diff --git a/test/tarantool-tests/lj-flush-on-trace.test.lua b/test/tarantool-tests/lj-flush-on-trace.test.lua
> index 81fd6e8f..c46b93f0 100644
> --- a/test/tarantool-tests/lj-flush-on-trace.test.lua
> +++ b/test/tarantool-tests/lj-flush-on-trace.test.lua
> @@ -3,10 +3,6 @@ local utils = require('utils')
> -- Disabled on *BSD due to #4819.
> utils.skipcond(jit.os == 'BSD', 'Disabled due to #4819')
> 
> --- XXX: Tweak the process environment to get around SIP.
> --- See the comment in suite CMakeLists.txt for more info.
> -utils.tweakenv(jit.os == 'OSX', 'DYLD_LIBRARY_PATH')
> -
> utils.selfrun(arg, {
>   {
>     arg = {
> diff --git a/test/tarantool-tests/utils.lua b/test/tarantool-tests/utils.lua
> index 5bd42b30..3b809515 100644
> --- a/test/tarantool-tests/utils.lua
> +++ b/test/tarantool-tests/utils.lua
> @@ -1,13 +1,8 @@
> local M = {}
> 
> -local ffi = require('ffi')
> local tap = require('tap')
> local bc = require('jit.bc')
> 
> -ffi.cdef([[
> -  int setenv(const char *name, const char *value, int overwrite);
> -]])
> -
> local function luacmd(args)
>   -- arg[-1] is guaranteed to be not nil.
>   local idx = -2
> @@ -78,18 +73,6 @@ function M.skipcond(condition, message)
>   os.exit(test:check() and 0 or 1)
> end
> 
> -function M.tweakenv(condition, variable)
> -  if not condition or os.getenv(variable) then return end
> -  local testvar = assert(os.getenv('TEST_' .. variable),
> -                         ('Neither %s nor auxiliary TEST_%s variables are set')
> -                         :format(variable, variable))
> -  -- XXX: The third argument of setenv(3) is set to zero to forbid
> -  -- overwriting the <variable>. Since there is the check above
> -  -- whether this <variable> is set in the process environment, it
> -  -- just makes this solution foolproof.
> -  ffi.C.setenv(variable, testvar, 0)
> -end
> -
> function M.hasbc(f, bytecode)
>   assert(type(f) == 'function', 'argument #1 should be a function')
>   assert(type(bytecode) == 'string', 'argument #2 should be a string')
> -- 
> 2.33.1
> 


  reply	other threads:[~2022-06-02  8:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 10:24 [Tarantool-patches] [PATCH luajit 0/2] FFI: fix arm64 call for HFA Sergey Kaplun via Tarantool-patches
2021-12-09 10:24 ` [Tarantool-patches] [PATCH luajit 1/2] test: set DYLD_LIBRARY_PATH environment variable Sergey Kaplun via Tarantool-patches
2022-06-02  8:51   ` sergos via Tarantool-patches [this message]
2022-06-29  8:31   ` Igor Munkin via Tarantool-patches
2021-12-09 10:24 ` [Tarantool-patches] [PATCH luajit 2/2] FFI/ARM64: Fix pass-by-value struct calling conventions Sergey Kaplun via Tarantool-patches
2022-06-02  8:51   ` sergos via Tarantool-patches
2022-06-28 19:05     ` Sergey Kaplun via Tarantool-patches
2022-06-28 19:47       ` Sergey Ostanevich via Tarantool-patches
2022-06-29  8:45       ` Igor Munkin via Tarantool-patches
2022-06-30 12:11 ` [Tarantool-patches] [PATCH luajit 0/2] FFI: fix arm64 call for HFA Igor Munkin 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=FA4E1862-B413-434C-9177-92B062AB6560@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=sergos@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 1/2] test: set DYLD_LIBRARY_PATH environment variable' \
    /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