2 # Copyright (C) 2011 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This test verifies that find does not have excessive memory consumption
19 # even for large directories. It's not executed by default; it will only
20 # run if the environment variable RUN_VERY_EXPENSIVE_TESTS is set.
22 testname="$(basename $0)"
24 . "${srcdir}"/binary_locations.sh
29 cd "$1" && echo "Creating test data in $(pwd -P)" >&2 || exit 1
33 printf "\r%03d/%03d" $i $max >&2
34 for j in $(seq 0 10000)
36 printf "%03d_%04d " $i $j
38 done | xargs sh -c 'touch "$@" || exit 255' fnord || exit 1
39 printf "\rTest files created.\n" >&2
44 if [[ -n "${RUN_VERY_EXPENSIVE_TESTS}" ]]; then
45 if outdir=$(mktemp -d); then
46 # Create some test files.
48 printf "Generating test data in %s (this may take some time...):\n" \
50 if make_test_data "${outdir}"; then
51 # We don't check oldfind, as it uses savedir, meaning that
52 # it stores all the directory entries. Hence the excessive
53 # memory consumption bug applies to oldfind even though it is
55 for exe in "${ftsfind}" "${oldfind}"; do
56 echo "Checking memory consumption of ${exe}..." >&2
57 if ( ulimit -v 50000 && ${exe} "${outdir}" >/dev/null; ); then
58 echo "Memory consumption of ${exe} is reasonable" >&2
60 bad="${bad}${bad:+\n}Memory consumption of ${exe} is too high"
64 bad="failed to set up the test in ${outdir}"
66 rm -rf "${outdir}" || exit 1
67 if [[ -n "${bad}" ]]; then
72 echo "FAIL: could not create a test output file." >&2
76 echo "${testname} was not run because" '${RUN_VERY_EXPENSIVE_TESTS}' \