hotspot/test/runtime/CompressedOops/CompressedClassSpaceSize.java
author iignatyev
Wed, 07 Dec 2016 14:37:35 +0300
changeset 42640 09dba077f1e7
parent 40631 ed82623d7831
permissions -rw-r--r--
8078450: Implement consistent process for quarantine of tests Reviewed-by: dfazunen, dholmes, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     4
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     8
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    13
 * accompanied this code).
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    14
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    18
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    21
 * questions.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    22
 */
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    23
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    24
/*
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    25
 * @test
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    26
 * @bug 8022865
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    27
 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35061
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 26688
diff changeset
    30
 *          java.management
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    31
 * @run main CompressedClassSpaceSize
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    32
 */
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    33
import jdk.test.lib.Platform;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    36
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    37
public class CompressedClassSpaceSize {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    38
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    40
        ProcessBuilder pb;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    41
        OutputAnalyzer output;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    42
        if (Platform.is64bit()) {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    43
            // Minimum size is 1MB
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    44
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    45
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    46
            output = new OutputAnalyzer(pb.start());
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents: 30604
diff changeset
    47
            output.shouldContain("outside the allowed range")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    48
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    49
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    50
            // Invalid size of -1 should be handled correctly
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    51
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    52
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    53
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    54
            output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    55
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    56
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    57
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    58
            // Maximum size is 3GB
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    59
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    60
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    61
            output = new OutputAnalyzer(pb.start());
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents: 30604
diff changeset
    62
            output.shouldContain("outside the allowed range")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    63
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    64
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    65
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    66
            // Make sure the minimum size is set correctly and printed
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    67
            pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    68
                                                       "-XX:CompressedClassSpaceSize=1m",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31371
diff changeset
    69
                                                       "-Xlog:gc+metaspace=trace",
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    70
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    71
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    72
            output.shouldContain("Compressed class space size: 1048576")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    73
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    74
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    75
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    76
            // Make sure the maximum size is set correctly and printed
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    77
            pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    78
                                                       "-XX:CompressedClassSpaceSize=3g",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31371
diff changeset
    79
                                                       "-Xlog:gc+metaspace=trace",
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    80
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    81
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    82
            output.shouldContain("Compressed class space size: 3221225472")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    83
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    84
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    85
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    86
            pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    87
                                                       "-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    88
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    89
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    90
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    91
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    92
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    93
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    94
            pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    95
                                                       "-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    96
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    97
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    98
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    99
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   100
        } else {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   101
            // 32bit platforms doesn't have compressed oops
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   102
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   103
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   104
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   105
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   106
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   107
        }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   108
    }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   109
}