]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: env: skip a few tests if LD_LIBRARY_PATH is set
authorCollin Funk <collin.funk1@gmail.com>
Fri, 19 Sep 2025 23:32:52 +0000 (16:32 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 19 Sep 2025 23:40:09 +0000 (16:40 -0700)
* 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
tests/env/env-null.sh

index 2d12c1843e4998051c993e859d69640fdf25bb43..6e01975c794ed92c1e2ba11d07ea64790f30dd48 100755 (executable)
@@ -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;
 
index 27d8c5fb2c55e6780217f90ca6da1a6d288ef681..c62e8740238e7dcb06111a48975133b0f5f9318f 100755 (executable)
 . "${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.