2 # make sure chgrp is reasonable
4 # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 if test "$VERBOSE" = yes; then
27 . $srcdir/../envvar-check
28 . $srcdir/../lang-default
29 . $srcdir/../group-names
33 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
34 trap '(exit $?); exit' 1 2 13 15
37 mkdir $tmp || framework_failure=1
38 cd $tmp || framework_failure=1
40 if test $framework_failure = 1; then
41 echo 'failure in testing framework' 1>&2
54 chgrp $g2 f2 || fail=1
55 chgrp -R $g1 d || fail=1
57 # Don't let verbose output interfere.
58 test "$VERBOSE" = yes && set +x
67 chgrp --verbose --reference=f2 f
68 chgrp -R --verbose $g2 d
69 chgrp -R --verbose $g1 d
80 # This should not change the group of f.
81 chgrp -h -c $g2 symlink
82 chown --from=:$g1 -c :$g2 f
84 # This *should* change the group of f.
85 # Though note that the diagnostic is misleading in that
86 # it says the `group of `symlink'' has been changed.
88 chown --from=:$g1 -c :$g2 f
90 # If -R is specified without -H or L, -h is assumed.
91 chgrp -h $g1 f symlink
93 chown --from=:$g1 -c :$g2 f
95 # Make sure we can change the group of inaccessible files.
97 chown --from=:$g2 -c :$g1 f
99 chown --from=:$g1 -c :$g2 f
101 # chown() must not be optimized away even when
102 # the file's owner and group already have the desired value.
110 # The following no-change chgrp command is supposed to update f's ctime,
111 # but on OpenBSD, it appears to be a no-op for some file system types
112 # (at least NFS) so g's ctime is more recent. This is not a big deal;
113 # this test works fine when the files are on a local file system (/tmp).
118 s/' to .*[^0-9:].*/' to SOMENAME/
123 cat <<\EOF > expected
124 changed group of `f' to G1
125 changed group of `f' to G2
126 ownership of `f' retained
127 changed group of `f' to G1
128 group of `f' retained as G1
129 changed group of `f' to SOMENAME
130 changed group of `d/f3' to G2
131 changed group of `d' to G2
132 changed group of `d/f3' to G1
133 changed group of `d' to G1
134 changed group of `d/f3' to G2
135 changed group of `d' to G2
136 changed group of `d/f3' to G1
137 changed group of `d' to G1
138 changed group of `d' to G2
139 changed ownership of `f' to :G2
140 changed group of `symlink' to G1
141 changed ownership of `f' to :G2
142 changed ownership of `f' to :G2
143 changed ownership of `f' to :G1
144 changed ownership of `f' to :G2
149 cmp expected actual \
150 || { diff expected actual 1>&2; fail=1; }
152 (exit $fail); exit $fail