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
This commit is contained in:
Bernhard Voelker 2020-02-09 19:58:07 +01:00
parent 28f11d689d
commit 2f9fff9e1f
5 changed files with 40 additions and 8 deletions

View File

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

View File

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

View File

@ -1 +0,0 @@
tmp/dir

View File

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

View File

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