* gnulib: Update submodule to latest.
[coreutils.git] / tests / install / basic-1
blob09c8d4437b9a164c46b6d01b15cdbc0644577ce9
1 #! /bin/sh
2 # Basic tests for "install".
4 # Copyright (C) 1998, 2000-2002, 2004-2008 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 if test "$VERBOSE" = yes; then
20 set -x
21 ginstall --version
24 . $srcdir/test-lib.sh
25 skip_if_root_
27 dir=dir
28 file=file
30 rm -rf $dir $file || framework_failure
31 mkdir -p $dir || framework_failure
32 echo foo > $file || framework_failure
34 fail=0
35 ginstall $file $dir || fail=1
36 # Make sure the source file still exists.
37 test -f $file || fail=1
38 # Make sure the dest file has been created.
39 test -f $dir/$file || fail=1
41 # Make sure strip works.
42 dd=dd$EXEEXT
43 dd2=dd2$EXEEXT
45 just_built_dd=$abs_top_builddir/src/$dd
47 test -r "$just_built_dd" || \
49 cat 1>&2 <<EOF
50 $0: WARNING!!!
51 Your just-built dd binary, $just_built_dd
52 is not readable, so skipping the remaining tests in this file.
53 EOF
54 exit 77
57 cp "$just_built_dd" . || fail=1
58 cp $dd $dd2 || fail=1
60 strip $dd2 || \
62 cat 1>&2 <<EOF
63 $0: WARNING!!!
64 Your strip command doesn't seem to work, so skipping
65 the test of install's --strip option.
66 EOF
67 exit 77
70 # This test would fail with 3.16s when using versions of strip that
71 # don't work on read-only files (the one from binutils works fine).
72 ginstall -s -c -m 555 $dd $dir || fail=1
73 # Make sure the source file is still around.
74 test -f $dd || fail=1
76 # Make sure that the destination file has the requested permissions.
77 mode=`ls -l $dir/$dd|cut -b-10`
78 test "$mode" = -r-xr-xr-x || fail=1
80 # These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
81 ginstall -d . || fail=1
82 ginstall -d newdir || fail=1
83 test -d newdir || fail=1
84 ginstall -d newdir1 newdir2 newdir3 || fail=1
85 test -d newdir1 || fail=1
86 test -d newdir2 || fail=1
87 test -d newdir3 || fail=1
89 # This fails because mkdir-p.c's make_dir_parents fails to return to its
90 # initial working directory ($iwd) after creating the first argument, and
91 # hence cannot do anything meaningful with the following relative-named dirs.
92 iwd=`pwd`
93 mkdir sub || fail=1
94 (cd sub && chmod 0 . && ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null) && fail=1
95 chmod 755 sub
97 # Ensure that the first argument-dir has been created.
98 test -d xx/yy || fail=1
100 # Make sure that the `rel' directory was not created...
101 test -d sub/rel && fail=1
102 # and make sure it was not created in the wrong place.
103 test -d xx/rel && fail=1
105 # Test that we can install from an unreadable directory with an
106 # inaccessible parent. coreutils 5.97 fails this test.
107 # Perform this test only if "." is on a local file system.
108 # Otherwise, it would fail e.g., on an NFS-mounted file system.
109 if df --local . >/dev/null 2>&1; then
110 mkdir -p sub1/d || fail=1
111 (cd sub1/d && chmod a-r . && chmod a-rx .. &&
112 ginstall -d "$iwd/xx/zz" rel/a rel/b) || fail=1
113 chmod 755 sub1 sub1/d || fail=1
114 test -d xx/zz || fail=1
115 test -d sub1/d/rel/a || fail=1
116 test -d sub1/d/rel/b || fail=1
119 touch file || fail=1
120 ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1
121 diff - out <<\EOF || fail=1
122 ginstall: creating directory `sub3'
123 ginstall: creating directory `sub3/a'
124 ginstall: creating directory `sub3/a/b'
125 ginstall: creating directory `sub3/a/b/c'
126 `file' -> `sub3/a/b/c/file'
129 Exit $fail