8209164: [TESTBUG] Apply jtreg skipped status to cds tests

Added the SkippedException where applicable

Reviewed-by: iklam, jiangli
This commit is contained in:
Mikhailo Seledtsov 2018-08-15 10:00:16 -07:00
parent f87ec5faf7
commit b71faed5df
8 changed files with 67 additions and 92 deletions

View File

@ -51,18 +51,16 @@ public class ArchiveDoesNotExist {
// -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);
}
}

View File

@ -50,10 +50,10 @@ public class CdsDifferentCompactStrings {
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);
}
}

View File

@ -35,7 +35,6 @@ import jdk.test.lib.cds.CDSOptions;
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 @@ public class NonBootLoaderClasses {
"-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('/', '.'));
}
}

View File

@ -36,7 +36,6 @@ import jdk.test.lib.cds.CDSTestUtils;
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 @@ public class PrintSharedArchiveAndExit {
"-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.
}
}

View File

@ -42,15 +42,14 @@ public class SharedSymbolTableBucketSize {
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

View File

@ -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 @@ public class TransformTestCommon {
// 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('.', '/');

View File

@ -36,8 +36,9 @@
* @run main/othervm -XX:-CompactStrings InvalidFileFormat
*/
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
// Checking most common error use cases
// 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"),
"invalidFormat" + File.separator + dataFileName);
if (!TestCommon.isUnableToMap(out))
out.shouldContain(expectedWarning).shouldHaveExitValue(1);
CDSTestUtils.checkMappingFailure(out);
out.shouldContain(expectedWarning).shouldHaveExitValue(1);
}
}

View File

@ -32,7 +32,7 @@ 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 {
@ -114,17 +114,14 @@ public class CDSTestUtils {
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 class CDSTestUtils {
}
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 class CDSTestUtils {
}
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 class CDSTestUtils {
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 @@ public class CDSTestUtils {
// 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 @@ public class CDSTestUtils {
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 @@ public class CDSTestUtils {
// 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 @@ public class CDSTestUtils {
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 @@ public class CDSTestUtils {
int expectedExitValue,
String... extraMatches) throws Exception {
if (isUnableToMap(output)) {
System.out.println(UnableToMapMsg);
return output;
throw new SkippedException(UnableToMapMsg);
}
output.shouldHaveExitValue(expectedExitValue);