2 # Basic tests for "install".
4 # Copyright (C) 1998-2016 Free Software Foundation, Inc.
6 # This program 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 3 of the License, or
9 # (at your option) any later version.
11 # This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
26 rm -rf $dir $file || framework_failure_
27 mkdir
-p $dir || framework_failure_
28 echo foo
> $file || framework_failure_
30 ginstall
$file $dir || fail
=1
31 # Make sure the source file still exists.
32 test -f $file || fail
=1
33 # Make sure the dest file has been created.
34 test -f $dir/$file || fail
=1
36 # Make sure strip works.
40 just_built_dd
=$abs_top_builddir/src
/$dd
42 test -r "$just_built_dd" \
43 || warn_
"WARNING!!! Your just-built dd binary, $just_built_dd
44 is not readable, so skipping the remaining tests in this file."
46 cp "$just_built_dd" . || fail
=1
51 ! test -e $abs_top_builddir/src
/coreutils \
52 && warn_
"WARNING!!! Your strip command doesn't seem to work,
53 so skipping the test of install's --strip option."
57 # This test would fail with 3.16s when using versions of strip that
58 # don't work on read-only files (the one from binutils works fine).
59 ginstall
$strip -c -m 555 $dd $dir || fail
=1
60 # Make sure the source file is still around.
63 # Make sure that the destination file has the requested permissions.
64 mode
=$
(ls -l $dir/$dd|cut
-b-10)
65 test "$mode" = -r-xr-xr-x || fail
=1
67 # These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
68 ginstall
-d . || fail
=1
69 ginstall
-d newdir || fail
=1
70 test -d newdir || fail
=1
71 ginstall
-d newdir1 newdir2 newdir3 || fail
=1
72 test -d newdir1 || fail
=1
73 test -d newdir2 || fail
=1
74 test -d newdir3 || fail
=1
76 # This fails because mkdir-p.c's make_dir_parents fails to return to its
77 # initial working directory ($iwd) after creating the first argument, and
78 # hence cannot do anything meaningful with the following relative-named dirs.
83 returns_
1 ginstall
-d "$iwd/xx/yy" rel
/sub1 rel
/sub2
2> /dev
/null
87 # Ensure that the first argument-dir has been created.
88 test -d xx
/yy || fail
=1
90 # Make sure that the 'rel' directory was not created...
91 test -d sub
/rel
&& fail
=1
92 # and make sure it was not created in the wrong place.
93 test -d xx
/rel
&& fail
=1
95 # Test that we can install from an unreadable directory with an
96 # inaccessible parent. coreutils 5.97 fails this test.
97 # Perform this test only if "." is on a local file system.
98 # Otherwise, it would fail e.g., on an NFS-mounted file system.
99 if is_local_dir_ .
; then
100 mkdir
-p sub
1/d || fail
=1
101 (cd sub
1/d
&& chmod a-r .
&& chmod a-rx ..
&&
102 ginstall
-d "$iwd/xx/zz" rel
/a rel
/b
) || fail
=1
103 chmod 755 sub1 sub
1/d || fail
=1
104 test -d xx
/zz || fail
=1
105 test -d sub
1/d
/rel
/a || fail
=1
106 test -d sub
1/d
/rel
/b || fail
=1
110 ginstall
-Dv file sub
3/a
/b
/c
/file >out
2>&1 || fail
=1
111 compare
- out
<<\EOF || fail
=1
112 ginstall
: creating directory
'sub3'
113 ginstall
: creating directory
'sub3/a'
114 ginstall
: creating directory
'sub3/a/b'
115 ginstall
: creating directory
'sub3/a/b/c'
116 'file' -> 'sub3/a/b/c/file'
119 # Test -D together with -t (available since coreutils >= 8.23).
120 # Let ginstall create a completely new destination hierarchy.
121 ginstall
-t sub
4/a
/b
/c
-Dv file >out
2>&1 || fail
=1
122 compare
- out
<<\EOF || fail
=1
123 ginstall
: creating directory
'sub4'
124 ginstall
: creating directory
'sub4/a'
125 ginstall
: creating directory
'sub4/a/b'
126 ginstall
: creating directory
'sub4/a/b/c'
127 'file' -> 'sub4/a/b/c/file'
130 # Ensure that -D with an already existing file as -t's option argument fails.
131 touch sub
4/file_exists || framework_failure_
132 ginstall
-t sub
4/file_exists
-Dv file >out
2>&1 && fail
=1
133 compare
- out
<<\EOF || fail
=1
134 ginstall
: target
'sub4/file_exists' is not a directory
137 # Ensure that -D with an already existing directory for -t's option argument
139 mkdir sub
4/dir_exists || framework_failure_
140 touch sub
4/dir_exists || framework_failure_
141 ginstall
-t sub
4/dir_exists
-Dv file >out
2>&1 || fail
=1
142 compare
- out
<<\EOF || fail
=1
143 'file' -> 'sub4/dir_exists/file'