id: don't call getcon unnecessarily
[coreutils.git] / tests / install / basic-1
blobaa80fcf33942793c98eaf42a1057060b24d3d1cb
1 #! /bin/sh
2 # Basic tests for "install".
4 # Copyright (C) 1998-2012 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=.}/init.sh"; path_prepend_ ../src
20 print_ver_ ginstall
21 skip_if_root_
23 dir=dir
24 file=file
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.
37 dd=dd$EXEEXT
38 dd2=dd2$EXEEXT
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
47 cp $dd $dd2 || fail=1
49 strip $dd2 \
50 || warn_ "WARNING!!! Your strip command doesn't seem to work,
51 so skipping the test of install's --strip option."
53 # This test would fail with 3.16s when using versions of strip that
54 # don't work on read-only files (the one from binutils works fine).
55 ginstall -s -c -m 555 $dd $dir || fail=1
56 # Make sure the source file is still around.
57 test -f $dd || fail=1
59 # Make sure that the destination file has the requested permissions.
60 mode=$(ls -l $dir/$dd|cut -b-10)
61 test "$mode" = -r-xr-xr-x || fail=1
63 # These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
64 ginstall -d . || fail=1
65 ginstall -d newdir || fail=1
66 test -d newdir || fail=1
67 ginstall -d newdir1 newdir2 newdir3 || fail=1
68 test -d newdir1 || fail=1
69 test -d newdir2 || fail=1
70 test -d newdir3 || fail=1
72 # This fails because mkdir-p.c's make_dir_parents fails to return to its
73 # initial working directory ($iwd) after creating the first argument, and
74 # hence cannot do anything meaningful with the following relative-named dirs.
75 iwd=$(pwd)
76 mkdir sub || fail=1
77 (cd sub &&
78 chmod 0 . &&
79 ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null
80 ) && fail=1
81 chmod 755 sub
83 # Ensure that the first argument-dir has been created.
84 test -d xx/yy || fail=1
86 # Make sure that the 'rel' directory was not created...
87 test -d sub/rel && fail=1
88 # and make sure it was not created in the wrong place.
89 test -d xx/rel && fail=1
91 # Test that we can install from an unreadable directory with an
92 # inaccessible parent. coreutils 5.97 fails this test.
93 # Perform this test only if "." is on a local file system.
94 # Otherwise, it would fail e.g., on an NFS-mounted file system.
95 if is_local_dir_ .; then
96 mkdir -p sub1/d || fail=1
97 (cd sub1/d && chmod a-r . && chmod a-rx .. &&
98 ginstall -d "$iwd/xx/zz" rel/a rel/b) || fail=1
99 chmod 755 sub1 sub1/d || fail=1
100 test -d xx/zz || fail=1
101 test -d sub1/d/rel/a || fail=1
102 test -d sub1/d/rel/b || fail=1
105 touch file || fail=1
106 ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1
107 compare - out <<\EOF || fail=1
108 ginstall: creating directory 'sub3'
109 ginstall: creating directory 'sub3/a'
110 ginstall: creating directory 'sub3/a/b'
111 ginstall: creating directory 'sub3/a/b/c'
112 'file' -> 'sub3/a/b/c/file'
115 Exit $fail