Tue, 17 Sep 2013 16:55:53 +0200
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
1.1 --- a/test/TEST.groups Fri Sep 13 16:55:44 2013 -0700 1.2 +++ b/test/TEST.groups Tue Sep 17 16:55:53 2013 +0200 1.3 @@ -72,18 +72,7 @@ 1.4 runtime/7194254/Test7194254.java \ 1.5 runtime/jsig/Test8017498.sh \ 1.6 runtime/Metaspace/FragmentMetaspace.java \ 1.7 - runtime/NMT/BaselineWithParameter.java \ 1.8 - runtime/NMT/JcmdScale.java \ 1.9 - runtime/NMT/JcmdWithNMTDisabled.java \ 1.10 - runtime/NMT/MallocTestType.java \ 1.11 runtime/NMT/ReleaseCommittedMemory.java \ 1.12 - runtime/NMT/ShutdownTwice.java \ 1.13 - runtime/NMT/SummaryAfterShutdown.java \ 1.14 - runtime/NMT/SummarySanityCheck.java \ 1.15 - runtime/NMT/ThreadedMallocTestType.java \ 1.16 - runtime/NMT/ThreadedVirtualAllocTestType.java \ 1.17 - runtime/NMT/VirtualAllocTestType.java \ 1.18 - runtime/RedefineObject/TestRedefineObject.java \ 1.19 serviceability/attach/AttachWithStalePidFile.java 1.20 1.21 # JRE adds further tests to compact3
2.1 --- a/test/gc/TestVerifyDuringStartup.java Fri Sep 13 16:55:44 2013 -0700 2.2 +++ b/test/gc/TestVerifyDuringStartup.java Tue Sep 17 16:55:53 2013 +0200 2.3 @@ -48,7 +48,7 @@ 2.4 "-XX:+VerifyDuringStartup", 2.5 "-version"}); 2.6 2.7 - System.out.print("Testing:\n" + JDKToolFinder.getCurrentJDKTool("java")); 2.8 + System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java")); 2.9 for (int i = 0; i < vmOpts.size(); i += 1) { 2.10 System.out.print(" " + vmOpts.get(i)); 2.11 }
3.1 --- a/test/testlibrary/com/oracle/java/testlibrary/JDKToolFinder.java Fri Sep 13 16:55:44 2013 -0700 3.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/JDKToolFinder.java Tue Sep 17 16:55:53 2013 +0200 3.3 @@ -23,7 +23,9 @@ 3.4 3.5 package com.oracle.java.testlibrary; 3.6 3.7 -import java.io.File; 3.8 +import java.io.FileNotFoundException; 3.9 +import java.nio.file.Path; 3.10 +import java.nio.file.Paths; 3.11 3.12 public final class JDKToolFinder { 3.13 3.14 @@ -32,38 +34,73 @@ 3.15 3.16 /** 3.17 * Returns the full path to an executable in jdk/bin based on System 3.18 - * property {@code compile.jdk} (set by jtreg test suite) 3.19 + * property {@code test.jdk} or {@code compile.jdk} (both are set by the jtreg test suite) 3.20 * 3.21 * @return Full path to an executable in jdk/bin 3.22 */ 3.23 public static String getJDKTool(String tool) { 3.24 - String binPath = System.getProperty("compile.jdk"); 3.25 - if (binPath == null) { 3.26 - throw new RuntimeException("System property 'compile.jdk' not set. " 3.27 - + "This property is normally set by jtreg. " 3.28 - + "When running test separately, set this property using " 3.29 - + "'-Dcompile.jdk=/path/to/jdk'."); 3.30 + 3.31 + // First try to find the executable in test.jdk 3.32 + try { 3.33 + return getTool(tool, "test.jdk"); 3.34 + } catch (FileNotFoundException e) { 3.35 + 3.36 } 3.37 - binPath += File.separatorChar + "bin" + File.separatorChar + tool; 3.38 3.39 - return binPath; 3.40 + // Now see if it's available in compile.jdk 3.41 + try { 3.42 + return getTool(tool, "compile.jdk"); 3.43 + } catch (FileNotFoundException e) { 3.44 + throw new RuntimeException("Failed to find " + tool + 3.45 + ", looked in test.jdk (" + System.getProperty("test.jdk") + 3.46 + ") and compile.jdk (" + System.getProperty("compile.jdk") + ")"); 3.47 + } 3.48 } 3.49 + 3.50 /** 3.51 - * Returns the full path to an executable in <current jdk>/bin based 3.52 - * on System property {@code test.jdk} (set by jtreg test suite) 3.53 + * Returns the full path to an executable in jdk/bin based on System 3.54 + * property {@code compile.jdk} 3.55 * 3.56 * @return Full path to an executable in jdk/bin 3.57 */ 3.58 - public static String getCurrentJDKTool(String tool) { 3.59 - String binPath = System.getProperty("test.jdk"); 3.60 - if (binPath == null) { 3.61 - throw new RuntimeException("System property 'test.jdk' not set. " 3.62 - + "This property is normally set by jtreg. " 3.63 - + "When running test separately, set this property using " 3.64 - + "'-Dtest.jdk=/path/to/jdk'."); 3.65 + public static String getCompileJDKTool(String tool) { 3.66 + try { 3.67 + return getTool(tool, "compile.jdk"); 3.68 + } catch (FileNotFoundException e) { 3.69 + throw new RuntimeException(e); 3.70 } 3.71 - binPath += File.separatorChar + "bin" + File.separatorChar + tool; 3.72 + } 3.73 3.74 - return binPath; 3.75 + /** 3.76 + * Returns the full path to an executable in jdk/bin based on System 3.77 + * property {@code test.jdk} 3.78 + * 3.79 + * @return Full path to an executable in jdk/bin 3.80 + */ 3.81 + public static String getTestJDKTool(String tool) { 3.82 + try { 3.83 + return getTool(tool, "test.jdk"); 3.84 + } catch (FileNotFoundException e) { 3.85 + throw new RuntimeException(e); 3.86 + } 3.87 + } 3.88 + 3.89 + private static String getTool(String tool, String property) throws FileNotFoundException { 3.90 + String jdkPath = System.getProperty(property); 3.91 + 3.92 + if (jdkPath == null) { 3.93 + throw new RuntimeException( 3.94 + "System property '" + property + "' not set. This property is normally set by jtreg. " 3.95 + + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'."); 3.96 + } 3.97 + 3.98 + Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : "")); 3.99 + 3.100 + Path jdkTool = Paths.get(jdkPath, toolName.toString()); 3.101 + if (!jdkTool.toFile().exists()) { 3.102 + throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath()); 3.103 + } 3.104 + 3.105 + return jdkTool.toAbsolutePath().toString(); 3.106 } 3.107 }