8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
authorccheung
Thu, 23 Aug 2018 09:35:09 -0700
changeset 51507 3e3764f8fe36
parent 51506 71c3b8c51977
child 51508 f99640a44d75
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests Summary: 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
test/hotspot/jtreg/runtime/appcds/HelloExtTest.java
test/hotspot/jtreg/runtime/appcds/OldClassTest.java
test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java
test/hotspot/jtreg/runtime/appcds/ProtectionDomain.java
test/hotspot/jtreg/runtime/appcds/cacheObject/RedefineClassTest.java
test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java
test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDump.java
test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDumpTransformer.java
test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/JvmtiAddPath.java
test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java
test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java
test/lib/jdk/test/lib/cds/CDSTestUtils.java
--- a/test/hotspot/jtreg/runtime/appcds/HelloExtTest.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/HelloExtTest.java	Thu Aug 23 09:35:09 2018 -0700
@@ -52,7 +52,7 @@
 
     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 @@
     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));
--- a/test/hotspot/jtreg/runtime/appcds/OldClassTest.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/OldClassTest.java	Thu Aug 23 09:35:09 2018 -0700
@@ -67,7 +67,6 @@
 
     TestCommon.run(
         "-cp", jar,
-        "-verbose:class",
         "Hello")
       .assertNormalExit("Hello Unicode world (Old)");
 
@@ -79,7 +78,6 @@
 
     TestCommon.run(
         "-cp", classpath,
-        "-verbose:class",
         "Hello")
       .assertNormalExit("Hello Unicode world (Old)");
   }
--- a/test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java	Thu Aug 23 09:35:09 2018 -0700
@@ -79,20 +79,20 @@
         // -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");
     }
 }
--- a/test/hotspot/jtreg/runtime/appcds/ProtectionDomain.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/ProtectionDomain.java	Thu Aug 23 09:35:09 2018 -0700
@@ -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 @@
     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");
   }
 }
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/RedefineClassTest.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/RedefineClassTest.java	Thu Aug 23 09:35:09 2018 -0700
@@ -34,7 +34,7 @@
  *        RedefineClassApp
  *        InstrumentationClassFileTransformer
  *        InstrumentationRegisterClassFileTransformer
- * @run main/othervm RedefineClassTest
+ * @run main RedefineClassTest
  */
 
 import com.sun.tools.attach.VirtualMachine;
@@ -89,7 +89,7 @@
                 bootCP,
                 "-XX:+UnlockDiagnosticVMOptions",
                 "-XX:+WhiteBoxAPI",
-                "-Xlog:gc+region=trace,cds=info",
+                "-Xlog:cds=info",
                 agentCmdArg,
                "RedefineClassApp", bootJar, appJar);
         out.reportDiagnosticSummary();
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Thu Aug 23 09:35:09 2018 -0700
@@ -57,7 +57,7 @@
         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 @@
         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
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDump.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDump.java	Thu Aug 23 09:35:09 2018 -0700
@@ -56,7 +56,8 @@
         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
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDumpTransformer.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/GCDuringDumpTransformer.java	Thu Aug 23 09:35:09 2018 -0700
@@ -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.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 @@
                 Thread.sleep(200); // let GC to have a chance to run
             } catch (Throwable t2) {}
         }
-        System.out.println("making garbage: done");
 
         return null;
     }
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java	Thu Aug 23 09:35:09 2018 -0700
@@ -62,7 +62,8 @@
         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";
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java	Thu Aug 23 09:35:09 2018 -0700
@@ -87,7 +87,6 @@
         // 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);
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java	Thu Aug 23 09:35:09 2018 -0700
@@ -118,7 +118,6 @@
         // 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 @@
         // 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",
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/JvmtiAddPath.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/JvmtiAddPath.java	Thu Aug 23 09:35:09 2018 -0700
@@ -113,7 +113,6 @@
                                     appJar,
                                     TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS),
                                     use_whitebox_jar,
-                                    "-Xlog:class+load=trace",
                                     modulePath);
         TestCommon.checkDump(output);
 
@@ -143,7 +142,6 @@
         output = TestCommon.createArchive(
                      appJar, TestCommon.list("JvmtiApp", "ExtraClass"),
                      use_whitebox_jar,
-                     "-Xlog:class+load=trace",
                      modulePath);
         TestCommon.checkDump(output);
         run(twoAppJars, modulePath,
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java	Thu Aug 23 09:35:09 2018 -0700
@@ -90,7 +90,6 @@
         // 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 @@
         // 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(
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java	Thu Aug 23 09:35:09 2018 -0700
@@ -188,7 +188,6 @@
 
         TestCommon.run("-Xlog:class+load=info",
                        "-cp", appJar,
-                       "--add-opens=java.base/java.security=ALL-UNNAMED",
                        agentParam,
                        "CustomLoaderApp",
                        customJar, loaderType, child)
--- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java	Thu Aug 23 11:33:51 2018 -0400
+++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java	Thu Aug 23 09:35:09 2018 -0700
@@ -200,11 +200,19 @@
         }
     }
 
-    // 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 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;