From bbde83899d6f76c50ad202879144432184e84293 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Fri, 19 Sep 2025 16:32:52 -0700 Subject: [PATCH] tests: env: skip a few tests if LD_LIBRARY_PATH is set * tests/env/env-null.sh: Skip test if LD_LIBRARY_PATH or platform's equivalent is set, since 'env -i' will unset it which may prevent programs from running. * tests/env/env-S.pl: Likewise. Issue and suggested fix reported by Bruno Haible. --- tests/env/env-S.pl | 13 +++++++++++++ tests/env/env-null.sh | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/env/env-S.pl b/tests/env/env-S.pl index 2d12c1843e..6e01975c79 100755 --- a/tests/env/env-S.pl +++ b/tests/env/env-S.pl @@ -27,6 +27,19 @@ $env =~ m!^([-+\@\w./]+)$! or CuSkip::skip "unusual absolute builddir name; skipping this test\n"; $env = $1; +# We may depend on a library found in LD_LIBRARY_PATH, or an equivalent +# environment variable. Skip the test if it is set since unsetting it may +# prevent us from running commands. +foreach my $var (qw(LD_LIBRARY_PATH LD_32_LIBRARY_PATH DYLD_LIBRARY_PATH + LIBPATH)) + { + if (exists $ENV{$var}) + { + CuSkip::skip ("programs may depend on $var being set; " + . "skipping this test\n"); + } + } + # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; diff --git a/tests/env/env-null.sh b/tests/env/env-null.sh index 27d8c5fb2c..c62e874023 100755 --- a/tests/env/env-null.sh +++ b/tests/env/env-null.sh @@ -19,6 +19,16 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ env printenv +# We may depend on a library found in LD_LIBRARY_PATH, or an equivalent +# environment variable. Skip the test if it is set since unsetting it may +# prevent us from running commands. +for var in LD_LIBRARY_PATH LD_32_LIBRARY_PATH DYLD_LIBRARY_PATH LIBPATH; do + eval val=\$$var + if test -n "$val"; then + skip_ "programs may depend on $var being set" + fi +done + # POSIX is clear that environ may, but need not be, sorted. # Environment variable values may contain newlines, which cannot be # observed by merely inspecting output from env. -- 2.47.3