Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/serviceability/7170638/SDTProbesGNULinuxTest.java
64478 views
1
/*
2
* Copyright (c) 2012, Red Hat, Inc.
3
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. 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
27
* @bug 7170638
28
* @summary Test SDT probes available on GNU/Linux when DTRACE_ENABLED
29
* @requires os.family == "linux"
30
* @requires vm.flagless
31
* @requires vm.hasDTrace
32
*
33
* @library /test/lib
34
* @run driver SDTProbesGNULinuxTest
35
*/
36
37
import jdk.test.lib.Utils;
38
import jdk.test.lib.process.OutputAnalyzer;
39
import jdk.test.lib.process.ProcessTools;
40
41
import java.nio.file.Files;
42
import java.nio.file.Path;
43
import java.nio.file.Paths;
44
45
public class SDTProbesGNULinuxTest {
46
public static void main(String[] args) throws Throwable {
47
// This test only matters when build with DTRACE_ENABLED.
48
try (var libjvms = Files.walk(Paths.get(Utils.TEST_JDK))) {
49
libjvms.filter(p -> "libjvm.so".equals(p.getFileName().toString()))
50
.map(Path::toAbsolutePath)
51
.forEach(SDTProbesGNULinuxTest::testLibJvm);
52
}
53
}
54
55
private static void testLibJvm(Path libjvm) {
56
System.out.println("Testing " + libjvm);
57
// We could iterate over all SDT probes and test them individually
58
// with readelf -n, but older readelf versions don't understand them.
59
try {
60
ProcessTools.executeCommand("readelf", "-S", libjvm.toString())
61
.shouldHaveExitValue(0)
62
.stdoutShouldContain(".note.stapsd");
63
} catch (Throwable t) {
64
throw new Error(t);
65
}
66
}
67
}
68
69