Hi Staffan,
Could you please submit this patch.
I have set sla and dholmes as reviewers.
The patch is attached.
Mattias
----- Original Message -----
From: [email protected]
To: [email protected], [email protected]
Cc: [email protected]
Sent: Tuesday, June 3, 2014 4:21:40 AM GMT +01:00 Amsterdam / Berlin / Bern /
Rome / Stockholm / Vienna
Subject: Re: RFR: 8036006 [TESTBUG] sun/tools/native2ascii/NativeErrors.java:
Process exit code was 0, but error was expected
+1
David
On 2/06/2014 10:14 PM, Staffan Larsen wrote:
> Looks good!
>
> Thanks,
> /Staffan
>
> On 2 jun 2014, at 14:11, Mattias Tobiasson <[email protected]>
> wrote:
>
>> Hi,
>> Could someone please review this test fix?
>>
>> The test tries to write to a read-only file and expects an error.
>> The test will fail if it is run as root, because root is allowed to write to
>> read-only files.
>>
>> The fix is to check if the file is really read-only with function
>> java.io.File.canWrite().
>> If we are root then canWrite() will return true and the read-only part of
>> the test is skipped.
>>
>> webrev: http://cr.openjdk.java.net/~ykantser/8036006/webrev.00/
>> bug: https://bugs.openjdk.java.net/browse/JDK-8036006
>>
>> Mattias
>>
>
# HG changeset patch
# User mtobiass
# Date 1401880336 -7200
# Node ID 1e568da40b2dbc3ba9eac74b98bb5a2009d6aaee
# Parent a63eb531f049347461268e51b82b376fe8fd461c
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
diff -r a63eb531f049 -r 1e568da40b2d test/sun/tools/native2ascii/NativeErrors.java
--- a/test/sun/tools/native2ascii/NativeErrors.java
+++ b/test/sun/tools/native2ascii/NativeErrors.java
@@ -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 {