2 # make sure chgrp is reasonable
4 if test "$VERBOSE" = yes; then
9 . $srcdir/../envvar-check
10 . $srcdir/../lang-default
11 . $srcdir/../group-names
15 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
19 mkdir $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
22 if test $framework_failure = 1; then
23 echo 'failure in testing framework' 1>&2
36 chgrp $g2 f2 || fail=1
37 chgrp -R $g1 d || fail=1
39 # Don't let verbose output interfere.
40 test "$VERBOSE" = yes && set +x
49 chgrp --verbose --reference=f2 f
50 chgrp -R --verbose $g2 d
51 chgrp -R --verbose $g1 d
62 # This should not change the group of f.
63 chgrp -h -c $g2 symlink
64 chown --from=:$g1 -c :$g2 f
66 # This *should* change the group of f.
67 # Though note that the diagnostic is misleading in that
68 # it says the `group of `symlink'' has been changed.
70 chown --from=:$g1 -c :$g2 f
72 # If -R is specified without -H or L, -h is assumed.
73 chgrp -h $g1 f symlink
75 chown --from=:$g1 -c :$g2 f
77 # Make sure we can change the group of inaccessible files.
79 chown --from=:$g2 -c :$g1 f
81 chown --from=:$g1 -c :$g2 f
83 # chown() must not be optimized away even when
84 # the file's owner and group already have the desired value.
92 # The following no-change chgrp command is supposed to update f's ctime,
93 # but on OpenBSD, it appears to be a no-op for some file system types
94 # (at least NFS) so g's ctime is more recent. This is not a big deal;
95 # this test works fine when the files are on a local file system (/tmp).
100 s/' to .*[^0-9:].*/' to SOMENAME/
105 cat <<\EOF > expected
106 changed group of `f' to G1
107 changed group of `f' to G2
108 ownership of `f' retained
109 changed group of `f' to G1
110 group of `f' retained as G1
111 changed group of `f' to SOMENAME
112 changed group of `d/f3' to G2
113 changed group of `d' to G2
114 changed group of `d/f3' to G1
115 changed group of `d' to G1
116 changed group of `d/f3' to G2
117 changed group of `d' to G2
118 changed group of `d/f3' to G1
119 changed group of `d' to G1
120 changed group of `d' to G2
121 changed ownership of `f' to :G2
122 changed group of `symlink' to G1
123 changed ownership of `f' to :G2
124 changed ownership of `f' to :G2
125 changed ownership of `f' to :G1
126 changed ownership of `f' to :G2
131 cmp expected actual \
132 || { diff expected actual 1>&2; fail=1; }
134 (exit $fail); exit $fail