coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: fix false rm -I test failure when run as root


From: Pádraig Brady
Subject: [PATCH] tests: fix false rm -I test failure when run as root
Date: Fri, 15 Nov 2013 18:37:59 +0000

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 |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/tests/rm/interactive-once.sh b/tests/rm/interactive-once.sh
index 1064c08..5dd5d98 100755
--- a/tests/rm/interactive-once.sh
+++ b/tests/rm/interactive-once.sh
@@ -39,9 +39,17 @@ 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=''
+  else
+    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 +80,20 @@ 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=''
+  else
+    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 +120,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 +132,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
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]