Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine05/VirtualMachine05.java
41160 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/VirtualMachine/VirtualMachine05.
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 VirtualMachine.list() 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.VirtualMachine.VirtualMachine05.VirtualMachine05
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.VirtualMachine.VirtualMachine05;
48
49
import com.sun.tools.attach.VirtualMachine;
50
import com.sun.tools.attach.VirtualMachineDescriptor;
51
import nsk.share.aod.AODTestRunner;
52
import nsk.share.test.TestUtils;
53
54
import java.util.List;
55
56
/*
57
* Test checks method VirtualMachine.list()
58
* (test checks that collection returned by VirtualMachine.list() contains current VM
59
* and another VM started by this test)
60
*/
61
public class VirtualMachine05 extends AODTestRunner {
62
63
public VirtualMachine05(String[] args) {
64
super(args);
65
}
66
67
public void doTestActions(String targetVMId) {
68
String currentVMId = getCurrentVMId();
69
70
log.display("Checking VirtualMachine.list()");
71
checkList(currentVMId, targetVMId);
72
}
73
74
private void checkList(String currentVMId, String targetVMId) {
75
VirtualMachineDescriptor currentVM = null;
76
VirtualMachineDescriptor targetVM = null;
77
78
for (VirtualMachineDescriptor vmDescriptor : VirtualMachine.list()) {
79
log.display("VirtualMachineDescriptor: " + vmDescriptor);
80
81
if (vmDescriptor.id().equals(currentVMId)) {
82
currentVM = vmDescriptor;
83
} else if (vmDescriptor.id().equals(targetVMId)) {
84
targetVM = vmDescriptor;
85
}
86
}
87
88
TestUtils.assertNotNull(currentVM, "VirtualMachine.list() didn't return descriptor for the current VM");
89
90
TestUtils.assertNotNull(targetVM, "VirtualMachine.list() didn't return descriptor for VM with id '" +
91
targetVMId + "'");
92
}
93
94
public static void main(String[] args) {
95
new VirtualMachine05(args).runTest();
96
}
97
}
98
99