From 65f8a39d90dd223e52c1077a6a37eabf05e95e21 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Fri, 15 Nov 2013 18:16:54 +0000
Subject: 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.
---
tests/rm/interactive-once.sh | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
(limited to 'tests/rm')
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 <