Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine06/VirtualMachine06.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/VirtualMachine06.
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 methods VirtualMachine.loadAgent(String agent) and
34
* VirtualMachine.loadAgent(String agent, String options).
35
* Test checks following cases:
36
* - it is possible to pass options to agent using loadAgent(String agent, String options)
37
* - it is possible to specify null options (in this case null is passed to the agentmain)
38
* - if agent throws exception from 'agentmain' VirtualMachine.loadAgent throws AgentInitializationException
39
*
40
* @library /vmTestbase /test/hotspot/jtreg/vmTestbase
41
* /test/lib
42
*
43
*
44
* @comment compile VM06Agent0[0-3].java to current directory
45
* @build nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent00
46
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent01
47
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent02
48
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent03
49
* @run driver jdk.test.lib.helpers.ClassFileInstaller
50
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent00
51
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent01
52
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent02
53
* nsk.aod.VirtualMachine.VirtualMachine06.VM06Agent03
54
*
55
* @comment create VM06Agent0[0-3].jar in current directory
56
* @run driver ExecDriver --cmd
57
* ${test.jdk}/bin/jar
58
* -cmf ${test.src}/VM06Agent00.mf
59
* VM06Agent00.jar
60
* nsk/aod/VirtualMachine/VirtualMachine06/VM06Agent00.class
61
* @run driver ExecDriver --cmd
62
* ${test.jdk}/bin/jar
63
* -cmf ${test.src}/VM06Agent01.mf
64
* VM06Agent01.jar
65
* nsk/aod/VirtualMachine/VirtualMachine06/VM06Agent01.class
66
* @run driver ExecDriver --cmd
67
* ${test.jdk}/bin/jar
68
* -cmf ${test.src}/VM06Agent02.mf
69
* VM06Agent02.jar
70
* nsk/aod/VirtualMachine/VirtualMachine06/VM06Agent02.class
71
* @run driver ExecDriver --cmd
72
* ${test.jdk}/bin/jar
73
* -cmf ${test.src}/VM06Agent03.mf
74
* VM06Agent03.jar
75
* nsk/aod/VirtualMachine/VirtualMachine06/VM06Agent03.class
76
*
77
*
78
* @build nsk.share.aod.TargetApplicationWaitingAgents
79
* @run main/othervm
80
* -XX:+UsePerfData
81
* nsk.aod.VirtualMachine.VirtualMachine06.VirtualMachine06
82
* -jdk ${test.jdk}
83
* -javaOpts="-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
84
* -target nsk.share.aod.TargetApplicationWaitingAgents
85
* -ja VM06Agent00.jar,VM06Agent01.jar,VM06Agent02.jar,VM06Agent03.jar
86
*/
87
88
package nsk.aod.VirtualMachine.VirtualMachine06;
89
90
import com.sun.tools.attach.AgentInitializationException;
91
import com.sun.tools.attach.VirtualMachine;
92
import nsk.share.TestBug;
93
import nsk.share.aod.AODTestRunner;
94
import nsk.share.aod.AgentInformation;
95
import nsk.share.test.TestUtils;
96
97
import java.util.List;
98
99
/*
100
* Test checks following methods:
101
* - VirtualMachine.loadAgent(String)
102
* - VirtualMachine.loadAgent(String, String)
103
*/
104
public class VirtualMachine06 extends AODTestRunner {
105
106
public VirtualMachine06(String[] args) {
107
super(args);
108
}
109
110
public void doTestActions(String targetVMId) throws Throwable {
111
// check that all required parameters were passed to the test
112
List<AgentInformation> agents = argParser.getAgents();
113
if (agents.size() != 4) {
114
throw new TestBug("Test requires 4 agents, actually " + agents.size() + " were specified");
115
}
116
for (AgentInformation agent : agents) {
117
if (!agent.jarAgent) {
118
throw new TestBug("Non JAR agent was specified");
119
}
120
}
121
122
VirtualMachine vm = VirtualMachine.attach(targetVMId);
123
124
try {
125
AgentInformation agent;
126
127
agent = agents.get(0);
128
log.display("Loading '" + agent.pathToAgent + "'");
129
// pass null options to agent
130
vm.loadAgent(agent.pathToAgent);
131
132
agent = agents.get(1);
133
log.display("Loading '" + agent.pathToAgent + "'");
134
// pass null options to agent
135
vm.loadAgent(agent.pathToAgent, null);
136
137
agent = agents.get(2);
138
log.display("Loading '" + agent.pathToAgent + "'");
139
// pass non-null options to agent
140
vm.loadAgent(agent.pathToAgent, "VirtualMachine06_TestOptions");
141
142
agent = agents.get(3);
143
log.display("Loading '" + agent.pathToAgent + "' (this agent throws exception from agentmain)");
144
try {
145
// check agent throwing exception from agentmain
146
vm.loadAgent(agent.pathToAgent);
147
TestUtils.testFailed("Expected AgentInitializationException wasn't thrown");
148
} catch (AgentInitializationException e) {
149
// expected exception
150
}
151
} finally {
152
vm.detach();
153
}
154
}
155
156
public static void main(String[] args) {
157
new VirtualMachine06(args).runTest();
158
}
159
}
160
161