* tests/instspc.test: Major rewrite to test for many other
[automake.git] / tests / instspc.test
blobbc63033c6c0e9658578a306269a0956be285b77e
1 #! /bin/sh
2 # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 # This file is part of GNU Automake.
6 # GNU Automake is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # GNU Automake is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Automake; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
21 # Check that installation to directory with shell metacharacters succeed.
22 # Original report from James Amundson about file names with spaces.
23 # Other characters added by Paul Eggert.
25 # This is mostly the same input as nobase.test, but we do not use
26 # libtool libraries, because Libtool does not preserve space in
27 # file names (Issue observed with ltmain.sh (GNU libtool) 1.5a (1.1323
28 # 2003/11/10 21:06:47))
31 required='gcc'
32 . ./defs || exit 1
34 set -e
36 # Set up files that won't change each time through the loop.
38 cat >> configure.in <<'EOF'
39 AC_PROG_CC
40 AC_PROG_RANLIB
41 AC_OUTPUT
42 EOF
44 mkdir sub
46 : > sub/base.h
47 : > sub/nobase.h
48 : > sub/base.dat
49 : > sub/nobase.dat
50 : > sub/base.sh
51 : > sub/nobase.sh
53 cat >source.c <<'EOF'
54 int
55 main (int argc, char **argv)
57 return 0;
59 EOF
60 cp source.c source2.c
62 cat > Makefile.am << 'EOF'
63 foodir = $(prefix)/foo
64 fooexecdir = $(prefix)/foo
66 foo_HEADERS = sub/base.h
67 nobase_foo_HEADERS = sub/nobase.h
69 dist_foo_DATA = sub/base.dat
70 nobase_dist_foo_DATA = sub/nobase.dat
72 dist_fooexec_SCRIPTS = sub/base.sh
73 nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
75 fooexec_PROGRAMS = sub/base
76 nobase_fooexec_PROGRAMS = sub/nobase
77 sub_base_SOURCES = source.c
78 sub_nobase_SOURCES = source.c
80 fooexec_LIBRARIES = sub/libbase.a
81 nobase_fooexec_LIBRARIES = sub/libnobase.a
82 sub_libbase_a_SOURCES = source.c
83 sub_libnobase_a_SOURCES = source.c
85 test-install-sep: install
86 test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
87 test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
88 test -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
89 test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
90 test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
91 test -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
92 test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
93 test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
94 test -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
95 test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
96 test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
97 test -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
98 test -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
99 test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
100 test -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
103 $ACLOCAL
104 $AUTOCONF
105 $AUTOMAKE -a
107 # Some control characters that are white space:
108 # back space, carriage return, form feed, horizontal tab, line feed, space
109 bs='\b'
110 cr=' '
111 ff='\f'
112 ht=' '
113 lf='
115 sp=' '
117 build_failures=
118 install_failures=
120 for file in \
121 '!' '"' '#' '$' '%' '&' \' '(' ')' '*' '+' ',' '-' ':' ';' \
122 '<' '=' '>' '?' '@' '[' '\' ']' '^' '`' '{' '|' '}' '~' \
123 "$bs" "$cr" "$ff" "$ht" "$lf" "$sp" \
124 '@<:@' '@:>@' '@S|@' '@%:@' '@&t@' \
125 "a${sp}b" "a${sp}${sp}b" "a${lf}b" ... a:
127 for test in build install; do
128 case $test in
129 build)
130 build=$file
131 dest=`pwd`/sub1;;
132 install)
133 build=sub1
134 dest=`pwd`/$file;;
135 esac
137 # Make sure this system supports this character in file names.
138 mkdir sub1 "./$file" || exit 77
140 cd "$build"
142 ../configure --prefix "/$file-prefix" &&
143 $MAKE &&
144 DESTDIR=$dest file=$file $MAKE -e test-install-sep ||
145 eval "${test}_failures=\"\$${test}_failures$lf\$file\""
147 cd ..
149 rm -fr sub1 "./$file"
150 done
151 done
153 # The list of the above file names that cannot be used as a build directory
154 # on a POSIX host. This list should be empty, but is not due to limitations
155 # in Autoconf, Automake, Make, or M4.
156 expected_build_failures='
161 '\''
164 '"$lf"'
165 @&t@
166 a'"${lf}"'b'
168 # Similarly, the list of file names that cannot be used as an install directory
169 # on a POSIX host. This list should also be empty.
170 expected_install_failures='
174 '\''
177 '"$lf"'
178 a'"${lf}"'b'
180 fail=0
181 for test in build install; do
182 eval failures=\$${test}_failures
183 case $failures in
185 cat >&2 <<EOF
186 $0: $test test failed for the following file names:$failures
188 eval test \"\$failures\" = \"\$expected_${test}_failures\" || fail=1
189 esac
190 done
192 exit $fail