< prev index next >
test/jdk/internal/jimage/ExecutableTest.java
Print this page
rev 12468 : 8132704: [TESTBUG] jdk/internal/jimage/ExecutableTest.java incorrectly asserts all files to be executable
*** 28,63 ****
import java.nio.file.attribute.PosixFilePermission;
import static java.nio.file.attribute.PosixFilePermission.*;
import java.util.EnumSet;
import java.util.Set;
/*
* @test
* @bug 8132475
* @summary Check that the executables in the current JDK image
* are executable by all users.
* @run main ExecutableTest
* @author Volker Simonis
*/
public class ExecutableTest {
public static void main(String args[]) throws Throwable {
String JAVA_HOME = System.getProperty("java.home");
! Path binPath = Paths.get(JAVA_HOME, "bin");
! DirectoryStream<Path> stream = Files.newDirectoryStream(binPath);
EnumSet<PosixFilePermission> execPerms =
EnumSet.of(GROUP_EXECUTE, OTHERS_EXECUTE, OWNER_EXECUTE);
! for (Path entry : stream) {
! if (Files.isRegularFile(entry)) {
! if (!Files.isExecutable(entry)) {
! throw new Error(entry + " is not executable!");
}
try {
! Set<PosixFilePermission> perm = Files.getPosixFilePermissions(entry);
if (!perm.containsAll(execPerms)) {
! throw new Error(entry + " has not all executable permissions!\n" +
"Should have: " + execPerms + "\nbut has: " + perm);
}
} catch (UnsupportedOperationException e) {}
}
}
--- 28,78 ----
import java.nio.file.attribute.PosixFilePermission;
import static java.nio.file.attribute.PosixFilePermission.*;
import java.util.EnumSet;
import java.util.Set;
+ import jdk.testlibrary.Platform;
+
/*
* @test
* @bug 8132475
* @summary Check that the executables in the current JDK image
* are executable by all users.
+ * @library /lib/testlibrary
* @run main ExecutableTest
* @author Volker Simonis
*/
public class ExecutableTest {
+ // We use a fixed list of binaries because not all the files in the
+ // bin/ directory are necessarily exectuables (see 8132704)
+ private static final String[] executables = {
+ "appletviewer", "idlj", "jar", "jarsigner", "java", "java-rmi.cgi", "javac",
+ "javadoc", "javah", "javap", "jcmd", "jconsole", "jdb", "jdeps", "jimage",
+ "jinfo", "jjs", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat",
+ "jstatd", "keytool", "orbd", "pack200", "policytool", "rmic", "rmid",
+ "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv",
+ "unpack200", "wsgen", "wsimport", "xjc" };
+
public static void main(String args[]) throws Throwable {
String JAVA_HOME = System.getProperty("java.home");
! String exeSuffix = Platform.isWindows() ? ".exe" : "";
!
EnumSet<PosixFilePermission> execPerms =
EnumSet.of(GROUP_EXECUTE, OTHERS_EXECUTE, OWNER_EXECUTE);
!
! for (String exe : executables) {
! Path path = Paths.get(JAVA_HOME, "bin", exe + exeSuffix);
! if (Files.isRegularFile(path)) {
! if (!Files.isExecutable(path)) {
! throw new Error(path + " is not executable!");
}
try {
! Set<PosixFilePermission> perm = Files.getPosixFilePermissions(path);
if (!perm.containsAll(execPerms)) {
! throw new Error(path + " has not all executable permissions!\n" +
"Should have: " + execPerms + "\nbut has: " + perm);
}
} catch (UnsupportedOperationException e) {}
}
}
< prev index next >