8209164: [TESTBUG] Apply jtreg skipped status to cds tests
Added the SkippedException where applicable Reviewed-by: iklam, jiangli
This commit is contained in:
parent
f87ec5faf7
commit
b71faed5df
@ -51,18 +51,16 @@ public class ArchiveDoesNotExist {
|
|||||||
|
|
||||||
// -Xshare=on
|
// -Xshare=on
|
||||||
OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
|
OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldContain("Specified shared archive not found")
|
out.shouldContain("Specified shared archive not found")
|
||||||
.shouldHaveExitValue(1);
|
.shouldHaveExitValue(1);
|
||||||
}
|
|
||||||
|
|
||||||
// -Xshare=auto
|
// -Xshare=auto
|
||||||
opts.setXShareMode("auto");
|
opts.setXShareMode("auto");
|
||||||
out = CDSTestUtils.runWithArchive(opts);
|
out = CDSTestUtils.runWithArchive(opts);
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldMatch("(java|openjdk) version")
|
out.shouldMatch("(java|openjdk) version")
|
||||||
.shouldNotContain("sharing")
|
.shouldNotContain("sharing")
|
||||||
.shouldHaveExitValue(0);
|
.shouldHaveExitValue(0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ public class CdsDifferentCompactStrings {
|
|||||||
CDSTestUtils.checkDump(out);
|
CDSTestUtils.checkDump(out);
|
||||||
|
|
||||||
out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
|
out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldMatch("The shared archive file's CompactStrings " +
|
|
||||||
"setting .* does not equal the current CompactStrings setting")
|
out.shouldMatch("The shared archive file's CompactStrings " +
|
||||||
.shouldHaveExitValue(1);
|
"setting .* does not equal the current CompactStrings setting")
|
||||||
}
|
.shouldHaveExitValue(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import jdk.test.lib.cds.CDSOptions;
|
|||||||
import jdk.test.lib.cds.CDSTestUtils;
|
import jdk.test.lib.cds.CDSTestUtils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class NonBootLoaderClasses {
|
public class NonBootLoaderClasses {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
@ -56,11 +55,11 @@ public class NonBootLoaderClasses {
|
|||||||
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
||||||
"-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary");
|
"-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary");
|
||||||
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
|
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldContain("archive is valid")
|
|
||||||
.shouldHaveExitValue(0) // Should report success in error code.
|
out.shouldContain("archive is valid")
|
||||||
.shouldContain(PLATFORM_CLASS.replace('/', '.'))
|
.shouldHaveExitValue(0) // Should report success in error code.
|
||||||
.shouldContain(APP_CLASS.replace('/', '.'));
|
.shouldContain(PLATFORM_CLASS.replace('/', '.'))
|
||||||
}
|
.shouldContain(APP_CLASS.replace('/', '.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import jdk.test.lib.cds.CDSTestUtils;
|
|||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
|
|
||||||
public class PrintSharedArchiveAndExit {
|
public class PrintSharedArchiveAndExit {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String archiveName = "PrintSharedArchiveAndExit.jsa";
|
String archiveName = "PrintSharedArchiveAndExit.jsa";
|
||||||
@ -49,20 +48,19 @@ public class PrintSharedArchiveAndExit {
|
|||||||
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
||||||
"-XX:+PrintSharedArchiveAndExit", "-version");
|
"-XX:+PrintSharedArchiveAndExit", "-version");
|
||||||
out = CDSTestUtils.executeAndLog(pb, "print-shared-archive-and-version");
|
out = CDSTestUtils.executeAndLog(pb, "print-shared-archive-and-version");
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldContain("archive is valid")
|
|
||||||
.shouldNotContain("java version") // Should not print JVM version
|
out.shouldContain("archive is valid")
|
||||||
.shouldHaveExitValue(0); // Should report success in error code.
|
.shouldNotContain("java version") // Should not print JVM version
|
||||||
}
|
.shouldHaveExitValue(0); // Should report success in error code.
|
||||||
|
|
||||||
pb = ProcessTools.createJavaProcessBuilder(
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
|
||||||
"-XX:+PrintSharedArchiveAndExit");
|
"-XX:+PrintSharedArchiveAndExit");
|
||||||
out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
|
out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
|
||||||
if (!CDSTestUtils.isUnableToMap(out)) {
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldContain("archive is valid")
|
out.shouldContain("archive is valid")
|
||||||
.shouldNotContain("Usage:") // Should not print JVM help message
|
.shouldNotContain("Usage:") // Should not print JVM help message
|
||||||
.shouldHaveExitValue(0); // Should report success in error code.
|
.shouldHaveExitValue(0); // Should report success in error code.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,14 @@ public class SharedSymbolTableBucketSize {
|
|||||||
CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize="
|
CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize="
|
||||||
+ Integer.valueOf(bucket_size));
|
+ Integer.valueOf(bucket_size));
|
||||||
CDSTestUtils.checkDump(output);
|
CDSTestUtils.checkDump(output);
|
||||||
|
CDSTestUtils.checkMappingFailure(output);
|
||||||
|
|
||||||
if (!CDSTestUtils.isUnableToMap(output)) {
|
String s = output.firstMatch("Average bucket size : .*");
|
||||||
String s = output.firstMatch("Average bucket size : .*");
|
Float f = Float.parseFloat(s.substring(25));
|
||||||
Float f = Float.parseFloat(s.substring(25));
|
int size = Math.round(f);
|
||||||
int size = Math.round(f);
|
if (size != bucket_size) {
|
||||||
if (size != bucket_size) {
|
throw new Exception("FAILED: incorrect bucket size " + size +
|
||||||
throw new Exception("FAILED: incorrect bucket size " + size +
|
", expect " + bucket_size);
|
||||||
", expect " + bucket_size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid SharedSymbolTableBucketSize input
|
// Invalid SharedSymbolTableBucketSize input
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.cds.CDSTestUtils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
|
|
||||||
// This class contains methods common to all transformation test cases
|
// This class contains methods common to all transformation test cases
|
||||||
public class TransformTestCommon {
|
public class TransformTestCommon {
|
||||||
|
|
||||||
@ -101,8 +100,7 @@ public class TransformTestCommon {
|
|||||||
// If we were not able to map an archive,
|
// If we were not able to map an archive,
|
||||||
// then do not perform other checks, since
|
// then do not perform other checks, since
|
||||||
// there was no sharing at all
|
// there was no sharing at all
|
||||||
if (CDSTestUtils.isUnableToMap(out))
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
return;
|
|
||||||
|
|
||||||
String childVmName = child.replace('.', '/');
|
String childVmName = child.replace('.', '/');
|
||||||
String parentVmName = parent.replace('.', '/');
|
String parentVmName = parent.replace('.', '/');
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
* @run main/othervm -XX:-CompactStrings InvalidFileFormat
|
* @run main/othervm -XX:-CompactStrings InvalidFileFormat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import jdk.test.lib.cds.CDSTestUtils;
|
||||||
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
// Checking most common error use cases
|
// Checking most common error use cases
|
||||||
// This file is not an exhastive test of various shared data file corruption
|
// This file is not an exhastive test of various shared data file corruption
|
||||||
@ -65,8 +66,8 @@ public class InvalidFileFormat {
|
|||||||
OutputAnalyzer out = SharedStringsUtils.dumpWithoutChecks(TestCommon.list("HelloString"),
|
OutputAnalyzer out = SharedStringsUtils.dumpWithoutChecks(TestCommon.list("HelloString"),
|
||||||
"invalidFormat" + File.separator + dataFileName);
|
"invalidFormat" + File.separator + dataFileName);
|
||||||
|
|
||||||
if (!TestCommon.isUnableToMap(out))
|
CDSTestUtils.checkMappingFailure(out);
|
||||||
out.shouldContain(expectedWarning).shouldHaveExitValue(1);
|
out.shouldContain(expectedWarning).shouldHaveExitValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import java.util.Date;
|
|||||||
import jdk.test.lib.Utils;
|
import jdk.test.lib.Utils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
// This class contains common test utilities for testing CDS
|
// This class contains common test utilities for testing CDS
|
||||||
public class CDSTestUtils {
|
public class CDSTestUtils {
|
||||||
@ -114,17 +114,14 @@ public class CDSTestUtils {
|
|||||||
public static class Result {
|
public static class Result {
|
||||||
private final OutputAnalyzer output;
|
private final OutputAnalyzer output;
|
||||||
private final CDSOptions options;
|
private final CDSOptions options;
|
||||||
private final boolean hasMappingFailure;
|
|
||||||
private final boolean hasAbnormalExit;
|
|
||||||
private final boolean hasNormalExit;
|
private final boolean hasNormalExit;
|
||||||
private final String CDS_DISABLED = "warning: CDS is disabled when the";
|
private final String CDS_DISABLED = "warning: CDS is disabled when the";
|
||||||
|
|
||||||
public Result(CDSOptions opts, OutputAnalyzer out) throws Exception {
|
public Result(CDSOptions opts, OutputAnalyzer out) throws Exception {
|
||||||
options = opts;
|
checkMappingFailure(out);
|
||||||
output = out;
|
this.options = opts;
|
||||||
hasMappingFailure = CDSTestUtils.checkCommonExecExceptions(output);
|
this.output = out;
|
||||||
hasAbnormalExit = (!hasMappingFailure) && (output.getExitValue() != 0);
|
hasNormalExit = (output.getExitValue() == 0);
|
||||||
hasNormalExit = (!hasMappingFailure) && (output.getExitValue() == 0);
|
|
||||||
|
|
||||||
if (hasNormalExit) {
|
if (hasNormalExit) {
|
||||||
if ("on".equals(options.xShareMode) &&
|
if ("on".equals(options.xShareMode) &&
|
||||||
@ -138,30 +135,22 @@ public class CDSTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Result assertNormalExit(Checker checker) throws Exception {
|
public Result assertNormalExit(Checker checker) throws Exception {
|
||||||
if (!hasMappingFailure) {
|
checker.check(output);
|
||||||
checker.check(output);
|
output.shouldHaveExitValue(0);
|
||||||
output.shouldHaveExitValue(0);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result assertAbnormalExit(Checker checker) throws Exception {
|
public Result assertAbnormalExit(Checker checker) throws Exception {
|
||||||
if (!hasMappingFailure) {
|
checker.check(output);
|
||||||
checker.check(output);
|
output.shouldNotHaveExitValue(0);
|
||||||
output.shouldNotHaveExitValue(0);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When {--limit-modules, --patch-module, and/or --upgrade-module-path}
|
// When {--limit-modules, --patch-module, and/or --upgrade-module-path}
|
||||||
// are specified, CDS is silently disabled for both -Xshare:auto and -Xshare:on.
|
// are specified, CDS is silently disabled for both -Xshare:auto and -Xshare:on.
|
||||||
public Result assertSilentlyDisabledCDS(Checker checker) throws Exception {
|
public Result assertSilentlyDisabledCDS(Checker checker) throws Exception {
|
||||||
if (hasMappingFailure) {
|
|
||||||
throw new RuntimeException("Unexpected mapping failure");
|
|
||||||
}
|
|
||||||
// this comes from a JVM warning message.
|
// this comes from a JVM warning message.
|
||||||
output.shouldContain(CDS_DISABLED);
|
output.shouldContain(CDS_DISABLED);
|
||||||
|
|
||||||
checker.check(output);
|
checker.check(output);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -181,34 +170,27 @@ public class CDSTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Result ifAbnormalExit(Checker checker) throws Exception {
|
public Result ifAbnormalExit(Checker checker) throws Exception {
|
||||||
if (hasAbnormalExit) {
|
if (!hasNormalExit) {
|
||||||
checker.check(output);
|
checker.check(output);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result ifNoMappingFailure(Checker checker) throws Exception {
|
public Result ifNoMappingFailure(Checker checker) throws Exception {
|
||||||
if (!hasMappingFailure) {
|
checker.check(output);
|
||||||
checker.check(output);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result assertNormalExit(String... matches) throws Exception {
|
public Result assertNormalExit(String... matches) throws Exception {
|
||||||
if (!hasMappingFailure) {
|
checkMatches(output, matches);
|
||||||
checkMatches(output, matches);
|
output.shouldHaveExitValue(0);
|
||||||
output.shouldHaveExitValue(0);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result assertAbnormalExit(String... matches) throws Exception {
|
public Result assertAbnormalExit(String... matches) throws Exception {
|
||||||
if (!hasMappingFailure) {
|
checkMatches(output, matches);
|
||||||
checkMatches(output, matches);
|
output.shouldNotHaveExitValue(0);
|
||||||
output.shouldNotHaveExitValue(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,7 +205,7 @@ public class CDSTestUtils {
|
|||||||
public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0");
|
public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0");
|
||||||
|
|
||||||
public static final String UnableToMapMsg =
|
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,
|
// Create bootstrap CDS archive,
|
||||||
// use extra JVM command line args as a prefix.
|
// use extra JVM command line args as a prefix.
|
||||||
@ -295,7 +277,7 @@ public class CDSTestUtils {
|
|||||||
// of exceptions and common errors.
|
// of exceptions and common errors.
|
||||||
// Exception e argument - an exception to be re-thrown if none of the common
|
// 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.
|
// 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 {
|
throws Exception {
|
||||||
if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) {
|
if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) {
|
||||||
throw new RuntimeException("Hotspot crashed");
|
throw new RuntimeException("Hotspot crashed");
|
||||||
@ -303,9 +285,6 @@ public class CDSTestUtils {
|
|||||||
if (output.getStdout().contains("TEST FAILED")) {
|
if (output.getStdout().contains("TEST FAILED")) {
|
||||||
throw new RuntimeException("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")) {
|
if (output.getOutput().contains("Unable to unmap shared space")) {
|
||||||
throw new RuntimeException("Unable to unmap shared space");
|
throw new RuntimeException("Unable to unmap shared space");
|
||||||
}
|
}
|
||||||
@ -314,18 +293,16 @@ public class CDSTestUtils {
|
|||||||
// at given address. This behavior is platform-specific, machine config-specific
|
// at given address. This behavior is platform-specific, machine config-specific
|
||||||
// and can be random (see ASLR).
|
// and can be random (see ASLR).
|
||||||
if (isUnableToMap(output)) {
|
if (isUnableToMap(output)) {
|
||||||
System.out.println(UnableToMapMsg);
|
throw new SkippedException(UnableToMapMsg);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkCommonExecExceptions(OutputAnalyzer output) throws Exception {
|
public static void checkCommonExecExceptions(OutputAnalyzer output) throws Exception {
|
||||||
return checkCommonExecExceptions(output, null);
|
checkCommonExecExceptions(output, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,6 +335,12 @@ public class CDSTestUtils {
|
|||||||
return false;
|
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 {
|
public static Result run(String... cliPrefix) throws Exception {
|
||||||
CDSOptions opts = new CDSOptions();
|
CDSOptions opts = new CDSOptions();
|
||||||
opts.setArchiveName(getDefaultArchiveName());
|
opts.setArchiveName(getDefaultArchiveName());
|
||||||
@ -446,8 +429,7 @@ public class CDSTestUtils {
|
|||||||
int expectedExitValue,
|
int expectedExitValue,
|
||||||
String... extraMatches) throws Exception {
|
String... extraMatches) throws Exception {
|
||||||
if (isUnableToMap(output)) {
|
if (isUnableToMap(output)) {
|
||||||
System.out.println(UnableToMapMsg);
|
throw new SkippedException(UnableToMapMsg);
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output.shouldHaveExitValue(expectedExitValue);
|
output.shouldHaveExitValue(expectedExitValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user