tests: make install-C slightly less prone to confusion
[coreutils.git] / tests / install / install-C
bloba1a9d6831109538a2150a1c184ef48c22b8e62f4
1 #!/bin/sh
2 # Ensure "install -C" works. (basic tests)
4 # Copyright (C) 2008-2009 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_setgid_
27 mode1=0644
28 mode2=0755
29 mode3=2755
31 fail=0
33 echo test > a || framework_failure
34 echo "\`a' -> \`b'" > out_installed_first || framework_failure
35 echo "removed \`b'
36 \`a' -> \`b'" > out_installed_second || framework_failure
37 : > out_empty || framework_failure
39 # destination file does not exist
40 ginstall -Cv -m$mode1 a b > out || fail=1
41 compare out out_installed_first || fail=1
43 # destination file exists
44 ginstall -Cv -m$mode1 a b > out || fail=1
45 compare out out_empty || fail=1
47 # destination file exists (long option)
48 ginstall -v --compare -m$mode1 a b > out || fail=1
49 compare out out_empty || fail=1
51 # destination file exists but -C is not given
52 ginstall -v -m$mode1 a b > out || fail=1
53 compare out out_installed_second || fail=1
55 # option -C ignored if any non-permission mode should be set
56 ginstall -Cv -m$mode3 a b > out || fail=1
57 compare out out_installed_second || fail=1
58 ginstall -Cv -m$mode3 a b > out || fail=1
59 compare out out_installed_second || fail=1
61 # files are not regular files
62 ln -s a c || framework_failure
63 ln -s b d || framework_failure
64 ginstall -Cv -m$mode1 c d > out || fail=1
65 echo "removed \`d'
66 \`c' -> \`d'" > out_installed_second_cd
67 compare out out_installed_second_cd || fail=1
69 # destination file exists but content differs
70 echo test1 > a || framework_failure
71 ginstall -Cv -m$mode1 a b > out || fail=1
72 compare out out_installed_second || fail=1
73 ginstall -Cv -m$mode1 a b > out || fail=1
74 compare out out_empty || fail=1
76 # destination file exists but content differs (same size)
77 echo test2 > a || framework_failure
78 ginstall -Cv -m$mode1 a b > out || fail=1
79 compare out out_installed_second || fail=1
80 ginstall -Cv -m$mode1 a b > out || fail=1
81 compare out out_empty || fail=1
83 # destination file exists but mode differs
84 ginstall -Cv -m$mode2 a b > out || fail=1
85 compare out out_installed_second || fail=1
86 ginstall -Cv -m$mode2 a b > out || fail=1
87 compare out out_empty || fail=1
89 # options -C and --preserve-timestamps are mutually exclusive
90 ginstall -C --preserve-timestamps a b && fail=1
92 # options -C and --strip are mutually exclusive
93 ginstall -C --strip --strip-program=echo a b && fail=1
95 Exit $fail