# HG changeset patch # User mseledtsov # Date 1534352416 25200 # Node ID 4699147a4f917f9e643f89412eeaad20cab0f9dd # Parent cb8cab787ba28ca5a4d489477feba59048cb2a9f 8209164: [TESTBUG] Apply jtreg skipped status to cds tests Summary: Added the SkippedException where applicable Reviewed-by: iklam, jiangli diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/ArchiveDoesNotExist.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/ArchiveDoesNotExist.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/ArchiveDoesNotExist.java Wed Aug 15 10:00:16 2018 -0700 @@ -51,18 +51,16 @@ // -Xshare=on OutputAnalyzer out = CDSTestUtils.runWithArchive(opts); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldContain("Specified shared archive not found") - .shouldHaveExitValue(1); - } + CDSTestUtils.checkMappingFailure(out); + out.shouldContain("Specified shared archive not found") + .shouldHaveExitValue(1); // -Xshare=auto opts.setXShareMode("auto"); out = CDSTestUtils.runWithArchive(opts); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldMatch("(java|openjdk) version") - .shouldNotContain("sharing") - .shouldHaveExitValue(0); - } + CDSTestUtils.checkMappingFailure(out); + out.shouldMatch("(java|openjdk) version") + .shouldNotContain("sharing") + .shouldHaveExitValue(0); } } diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentCompactStrings.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentCompactStrings.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentCompactStrings.java Wed Aug 15 10:00:16 2018 -0700 @@ -50,10 +50,10 @@ CDSTestUtils.checkDump(out); out = CDSTestUtils.runWithArchive(loadCompactStringsArgument); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldMatch("The shared archive file's CompactStrings " + - "setting .* does not equal the current CompactStrings setting") - .shouldHaveExitValue(1); - } + CDSTestUtils.checkMappingFailure(out); + + out.shouldMatch("The shared archive file's CompactStrings " + + "setting .* does not equal the current CompactStrings setting") + .shouldHaveExitValue(1); } } diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java Wed Aug 15 10:00:16 2018 -0700 @@ -35,7 +35,6 @@ import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import java.io.File; public class NonBootLoaderClasses { public static void main(String[] args) throws Exception { @@ -56,11 +55,11 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, "-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary"); OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "print-shared-archive"); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldContain("archive is valid") - .shouldHaveExitValue(0) // Should report success in error code. - .shouldContain(PLATFORM_CLASS.replace('/', '.')) - .shouldContain(APP_CLASS.replace('/', '.')); - } + CDSTestUtils.checkMappingFailure(out); + + out.shouldContain("archive is valid") + .shouldHaveExitValue(0) // Should report success in error code. + .shouldContain(PLATFORM_CLASS.replace('/', '.')) + .shouldContain(APP_CLASS.replace('/', '.')); } } diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java Wed Aug 15 10:00:16 2018 -0700 @@ -36,7 +36,6 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; - public class PrintSharedArchiveAndExit { public static void main(String[] args) throws Exception { String archiveName = "PrintSharedArchiveAndExit.jsa"; @@ -49,20 +48,19 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, "-XX:+PrintSharedArchiveAndExit", "-version"); out = CDSTestUtils.executeAndLog(pb, "print-shared-archive-and-version"); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldContain("archive is valid") - .shouldNotContain("java version") // Should not print JVM version - .shouldHaveExitValue(0); // Should report success in error code. - } + CDSTestUtils.checkMappingFailure(out); + + out.shouldContain("archive is valid") + .shouldNotContain("java version") // Should not print JVM version + .shouldHaveExitValue(0); // Should report success in error code. pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, "-XX:+PrintSharedArchiveAndExit"); out = CDSTestUtils.executeAndLog(pb, "print-shared-archive"); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldContain("archive is valid") - .shouldNotContain("Usage:") // Should not print JVM help message - .shouldHaveExitValue(0); // Should report success in error code. - } + CDSTestUtils.checkMappingFailure(out); + out.shouldContain("archive is valid") + .shouldNotContain("Usage:") // Should not print JVM help message + .shouldHaveExitValue(0); // Should report success in error code. } } diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/SharedSymbolTableBucketSize.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedSymbolTableBucketSize.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedSymbolTableBucketSize.java Wed Aug 15 10:00:16 2018 -0700 @@ -42,15 +42,14 @@ CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize=" + Integer.valueOf(bucket_size)); CDSTestUtils.checkDump(output); + CDSTestUtils.checkMappingFailure(output); - if (!CDSTestUtils.isUnableToMap(output)) { - String s = output.firstMatch("Average bucket size : .*"); - Float f = Float.parseFloat(s.substring(25)); - int size = Math.round(f); - if (size != bucket_size) { - throw new Exception("FAILED: incorrect bucket size " + size + - ", expect " + bucket_size); - } + String s = output.firstMatch("Average bucket size : .*"); + Float f = Float.parseFloat(s.substring(25)); + int size = Math.round(f); + if (size != bucket_size) { + throw new Exception("FAILED: incorrect bucket size " + size + + ", expect " + bucket_size); } // Invalid SharedSymbolTableBucketSize input diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java Wed Aug 15 10:00:16 2018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; - // This class contains methods common to all transformation test cases public class TransformTestCommon { @@ -101,8 +100,7 @@ // If we were not able to map an archive, // then do not perform other checks, since // there was no sharing at all - if (CDSTestUtils.isUnableToMap(out)) - return; + CDSTestUtils.checkMappingFailure(out); String childVmName = child.replace('.', '/'); String parentVmName = parent.replace('.', '/'); diff -r cb8cab787ba2 -r 4699147a4f91 test/hotspot/jtreg/runtime/appcds/sharedStrings/InvalidFileFormat.java --- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/InvalidFileFormat.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/InvalidFileFormat.java Wed Aug 15 10:00:16 2018 -0700 @@ -36,8 +36,9 @@ * @run main/othervm -XX:-CompactStrings InvalidFileFormat */ +import java.io.File; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import java.io.File; // Checking most common error use cases // This file is not an exhastive test of various shared data file corruption @@ -65,8 +66,8 @@ OutputAnalyzer out = SharedStringsUtils.dumpWithoutChecks(TestCommon.list("HelloString"), "invalidFormat" + File.separator + dataFileName); - if (!TestCommon.isUnableToMap(out)) - out.shouldContain(expectedWarning).shouldHaveExitValue(1); + CDSTestUtils.checkMappingFailure(out); + out.shouldContain(expectedWarning).shouldHaveExitValue(1); } } diff -r cb8cab787ba2 -r 4699147a4f91 test/lib/jdk/test/lib/cds/CDSTestUtils.java --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java Wed Aug 15 14:35:33 2018 +0200 +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java Wed Aug 15 10:00:16 2018 -0700 @@ -32,7 +32,7 @@ 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 { @@ -114,17 +114,14 @@ public static class Result { private final OutputAnalyzer output; private final CDSOptions options; - private final boolean hasMappingFailure; - private final boolean hasAbnormalExit; private final boolean hasNormalExit; 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); + checkMappingFailure(out); + this.options = opts; + this.output = out; + hasNormalExit = (output.getExitValue() == 0); if (hasNormalExit) { if ("on".equals(options.xShareMode) && @@ -138,30 +135,22 @@ } public Result assertNormalExit(Checker checker) throws Exception { - if (!hasMappingFailure) { - checker.check(output); - output.shouldHaveExitValue(0); - } + checker.check(output); + output.shouldHaveExitValue(0); return this; } public Result assertAbnormalExit(Checker checker) throws Exception { - if (!hasMappingFailure) { - checker.check(output); - output.shouldNotHaveExitValue(0); - } + checker.check(output); + output.shouldNotHaveExitValue(0); return this; } // When {--limit-modules, --patch-module, and/or --upgrade-module-path} // are specified, CDS is silently disabled for both -Xshare:auto and -Xshare:on. public Result assertSilentlyDisabledCDS(Checker checker) throws Exception { - if (hasMappingFailure) { - throw new RuntimeException("Unexpected mapping failure"); - } // this comes from a JVM warning message. output.shouldContain(CDS_DISABLED); - checker.check(output); return this; } @@ -181,34 +170,27 @@ } public Result ifAbnormalExit(Checker checker) throws Exception { - if (hasAbnormalExit) { + if (!hasNormalExit) { checker.check(output); } return this; } public Result ifNoMappingFailure(Checker checker) throws Exception { - if (!hasMappingFailure) { - checker.check(output); - } + checker.check(output); return this; } public Result assertNormalExit(String... matches) throws Exception { - if (!hasMappingFailure) { - checkMatches(output, matches); - output.shouldHaveExitValue(0); - } + checkMatches(output, matches); + output.shouldHaveExitValue(0); return this; } public Result assertAbnormalExit(String... matches) throws Exception { - if (!hasMappingFailure) { - checkMatches(output, matches); - output.shouldNotHaveExitValue(0); - } - + checkMatches(output, matches); + output.shouldNotHaveExitValue(0); return this; } } @@ -223,7 +205,7 @@ 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"; + "Unable to map shared archive: test did not complete"; // Create bootstrap CDS archive, // use extra JVM command line args as a prefix. @@ -295,7 +277,7 @@ // 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) + 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"); @@ -303,9 +285,6 @@ 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"); } @@ -314,18 +293,16 @@ // 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; + throw new SkippedException(UnableToMapMsg); } if (e != null) { throw e; } - return false; } - public static boolean checkCommonExecExceptions(OutputAnalyzer output) throws Exception { - return checkCommonExecExceptions(output, null); + public static void checkCommonExecExceptions(OutputAnalyzer output) throws Exception { + checkCommonExecExceptions(output, null); } @@ -358,6 +335,12 @@ 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()); @@ -446,8 +429,7 @@ int expectedExitValue, String... extraMatches) throws Exception { if (isUnableToMap(output)) { - System.out.println(UnableToMapMsg); - return output; + throw new SkippedException(UnableToMapMsg); } output.shouldHaveExitValue(expectedExitValue);