diff options
author | Jim Meyering <meyering@redhat.com> | 2009-11-23 17:35:20 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-11-23 17:49:39 +0100 |
commit | ab6b27eba720c04da91f5300121a6fe06d1fa9b4 (patch) | |
tree | 627c8af72d526d4ae6640dfa33ff338800771865 /tests | |
parent | 9cf9f8e1e05c07e9dcf707e604b37c9a8f736c29 (diff) | |
download | coreutils-ab6b27eba720c04da91f5300121a6fe06d1fa9b4.tar.xz |
tests: avoid test failures when PATH contains an unsearchable directory
* tests/test-lib.sh (sanitize_path_): New function.
Always call it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-lib.sh | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 456a30a24..06087ea29 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -23,6 +23,31 @@ if test $? != 11; then Exit 77 fi +# Having an unsearchable directory in PATH causes execve to fail with EACCES +# when applied to an unresolvable program name, contrary to the desired ENOENT. +# Avoid the problem by rewriting PATH to exclude unsearchable directories. +sanitize_path_() +{ + local saved_IFS=$IFS + IFS=: + set - $PATH + IFS=$saved_IFS + + local d d1 + local colon= + local new_path= + for d in "$@"; do + test -z "$d" && d1=. || d1=$d + if ls -d "$d1/." > /dev/null 2>&1; then + new_path="$new_path$colon$d" + colon=':' + fi + done + + PATH=$new_path + export PATH +} + skip_test_() { echo "$0: skipping test: $@" | head -1 1>&9 @@ -54,7 +79,6 @@ require_selinux_enforcing_() || skip_test_ "This test is useful only with SELinux in Enforcing mode." } - require_openat_support_() { # Skip this test if your system has neither the openat-style functions @@ -396,5 +420,7 @@ else compare() { cmp "$@"; } fi +sanitize_path_ + # Initialize; all bourne shell scripts end with "Exit $fail". fail=0 |