8224264: [TESTBUG] HelloDynamicCustom.java test failed on the Windows platform in tiers 6 and 7 testing
authorccheung
Thu, 23 May 2019 10:05:02 -0700
changeset 55011 2218f9d57d2f
parent 55010 8559810c60f8
child 55012 fb0cfce19262
8224264: [TESTBUG] HelloDynamicCustom.java test failed on the Windows platform in tiers 6 and 7 testing Summary: Making use of the DynamicArchiveTestBase class so that mapping failure can be handled more robustly. Reviewed-by: iklam
test/hotspot/jtreg/runtime/appcds/dynamicArchive/HelloDynamicCustom.java
--- a/test/hotspot/jtreg/runtime/appcds/dynamicArchive/HelloDynamicCustom.java	Thu May 23 09:03:58 2019 -0700
+++ b/test/hotspot/jtreg/runtime/appcds/dynamicArchive/HelloDynamicCustom.java	Thu May 23 10:05:02 2019 -0700
@@ -37,49 +37,50 @@
 
 import java.io.File;
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.process.ProcessTools;
 
-public class HelloDynamicCustom {
+public class HelloDynamicCustom extends DynamicArchiveTestBase {
     private static final String ARCHIVE_NAME =
-        System.getProperty("test.classes") + File.separator + "HelloDynamicCustom.jsa";
+        System.getProperty("test.classes") + File.separator + "HelloDynamicCustom-top.jsa";
 
     public static void main(String[] args) throws Exception {
+        runTest(HelloDynamicCustom::testDefaultBase);
+    }
+
+    private static void testDefaultBase() throws Exception {
         String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar");
         String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
         String appJar = ClassFileInstaller.getJarPath("hello.jar");
         String customJarPath = ClassFileInstaller.getJarPath("hello_custom.jar");
         String mainAppClass = "HelloUnload";
 
-        ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
+        dump(ARCHIVE_NAME,
             use_whitebox_jar,
             "-XX:+UnlockDiagnosticVMOptions",
             "-XX:+WhiteBoxAPI",
             "-Xlog:cds",
             "-Xlog:cds+dynamic=debug",
-            "-Xshare:auto",
-            "-XX:ArchiveClassesAtExit=" + ARCHIVE_NAME,
             "-cp", appJar,
-            mainAppClass, customJarPath, "false", "false");
-        TestCommon.executeAndLog(dumpPb, "dump")
-            .shouldContain("Buffer-space to target-space delta")
-            .shouldContain("Written dynamic archive 0x")
-            .shouldNotContain("klasses.*=.*CustomLoadee")   // Fixme -- use a better way to decide if a class has been archived
-            .shouldHaveExitValue(0);
+            mainAppClass, customJarPath, "false", "false")
+            .assertNormalExit(output -> {
+                output.shouldContain("Buffer-space to target-space delta")
+                      .shouldContain("Written dynamic archive 0x")
+                      .shouldNotContain("klasses.*=.*CustomLoadee")
+                      .shouldHaveExitValue(0);
+                });
 
-        ProcessBuilder execPb = ProcessTools.createJavaProcessBuilder(true,
+        run(ARCHIVE_NAME,
             use_whitebox_jar,
             "-XX:+UnlockDiagnosticVMOptions",
             "-XX:+WhiteBoxAPI",
             "-Xlog:class+load",
             "-Xlog:cds=debug",
             "-Xlog:cds+dynamic=info",
-            "-Xshare:auto",
-            "-XX:SharedArchiveFile=" + ARCHIVE_NAME,
             "-cp", appJar,
-            mainAppClass, customJarPath, "false", "true");
-        TestCommon.executeAndLog(execPb, "exec")
-            .shouldContain("HelloUnload source: shared objects file")
-            .shouldContain("CustomLoadee source: shared objects file")
-            .shouldHaveExitValue(0);
+            mainAppClass, customJarPath, "false", "true")
+            .assertNormalExit(output -> {
+                output.shouldContain("HelloUnload source: shared objects file")
+                      .shouldContain("CustomLoadee source: shared objects file")
+                      .shouldHaveExitValue(0);
+                });
     }
 }