2002-05-21 22:58:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# exercise another small part of remove.c
|
|
|
|
|
|
2012-01-01 09:47:10 +01:00
|
|
|
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2007-07-23 14:35:58 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-17 19:58:17 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 14:35:58 +02:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-17 19:58:17 +00:00
|
|
|
# (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
|
2007-07-23 14:35:58 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2010-11-14 11:05:05 +01:00
|
|
|
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
2010-11-17 21:35:31 +01:00
|
|
|
print_ver_ rm
|
2007-09-12 14:52:26 +02:00
|
|
|
skip_if_root_
|
2002-05-21 22:58:48 +00:00
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
mkdir -p a/0 || framework_failure_
|
|
|
|
|
mkdir -p a/1/2 b/3 || framework_failure_
|
|
|
|
|
mkdir a/2 a/3 || framework_failure_
|
|
|
|
|
chmod u-x a/1 b || framework_failure_
|
2002-05-21 22:58:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Exercise two separate code paths -- though both result
|
|
|
|
|
# in the same sort of diagnostic.
|
|
|
|
|
# Both of these should fail.
|
|
|
|
|
rm -rf a b > out 2>&1 && fail=1
|
2005-11-22 15:06:30 +00:00
|
|
|
cat <<\EOF > exp
|
2012-01-07 17:47:58 +01:00
|
|
|
rm: cannot remove 'a/1': Permission denied
|
|
|
|
|
rm: cannot remove 'b': Permission denied
|
2002-05-21 22:58:48 +00:00
|
|
|
EOF
|
|
|
|
|
|
2005-11-22 15:06:30 +00:00
|
|
|
cat <<\EOF > exp-solaris
|
2012-01-07 17:47:58 +01:00
|
|
|
rm: cannot remove 'a/1/2': Permission denied
|
|
|
|
|
rm: cannot remove 'b/3': Permission denied
|
2005-11-22 15:06:30 +00:00
|
|
|
EOF
|
|
|
|
|
|
2007-09-12 14:52:26 +02:00
|
|
|
cmp out exp > /dev/null 2>&1 \
|
|
|
|
|
|| { cmp out exp-solaris > /dev/null 2>&1 || fail=1; }
|
2011-11-22 10:08:04 +01:00
|
|
|
test $fail = 1 && compare exp out
|
2002-05-21 22:58:48 +00:00
|
|
|
|
2005-11-22 15:06:30 +00:00
|
|
|
test -d a/0 && fail=1
|
2002-05-21 22:58:48 +00:00
|
|
|
test -d a/1 || fail=1
|
2005-11-22 15:06:30 +00:00
|
|
|
test -d a/2 && fail=1
|
|
|
|
|
test -d a/3 && fail=1
|
|
|
|
|
|
2002-05-21 22:58:48 +00:00
|
|
|
chmod u+x b
|
|
|
|
|
test -d b/3 || fail=1
|
|
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|