提交 5fe77ae1 编写于 作者: C ctornqvi

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: dholmes, hseigel
上级 f8aa0456
......@@ -72,18 +72,7 @@ needs_jdk = \
runtime/7194254/Test7194254.java \
runtime/jsig/Test8017498.sh \
runtime/Metaspace/FragmentMetaspace.java \
runtime/NMT/BaselineWithParameter.java \
runtime/NMT/JcmdScale.java \
runtime/NMT/JcmdWithNMTDisabled.java \
runtime/NMT/MallocTestType.java \
runtime/NMT/ReleaseCommittedMemory.java \
runtime/NMT/ShutdownTwice.java \
runtime/NMT/SummaryAfterShutdown.java \
runtime/NMT/SummarySanityCheck.java \
runtime/NMT/ThreadedMallocTestType.java \
runtime/NMT/ThreadedVirtualAllocTestType.java \
runtime/NMT/VirtualAllocTestType.java \
runtime/RedefineObject/TestRedefineObject.java \
serviceability/attach/AttachWithStalePidFile.java
# JRE adds further tests to compact3
......
......@@ -48,7 +48,7 @@ public class TestVerifyDuringStartup {
"-XX:+VerifyDuringStartup",
"-version"});
System.out.print("Testing:\n" + JDKToolFinder.getCurrentJDKTool("java"));
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
for (int i = 0; i < vmOpts.size(); i += 1) {
System.out.print(" " + vmOpts.get(i));
}
......
......@@ -23,7 +23,9 @@
package com.oracle.java.testlibrary;
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.nio.file.Paths;
public final class JDKToolFinder {
......@@ -32,38 +34,73 @@ public final class JDKToolFinder {
/**
* Returns the full path to an executable in jdk/bin based on System
* property {@code compile.jdk} (set by jtreg test suite)
* property {@code test.jdk} or {@code 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("compile.jdk");
if (binPath == null) {
throw new RuntimeException("System property 'compile.jdk' not set. "
+ "This property is normally set by jtreg. "
+ "When running test separately, set this property using "
+ "'-Dcompile.jdk=/path/to/jdk'.");
// First try to find the executable in test.jdk
try {
return getTool(tool, "test.jdk");
} catch (FileNotFoundException e) {
}
binPath += File.separatorChar + "bin" + File.separatorChar + tool;
return binPath;
// Now see if it's available in compile.jdk
try {
return getTool(tool, "compile.jdk");
} catch (FileNotFoundException e) {
throw new RuntimeException("Failed to find " + tool +
", looked in test.jdk (" + System.getProperty("test.jdk") +
") and compile.jdk (" + System.getProperty("compile.jdk") + ")");
}
}
/**
* Returns the full path to an executable in jdk/bin based on System
* property {@code compile.jdk}
*
* @return Full path to an executable in jdk/bin
*/
public static String getCompileJDKTool(String tool) {
try {
return getTool(tool, "compile.jdk");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
/**
* Returns the full path to an executable in &lt;current jdk&gt;/bin based
* on System property {@code test.jdk} (set by jtreg test suite)
* Returns the full path to an executable in jdk/bin based on System
* property {@code test.jdk}
*
* @return Full path to an executable in jdk/bin
*/
public static String getCurrentJDKTool(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. "
+ "When running test separately, set this property using "
+ "'-Dtest.jdk=/path/to/jdk'.");
public static String getTestJDKTool(String tool) {
try {
return getTool(tool, "test.jdk");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
private static String getTool(String tool, String property) throws FileNotFoundException {
String jdkPath = System.getProperty(property);
if (jdkPath == null) {
throw new RuntimeException(
"System property '" + property + "' not set. This property is normally set by jtreg. "
+ "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
}
Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));
Path jdkTool = Paths.get(jdkPath, toolName.toString());
if (!jdkTool.toFile().exists()) {
throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
}
binPath += File.separatorChar + "bin" + File.separatorChar + tool;
return binPath;
return jdkTool.toAbsolutePath().toString();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册