Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/TestVerifySubSet.java
32281 views
/*1* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test TestVerifySubSet.java24* @key gc25* @bug 807272526* @summary Test VerifySubSet option27* @library /testlibrary28*/2930import com.oracle.java.testlibrary.OutputAnalyzer;31import com.oracle.java.testlibrary.ProcessTools;32import java.util.ArrayList;33import java.util.Collections;3435class RunSystemGC {36public static void main(String args[]) throws Exception {37System.gc();38}39}4041public class TestVerifySubSet {42private static String[] getTestJavaOpts() {43String testVmOptsStr = System.getProperty("test.java.opts");44if (!testVmOptsStr.isEmpty()) {45return testVmOptsStr.split(" ");46} else {47return new String[] {};48}49}5051private static OutputAnalyzer runTest(String subset) throws Exception {52ArrayList<String> vmOpts = new ArrayList();5354Collections.addAll(vmOpts, getTestJavaOpts());55Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",56"-XX:+VerifyBeforeGC",57"-XX:+VerifyAfterGC",58"-XX:VerifySubSet="+subset,59RunSystemGC.class.getName()});60ProcessBuilder pb =61ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));62OutputAnalyzer output = new OutputAnalyzer(pb.start());6364System.out.println("Output:\n" + output.getOutput());65return output;66}6768public static void main(String args[]) throws Exception {6970OutputAnalyzer output;7172output = runTest("heap, threads, codecache, metaspace");73output.shouldContain("Heap");74output.shouldContain("Threads");75output.shouldContain("CodeCache");76output.shouldContain("MetaspaceAux");77output.shouldNotContain("SymbolTable");78output.shouldNotContain("StringTable");79output.shouldNotContain("SystemDictionary");80output.shouldNotContain("CodeCache Oops");81output.shouldHaveExitValue(0);8283output = runTest("hello, threads, codecache, metaspace");84output.shouldContain("memory sub-system is unknown, please correct it");85output.shouldNotContain("Threads");86output.shouldNotContain("CodeCache");87output.shouldNotContain("MetaspaceAux");88output.shouldHaveExitValue(1);89}90}919293