tests: avoid two spurious failures on FreeBSD
[automake.git] / t / instmany-python.sh
blob9cc659ad548d93c1e340df85b2f07fe42671aa57
1 #! /bin/sh
2 # Copyright (C) 2008-2012 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 2, or (at your option)
7 # 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/>.
17 # Installing many files should not exceed the command line length limit.
19 # This is the python sister test of 'instmany.sh', see there for details.
21 required='python'
22 . ./defs || exit 1
24 limit=2500
25 subdir=long_subdir_name_with_many_characters
26 nfiles=81
27 list=$(seq_ 1 $nfiles)
29 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
30 #! /bin/sh
31 # Fake install script. This doesn't really install
32 # (the INSTALL path below would be wrong outside this directory).
33 limit=@limit@
34 INSTALL='@INSTALL@'
35 len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
36 if test $len -ge $limit; then
37 echo "$0: safe command line limit of $limit characters exceeded" >&2
38 exit 1
40 exit 0
41 END
43 # Creative quoting in the next line to please maintainer-check.
44 sed "s|@limit@|$limit|g" >'rm' <<'END'
45 #! /bin/sh
46 limit=@limit@
47 PATH=$save_PATH
48 export PATH
49 RM='rm -f'
50 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
51 if test $len -ge $limit; then
52 echo "$0: safe command line limit of $limit characters exceeded" >&2
53 exit 1
55 exec $RM "$@"
56 exit 1
57 END
59 chmod +x rm
61 cat >>configure.ac <<END
62 AM_PATH_PYTHON
63 AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
64 AC_CONFIG_FILES([$subdir/Makefile])
65 AC_OUTPUT
66 END
68 cat >Makefile.am <<END
69 SUBDIRS = $subdir
70 END
72 mkdir $subdir
73 cd $subdir
75 cat >Makefile.am <<'END'
76 python_PYTHON =
77 nobase_python_PYTHON =
78 END
80 for n in $list; do
81 unindent >>Makefile.am <<END
82 python_PYTHON += python$n.py
83 nobase_python_PYTHON += npython$n.py
84 END
85 echo >python$n.py
86 echo >npython$n.py
87 done
89 cd ..
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE --add-missing
94 instdir=$(pwd)/inst
95 mkdir build
96 cd build
97 ../configure --prefix="$instdir"
98 $MAKE
99 # Try whether native install (or install-sh) works.
100 $MAKE install
101 # Multiple uninstall should work, too.
102 $MAKE uninstall
103 $MAKE uninstall
104 test $(find "$instdir" -type f -print | wc -l) -eq 0
106 # Try whether we don't exceed the low limit.
107 INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
108 env save_PATH="$PATH" PATH="$(pwd)/..$PATH_SEPARATOR$PATH" $MAKE uninstall
110 cd $subdir
111 srcdir=../../$subdir
113 # Ensure 'make install' fails when 'install' fails.
115 for file in python3.py python$nfiles.py
117 chmod a-r $srcdir/$file
118 test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
119 $MAKE install && exit 1
120 chmod u+r $srcdir/$file
121 done
123 for file in npython3.py npython$nfiles.py
125 chmod a-r $srcdir/$file
126 $MAKE install && exit 1
127 chmod u+r $srcdir/$file
128 done