From 9eb4c31eb78c28dd9f72d1cbb940270311be343c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 30 Aug 2012 14:13:12 +0200 Subject: tests: add .sh and .pl suffixes to shell and perl tests, respectively Not only this shrinks the size of the generated Makefile (from > 6300 lines to ~3000), but will allow further simplifications in future changes. * tests/Makefile.am (TEST_EXTENSIONS): Add '.sh' and '.pl'. (PL_LOG_COMPILER, SH_LOG_COMPILER): New, still defined simply to $(LOG_COMPILER) for the time being. (TESTS, root_tests): Adjust as described. * All tests: Rename as described. --- tests/chgrp/basic | 110 ---------------------------------------- tests/chgrp/basic.sh | 110 ++++++++++++++++++++++++++++++++++++++++ tests/chgrp/default-no-deref | 33 ------------ tests/chgrp/default-no-deref.sh | 33 ++++++++++++ tests/chgrp/deref | 60 ---------------------- tests/chgrp/deref.sh | 60 ++++++++++++++++++++++ tests/chgrp/no-x | 54 -------------------- tests/chgrp/no-x.sh | 54 ++++++++++++++++++++ tests/chgrp/posix-H | 70 ------------------------- tests/chgrp/posix-H.sh | 70 +++++++++++++++++++++++++ tests/chgrp/recurse | 53 ------------------- tests/chgrp/recurse.sh | 53 +++++++++++++++++++ 12 files changed, 380 insertions(+), 380 deletions(-) delete mode 100755 tests/chgrp/basic create mode 100755 tests/chgrp/basic.sh delete mode 100755 tests/chgrp/default-no-deref create mode 100755 tests/chgrp/default-no-deref.sh delete mode 100755 tests/chgrp/deref create mode 100755 tests/chgrp/deref.sh delete mode 100755 tests/chgrp/no-x create mode 100755 tests/chgrp/no-x.sh delete mode 100755 tests/chgrp/posix-H create mode 100755 tests/chgrp/posix-H.sh delete mode 100755 tests/chgrp/recurse create mode 100755 tests/chgrp/recurse.sh (limited to 'tests/chgrp') diff --git a/tests/chgrp/basic b/tests/chgrp/basic deleted file mode 100755 index 8ce2f2ddc..000000000 --- a/tests/chgrp/basic +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -# make sure chgrp is reasonable - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - - -set _ $groups; shift -g1=$1 -g2=$2 -mkdir d -touch f f2 d/f3 -chgrp $g1 f || fail=1 -chgrp $g2 f || fail=1 -chgrp $g2 f2 || fail=1 -chgrp -R $g1 d || fail=1 - -d_files='d d/f3' - -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp '' f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp --reference=f2 f ; test $(stat --p=%g f) = $g2 || fail=1 - -chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 -chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 -chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 -chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 -chgrp $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g1:" || fail=1 - -rm -f f -touch f -ln -s f symlink -chgrp $g1 f -test $(stat --printf=%g f) = $g1 || fail=1 - -# This should not change the group of f. -chgrp -h $g2 symlink -test $(stat --printf=%g f) = $g1 || fail=1 - -# Don't fail if chgrp failed to set the group of a symlink. -# Some systems don't support that. -test $(stat --printf=%g symlink) = $g2 || - echo 'info: failed to set group of symlink' 1>&2 - -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# This *should* change the group of f. -# Though note that the diagnostic is misleading in that -# it says the 'group of 'symlink'' has been changed. -chgrp $g1 symlink; test $(stat --printf=%g f) = $g1 || fail=1 -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# If -R is specified without -H or L, -h is assumed. -chgrp -h $g1 f symlink; test $(stat --printf=%g symlink) = $g1 || fail=1 -chgrp -R $g2 symlink -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# Make sure we can change the group of inaccessible files. -chmod a-r f -chown --from=:$g2 :$g1 f; test $(stat --printf=%g f) = $g1 || fail=1 -chmod 0 f -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# chown() must not be optimized away even when -# the file's owner and group already have the desired value. -rm -f f g -touch f g -chgrp $g1 f g -chgrp $g2 g -sleep 1 -chgrp $g1 f - -# The following no-change chgrp command is supposed to update f's ctime, -# but on OpenBSD and Darwin 7.9.0-8.11.1 (aka MacOS X 10.3.9 - 10.4.11) -# it appears to be a no-op for some file system types (at least NFS) so g's -# ctime is more recent. This is not a big deal; -# this test works fine when the files are on a local file system (/tmp). -chgrp '' f -test "$(ls -C -c -t f g)" = 'f g' || \ - { - case $host_triplet in - *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;; - *darwin7.9.*|*darwin8.*) - echo ignoring known MacOS X-specific chgrp failure 1>&2 ;; - *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2; - fail=1 ;; - esac - } - -Exit $fail diff --git a/tests/chgrp/basic.sh b/tests/chgrp/basic.sh new file mode 100755 index 000000000..8ce2f2ddc --- /dev/null +++ b/tests/chgrp/basic.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# make sure chgrp is reasonable + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + + +set _ $groups; shift +g1=$1 +g2=$2 +mkdir d +touch f f2 d/f3 +chgrp $g1 f || fail=1 +chgrp $g2 f || fail=1 +chgrp $g2 f2 || fail=1 +chgrp -R $g1 d || fail=1 + +d_files='d d/f3' + +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp '' f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp --reference=f2 f ; test $(stat --p=%g f) = $g2 || fail=1 + +chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 +chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 +chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 +chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 +chgrp $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g1:" || fail=1 + +rm -f f +touch f +ln -s f symlink +chgrp $g1 f +test $(stat --printf=%g f) = $g1 || fail=1 + +# This should not change the group of f. +chgrp -h $g2 symlink +test $(stat --printf=%g f) = $g1 || fail=1 + +# Don't fail if chgrp failed to set the group of a symlink. +# Some systems don't support that. +test $(stat --printf=%g symlink) = $g2 || + echo 'info: failed to set group of symlink' 1>&2 + +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# This *should* change the group of f. +# Though note that the diagnostic is misleading in that +# it says the 'group of 'symlink'' has been changed. +chgrp $g1 symlink; test $(stat --printf=%g f) = $g1 || fail=1 +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# If -R is specified without -H or L, -h is assumed. +chgrp -h $g1 f symlink; test $(stat --printf=%g symlink) = $g1 || fail=1 +chgrp -R $g2 symlink +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# Make sure we can change the group of inaccessible files. +chmod a-r f +chown --from=:$g2 :$g1 f; test $(stat --printf=%g f) = $g1 || fail=1 +chmod 0 f +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# chown() must not be optimized away even when +# the file's owner and group already have the desired value. +rm -f f g +touch f g +chgrp $g1 f g +chgrp $g2 g +sleep 1 +chgrp $g1 f + +# The following no-change chgrp command is supposed to update f's ctime, +# but on OpenBSD and Darwin 7.9.0-8.11.1 (aka MacOS X 10.3.9 - 10.4.11) +# it appears to be a no-op for some file system types (at least NFS) so g's +# ctime is more recent. This is not a big deal; +# this test works fine when the files are on a local file system (/tmp). +chgrp '' f +test "$(ls -C -c -t f g)" = 'f g' || \ + { + case $host_triplet in + *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;; + *darwin7.9.*|*darwin8.*) + echo ignoring known MacOS X-specific chgrp failure 1>&2 ;; + *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2; + fail=1 ;; + esac + } + +Exit $fail diff --git a/tests/chgrp/default-no-deref b/tests/chgrp/default-no-deref deleted file mode 100755 index 5d140a8da..000000000 --- a/tests/chgrp/default-no-deref +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that chgrp -R does not dereference symlinks. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g2=$2 - -mkdir d && touch f && ln -s ../f d/s || framework_failure_ - - -g_init=$(stat --printf=%g f) -chgrp -R $g2 d || fail=1 -test $(stat --printf=%g f) = $g_init || fail=1 - -Exit $fail diff --git a/tests/chgrp/default-no-deref.sh b/tests/chgrp/default-no-deref.sh new file mode 100755 index 000000000..5d140a8da --- /dev/null +++ b/tests/chgrp/default-no-deref.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that chgrp -R does not dereference symlinks. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g2=$2 + +mkdir d && touch f && ln -s ../f d/s || framework_failure_ + + +g_init=$(stat --printf=%g f) +chgrp -R $g2 d || fail=1 +test $(stat --printf=%g f) = $g_init || fail=1 + +Exit $fail diff --git a/tests/chgrp/deref b/tests/chgrp/deref deleted file mode 100755 index 4c186ee82..000000000 --- a/tests/chgrp/deref +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# see if chgrp can change the group of a symlink - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - -touch f -ln -s f symlink - -chgrp -h $g2 symlink 2> /dev/null -set _ $(ls -ln symlink) -g=$5 -test "$g" = $g2 || - skip_ "your system doesn't support changing the owner or group" \ - "of a symbolic link." - - -chgrp $g1 f -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 - -chgrp -h $g2 symlink || fail=1 -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -# This should not change the group of f. -chgrp -h $g2 symlink || fail=1 -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -chgrp $g2 f -set _ $(ls -ln f); g=$5; test "$g" = $g2 || fail=1 - -# This *should* change the group of f. -# Though note that the diagnostic you'd get with -c is misleading in that -# it says the 'group of 'symlink'' has been changed. -chgrp --dereference $g1 symlink -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -Exit $fail diff --git a/tests/chgrp/deref.sh b/tests/chgrp/deref.sh new file mode 100755 index 000000000..4c186ee82 --- /dev/null +++ b/tests/chgrp/deref.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# see if chgrp can change the group of a symlink + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + +touch f +ln -s f symlink + +chgrp -h $g2 symlink 2> /dev/null +set _ $(ls -ln symlink) +g=$5 +test "$g" = $g2 || + skip_ "your system doesn't support changing the owner or group" \ + "of a symbolic link." + + +chgrp $g1 f +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 + +chgrp -h $g2 symlink || fail=1 +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +# This should not change the group of f. +chgrp -h $g2 symlink || fail=1 +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +chgrp $g2 f +set _ $(ls -ln f); g=$5; test "$g" = $g2 || fail=1 + +# This *should* change the group of f. +# Though note that the diagnostic you'd get with -c is misleading in that +# it says the 'group of 'symlink'' has been changed. +chgrp --dereference $g1 symlink +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +Exit $fail diff --git a/tests/chgrp/no-x b/tests/chgrp/no-x deleted file mode 100755 index 6e9347f99..000000000 --- a/tests/chgrp/no-x +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Make sure chgrp gives the right diagnostic for a readable, -# but inaccessible directory. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ -skip_if_root_ - -set _ $groups; shift -g1=$1 -g2=$2 - -mkdir -p d/no-x/y || framework_failure_ -chmod u=rw d/no-x || framework_failure_ - - -# This must exit nonzero. -chgrp -R $g2 d >/dev/null 2>out && fail=1 - -prog=chgrp -# NOTE: this code is the same for all tests/*/no-x tests. -# Depending on whether fts is using native fdopendir, we see one -# of the following diagnostics (note also the /y suffix in one case): -# prog: 'd/no-x': Permission denied -# prog: cannot access 'd/no-x/y': Permission denied -# prog: cannot read directory 'd/no-x': Permission denied -# Convert either of the latter two to the first one. -sed "s/^$prog: cannot access /$prog: /" out > t && mv t out -sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out -sed 's,d/no-x/y,d/no-x,' out > t && mv t out - -cat < exp -$prog: 'd/no-x': Permission denied -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chgrp/no-x.sh b/tests/chgrp/no-x.sh new file mode 100755 index 000000000..6e9347f99 --- /dev/null +++ b/tests/chgrp/no-x.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Make sure chgrp gives the right diagnostic for a readable, +# but inaccessible directory. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ +skip_if_root_ + +set _ $groups; shift +g1=$1 +g2=$2 + +mkdir -p d/no-x/y || framework_failure_ +chmod u=rw d/no-x || framework_failure_ + + +# This must exit nonzero. +chgrp -R $g2 d >/dev/null 2>out && fail=1 + +prog=chgrp +# NOTE: this code is the same for all tests/*/no-x tests. +# Depending on whether fts is using native fdopendir, we see one +# of the following diagnostics (note also the /y suffix in one case): +# prog: 'd/no-x': Permission denied +# prog: cannot access 'd/no-x/y': Permission denied +# prog: cannot read directory 'd/no-x': Permission denied +# Convert either of the latter two to the first one. +sed "s/^$prog: cannot access /$prog: /" out > t && mv t out +sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out +sed 's,d/no-x/y,d/no-x,' out > t && mv t out + +cat < exp +$prog: 'd/no-x': Permission denied +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chgrp/posix-H b/tests/chgrp/posix-H deleted file mode 100755 index 3965f1ff5..000000000 --- a/tests/chgrp/posix-H +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Test POSIX-mandated -H option. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - -mkdir 1 2 3 || framework_failure_ -touch 1/1F 2/2F 3/3F || framework_failure_ -ln -s 1 1s || framework_failure_ -ln -s ../3 2/2s || framework_failure_ -chgrp -R $g1 1 2 3 || framework_failure_ - - -chgrp --preserve-root -H -R $g2 1s 2 || fail=1 - -# These must have group $g2. -# ========================= -changed=' -1 -1/1F -2 -2/2F -3 -' -for i in $changed; do - # Filter out symlinks (entries that end in 's'), since it's not - # possible to change their group/owner information on some systems. - case $i in *s) continue;; esac - set _ $(ls -dgn $i); shift - group=$3 - test $group = $g2 || fail=1 -done - -# These must have group $g1. -# ========================= -not_changed=' -1s -2/2s -3/3F -' -for i in $not_changed; do - # Filter out symlinks (entries that end in 's'), since it's not - # possible to change their group/owner information on some systems. - case $i in *s) continue;; esac - set _ $(ls -dgn $i); shift - group=$3 - test $group = $g1 || fail=1 -done - -Exit $fail diff --git a/tests/chgrp/posix-H.sh b/tests/chgrp/posix-H.sh new file mode 100755 index 000000000..3965f1ff5 --- /dev/null +++ b/tests/chgrp/posix-H.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Test POSIX-mandated -H option. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + +mkdir 1 2 3 || framework_failure_ +touch 1/1F 2/2F 3/3F || framework_failure_ +ln -s 1 1s || framework_failure_ +ln -s ../3 2/2s || framework_failure_ +chgrp -R $g1 1 2 3 || framework_failure_ + + +chgrp --preserve-root -H -R $g2 1s 2 || fail=1 + +# These must have group $g2. +# ========================= +changed=' +1 +1/1F +2 +2/2F +3 +' +for i in $changed; do + # Filter out symlinks (entries that end in 's'), since it's not + # possible to change their group/owner information on some systems. + case $i in *s) continue;; esac + set _ $(ls -dgn $i); shift + group=$3 + test $group = $g2 || fail=1 +done + +# These must have group $g1. +# ========================= +not_changed=' +1s +2/2s +3/3F +' +for i in $not_changed; do + # Filter out symlinks (entries that end in 's'), since it's not + # possible to change their group/owner information on some systems. + case $i in *s) continue;; esac + set _ $(ls -dgn $i); shift + group=$3 + test $group = $g1 || fail=1 +done + +Exit $fail diff --git a/tests/chgrp/recurse b/tests/chgrp/recurse deleted file mode 100755 index 95a910f6c..000000000 --- a/tests/chgrp/recurse +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# ad-hoc tests of chgrp with -R and -H or -L and symlinks - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - - -# chgrp -R should not traverse a symlink to a directory. -mkdir d e -touch d/dd e/ee -ln -s ../e d/s -chgrp -R $g1 e/ee || fail=1 -# This should not should change the group of e/ee -chgrp -R $g2 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g1 || fail=1 -# This must change the group of e/ee, since -L makes -# chgrp traverse the symlink from d/s into e. -chgrp -L -R $g2 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 - -# This must *not* change the group of e/ee -chgrp -H -R $g1 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 - -ln -s d link - -# This shouldn't change the group of e/ee either. -chgrp -H -R $g1 link || fail=1 -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 -# But it *should* change d/dd. -set _ $(ls -ln d/dd); g=$5; test "$g" = $g1 || fail=1 - -Exit $fail diff --git a/tests/chgrp/recurse.sh b/tests/chgrp/recurse.sh new file mode 100755 index 000000000..95a910f6c --- /dev/null +++ b/tests/chgrp/recurse.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# ad-hoc tests of chgrp with -R and -H or -L and symlinks + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + + +# chgrp -R should not traverse a symlink to a directory. +mkdir d e +touch d/dd e/ee +ln -s ../e d/s +chgrp -R $g1 e/ee || fail=1 +# This should not should change the group of e/ee +chgrp -R $g2 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g1 || fail=1 +# This must change the group of e/ee, since -L makes +# chgrp traverse the symlink from d/s into e. +chgrp -L -R $g2 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 + +# This must *not* change the group of e/ee +chgrp -H -R $g1 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 + +ln -s d link + +# This shouldn't change the group of e/ee either. +chgrp -H -R $g1 link || fail=1 +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 +# But it *should* change d/dd. +set _ $(ls -ln d/dd); g=$5; test "$g" = $g1 || fail=1 + +Exit $fail -- cgit v1.2.3-70-g09d2