Path: blob/master/test/hotspot/jtreg/compiler/codecache/cli/printcodecache/PrintCodeCacheRunner.java
41154 views
/*1* Copyright (c) 2014, 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*/2223package compiler.codecache.cli.printcodecache;2425import compiler.codecache.cli.common.CodeCacheCLITestCase;26import compiler.codecache.cli.common.CodeCacheInfoFormatter;27import compiler.codecache.cli.common.CodeCacheOptions;28import jdk.test.lib.process.ExitCode;29import jdk.test.lib.cli.CommandLineOptionTest;30import sun.hotspot.code.BlobType;3132import java.util.EnumSet;33import java.util.stream.Collectors;3435/**36* Runner implementation aimed to verify PrintCodeCache output.37*/38public class PrintCodeCacheRunner implements CodeCacheCLITestCase.Runner {39private final boolean printCodeCache;4041public PrintCodeCacheRunner(boolean printCodeCache) {42this.printCodeCache = printCodeCache;43}4445public PrintCodeCacheRunner() {46this(true);47}4849@Override50public void run(CodeCacheCLITestCase.Description testCaseDescription,51CodeCacheOptions options) throws Throwable {52CodeCacheOptions expectedValues53= testCaseDescription.expectedValues(options);5455String[] expectedMessages56= testCaseDescription.involvedCodeHeaps.stream()57.map(heap -> CodeCacheInfoFormatter.forHeap(heap)58.withSize(expectedValues.sizeForHeap(heap)))59.map(CodeCacheInfoFormatter::getInfoString)60.toArray(String[]::new);6162EnumSet<BlobType> unexpectedHeapsSet63= EnumSet.complementOf(testCaseDescription.involvedCodeHeaps);6465String[] unexpectedMessages = CodeCacheInfoFormatter.forHeaps(66unexpectedHeapsSet.toArray(67new BlobType[unexpectedHeapsSet.size()]));6869String description = String.format("JVM output should contain entries "70+ "for following code heaps: [%s] and should not contain "71+ "entries for following code heaps: [%s].",72testCaseDescription.involvedCodeHeaps.stream()73.map(BlobType::name)74.collect(Collectors.joining(", ")),75unexpectedHeapsSet.stream()76.map(BlobType::name)77.collect(Collectors.joining(", ")));7879CommandLineOptionTest.verifySameJVMStartup(expectedMessages,80unexpectedMessages, "JVM startup failure is not expected, "81+ "since all options have allowed values", description,82ExitCode.OK,83testCaseDescription.getTestOptions(options,84CommandLineOptionTest.prepareBooleanFlag(85"PrintCodeCache", printCodeCache),86// Do not use large pages to avoid large page87// alignment of code heaps affecting their size.88"-XX:-UseLargePages"));89}90}919293