8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
authorccheung
Mon, 22 Oct 2018 14:31:10 -0700
changeset 52218 111ba072921b
parent 52217 5e3a8f387701
child 52219 151b990e3764
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested Summary: use CDSTestUtils.run() instead of CDSTestUtils.executeAndLog(). Reviewed-by: iklam
test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java
test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java	Mon Oct 22 13:31:42 2018 -0700
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/NonBootLoaderClasses.java	Mon Oct 22 14:31:10 2018 -0700
@@ -34,7 +34,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;
 
 public class NonBootLoaderClasses {
     public static void main(String[] args) throws Exception {
@@ -50,16 +49,16 @@
         CDSTestUtils.createArchiveAndCheck(opts);
 
         // Print the shared dictionary and inspect the output
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-                "-cp", "\"\"",
+        opts = (new CDSOptions())
+            .setUseVersion(false)
+            .addSuffix( "-cp", "\"\"",
                 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
                 "-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary");
-        OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
-        CDSTestUtils.checkMappingFailure(out);
-
-        out.shouldContain("archive is valid")
-            .shouldHaveExitValue(0)               // Should report success in error code.
-            .shouldContain(PLATFORM_CLASS.replace('/', '.'))
-            .shouldContain(APP_CLASS.replace('/', '.'));
+        CDSTestUtils.run(opts)
+            .assertNormalExit(output -> {
+                output.shouldContain("archive is valid");
+                output.shouldContain(PLATFORM_CLASS.replace('/', '.'));
+                output.shouldContain(APP_CLASS.replace('/', '.'));
+            });
    }
 }
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Mon Oct 22 13:31:42 2018 -0700
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Mon Oct 22 14:31:10 2018 -0700
@@ -33,7 +33,6 @@
 
 import jdk.test.lib.cds.CDSOptions;
 import jdk.test.lib.cds.CDSTestUtils;
-import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
 
 public class PrintSharedArchiveAndExit {
@@ -44,23 +43,24 @@
         CDSTestUtils.checkDump(out);
 
         // (1) With a valid archive
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-                "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
+        opts = (new CDSOptions())
+            .setUseVersion(false)
+            .addSuffix( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
                 "-XX:+PrintSharedArchiveAndExit", "-version");
-        out = CDSTestUtils.executeAndLog(pb, "print-shared-archive-and-version");
-        CDSTestUtils.checkMappingFailure(out);
+        CDSTestUtils.run(opts)
+            .assertNormalExit(output -> {
+                output.shouldContain("archive is valid");
+                output.shouldNotContain("java version"); // Should not print JVM version
+            });
 
-        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,
+        opts = (new CDSOptions())
+            .setUseVersion(false)
+            .addSuffix( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName,
                 "-XX:+PrintSharedArchiveAndExit");
-        out = CDSTestUtils.executeAndLog(pb, "print-shared-archive");
-        CDSTestUtils.checkMappingFailure(out);
-        out.shouldContain("archive is valid")
-            .shouldNotContain("Usage:")           // Should not print JVM help message
-            .shouldHaveExitValue(0);              // Should report success in error code.
+        CDSTestUtils.run(opts)
+            .assertNormalExit(output -> {
+                output.shouldContain("archive is valid");
+                output.shouldNotContain("Usage:"); // Should not print JVM help message
+            });
     }
 }