7065902: (file) test/java/nio/file/Files/Misc.java fails on Solaris 11 when run as root
Reviewed-by: alanb
--- a/jdk/test/java/nio/file/Files/Misc.java Thu Nov 21 11:58:51 2013 -0800
+++ b/jdk/test/java/nio/file/Files/Misc.java Thu Nov 21 14:16:49 2013 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -313,8 +313,14 @@
acl.add(0, entry);
view.setAcl(acl);
try {
- assertTrue(!isWritable(file));
- assertTrue(!isExecutable(file));
+ if (isRoot()) {
+ // root has all permissions
+ assertTrue(isWritable(file));
+ assertTrue(isExecutable(file));
+ } else {
+ assertTrue(!isWritable(file));
+ assertTrue(!isExecutable(file));
+ }
} finally {
// Restore ACL
acl.remove(0);
@@ -353,4 +359,12 @@
if (!okay)
throw new RuntimeException("Assertion Failed");
}
+
+ private static boolean isRoot() {
+ if (System.getProperty("os.name").startsWith("Windows"))
+ return false;
+
+ Path passwd = Paths.get("/etc/passwd");
+ return Files.isWritable(passwd);
+ }
}