003191320d5a717bc51874ccda8161aa4476304b
[platform/upstream/automake.git] / tests / instmany-python.test
1 #! /bin/sh
2 # Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Installing many files should not exceed the command line length limit.
18
19 # This is the python sister test of instmany.test, see there for details.
20
21 required='python'
22 . ./defs || Exit 1
23
24 limit=2500
25 subdir=long_subdir_name_with_many_characters
26 nfiles=81
27 list=`seq_ 1 $nfiles`
28
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
39 fi
40 exit 0
41 END
42
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
54 fi
55 exec $RM "$@"
56 exit 1
57 END
58
59 chmod +x rm
60
61 cat >>configure.in <<END
62 AM_PATH_PYTHON
63 AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
64 AC_CONFIG_FILES([$subdir/Makefile])
65 AC_OUTPUT
66 END
67
68 cat >Makefile.am <<END
69 SUBDIRS = $subdir
70 END
71
72 mkdir $subdir
73 cd $subdir
74
75 cat >Makefile.am <<'END'
76 python_PYTHON =
77 nobase_python_PYTHON =
78 END
79
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
88
89 cd ..
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE --add-missing
93
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` = 0
105
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
109
110 cd $subdir
111 srcdir=../../$subdir
112
113 # Ensure 'make install' fails when 'install' fails.
114
115 for file in python3.py python$nfiles.py
116 do
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
122
123 for file in npython3.py npython$nfiles.py
124 do
125   chmod a-r $srcdir/$file
126   $MAKE install && Exit 1
127   chmod u+r $srcdir/$file
128 done
129
130 :