test/testlibrary/com/oracle/java/testlibrary/JDKToolFinder.java
Print this page
rev 5194 : 8014905: [TESTBUG] Some hotspot tests should be updated to divide test jdk and compile jdk
Summary: Change JDKToolFinder to look in compile.jdk if the executable cannot be found in test.jdk
Reviewed-by:
@@ -21,30 +21,47 @@
* questions.
*/
package com.oracle.java.testlibrary;
-import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
public final class JDKToolFinder {
private JDKToolFinder() {
}
/**
- * Returns the full path to an executable in jdk/bin based on System property
- * test.jdk (set by jtreg test suite)
+ * Returns the full path to an executable in jdk/bin based on System
+ * property test.jdk or compile.jdk (both are set by the jtreg test suite)
*
* @return Full path to an executable in jdk/bin
*/
public static String getJDKTool(String tool) {
- String binPath = System.getProperty("test.jdk");
- if (binPath == null) {
- throw new RuntimeException("System property 'test.jdk' not set. This property is normally set by jtreg. "
+ String compileJdkPath = System.getProperty("compile.jdk");
+ String testJdkPath = System.getProperty("test.jdk");
+
+ if (testJdkPath == null) {
+ throw new RuntimeException(
+ "System property 'test.jdk' not set. This property is normally set by jtreg. "
+ "When running test separately, set this property using '-Dtest.jdk=/path/to/jdk'.");
}
- binPath += File.separatorChar + "bin" + File.separatorChar + tool;
+ Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));
+
+ // First try with test.jdk, if the tool can't be found there, check
+ // compile.jdk
+ Path testJdkTool = Paths.get(testJdkPath, toolName.toString());
+ if (!testJdkTool.toFile().exists()) {
+ Path compileJdkTool = Paths.get(compileJdkPath, toolName.toString());
+ if (!compileJdkTool.toFile().exists()) {
+ throw new RuntimeException("Failed to find " + tool +
+ ", looked in test.jdk (" + testJdkTool.toAbsolutePath() +
+ ") and compile.jdk (" + compileJdkTool.toAbsolutePath() + ")");
+ }
+ return compileJdkTool.toAbsolutePath().toString();
+ }
- return binPath;
+ return testJdkTool.toAbsolutePath().toString();
}
}