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