mirror of
https://https.git.savannah.gnu.org/git/findutils.git
synced 2026-01-26 15:39:06 +00:00
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:
parent
28f11d689d
commit
2f9fff9e1f
@ -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
|
||||
|
||||
@ -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
|
||||
@ -1 +0,0 @@
|
||||
tmp/dir
|
||||
39
tests/find/depth-unreadable-dir.sh
Executable file
39
tests/find/depth-unreadable-dir.sh
Executable 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
|
||||
@ -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 \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user