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.
This commit is contained in:
Collin Funk 2025-09-19 16:32:52 -07:00
parent d9ff4d9af2
commit bbde83899d
2 changed files with 23 additions and 0 deletions

13
tests/env/env-S.pl vendored
View File

@ -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;

10
tests/env/env-null.sh vendored
View File

@ -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.