8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines
authorpliden
Tue, 15 Mar 2016 08:02:17 +0100
changeset 37104 0950120451c4
parent 37103 79c0f8e4b7b7
child 37105 e66ce2ddedf8
8148239: TestSelectDefaultGC.java incorrectly expects G1 on non-server class machines Reviewed-by: brutisso, kzhaldyb
hotspot/test/gc/arguments/TestSelectDefaultGC.java
--- a/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Tue Mar 15 08:01:50 2016 +0100
+++ b/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Tue Mar 15 08:02:17 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -27,9 +27,9 @@
  * @bug 8068582
  * @key gc
  * @library /testlibrary
+ * @requires vm.gc=="null"
  * @modules java.base/sun.misc
  *          java.management
- * @ignore 8148239
  * @run driver TestSelectDefaultGC
  */
 
@@ -41,24 +41,40 @@
         output.shouldMatch(" " + option + " .*=.* " + value + " ");
     }
 
-    public static void main(String[] args) throws Exception {
+    public static void testDefaultGC(boolean actAsServer) throws Exception {
+        String[] args = new String[] {
+          "-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine",
+          "-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine",
+          "-XX:+PrintFlagsFinal",
+          "-version"
+        };
+
         // Start VM without specifying GC
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintFlagsFinal", "-version");
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldHaveExitValue(0);
 
-        boolean isServerVM = Platform.isServer();
-        boolean isEmbeddedVM = Platform.isEmbedded();
+        final boolean isServer = actAsServer;
+        final boolean isEmbedded = Platform.isEmbedded();
 
         // Verify GC selection
-        // G1 is default for non-embedded server VMs
-        assertVMOption(output, "UseG1GC",            isServerVM && !isEmbeddedVM);
-        // Parallel is default for embedded server VMs
-        assertVMOption(output, "UseParallelGC",      isServerVM && isEmbeddedVM);
-        assertVMOption(output, "UseParallelOldGC",   isServerVM && isEmbeddedVM);
-        // Serial is default for non-server VMs
-        assertVMOption(output, "UseSerialGC",        !isServerVM);
+        // G1 is default for non-embedded server class machines
+        assertVMOption(output, "UseG1GC",            isServer && !isEmbedded);
+        // Parallel is default for embedded server class machines
+        assertVMOption(output, "UseParallelGC",      isServer && isEmbedded);
+        assertVMOption(output, "UseParallelOldGC",   isServer && isEmbedded);
+        // Serial is default for non-server class machines
+        assertVMOption(output, "UseSerialGC",        !isServer);
+        // CMS is never default
         assertVMOption(output, "UseConcMarkSweepGC", false);
         assertVMOption(output, "UseParNewGC",        false);
     }
+
+    public static void main(String[] args) throws Exception {
+        // Test server class machine
+        testDefaultGC(false);
+
+        // Test non-server class machine
+        testDefaultGC(true);
+    }
 }