Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / instmany-python.test
1 #! /bin/sh
2 # Copyright (C) 2008, 2009, 2010 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 set -e
25
26 limit=2500
27 subdir=long_subdir_name_with_many_characters
28 nfiles=81
29
30 list=`(seq 1 $nfiles) 2>/dev/null || {
31   i=1
32   while test $i -le $nfiles; do
33     echo $i
34     i=\`expr $i + 1\`
35   done; }`
36
37 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
38 #! /bin/sh
39 # Fake install script.  This doesn't really install
40 # (the INSTALL path below would be wrong outside this directory).
41 limit=@limit@
42 INSTALL='@INSTALL@'
43 len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
44 if test $len -ge $limit; then
45   echo "$0: safe command line limit of $limit characters exceeded" >&2
46   exit 1
47 fi
48 exit 0
49 END
50
51 # Creative quoting in the next line to please maintainer-check.
52 sed "s|@limit@|$limit|g" >'rm' <<'END'
53 #! /bin/sh
54 limit=@limit@
55 PATH=$save_PATH
56 export PATH
57 RM='rm -f'
58 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
59 if test $len -ge $limit; then
60   echo "$0: safe command line limit of $limit characters exceeded" >&2
61   exit 1
62 fi
63 exec $RM "$@"
64 exit 1
65 END
66
67 chmod +x rm
68
69 cat >>configure.in <<END
70 AM_PATH_PYTHON
71 AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
72 AC_CONFIG_FILES([$subdir/Makefile])
73 AC_OUTPUT
74 END
75
76 cat >Makefile.am <<END
77 SUBDIRS = $subdir
78 END
79
80 mkdir $subdir
81 cd $subdir
82
83 cat >Makefile.am <<'END'
84 python_PYTHON =
85 nobase_python_PYTHON =
86 END
87
88 for n in $list; do
89   cat >>Makefile.am <<END
90 python_PYTHON += python$n.py
91 nobase_python_PYTHON += npython$n.py
92 END
93   echo >python$n.py
94   echo >npython$n.py
95 done
96
97 cd ..
98 $ACLOCAL
99 $AUTOCONF
100 $AUTOMAKE --add-missing
101
102 instdir=`pwd`/inst
103 mkdir build
104 cd build
105 ../configure --prefix="$instdir"
106 $MAKE
107 # Try whether native install (or install-sh) works.
108 $MAKE install
109 # Multiple uninstall should work, too.
110 $MAKE uninstall
111 $MAKE uninstall
112 test `find "$instdir" -type f -print | wc -l` = 0
113
114 # Try whether we don't exceed the low limit.
115 INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
116 env save_PATH="$PATH" PATH="`pwd`/..$PATH_SEPARATOR$PATH" $MAKE uninstall
117
118 cd $subdir
119 srcdir=../../$subdir
120
121 # Ensure 'make install' fails when 'install' fails.
122
123 for file in python3.py python$nfiles.py
124 do
125   chmod a-r $srcdir/$file
126   test ! -r $srcdir/$file || Exit 77
127   $MAKE install && Exit 1
128   chmod u+r $srcdir/$file
129 done
130
131 for file in npython3.py npython$nfiles.py
132 do
133   chmod a-r $srcdir/$file
134   $MAKE install && Exit 1
135   chmod u+r $srcdir/$file
136 done
137
138 :