mirror of
https://https.git.savannah.gnu.org/git/findutils.git
synced 2026-01-26 15:39:06 +00:00
tests: migrate 'execdir-fd-leak' to the new testsuite
* find/testsuite/sv-34976-execdir-fd-leak.sh: Move to ... * tests/find/execdir-fd-leak.sh: ... this, and apply the above. Simplify, and make more robust. * find/testsuite/Makefile.am (tests_shell_progs): Remove the reference to this test ... * tests/local.mk (all_tests): .. and add it here.
This commit is contained in:
parent
c809ce8fa2
commit
1027613d0f
@ -253,7 +253,6 @@ find.posix/user-missing.exp
|
||||
|
||||
test_shell_progs = \
|
||||
test_type-list.sh \
|
||||
sv-34976-execdir-fd-leak.sh \
|
||||
sv-48030-exec-plus-bug.sh \
|
||||
sv-48180-refuse-noop.sh \
|
||||
sv-52220.sh
|
||||
|
||||
@ -1,26 +1,25 @@
|
||||
#! /bin/sh
|
||||
#!/bin/sh
|
||||
# This test verifies that find does not leak a file descriptor for the working
|
||||
# directory specified by the -execdir option.
|
||||
# See Savannah bug #34976.
|
||||
|
||||
# Copyright (C) 2013-2019 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/>.
|
||||
#
|
||||
|
||||
# This test verifies that find does not leak a file descriptor for the working
|
||||
# directory specified by the -execdir option [Savannah bug #34976].
|
||||
|
||||
testname="$(basename $0)"
|
||||
|
||||
. "${srcdir}"/binary_locations.sh
|
||||
. "${srcdir=.}/tests/init.sh"
|
||||
print_ver_ find oldfind
|
||||
|
||||
# seq is not required by POSIX, so we have manual lists of number here instead.
|
||||
three_to_thirty_five="3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35"
|
||||
@ -37,44 +36,31 @@ test_ulimit() {
|
||||
done | sh -x ;
|
||||
) 2>/dev/null
|
||||
}
|
||||
# Opening 33 files with a limit of 50 should work.
|
||||
# Opening 33 files with a limit of 40 should work.
|
||||
test_ulimit 40 || { echo "SKIP: ulimit does not work (case 1)" >&2; exit 0 ; }
|
||||
# Opening 33 files with a limit of 20 should fail.
|
||||
test_ulimit 20 && { echo "SKIP: ulimit does not work (case 2)" >&2; exit 0 ; }
|
||||
|
||||
die() {
|
||||
echo "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create test files, each 98 in the directories ".", "one" and "two".
|
||||
make_test_data() {
|
||||
d="$1"
|
||||
(
|
||||
cd "$1" || exit 1
|
||||
mkdir one two || exit 1
|
||||
for i in ${three_to_hundred} ; do
|
||||
# We don't quote the RHS here because we actually want to create 3 files.
|
||||
touch $(printf './%03d one/%03d two/%03d ' $i $i $i) || exit 1
|
||||
done
|
||||
) \
|
||||
|| die "failed to set up the test in ${outdir}"
|
||||
mkdir one two || return 1
|
||||
for i in ${three_to_hundred} ; do
|
||||
# We don't quote the RHS here because we actually want to create 3 files.
|
||||
touch $(printf './%03d one/%03d two/%03d ' $i $i $i) \
|
||||
|| return 1
|
||||
done
|
||||
}
|
||||
|
||||
outdir="$(mktemp -d)" || die "FAIL: could not create a test files."
|
||||
|
||||
# Create some test files.
|
||||
make_test_data "${outdir}" || die "FAIL: failed to set up the test in ${outdir}"
|
||||
make_test_data \
|
||||
|| framework_failure_ "failed to set up the test"
|
||||
|
||||
fail=0
|
||||
for exe in "${ftsfind}" "${oldfind}"; do
|
||||
for exe in find oldfind; do
|
||||
( ulimit -n 30 && \
|
||||
${exe} "${outdir}" -type f -execdir cat '{}' \; >/dev/null; ) \
|
||||
|| { \
|
||||
echo "Option -execdir of ${exe} leaks file descriptors" >&2 ; \
|
||||
fail=1 ; \
|
||||
}
|
||||
${exe} . -type f -execdir cat '{}' \; >/dev/null; \
|
||||
) \
|
||||
|| { echo "Option -execdir of ${exe} leaks file descriptors" >&2 ; \
|
||||
fail=1 ; }
|
||||
done
|
||||
|
||||
rm -rf "${outdir}" || exit 1
|
||||
exit $fail
|
||||
Exit $fail
|
||||
@ -109,6 +109,7 @@ all_tests = \
|
||||
tests/find/printf_escapechars.sh \
|
||||
tests/find/printf_escape_c.sh \
|
||||
tests/find/printf_inode.sh \
|
||||
tests/find/execdir-fd-leak.sh \
|
||||
$(all_root_tests)
|
||||
|
||||
$(TEST_LOGS): $(PROGRAMS)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user