summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-11-15 18:16:54 +0000
committerPádraig Brady <P@draigBrady.com>2013-11-18 01:30:19 +0000
commit65f8a39d90dd223e52c1077a6a37eabf05e95e21 (patch)
tree87e513c09b10d5ab31a74684b1996066fe802905 /tests
parent4e37fc642f6dfda7b7d78531420355c9ad3a824d (diff)
downloadcoreutils-65f8a39d90dd223e52c1077a6a37eabf05e95e21.tar.xz
tests: fix false rm -I test failure when run as root
Fix a recent regression introduced in commit v8.21-127-g5ee7d8f Also related to this is the recent query about root run `rm -I` ignoring the mode bits of a file: https://bugzilla.redhat.com/1013171 * tests/rm/interactive-once.sh: Avoid the messages and corresponding file presence checks with write protected files when running as root.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/rm/interactive-once.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/rm/interactive-once.sh b/tests/rm/interactive-once.sh
index 1064c0851..4ad76c01a 100755
--- a/tests/rm/interactive-once.sh
+++ b/tests/rm/interactive-once.sh
@@ -39,9 +39,15 @@ if ls /dev/stdin >/dev/null 2>&1; then
echo 'one file, read only, answer no' >> err || fail=1
touch file1-1 || framework_failure_
chmod a-w file1-1 || framework_failure_
+ if ! test -w file1-1; then
+ # root won't get prompted
+ write_prot_msg1="rm: remove write-protected regular empty file 'file1-1'? "
+ fi
rm ---presume-input-tty -I file1-* < in-n >> out 2>> err || fail=1
echo . >> err || fail=1
- test -f file1-1 || fail=1
+ if test "$write_prot_msg1"; then
+ test -f file1-1 || fail=1
+ fi
fi
echo 'three files, no recursion' >> err || fail=1
@@ -72,12 +78,18 @@ if ls /dev/stdin >/dev/null 2>&1; then
touch file3-1 file3-2 file3-3 file3-4 || framework_failure_
echo non_empty > file3-4 || framework_failure_ # to shorten diagnostic
chmod a-w file3-4 || framework_failure_
+ if ! test -w file3-4; then
+ # root won't get prompted
+ write_prot_msg2="rm: remove write-protected regular file 'file3-4'? "
+ fi
cat in-y in-n | rm ---presume-input-tty -I file3-* >> out 2>> err || fail=1
echo . >> err || fail=1
test -f file3-1 && fail=1
test -f file3-2 && fail=1
test -f file3-3 && fail=1
- test -f file3-4 || fail=1
+ if test "$write_prot_msg2"; then
+ test -f file3-4 || fail=1
+ fi
fi
echo 'one file, recursion, answer no' >> err || fail=1
@@ -104,11 +116,11 @@ test -d dir2-2 && fail=1
cat <<\EOF > expout || fail=1
EOF
-cat <<\EOF > experr || fail=1
+cat <<EOF > experr || fail=1
one file, no recursion
.
one file, read only, answer no
-rm: remove write-protected regular empty file 'file1-1'? .
+$write_prot_msg1.
three files, no recursion
.
four files, no recursion, answer no
@@ -116,7 +128,7 @@ rm: remove 4 arguments? .
four files, no recursion, answer yes
rm: remove 4 arguments? .
four files, no recursion, 1 read only, answer yes no
-rm: remove 4 arguments? rm: remove write-protected regular file 'file3-4'? .
+rm: remove 4 arguments? $write_prot_msg2.
one file, recursion, answer no
rm: remove 1 argument recursively? .
one file, recursion, answer yes