From 28b17b749e0e7d8e655630a733928230758df64a Mon Sep 17 00:00:00 2001 From: dxu Date: Thu, 21 Nov 2013 14:16:49 -0800 Subject: [PATCH] 7065902: (file) test/java/nio/file/Files/Misc.java fails on Solaris 11 when run as root Reviewed-by: alanb --- test/java/nio/file/Files/Misc.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/java/nio/file/Files/Misc.java b/test/java/nio/file/Files/Misc.java index 6e704ee44..191a4fa28 100644 --- a/test/java/nio/file/Files/Misc.java +++ b/test/java/nio/file/Files/Misc.java @@ -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 @@ public class Misc { 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 @@ public class Misc { 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); + } } -- GitLab