8044419: TEST_BUG: com/sun/jdi/JdbReadTwiceTest.sh fails when run under root
authorykantser
Mon, 26 Jan 2015 08:52:46 +0100
changeset 28761 7abffa3717a5
parent 28760 b83d51c77b31
child 28762 4c74ad747f7e
8044419: TEST_BUG: com/sun/jdi/JdbReadTwiceTest.sh fails when run under root Reviewed-by: dsamersoff, sla Contributed-by: mattias.tobiasson@oracle.com
jdk/test/ProblemList.txt
jdk/test/com/sun/jdi/JdbReadTwiceTest.sh
--- a/jdk/test/ProblemList.txt	Fri Jan 23 14:20:52 2015 +0100
+++ b/jdk/test/ProblemList.txt	Mon Jan 26 08:52:46 2015 +0100
@@ -292,9 +292,6 @@
 # 8043571
 com/sun/jdi/RepStep.java                                        generic-all
 
-# 8044419
-com/sun/jdi/JdbReadTwiceTest.sh                                 generic-all
-
 # 8058616
 com/sun/jdi/RedefinePop.sh                                      generic-all
 
--- a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh	Fri Jan 23 14:20:52 2015 +0100
+++ b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh	Mon Jan 26 08:52:46 2015 +0100
@@ -204,27 +204,37 @@
     clean
 fi
 
+echo
+echo "+++++++++++++++++++++++++++++++++++"
+echo "Read an unreadable file - verify the read fails."
 
-if [ ! -r c:/ ] ; then
-    # Can't make a file unreadable under MKS.
-    echo
-    echo "+++++++++++++++++++++++++++++++++++"
-    echo "Read an unreadable file - verify the read fails."
-    # If the file exists, we try to read it.  The
-    # read will fail.
-    mkFiles $HOME/jdb.ini
-    id > $HOME/jdb.ini
-    chmod a-r $HOME/jdb.ini
-    if grep -q "uid=" $HOME/jdb.ini  ; then
-      echo "Unable to make file unreadable, so test will fail. chmod: $HOME/jdb.ini"
-      if grep -q "uid=0" $HOME/jdb.ini  ; then
-        echo "The test is running as root. Fix infrastructure!"
-      fi
-    fi  
+canMakeUnreadable=No
+id > $HOME/jdb.ini
+if chmod a-r $HOME/jdb.ini 
+then
+  grep -q 'uid=0(' $HOME/jdb.ini 2> /dev/null
+  case $? in
+    0)
+      echo "Error! Can't make file unreadable running as root"
+    ;;
+    1)
+      echo "Error! Can't make file unreadable for some other reason (windows?)"
+    ;;
+    *)
+      echo "OK. the file is unreadable"
+      canMakeUnreadable=Yes 
+    ;;
+   esac
+else    
+  echo "Error! Can't create or chmod file"
+fi  
+
+if [ "$canMakeUnreadable" = "Yes" ]
+then
     doit
     failIfNot 1 "open: $HOME/jdb.ini"
-    clean
 fi
+clean
 
 
 echo
@@ -246,8 +256,8 @@
     doit
     failIfNot 1 "from $fred"
 
-    if [ ! -r c:/ ] ; then
-        # Can't make a file unreadable under MKS
+    if [ "$canMakeUnreadable" = "Yes" ]
+    then
         chmod a-r $fred
         doit
         failIfNot 1 "open: $fred"