automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [PATCH 1/6] [ng] coverage: cleaning rules with lots of fil


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 1/6] [ng] coverage: cleaning rules with lots of files to clean
Date: Sat, 7 Jul 2012 22:40:42 +0200

* 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 <address@hidden>
---
 t/clean-many.sh  |   63 ++++++++++++++++++++++++++++++++++++++++++
 t/clean-many2.sh |   81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 144 insertions(+)
 create mode 100755 t/clean-many.sh
 create mode 100755 t/clean-many2.sh

diff --git a/t/clean-many.sh b/t/clean-many.sh
new file mode 100755
index 0000000..3f3d9a7
--- /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 <http://www.gnu.org/licenses/>.
+
+# 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.
address@hidden@ 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 <files.mk) -eq 65538 || fatal_ "populating 'files.mk'"
+
+touch foo bar
+$MAKE maintainer-clean
+test ! -e foo
+test ! -e bar
+
+:
diff --git a/t/clean-many2.sh b/t/clean-many2.sh
new file mode 100755
index 0000000..e7505be
--- /dev/null
+++ b/t/clean-many2.sh
@@ -0,0 +1,81 @@
+#! /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 <http://www.gnu.org/licenses/>.
+
+# 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
+
+:
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]