tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / instsh2.sh
blob9e6182c80931433bd608fd7bafd61d1391e7f6a1
1 #! /bin/sh
2 # Copyright (C) 2002-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 # Various install-sh checks.
19 am_create_testdir=empty
20 . ./defs || exit 1
22 get_shell_script install-sh
24 # Basic errors.
25 ./install-sh && exit 1
26 ./install-sh -m 644 dest && exit 1
28 # Directories.
30 # It should be OK to create no directory. We sometimes need
31 # this when directory are conditionally defined.
32 ./install-sh -d
33 # One directory.
34 ./install-sh -d d0
35 test -d d0
36 # Multiple directories (for make installdirs).
37 ./install-sh -d d1 d2 d3 d4
38 test -d d1
39 test -d d2
40 test -d d3
41 test -d d4
42 # Subdirectories.
43 ./install-sh -d p1/p2/p3 p4//p5//p6//
44 test -d p1/p2/p3
45 test -d p4/p5/p6
47 # Files.
48 : > x
49 ./install-sh -c -m 644 x y
50 test -f x
51 test -f y
52 ./install-sh -m 644 y z
53 test -f y
54 test -f z
55 # Multiple files.
56 ./install-sh -m 644 -c x z d1
57 test -f x
58 test -f z
59 test -f d1/x
60 test -f d1/z
61 ./install-sh -m 644 x z d2//
62 test -f x
63 test -f z
64 test -f d2/x
65 test -f d2/z
66 ./install-sh -t d3 -m 644 x z
67 test -f x
68 test -f z
69 test -f d3/x
70 test -f d3/z
71 ./install-sh -t d4// -m 644 x z
72 test -f x
73 test -f z
74 test -f d4/x
75 test -f d4/z
76 ./install-sh -T x d3/y
77 test -f x
78 test -f d3/y
79 ./install-sh -T x d3 && exit 1
80 ./install-sh -T x d4// && exit 1
82 # Ensure that install-sh works with names that include spaces.
83 touch 'a b'
84 mkdir 'x y'
85 ./install-sh 'a b' 'x y'
86 test -f x\ \ y/a\ \ b
87 test -f 'a b'
89 # Ensure we do not run into 'test' operator precedence bugs with Tru64 sh.
90 for c in = '(' ')' '!'; do
91 ./install-sh $c 2>stderr && { cat stderr >&2; exit 1; }
92 cat stderr >&2
93 grep 'test: ' stderr && exit 1
94 # Skip tests if the file system is not capable.
95 mkdir ./$c || continue
96 rmdir ./$c
97 ./install-sh -d $c/$c/$c
98 rm -rf ./$c
99 ./install-sh -d $c d5/$c/$c
100 test -d ./$c
101 test -d d5/$c/$c
102 ./install-sh x $c
103 test -f ./$c/x
104 rm -f ./$c/x
105 ./install-sh -t $c x
106 test -f ./$c/x
107 rm -rf ./$c
108 ( : > ./$c ) || continue
109 ./install-sh $c x d5/$c/$c
110 test -f d5/$c/$c/x
111 test -f d5/$c/$c/$c
112 rm -f d5/$c/$c/?
113 ./install-sh -t d5/$c/$c $c x
114 test -f d5/$c/$c/x
115 test -f d5/$c/$c/$c
116 done