Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java
41159 views
/*1* Copyright (c) 2017, 2021, 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*/222324/*25* @test26*27* @summary converted from VM Testbase vm/compiler/CodeCacheInfo.28* VM Testbase readme:29* DESCRIPTION30* Test calls java -version and checks enhanced output format of the31* -XX:+PrintCodeCache vm option.32*33* @library /vmTestbase34* /test/lib35* @build sun.hotspot.WhiteBox36* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox37* @run main/othervm38* -Xmixed39* -Xbootclasspath/a:.40* -XX:+UnlockDiagnosticVMOptions41* -XX:+WhiteBoxAPI42* vm.compiler.CodeCacheInfo.Test43*/4445package vm.compiler.CodeCacheInfo;4647import sun.hotspot.WhiteBox;48import jdk.test.lib.process.OutputAnalyzer;49import jdk.test.lib.process.ProcessTools;5051public class Test {52private static final String SEG_REGEXP;53private static final String NOSEG_REGEXP;5455static {56String p1 = " size=\\d+Kb used=\\d+Kb max_used=\\d+Kb free=\\d+Kb\\n";57String p2 = " bounds \\[0x[0-9a-f]+, 0x[0-9a-f]+, 0x[0-9a-f]+\\]\\n";58String p3 = " total_blobs=\\d+ nmethods=\\d+ adapters=\\d+\\n";59String p4 = " compilation: enabled\\n";6061String segPrefix = "^(CodeHeap '[^']+':" + p1 + p2 + ")+";62String nosegPrefix = "^CodeCache:" + p1 + p2;6364SEG_REGEXP = segPrefix + p3 + p4;65NOSEG_REGEXP = nosegPrefix + p3 + p4;66}6768public static void main(String[] args) throws Exception {69{70System.out.println("SegmentedCodeCache is enabled");71var pb = ProcessTools.createTestJvm(72"-XX:+SegmentedCodeCache",73"-XX:+PrintCodeCache",74"-version");75var output = new OutputAnalyzer(pb.start());76output.shouldHaveExitValue(0);77output.stdoutShouldMatch(SEG_REGEXP);78}79{80System.out.println("SegmentedCodeCache is disabled");81var pb = ProcessTools.createTestJvm(82"-XX:-SegmentedCodeCache",83"-XX:+PrintCodeCache",84"-version");85var output = new OutputAnalyzer(pb.start());86output.shouldHaveExitValue(0);87output.stdoutShouldMatch(NOSEG_REGEXP);88}89}90}919293