From: Stefano Lattarini Date: Mon, 2 Jul 2012 10:04:36 +0000 (+0200) Subject: [ng] coverage: cleaning rules with lots of files to clean X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8a46a77d412b3bd5d371f5f35281b91efe1dc18;p=thirdparty%2Fautomake.git [ng] coverage: cleaning rules with lots of files to clean * t/clean-many.sh: New test, try cleaning ~ 130 thousands files. Currently fails on some systems (e.g., NetBSD 5.1). * t/clean-many2.sh: New test, check that our cleaning rules do not hit errors due to an exceeded command line length when there are many files to clean; it does so by faking a very low command line length limit for 'rm' (max 50 arguments). Currently failing. Signed-off-by: Stefano Lattarini --- diff --git a/t/clean-many.sh b/t/clean-many.sh new file mode 100755 index 000000000..3f3d9a739 --- /dev/null +++ b/t/clean-many.sh @@ -0,0 +1,63 @@ +#! /bin/sh +# Copyright (C) 2012 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 2, 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 . + +# Check that our cleaning rules do not hit errors due to a huge number +# of files to be removed. Checks similar in spirit are done by sister +# test 'clean-many2.sh', which fakes an artificially low command line +# length limit for 'rm'. + +. ./defs || exit 1 + +cat >> configure.ac << 'END' +AC_SUBST([safe_include], [include]) +AC_OUTPUT +END + +cat > Makefile.am <<'END' +# Don't use 'include' here: we want this processed at make runtime, +# not at automake runtime. Otherwise Automake runs too slow. +@safe_include@ files.mk +MOSTLYCLEANFILES = $(files) +CLEANFILES = $(files) +DISTCLEANFILES = $(files) +MAINTANERCLEANFILES = $(files) +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure + +# Yes, we want to clean ~ 130 thousands files. So what? +i=2 +echo foo bar > t +while test $i -le 17; do + i=$(($i + 1)) + cat t t > t2 + mv -f t2 t +done +(echo 'files = \' && sed 's/$/ \\/' t && echo '$(am__empty)') > files.mk +rm -f t + +# 2^17 + 2 = 131074. +test $(wc -l . + +# Check that our cleaning rules do not hit errors due to an exceeded +# command line length when there are many files to clean. Here, we +# fake a very low command line length limit for 'rm' (max 50 arguments). +# The sister test 'clean-many.sh' try to hit the real command line length +# limit of the system, by declaring a huge number of files to be cleaned. + +. ./defs || exit 1 + +echo AC_OUTPUT >> configure.ac + +oPATH=$PATH; export oPATH +mkdir bin +cat > bin/rm <<'END' +#!/bin/sh +PATH=$oPATH; export PATH +if test $# -eq 0; then + echo "rm: missing argument" >&2 + exit 1 +elif test $# -gt 50; then + echo "rm: argument list too long ($# arguments)" >&2 + exit 1 +fi +exec rm "$@" +END +chmod a+x bin/rm +PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH + +cat > Makefile.am <<'END' +MOSTLYCLEANFILES = $(files) +CLEANFILES = $(files) +DISTCLEANFILES = $(files) +MAINTANERCLEANFILES = $(files) +include files.am +END + +echo foo bar > t +i=1 +while test $i -le 10; do + cat t t > t2 && mv -f t2 t || exit 99 + i=$(($i + 1)) +done + +# Sanity check. +rm -f $(cat t) && fatal_ "setting up 'rm' wrapper" + +(echo 'files = \' && sed 's/$/ \\/' t && echo '$(am__empty)') >files.am +rm -f t + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a +./configure +cp config.status config-status.sav \ + +for target in mostlyclean clean distclean maintainer-clean; do + echo dummy > foo + echo dummy > bar + $MAKE $target + test ! -e foo + test ! -e foo + cp config-status.sav config.status && ./config.status Makefile \ + || fatal_ "resetting Makefile after cleanup" +done + +: