Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/StressTestTemplate.java
41161 views
1
/*
2
* Copyright (c) 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
package nsk.share.jdi;
25
26
import com.sun.jdi.event.Event;
27
import nsk.share.Consts;
28
import nsk.share.TestBug;
29
30
import java.io.PrintStream;
31
import java.util.ArrayList;
32
33
/*
34
* Class is intended for stress testing, expected command line parameters:
35
* - debuggee class name (e.g.: -debuggeeClassName nsk.share.jdi.MonitorEventsDebuggee)
36
* - one or more tested event types (e.g.: -eventTypes MONITOR_CONTENTED_ENTER:MONITOR_CONTENTED_ENTERED)
37
* - number of events which should be generated during test execution (e.g.: -eventsNumber 500)
38
* - number of threads which simultaneously generate events (e.g.: -threadsNumber 10)
39
*
40
* Class parses command line and calls method JDIEventsDebugger.stressTestTemplate.
41
*/
42
public class StressTestTemplate extends JDIEventsDebugger {
43
protected String debuggeeClassName;
44
protected EventType[] testedEventTypes;
45
protected int eventsNumber = 1;
46
protected int threadsNumber = 1;
47
48
public static void main(String[] argv) {
49
System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
50
}
51
52
public static int run(String[] argv, PrintStream out) {
53
return new StressTestTemplate().runIt(argv, out);
54
}
55
56
protected String[] doInit(String[] args, PrintStream out) {
57
args = super.doInit(args, out);
58
59
ArrayList<String> standardArgs = new ArrayList<String>();
60
61
for (int i = 0; i < args.length; i++) {
62
if (args[i].equals("-eventsNumber") && (i < args.length - 1)) {
63
eventsNumber = Integer.parseInt(args[i + 1]);
64
65
// for this stress test events number is equivalent of iterations
66
// (don't support 0 value of IterationsFactor)
67
if (stressOptions.getIterationsFactor() != 0) {
68
eventsNumber *= stressOptions.getIterationsFactor();
69
}
70
i++;
71
} else if (args[i].equals("-threadsNumber") && (i < args.length - 1)) {
72
threadsNumber = Integer.parseInt(args[i + 1]);
73
74
// if 'threadsNumber' is specified test should take in account stress options
75
threadsNumber *= stressOptions.getThreadsFactor();
76
77
i++;
78
} else if (args[i].equals("-debuggeeClassName") && (i < args.length - 1)) {
79
debuggeeClassName = args[i + 1];
80
i++;
81
} else if (args[i].equals("-eventTypes") && (i < args.length - 1)) {
82
String[] eventTypesNames = args[i + 1].split(":");
83
testedEventTypes = new EventType[eventTypesNames.length];
84
try {
85
for (int j = 0; j < eventTypesNames.length; j++) {
86
testedEventTypes[j] = EventType.valueOf(eventTypesNames[j]);
87
}
88
} catch (IllegalArgumentException e) {
89
throw new TestBug("Invalid event type", e);
90
}
91
92
i++;
93
} else {
94
standardArgs.add(args[i]);
95
}
96
}
97
98
if (testedEventTypes == null || testedEventTypes.length == 0) {
99
throw new TestBug("Test requires 'eventTypes' parameter");
100
}
101
102
if (debuggeeClassName == null) {
103
throw new TestBug("Test requires 'debuggeeClassName' parameter");
104
}
105
106
return standardArgs.toArray(new String[]{});
107
}
108
109
// can't control events from system libraries, so save events only from nsk packages
110
protected boolean shouldSaveEvent(Event event) {
111
return EventTestTemplates.isEventFromNSK(event, debuggee);
112
}
113
114
protected String debuggeeClassName() {
115
return debuggeeClassName;
116
}
117
118
public void doTest() {
119
prepareDebuggee(testedEventTypes);
120
121
EventTestTemplates.runTestWithRerunPossibilty(this,
122
() -> stressTestTemplate(testedEventTypes, eventsNumber, threadsNumber));
123
124
eventHandler.stopEventHandler();
125
removeDefaultBreakpoint();
126
}
127
}
128
129