hotspot/test/gc/TestVerifySubSet.java
author alanb
Tue, 03 May 2016 09:11:31 +0100
changeset 37827 09fa0c82a5f7
parent 36851 03e2f4d0a421
child 38084 21c37af5ba7e
permissions -rw-r--r--
8154956: Module system implementation refresh (4/2016) Reviewed-by: alanb, mchung, chegar, redestad Contributed-by: alan.bateman@oracle.com, erik.joelsson@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35509
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     1
/*
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     4
 *
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     8
 *
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    13
 * accompanied this code).
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    14
 *
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    18
 *
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    21
 * questions.
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    22
 */
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    23
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    24
/* @test TestVerifySubSet.java
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    25
 * @key gc
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    26
 * @bug 8072725
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    27
 * @summary Test VerifySubSet option
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    28
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35509
diff changeset
    29
 * @modules java.base/jdk.internal.misc
35509
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    30
 *          java.management
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    31
 */
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    32
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    33
import jdk.test.lib.OutputAnalyzer;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    34
import jdk.test.lib.ProcessTools;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    35
import java.util.ArrayList;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    36
import java.util.Collections;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    37
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    38
class RunSystemGC {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    39
    public static void main(String args[]) throws Exception {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    40
        System.gc();
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    41
    }
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    42
}
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    43
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    44
public class TestVerifySubSet {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    45
    private static String[] getTestJavaOpts() {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    46
        String testVmOptsStr = System.getProperty("test.java.opts");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    47
        if (!testVmOptsStr.isEmpty()) {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    48
            return testVmOptsStr.split(" ");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    49
        } else {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    50
            return new String[] {};
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    51
        }
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    52
    }
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    53
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    54
    private static OutputAnalyzer runTest(String subset) throws Exception {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    55
        ArrayList<String> vmOpts = new ArrayList();
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    56
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    57
        Collections.addAll(vmOpts, getTestJavaOpts());
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    58
        Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    59
                                                 "-XX:+VerifyBeforeGC",
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    60
                                                 "-XX:+VerifyAfterGC",
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    61
                                                 "-Xlog:gc+verify=debug",
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    62
                                                 "-XX:VerifySubSet="+subset,
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    63
                                                 RunSystemGC.class.getName()});
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    64
        ProcessBuilder pb =
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    65
            ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    66
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    67
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    68
        System.out.println("Output:\n" + output.getOutput());
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    69
        return output;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    70
    }
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    71
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    72
    public static void main(String args[]) throws Exception {
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    73
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    74
        OutputAnalyzer output;
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    75
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    76
        output = runTest("heap, threads, codecache, metaspace");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    77
        output.shouldContain("Heap");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    78
        output.shouldContain("Threads");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    79
        output.shouldContain("CodeCache");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    80
        output.shouldContain("MetaspaceAux");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    81
        output.shouldNotContain("SymbolTable");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    82
        output.shouldNotContain("StringTable");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    83
        output.shouldNotContain("SystemDictionary");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    84
        output.shouldNotContain("CodeCache Oops");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    85
        output.shouldHaveExitValue(0);
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    86
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    87
        output = runTest("hello, threads, codecache, metaspace");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    88
        output.shouldContain("memory sub-system is unknown, please correct it");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    89
        output.shouldNotContain("Threads");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    90
        output.shouldNotContain("CodeCache");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    91
        output.shouldNotContain("MetaspaceAux");
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    92
        output.shouldHaveExitValue(1);
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    93
    }
15f2d488eeee 8072725: Provide more granular levels for GC verification
poonam
parents:
diff changeset
    94
}