< prev index next >

test/lib/jdk/test/lib/cds/CDSTestUtils.java

Print this page

        

*** 30,40 **** import java.util.ArrayList; import java.util.Date; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; ! // This class contains common test utilities for testing CDS public class CDSTestUtils { public interface Checker { public void check(OutputAnalyzer output) throws Exception; --- 30,40 ---- import java.util.ArrayList; import java.util.Date; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; ! import jtreg.SkippedException; // This class contains common test utilities for testing CDS public class CDSTestUtils { public interface Checker { public void check(OutputAnalyzer output) throws Exception;
*** 120,130 **** private final String CDS_DISABLED = "warning: CDS is disabled when the"; public Result(CDSOptions opts, OutputAnalyzer out) throws Exception { options = opts; output = out; ! hasMappingFailure = CDSTestUtils.checkCommonExecExceptions(output); hasAbnormalExit = (!hasMappingFailure) && (output.getExitValue() != 0); hasNormalExit = (!hasMappingFailure) && (output.getExitValue() == 0); if (hasNormalExit) { if ("on".equals(options.xShareMode) && --- 120,130 ---- private final String CDS_DISABLED = "warning: CDS is disabled when the"; public Result(CDSOptions opts, OutputAnalyzer out) throws Exception { options = opts; output = out; ! hasMappingFailure = isUnableToMap(output); hasAbnormalExit = (!hasMappingFailure) && (output.getExitValue() != 0); hasNormalExit = (!hasMappingFailure) && (output.getExitValue() == 0); if (hasNormalExit) { if ("on".equals(options.xShareMode) &&
*** 221,231 **** // This property is passed to child test processes public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0"); public static final String UnableToMapMsg = ! "Unable to map shared archive: test did not complete; assumed PASS"; // Create bootstrap CDS archive, // use extra JVM command line args as a prefix. // For CDS tests specifying prefix makes more sense than specifying suffix, since // normally there are no classes or arguments to classes, just "-version" --- 221,231 ---- // This property is passed to child test processes public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0"); public static final String UnableToMapMsg = ! "Unable to map shared archive: test did not complete"; // Create bootstrap CDS archive, // use extra JVM command line args as a prefix. // For CDS tests specifying prefix makes more sense than specifying suffix, since // normally there are no classes or arguments to classes, just "-version"
*** 293,333 **** // However exceptions that occur in the child process do not automatically propagate // to the parent process. This mechanism aims to improve the propagation // of exceptions and common errors. // Exception e argument - an exception to be re-thrown if none of the common // exceptions match. Pass null if you wish not to re-throw any exception. ! public static boolean checkCommonExecExceptions(OutputAnalyzer output, Exception e) throws Exception { if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) { throw new RuntimeException("Hotspot crashed"); } if (output.getStdout().contains("TEST FAILED")) { throw new RuntimeException("Test Failed"); } - if (output.getOutput().contains("shared class paths mismatch")) { - // throw new RuntimeException("shared class paths mismatch"); - } if (output.getOutput().contains("Unable to unmap shared space")) { throw new RuntimeException("Unable to unmap shared space"); } // Special case -- sometimes Xshare:on fails because it failed to map // at given address. This behavior is platform-specific, machine config-specific // and can be random (see ASLR). if (isUnableToMap(output)) { ! System.out.println(UnableToMapMsg); ! return true; } if (e != null) { throw e; } - return false; } ! public static boolean checkCommonExecExceptions(OutputAnalyzer output) throws Exception { ! return checkCommonExecExceptions(output, null); } // Check the output for indication that mapping of the archive failed. // Performance note: this check seems to be rather costly - searching the entire --- 293,328 ---- // However exceptions that occur in the child process do not automatically propagate // to the parent process. This mechanism aims to improve the propagation // of exceptions and common errors. // Exception e argument - an exception to be re-thrown if none of the common // exceptions match. Pass null if you wish not to re-throw any exception. ! public static void checkCommonExecExceptions(OutputAnalyzer output, Exception e) throws Exception { if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) { throw new RuntimeException("Hotspot crashed"); } if (output.getStdout().contains("TEST FAILED")) { throw new RuntimeException("Test Failed"); } if (output.getOutput().contains("Unable to unmap shared space")) { throw new RuntimeException("Unable to unmap shared space"); } // Special case -- sometimes Xshare:on fails because it failed to map // at given address. This behavior is platform-specific, machine config-specific // and can be random (see ASLR). if (isUnableToMap(output)) { ! throw new SkippedException(UnableToMapMsg); } if (e != null) { throw e; } } ! public static void checkCommonExecExceptions(OutputAnalyzer output) throws Exception { ! checkCommonExecExceptions(output, null); } // Check the output for indication that mapping of the archive failed. // Performance note: this check seems to be rather costly - searching the entire
*** 356,365 **** --- 351,366 ---- } return false; } + public static void checkMappingFailure(OutputAnalyzer out) throws SkippedException { + if (isUnableToMap(out)) { + throw new SkippedException(UnableToMapMsg); + } + } + public static Result run(String... cliPrefix) throws Exception { CDSOptions opts = new CDSOptions(); opts.setArchiveName(getDefaultArchiveName()); opts.addPrefix(cliPrefix); return new Result(opts, runWithArchive(opts));
*** 444,455 **** public static OutputAnalyzer checkExecExpectError(OutputAnalyzer output, int expectedExitValue, String... extraMatches) throws Exception { if (isUnableToMap(output)) { ! System.out.println(UnableToMapMsg); ! return output; } output.shouldHaveExitValue(expectedExitValue); checkMatches(output, extraMatches); return output; --- 445,455 ---- public static OutputAnalyzer checkExecExpectError(OutputAnalyzer output, int expectedExitValue, String... extraMatches) throws Exception { if (isUnableToMap(output)) { ! throw new SkippedException(UnableToMapMsg); } output.shouldHaveExitValue(expectedExitValue); checkMatches(output, extraMatches); return output;
< prev index next >