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

View File

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

View File

@ -79,20 +79,20 @@ public class ProhibitedPackage {
// -Xshare:on // -Xshare:on
TestCommon.run( TestCommon.run(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper") "-cp", appJar, "ProhibitedHelper")
.assertNormalExit("Prohibited package name: java.lang"); .assertNormalExit("Prohibited package name: java.lang");
// -Xshare:auto // -Xshare:auto
output = TestCommon.execAuto( output = TestCommon.execAuto(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper"); "-cp", appJar, "ProhibitedHelper");
CDSOptions opts = (new CDSOptions()).setXShareMode("auto"); CDSOptions opts = (new CDSOptions()).setXShareMode("auto");
TestCommon.checkExec(output, opts, "Prohibited package name: java.lang"); TestCommon.checkExec(output, opts, "Prohibited package name: java.lang");
// -Xshare:off // -Xshare:off
output = TestCommon.execOff( output = TestCommon.execOff(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
"-cp", appJar, "-Xlog:class+load=info", "ProhibitedHelper"); "-cp", appJar, "ProhibitedHelper");
output.shouldContain("Prohibited package name: java.lang"); 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. * 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
@ -57,16 +57,16 @@ public class ProtectionDomain {
OutputAnalyzer output; OutputAnalyzer output;
// First class is loaded from CDS, second class is loaded from JAR // 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"); TestCommon.checkExec(output, "Protection Domains match");
// First class is loaded from JAR, second class is loaded from CDS // 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"); TestCommon.checkExec(output, "Protection Domains match");
// Test ProtectionDomain for application and extension module classes from the // Test ProtectionDomain for application and extension module classes from the
// "modules" jimage // "modules" jimage
output = TestCommon.exec(appJar, "-verbose:class", "JimageClassProtDomain"); output = TestCommon.exec(appJar, "JimageClassProtDomain");
output.shouldNotContain("Failed: Protection Domains do not match"); output.shouldNotContain("Failed: Protection Domains do not match");
} }
} }

View File

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

View File

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

View File

@ -56,7 +56,8 @@ public class GCDuringDump {
String appJar = String appJar =
ClassFileInstaller.writeJar("GCDuringDumpApp.jar", appClasses); 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++) { for (int i=0; i<2; i++) {
// i = 0 -- run without agent = no extra GCs // 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. * 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
@ -28,13 +28,8 @@ import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
public class GCDuringDumpTransformer implements ClassFileTransformer { public class GCDuringDumpTransformer implements ClassFileTransformer {
static int n = 0;
public byte[] transform(ClassLoader loader, String name, Class<?> classBeingRedefined, public byte[] transform(ClassLoader loader, String name, Class<?> classBeingRedefined,
ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException { ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException {
n++;
System.out.println("dump time loading: " + name + " in loader: " + loader);
System.out.println("making garbage: " + n);
try { try {
makeGarbage(); makeGarbage();
} catch (Throwable t) { } catch (Throwable t) {
@ -43,7 +38,6 @@ public class GCDuringDumpTransformer implements ClassFileTransformer {
Thread.sleep(200); // let GC to have a chance to run Thread.sleep(200); // let GC to have a chance to run
} catch (Throwable t2) {} } catch (Throwable t2) {}
} }
System.out.println("making garbage: done");
return null; return null;
} }

View File

@ -62,7 +62,8 @@ public class GCSharedStringsDuringDump {
String appJar = String appJar =
ClassFileInstaller.writeJar("GCSharedStringsDuringDumpApp.jar", appClasses); 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 = String sharedArchiveCfgFile =
System.getProperty("user.dir") + File.separator + "GCSharedStringDuringDump_gen.txt"; 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. // the class in the modular jar in the -cp won't be archived.
OutputAnalyzer output = TestCommon.createArchive( OutputAnalyzer output = TestCommon.createArchive(
destJar.toString(), appClasses, destJar.toString(), appClasses,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(), "--module-path", moduleDir.toString(),
"-m", TEST_MODULE1); "-m", TEST_MODULE1);
TestCommon.checkDump(output); TestCommon.checkDump(output);

View File

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

View File

@ -113,7 +113,6 @@ public class JvmtiAddPath {
appJar, appJar,
TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS), TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS),
use_whitebox_jar, use_whitebox_jar,
"-Xlog:class+load=trace",
modulePath); modulePath);
TestCommon.checkDump(output); TestCommon.checkDump(output);
@ -143,7 +142,6 @@ public class JvmtiAddPath {
output = TestCommon.createArchive( output = TestCommon.createArchive(
appJar, TestCommon.list("JvmtiApp", "ExtraClass"), appJar, TestCommon.list("JvmtiApp", "ExtraClass"),
use_whitebox_jar, use_whitebox_jar,
"-Xlog:class+load=trace",
modulePath); modulePath);
TestCommon.checkDump(output); TestCommon.checkDump(output);
run(twoAppJars, modulePath, 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. // the class in the modular jar in the -cp won't be archived.
OutputAnalyzer output = TestCommon.createArchive( OutputAnalyzer output = TestCommon.createArchive(
destJar.toString(), appClasses, destJar.toString(), appClasses,
"-Xlog:class+load=trace",
"--module-path", moduleDir.toString(), "--module-path", moduleDir.toString(),
"-m", TEST_MODULE1); "-m", TEST_MODULE1);
TestCommon.checkDump(output); TestCommon.checkDump(output);
@ -169,8 +168,7 @@ public class MainModuleOnly {
// run with the archive and the jar with modified timestamp. // run with the archive and the jar with modified timestamp.
// It should fail due to timestamp of the jar doesn't match the one // It should fail due to timestamp of the jar doesn't match the one
// used during dump time. // used during dump time.
TestCommon.run("-Xlog:class+load=trace", TestCommon.run("-cp", destJar.toString(),
"-cp", destJar.toString(),
"--module-path", moduleDir.toString(), "--module-path", moduleDir.toString(),
"-m", TEST_MODULE1) "-m", TEST_MODULE1)
.assertAbnormalExit( .assertAbnormalExit(

View File

@ -188,7 +188,6 @@ public class TransformRelatedClassesAppCDS extends TransformRelatedClasses {
TestCommon.run("-Xlog:class+load=info", TestCommon.run("-Xlog:class+load=info",
"-cp", appJar, "-cp", appJar,
"--add-opens=java.base/java.security=ALL-UNNAMED",
agentParam, agentParam,
"CustomLoaderApp", "CustomLoaderApp",
customJar, loaderType, child) 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 // A number to be included in the filename of the stdout and the stderr output file.
// the parent/main stdout of the test. static int logCounter = 0;
// By default such output is logged into a file, and is copied into the main stdout.
public static final boolean CopyChildStdoutToMainStdout = private static int getNextLogCounter() {
Boolean.valueOf(System.getProperty("test.cds.copy.child.stdout", "true")); 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 // This property is passed to child test processes
public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0"); 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 { public static OutputAnalyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception {
long started = System.currentTimeMillis(); long started = System.currentTimeMillis();
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
String outputFileNamePrefix =
getTestName() + "-" + String.format("%04d", getNextLogCounter()) + "-" + logName;
writeFile(getOutputFile(logName + ".stdout"), output.getStdout()); writeFile(getOutputFile(outputFileNamePrefix + ".stdout"), output.getStdout());
writeFile(getOutputFile(logName + ".stderr"), output.getStderr()); writeFile(getOutputFile(outputFileNamePrefix + ".stderr"), output.getStderr());
System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]"); 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()); System.out.println("[STDERR]\n" + output.getStderr());
if (CopyChildStdoutToMainStdout) if (copyChildStdoutToMainStdout)
System.out.println("[STDOUT]\n" + output.getStdout()); System.out.println("[STDOUT]\n" + output.getStdout());
return output; return output;