8036006: [TESTBUG] sun/tools/native2ascii/NativeErrors.java fails: Process exit code was 0, but error was expected.
authormtobiass
Wed, 04 Jun 2014 13:12:16 +0200
changeset 24707 f1225d0f947c
parent 24706 c825cd1299e4
child 24708 13efc72a09bd
8036006: [TESTBUG] sun/tools/native2ascii/NativeErrors.java fails: Process exit code was 0, but error was expected. Summary: Ignore read-only test if file is not read-only. This will happen when test is run as root. Reviewed-by: sla, dholmes
jdk/test/sun/tools/native2ascii/NativeErrors.java
--- a/jdk/test/sun/tools/native2ascii/NativeErrors.java	Wed Jun 04 16:26:11 2014 +0400
+++ b/jdk/test/sun/tools/native2ascii/NativeErrors.java	Wed Jun 04 13:12:16 2014 +0200
@@ -73,7 +73,14 @@
             throw new Error("Output file cannot be made read only: " + path2);
         }
         f2.deleteOnExit();
-        checkResult(executeCmd(path1, path2), "err.cannot.write");
+        if ( f2.canWrite() ) {
+            String msg = "Output file is still writable. " +
+                    "Probably because test is run as root. Read-only test skipped.";
+            System.out.println(msg);
+        } else {
+            // Test write to a read-only file.
+            checkResult(executeCmd(path1, path2), "err.cannot.write");
+        }
     }
 
     private static String executeCmd(String... toolArgs) throws Throwable {