Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/AttachProvider/AttachProvider01/AttachProvider01.java
41161 views
1
/*
2
* Copyright (c) 2008, 2020, 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
/*
25
* @test
26
*
27
* @summary converted from VM Testbase nsk/aod/AttachProvider/AttachProvider01.
28
* VM Testbase keywords: [feature_282, jdk]
29
* VM Testbase readme:
30
* Description :
31
* Test checks work of Attach API (com.sun.tools.attach).
32
* Test is based on the nsk.share.aod framework.
33
* This test checks that method AttachProvider.listVirtualMachines() returns
34
* VirtualMachineDescriptors for 2 VMs started by this test.
35
*
36
* @library /vmTestbase /test/hotspot/jtreg/vmTestbase
37
* /test/lib
38
* @build nsk.share.aod.DummyTargetApplication
39
* @run main/othervm
40
* -XX:+UsePerfData
41
* nsk.aod.AttachProvider.AttachProvider01.AttachProvider01
42
* -jdk ${test.jdk}
43
* -javaOpts="-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
44
* -target nsk.share.aod.DummyTargetApplication
45
*/
46
47
package nsk.aod.AttachProvider.AttachProvider01;
48
49
import com.sun.tools.attach.VirtualMachine;
50
import com.sun.tools.attach.VirtualMachineDescriptor;
51
import com.sun.tools.attach.spi.AttachProvider;
52
import nsk.share.aod.AODTestRunner;
53
import nsk.share.test.TestUtils;
54
55
import java.util.List;
56
57
/*
58
* Test checks method AttachProvider.listVirtualMachines()
59
* (test checks that collection returned by AttachProvider.listVirtualMachines() contains current VM
60
* and another VM started by this test)
61
*/
62
public class AttachProvider01 extends AODTestRunner {
63
64
public AttachProvider01(String[] args) {
65
super(args);
66
}
67
68
public void doTestActions(String targetVMId) {
69
String currentVMId = getCurrentVMId();
70
71
for (AttachProvider provider : AttachProvider.providers()) {
72
log.display("Checking AttachProvider.listVirtualMachines() (provider: " + provider + ")");
73
checkList(provider.listVirtualMachines(), currentVMId, targetVMId);
74
}
75
}
76
77
private void checkList(List<VirtualMachineDescriptor> vmDescriptors, String currentVMId, String targetVMId) {
78
VirtualMachineDescriptor currentVMDesc = null;
79
VirtualMachineDescriptor targetVMDesc = null;
80
81
for (VirtualMachineDescriptor vmDescriptor : VirtualMachine.list()) {
82
log.display("VirtualMachineDescriptor: " + vmDescriptor);
83
84
if (vmDescriptor.id().equals(currentVMId)) {
85
currentVMDesc = vmDescriptor;
86
} else if (vmDescriptor.id().equals(targetVMId)) {
87
targetVMDesc = vmDescriptor;
88
}
89
}
90
91
TestUtils.assertNotNull(currentVMDesc, "VirtualMachine.list() didn't return descriptor for the current VM");
92
TestUtils.assertNotNull(targetVMDesc, "VirtualMachine.list() didn't return descriptor for VM with id '" +
93
targetVMId + "'");
94
}
95
96
public static void main(String[] args) {
97
new AttachProvider01(args).runTest();
98
}
99
}
100
101