Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/dcmd/compiler/PerfMapTest.java
41153 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2020, Arm Limited. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*/
24
25
/*
26
* @test PerfMapTest
27
* @bug 8254723
28
* @requires os.family == "linux"
29
* @library /test/lib
30
* @modules java.base/jdk.internal.misc
31
* java.compiler
32
* java.management
33
* jdk.internal.jvmstat/sun.jvmstat.monitor
34
* @run testng/othervm PerfMapTest
35
* @summary Test of diagnostic command Compiler.perfmap
36
*/
37
38
import org.testng.annotations.Test;
39
import org.testng.Assert;
40
41
import jdk.test.lib.process.OutputAnalyzer;
42
import jdk.test.lib.dcmd.CommandExecutor;
43
import jdk.test.lib.dcmd.JMXExecutor;
44
45
import java.io.IOException;
46
import java.nio.file.Files;
47
import java.nio.file.Path;
48
import java.nio.file.Paths;
49
import java.util.regex.Matcher;
50
import java.util.regex.Pattern;
51
52
/**
53
* Call jcmd Compiler.perfmap and check the output file has the expected
54
* format.
55
*/
56
public class PerfMapTest {
57
58
static final Pattern LINE_PATTERN =
59
Pattern.compile("^((?:0x)?\\p{XDigit}+)\\s+((?:0x)?\\p{XDigit}+)\\s+(.*)$");
60
61
public void run(CommandExecutor executor) {
62
OutputAnalyzer output = executor.execute("Compiler.perfmap");
63
64
output.stderrShouldBeEmpty();
65
output.stdoutShouldBeEmpty();
66
67
final long pid = ProcessHandle.current().pid();
68
final Path path = Paths.get(String.format("/tmp/perf-%d.map", pid));
69
70
Assert.assertTrue(Files.exists(path));
71
72
// Sanity check the file contents
73
try {
74
for (String entry : Files.readAllLines(path)) {
75
Matcher m = LINE_PATTERN.matcher(entry);
76
Assert.assertTrue(m.matches(), "Invalid file format: " + entry);
77
}
78
} catch (IOException e) {
79
Assert.fail(e.toString());
80
}
81
}
82
83
@Test
84
public void jmx() {
85
run(new JMXExecutor());
86
}
87
}
88
89