summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2020-02-09 19:58:07 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2020-02-10 18:54:40 +0100
commit2f9fff9e1f0c0b7a9034d7c46ca197ce693c4736 (patch)
treedd3c4677bbd2b61a48a1a48d99f8c0d4df445b67
parent28f11d689dc61f9202de44078d67299419fbad26 (diff)
downloadfindutils-2f9fff9e1.tar.gz
tests: avoid FP when run as root
Test 'sv-bug-54171' produced a false-positive error as 'find' would not fail for an unreadable directory when run as root. Migrate the test to the newer shell-based tests, and add the 'skip_if_root_' guard to avoid a false-positive. * find/testsuite/find.posix/sv-bug-54171.exp: Remove. * find/testsuite/find.posix/sv-bug-54171.xo: Remove. * find/testsuite/Makefile.am (EXTRA_DIST_XO, EXTRA_DIST_EXP): Remove the above deleted test. * tests/find/depth-unreadable-dir.sh: Add test. * tests/local.mk (all_tests): Reference it. Test FP introduced in commit v4.6.0-178-gdf4610d0. Fixes https://savannah.gnu.org/bugs/?57762 and https://bugzilla.redhat.com/1799064
-rw-r--r--find/testsuite/Makefile.am2
-rw-r--r--find/testsuite/find.posix/sv-bug-54171.exp5
-rw-r--r--find/testsuite/find.posix/sv-bug-54171.xo1
-rwxr-xr-xtests/find/depth-unreadable-dir.sh39
-rw-r--r--tests/local.mk1
5 files changed, 40 insertions, 8 deletions
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index d252451..77a2902 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -119,7 +119,6 @@ find.posix/prune-stat.xo \
find.posix/sizetype.xo \
find.posix/sv-bug-15235.xo \
find.posix/sv-bug-19613.xo \
-find.posix/sv-bug-54171.xo \
find.posix/typesize.xo
@@ -246,7 +245,6 @@ find.posix/sv-bug-15235.exp \
find.posix/sv-bug-19605.exp \
find.posix/sv-bug-19613.exp \
find.posix/sv-bug-19617.exp \
-find.posix/sv-bug-54171.exp \
find.posix/typesize.exp \
find.posix/user-empty.exp \
find.posix/user-missing.exp
diff --git a/find/testsuite/find.posix/sv-bug-54171.exp b/find/testsuite/find.posix/sv-bug-54171.exp
deleted file mode 100644
index 8e5448f..0000000
--- a/find/testsuite/find.posix/sv-bug-54171.exp
+++ /dev/null
@@ -1,5 +0,0 @@
-exec rm -rf tmp
-exec mkdir tmp tmp/dir
-exec chmod 0311 tmp/dir
-find_start f {tmp -depth -name dir }
-exec rm -rf tmp
diff --git a/find/testsuite/find.posix/sv-bug-54171.xo b/find/testsuite/find.posix/sv-bug-54171.xo
deleted file mode 100644
index 2dc4706..0000000
--- a/find/testsuite/find.posix/sv-bug-54171.xo
+++ /dev/null
@@ -1 +0,0 @@
-tmp/dir
diff --git a/tests/find/depth-unreadable-dir.sh b/tests/find/depth-unreadable-dir.sh
new file mode 100755
index 0000000..86e2fd6
--- /dev/null
+++ b/tests/find/depth-unreadable-dir.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# find -depth: ensure to output an unreadable directory.
+
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; fu_path_prepend_
+print_ver_ find
+
+# Find run as root would not fail for an unreadable directory.
+skip_if_root_
+
+# Prepare an unreadable directory, and the expected stdout/stderr.
+mkdir tmp tmp/dir \
+ && chmod 0311 tmp/dir \
+ && echo 'tmp/dir' > exp \
+ && echo "find: 'tmp/dir': Permission denied" > experr \
+ || framework_failure_
+
+# Run FTS-based find with -depth; versions < 4.7.0 failed to output
+# an unreadable directory (see #54171).
+returns_ 1 find tmp -depth -name dir > out 2> err || fail=1
+
+compare exp out || fail=1
+compare experr err || fail=1
+
+Exit $fail
diff --git a/tests/local.mk b/tests/local.mk
index dccc734..986df55 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -106,6 +106,7 @@ check-root:
all_tests = \
tests/misc/help-version.sh \
+ tests/find/depth-unreadable-dir.sh \
tests/find/many-dir-entries-vs-OOM.sh \
tests/find/name-lbracket-literal.sh \
tests/find/printf_escapechars.sh \