maint: use single copyright year range
[coreutils/ericb.git] / tests / install / install-C
blob0883d9e6b8c8e912056221aea16bdafb6ede69a4
1 #!/bin/sh
2 # Ensure "install -C" works. (basic tests)
4 # Copyright (C) 2008-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_setgid_
23 mode1=0644
24 mode2=0755
25 mode3=2755
28 echo test > a || framework_failure_
29 echo "'a' -> 'b'" > out_installed_first || framework_failure_
30 echo "removed 'b'
31 'a' -> 'b'" > out_installed_second || framework_failure_
32 : > out_empty || framework_failure_
34 # destination file does not exist
35 ginstall -Cv -m$mode1 a b > out || fail=1
36 compare out out_installed_first || fail=1
38 # destination file exists
39 ginstall -Cv -m$mode1 a b > out || fail=1
40 compare out out_empty || fail=1
42 # destination file exists (long option)
43 ginstall -v --compare -m$mode1 a b > out || fail=1
44 compare out out_empty || fail=1
46 # destination file exists but -C is not given
47 ginstall -v -m$mode1 a b > out || fail=1
48 compare out out_installed_second || fail=1
50 # option -C ignored if any non-permission mode should be set
51 ginstall -Cv -m$mode3 a b > out || fail=1
52 compare out out_installed_second || fail=1
53 ginstall -Cv -m$mode3 a b > out || fail=1
54 compare out out_installed_second || fail=1
56 # files are not regular files
57 ln -s a c || framework_failure_
58 ln -s b d || framework_failure_
59 ginstall -Cv -m$mode1 c d > out || fail=1
60 echo "removed 'd'
61 'c' -> 'd'" > out_installed_second_cd
62 compare out out_installed_second_cd || fail=1
64 # destination file exists but content differs
65 echo test1 > a || framework_failure_
66 ginstall -Cv -m$mode1 a b > out || fail=1
67 compare out out_installed_second || fail=1
68 ginstall -Cv -m$mode1 a b > out || fail=1
69 compare out out_empty || fail=1
71 # destination file exists but content differs (same size)
72 echo test2 > a || framework_failure_
73 ginstall -Cv -m$mode1 a b > out || fail=1
74 compare out out_installed_second || fail=1
75 ginstall -Cv -m$mode1 a b > out || fail=1
76 compare out out_empty || fail=1
78 # destination file exists but mode differs
79 ginstall -Cv -m$mode2 a b > out || fail=1
80 compare out out_installed_second || fail=1
81 ginstall -Cv -m$mode2 a b > out || fail=1
82 compare out out_empty || fail=1
84 # options -C and --preserve-timestamps are mutually exclusive
85 ginstall -C --preserve-timestamps a b && fail=1
87 # options -C and --strip are mutually exclusive
88 ginstall -C --strip --strip-program=echo a b && fail=1
90 Exit $fail