Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codecache/cli/printcodecache/PrintCodeCacheRunner.java
41154 views
1
/*
2
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package compiler.codecache.cli.printcodecache;
25
26
import compiler.codecache.cli.common.CodeCacheCLITestCase;
27
import compiler.codecache.cli.common.CodeCacheInfoFormatter;
28
import compiler.codecache.cli.common.CodeCacheOptions;
29
import jdk.test.lib.process.ExitCode;
30
import jdk.test.lib.cli.CommandLineOptionTest;
31
import sun.hotspot.code.BlobType;
32
33
import java.util.EnumSet;
34
import java.util.stream.Collectors;
35
36
/**
37
* Runner implementation aimed to verify PrintCodeCache output.
38
*/
39
public class PrintCodeCacheRunner implements CodeCacheCLITestCase.Runner {
40
private final boolean printCodeCache;
41
42
public PrintCodeCacheRunner(boolean printCodeCache) {
43
this.printCodeCache = printCodeCache;
44
}
45
46
public PrintCodeCacheRunner() {
47
this(true);
48
}
49
50
@Override
51
public void run(CodeCacheCLITestCase.Description testCaseDescription,
52
CodeCacheOptions options) throws Throwable {
53
CodeCacheOptions expectedValues
54
= testCaseDescription.expectedValues(options);
55
56
String[] expectedMessages
57
= testCaseDescription.involvedCodeHeaps.stream()
58
.map(heap -> CodeCacheInfoFormatter.forHeap(heap)
59
.withSize(expectedValues.sizeForHeap(heap)))
60
.map(CodeCacheInfoFormatter::getInfoString)
61
.toArray(String[]::new);
62
63
EnumSet<BlobType> unexpectedHeapsSet
64
= EnumSet.complementOf(testCaseDescription.involvedCodeHeaps);
65
66
String[] unexpectedMessages = CodeCacheInfoFormatter.forHeaps(
67
unexpectedHeapsSet.toArray(
68
new BlobType[unexpectedHeapsSet.size()]));
69
70
String description = String.format("JVM output should contain entries "
71
+ "for following code heaps: [%s] and should not contain "
72
+ "entries for following code heaps: [%s].",
73
testCaseDescription.involvedCodeHeaps.stream()
74
.map(BlobType::name)
75
.collect(Collectors.joining(", ")),
76
unexpectedHeapsSet.stream()
77
.map(BlobType::name)
78
.collect(Collectors.joining(", ")));
79
80
CommandLineOptionTest.verifySameJVMStartup(expectedMessages,
81
unexpectedMessages, "JVM startup failure is not expected, "
82
+ "since all options have allowed values", description,
83
ExitCode.OK,
84
testCaseDescription.getTestOptions(options,
85
CommandLineOptionTest.prepareBooleanFlag(
86
"PrintCodeCache", printCodeCache),
87
// Do not use large pages to avoid large page
88
// alignment of code heaps affecting their size.
89
"-XX:-UseLargePages"));
90
}
91
}
92
93