hotspot/test/gc/arguments/TestSelectDefaultGC.java
author twisti
Mon, 27 Apr 2015 09:02:41 -0700
changeset 30288 476c276de939
parent 30271 97a537c6526e
child 30604 b8d532cb6420
permissions -rw-r--r--
8022853: add ability to load uncompressed object and Klass references in a compressed environment to Unsafe Reviewed-by: coleenp, jrose, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30271
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     1
/*
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     4
 *
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     8
 *
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    13
 * accompanied this code).
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    14
 *
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    18
 *
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    21
 * questions.
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    22
 */
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    23
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    24
/*
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    25
 * @test TestSelectDefaultGC
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    26
 * @summary Test selection of GC when no GC option is specified
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    27
 * @bug 8068582
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    28
 * @key gc
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    29
 * @library /testlibrary
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    30
 * @modules java.base/sun.misc
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    31
 *          java.management
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    32
 * @run driver TestSelectDefaultGC
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    33
 */
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    34
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    35
import com.oracle.java.testlibrary.*;
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    36
import java.util.regex.*;
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    37
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    38
public class TestSelectDefaultGC {
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    39
    public static boolean versionStringContains(OutputAnalyzer output, String pattern) {
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    40
        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStderr());
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    41
        return matcher.find();
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    42
    }
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    43
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    44
    public static void assertVMOption(OutputAnalyzer output, String option, boolean value) {
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    45
        output.shouldMatch(" " + option + " .*=.* " + value + " ");
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    46
    }
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    47
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    48
    public static void main(String[] args) throws Exception {
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    49
        // Start VM without specifying GC
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    50
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintFlagsFinal", "-version");
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    51
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    52
        output.shouldHaveExitValue(0);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    53
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    54
        boolean isServerVM = versionStringContains(output, "Server VM");
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    55
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    56
        // Verify GC selection
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    57
        assertVMOption(output, "UseParallelGC",      isServerVM);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    58
        assertVMOption(output, "UseParallelOldGC",   isServerVM);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    59
        assertVMOption(output, "UseSerialGC",        !isServerVM);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    60
        assertVMOption(output, "UseConcMarkSweepGC", false);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    61
        assertVMOption(output, "UseG1GC",            false);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    62
        assertVMOption(output, "UseParNewGC",        false);
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    63
    }
97a537c6526e 8068582: UseSerialGC not always set up properly
pliden
parents:
diff changeset
    64
}