8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests

Changed the value of the property test.cds.copy.child.stdout to false so that stdout of child processes are logged in files. Each stdout and stderr file will have a unique name.

Reviewed-by: iklam
This commit is contained in:
Calvin Cheung 2018-08-23 09:35:09 -07:00
parent 78363850b9
commit c3adb5f87d
15 changed files with 39 additions and 42 deletions

View File

@ -52,7 +52,7 @@ public class HelloExtTest {
TestCommon.dump(appJar,
TestCommon.list("javax/annotation/processing/FilerException", "[Ljava/lang/Comparable;"),
bootClassPath, "-verbose:class");
bootClassPath);
String prefix = ".class.load. ";
String class_pattern = ".*LambdaForm[$]MH[/][0123456789].*";
@ -60,12 +60,12 @@ public class HelloExtTest {
String pattern = prefix + class_pattern + suffix;
TestCommon.run("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, bootClassPath, "-verbose:class", "HelloExt")
"-cp", appJar, bootClassPath, "-Xlog:class+load", "HelloExt")
.assertNormalExit(output -> output.shouldNotMatch(pattern));
TestCommon.run("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, bootClassPath, "-verbose:class",
"-cp", appJar, bootClassPath, "-Xlog:class+load",
"-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary",
"HelloExt")
.assertNormalExit(output -> output.shouldNotMatch(class_pattern));

View File

@ -67,7 +67,6 @@ public class OldClassTest implements Opcodes {
TestCommon.run(
"-cp", jar,
"-verbose:class",
"Hello")
.assertNormalExit("Hello Unicode world (Old)");
@ -79,7 +78,6 @@ public class OldClassTest implements Opcodes {
TestCommon.run(
"-cp", classpath,
"-verbose:class",
"Hello")
.assertNormalExit("Hello Unicode world (Old)");
}

View File

@ -79,20 +79,20 @@ public class ProhibitedPackage {
// -Xshare:on
TestCommon.run(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper")
"-cp", appJar, "ProhibitedHelper")
.assertNormalExit("Prohibited package name: java.lang");
// -Xshare:auto
output = TestCommon.execAuto(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper");
"-cp", appJar, "ProhibitedHelper");
CDSOptions opts = (new CDSOptions()).setXShareMode("auto");
TestCommon.checkExec(output, opts, "Prohibited package name: java.lang");
// -Xshare:off
output = TestCommon.execOff(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper");
"-cp", appJar, "ProhibitedHelper");
output.shouldContain("Prohibited package name: java.lang");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -57,16 +57,16 @@ public class ProtectionDomain {
OutputAnalyzer output;
// First class is loaded from CDS, second class is loaded from JAR
output = TestCommon.exec(appJar, "-verbose:class", "ProtDomain");
output = TestCommon.exec(appJar, "ProtDomain");
TestCommon.checkExec(output, "Protection Domains match");
// First class is loaded from JAR, second class is loaded from CDS
output = TestCommon.exec(appJar, "-verbose:class", "ProtDomainB");
output = TestCommon.exec(appJar, "ProtDomainB");
TestCommon.checkExec(output, "Protection Domains match");
// Test ProtectionDomain for application and extension module classes from the
// "modules" jimage
output = TestCommon.exec(appJar, "-verbose:class", "JimageClassProtDomain");
output = TestCommon.exec(appJar, "JimageClassProtDomain");
output.shouldNotContain("Failed: Protection Domains do not match");
}
}

View File

@ -34,7 +34,7 @@
* RedefineClassApp
* InstrumentationClassFileTransformer
* InstrumentationRegisterClassFileTransformer
* @run main/othervm RedefineClassTest
* @run main RedefineClassTest
*/
import com.sun.tools.attach.VirtualMachine;
@ -89,7 +89,7 @@ public class RedefineClassTest {
bootCP,
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xlog:gc+region=trace,cds=info",
"-Xlog:cds=info",
agentCmdArg,
"RedefineClassApp", bootJar, appJar);
out.reportDiagnosticSummary();

View File

@ -57,7 +57,7 @@ public class ArrayTest {
String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
// create an archive containing array classes
OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list(arrayClasses), bootClassPath, "-verbose:class");
OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list(arrayClasses), bootClassPath);
// we currently don't support array classes during CDS dump
output.shouldContain("Preload Warning: Cannot find [Ljava/lang/Comparable;")
.shouldContain("Preload Warning: Cannot find [I")
@ -70,7 +70,6 @@ public class ArrayTest {
argsList.add("-cp");
argsList.add(appJar);
argsList.add(bootClassPath);
argsList.add("-verbose:class");
argsList.add("ArrayTestHelper");
// the following are input args to the ArrayTestHelper.
// skip checking array classes during run time

View File

@ -56,7 +56,8 @@ public class GCDuringDump {
String appJar =
ClassFileInstaller.writeJar("GCDuringDumpApp.jar", appClasses);
String gcLog = "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug";
String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ?
"-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion";
for (int i=0; i<2; i++) {
// i = 0 -- run without agent = no extra GCs

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@ -28,13 +28,8 @@ import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
public class GCDuringDumpTransformer implements ClassFileTransformer {
static int n = 0;
public byte[] transform(ClassLoader loader, String name, Class<?> classBeingRedefined,
ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException {
n++;
System.out.println("dump time loading: " + name + " in loader: " + loader);
System.out.println("making garbage: " + n);
try {
makeGarbage();
} catch (Throwable t) {
@ -43,7 +38,6 @@ public class GCDuringDumpTransformer implements ClassFileTransformer {
Thread.sleep(200); // let GC to have a chance to run
} catch (Throwable t2) {}
}
System.out.println("making garbage: done");
return null;
}

View File

@ -62,7 +62,8 @@ public class GCSharedStringsDuringDump {
String appJar =
ClassFileInstaller.writeJar("GCSharedStringsDuringDumpApp.jar", appClasses);
String gcLog = "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug";
String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ?
"-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion";
String sharedArchiveCfgFile =
System.getProperty("user.dir") + File.separator + "GCSharedStringDuringDump_gen.txt";

View File

@ -87,7 +87,6 @@ public class AddOpens {
// the class in the modular jar in the -cp won't be archived.
OutputAnalyzer output = TestCommon.createArchive(
destJar.toString(), appClasses,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(),
"-m", TEST_MODULE1);
TestCommon.checkDump(output);

View File

@ -118,7 +118,6 @@ public class ExportModule {
// the module in the --module-path
OutputAnalyzer output = TestCommon.createArchive(
appJar.toString(), appClasses,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(),
"--add-modules", TEST_MODULE2, MAIN_CLASS);
TestCommon.checkDump(output);
@ -142,7 +141,6 @@ public class ExportModule {
// unnmaed.
output = TestCommon.createArchive(
appJar2.toString(), appClasses2,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(),
"--add-modules", TEST_MODULE2,
"--add-exports", "org.astro/org.astro=ALL-UNNAMED",

View File

@ -113,7 +113,6 @@ public class JvmtiAddPath {
appJar,
TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS),
use_whitebox_jar,
"-Xlog:class+load=trace",
modulePath);
TestCommon.checkDump(output);
@ -143,7 +142,6 @@ public class JvmtiAddPath {
output = TestCommon.createArchive(
appJar, TestCommon.list("JvmtiApp", "ExtraClass"),
use_whitebox_jar,
"-Xlog:class+load=trace",
modulePath);
TestCommon.checkDump(output);
run(twoAppJars, modulePath,

View File

@ -90,7 +90,6 @@ public class MainModuleOnly {
// the class in the modular jar in the -cp won't be archived.
OutputAnalyzer output = TestCommon.createArchive(
destJar.toString(), appClasses,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(),
"-m", TEST_MODULE1);
TestCommon.checkDump(output);
@ -169,8 +168,7 @@ public class MainModuleOnly {
// run with the archive and the jar with modified timestamp.
// It should fail due to timestamp of the jar doesn't match the one
// used during dump time.
TestCommon.run("-Xlog:class+load=trace",
"-cp", destJar.toString(),
TestCommon.run("-cp", destJar.toString(),
"--module-path", moduleDir.toString(),
"-m", TEST_MODULE1)
.assertAbnormalExit(

View File

@ -188,7 +188,6 @@ public class TransformRelatedClassesAppCDS extends TransformRelatedClasses {
TestCommon.run("-Xlog:class+load=info",
"-cp", appJar,
"--add-opens=java.base/java.security=ALL-UNNAMED",
agentParam,
"CustomLoaderApp",
customJar, loaderType, child)

View File

@ -200,11 +200,19 @@ public class CDSTestUtils {
}
}
// Specify this property to copy sdandard output of the child test process to
// the parent/main stdout of the test.
// By default such output is logged into a file, and is copied into the main stdout.
public static final boolean CopyChildStdoutToMainStdout =
Boolean.valueOf(System.getProperty("test.cds.copy.child.stdout", "true"));
// A number to be included in the filename of the stdout and the stderr output file.
static int logCounter = 0;
private static int getNextLogCounter() {
return logCounter++;
}
// By default, stdout of child processes are logged in files such as
// <testname>-0000-exec.stdout. If you want to also include the stdout
// inside jtr files, you can override this in the jtreg command line like
// "jtreg -Dtest.cds.copy.child.stdout=true ...."
public static final boolean copyChildStdoutToMainStdout =
Boolean.getBoolean("test.cds.copy.child.stdout");
// This property is passed to child test processes
public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0");
@ -549,13 +557,17 @@ public class CDSTestUtils {
public static OutputAnalyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception {
long started = System.currentTimeMillis();
OutputAnalyzer output = new OutputAnalyzer(pb.start());
String outputFileNamePrefix =
getTestName() + "-" + String.format("%04d", getNextLogCounter()) + "-" + logName;
writeFile(getOutputFile(logName + ".stdout"), output.getStdout());
writeFile(getOutputFile(logName + ".stderr"), output.getStderr());
writeFile(getOutputFile(outputFileNamePrefix + ".stdout"), output.getStdout());
writeFile(getOutputFile(outputFileNamePrefix + ".stderr"), output.getStderr());
System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]");
System.out.println("[logging stdout to " + outputFileNamePrefix + ".stdout]");
System.out.println("[logging stderr to " + outputFileNamePrefix + ".stderr]");
System.out.println("[STDERR]\n" + output.getStderr());
if (CopyChildStdoutToMainStdout)
if (copyChildStdoutToMainStdout)
System.out.println("[STDOUT]\n" + output.getStdout());
return output;