author | dcubed |
Tue, 05 Jul 2016 14:00:21 -0700 | |
changeset 39696 | 80c9894e18f9 |
parent 36549 | d191b3de2ad3 |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
34215 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 compiler.compilercontrol.jcmd; |
|
25 |
||
26 |
import compiler.compilercontrol.parser.HugeDirectiveUtil; |
|
27 |
import compiler.compilercontrol.share.AbstractTestBase; |
|
28 |
import compiler.compilercontrol.share.method.MethodDescriptor; |
|
29 |
import compiler.compilercontrol.share.scenario.Executor; |
|
30 |
import jdk.test.lib.OutputAnalyzer; |
|
31 |
import jdk.test.lib.TimeLimitedRunner; |
|
32 |
import jdk.test.lib.Utils; |
|
33 |
import pool.PoolHelper; |
|
34 |
||
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
35 |
import java.util.ArrayList; |
34215 | 36 |
import java.util.List; |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
37 |
import java.util.Random; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
38 |
import java.util.concurrent.TimeUnit; |
34215 | 39 |
import java.util.stream.Collectors; |
40 |
||
41 |
public abstract class StressAddJcmdBase { |
|
42 |
private static final int DIRECTIVES_AMOUNT = Integer.getInteger( |
|
43 |
"compiler.compilercontrol.jcmd.StressAddJcmdBase.directivesAmount", |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
44 |
200); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
45 |
private static final int TIMEOUT = Integer.getInteger( |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
46 |
"compiler.compilercontrol.jcmd.StressAddJcmdBase.timeout", |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
47 |
30); |
34215 | 48 |
private static final List<MethodDescriptor> DESCRIPTORS = new PoolHelper() |
49 |
.getAllMethods().stream() |
|
50 |
.map(pair -> AbstractTestBase |
|
51 |
.getValidMethodDescriptor(pair.first)) |
|
52 |
.collect(Collectors.toList()); |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
53 |
private static final String DIRECTIVE_FILE = "directives.json"; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
54 |
private static final List<String> VM_OPTIONS = new ArrayList<>(); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
55 |
private static final Random RANDOM = Utils.getRandomInstance(); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
56 |
|
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
57 |
static { |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
58 |
VM_OPTIONS.add("-Xmixed"); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
59 |
VM_OPTIONS.add("-XX:+UnlockDiagnosticVMOptions"); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
60 |
VM_OPTIONS.add("-XX:+LogCompilation"); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
61 |
VM_OPTIONS.add("-XX:CompilerDirectivesLimit=1001"); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
62 |
} |
34215 | 63 |
|
64 |
/** |
|
65 |
* Performs test |
|
66 |
*/ |
|
67 |
public void test() { |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
68 |
HugeDirectiveUtil.createHugeFile(DESCRIPTORS, DIRECTIVE_FILE, |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
69 |
DIRECTIVES_AMOUNT); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
70 |
Executor executor = new TimeLimitedExecutor(); |
34216
2818af1ce748
8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
34215
diff
changeset
|
71 |
List<OutputAnalyzer> outputAnalyzers = executor.execute(); |
2818af1ce748
8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
34215
diff
changeset
|
72 |
outputAnalyzers.get(0).shouldHaveExitValue(0); |
34215 | 73 |
} |
74 |
||
75 |
/** |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
76 |
* Makes connection to the test VM and performs a diagnostic command |
34215 | 77 |
* |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
78 |
* @param pid a pid of the VM under test |
34215 | 79 |
* @return true if the test should continue invocation of this method |
80 |
*/ |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
81 |
protected abstract boolean makeConnection(int pid); |
34215 | 82 |
|
83 |
/** |
|
84 |
* Finish test executions |
|
85 |
*/ |
|
86 |
protected void finish() { } |
|
87 |
||
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
88 |
protected String nextCommand() { |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
89 |
int i = RANDOM.nextInt(JcmdCommand.values().length); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
90 |
JcmdCommand jcmdCommand = JcmdCommand.values()[i]; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
91 |
switch (jcmdCommand) { |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
92 |
case ADD: |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
93 |
return jcmdCommand.command + " " + DIRECTIVE_FILE; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
94 |
case PRINT: |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
95 |
case CLEAR: |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
96 |
case REMOVE: |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
97 |
return jcmdCommand.command; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
98 |
default: |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
99 |
throw new Error("TESTBUG: incorrect command: " + jcmdCommand); |
34215 | 100 |
} |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
101 |
} |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
102 |
|
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
103 |
private enum JcmdCommand { |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
104 |
ADD("Compiler.directives_add"), |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
105 |
PRINT("Compiler.directives_print"), |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
106 |
CLEAR("Compiler.directives_clear"), |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
107 |
REMOVE("Compiler.directives_remove"); |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
108 |
|
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
109 |
public final String command; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
110 |
|
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
111 |
JcmdCommand(String command) { |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
112 |
this.command = command; |
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
113 |
} |
34215 | 114 |
} |
115 |
||
116 |
private class TimeLimitedExecutor extends Executor { |
|
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
117 |
public TimeLimitedExecutor() { |
34215 | 118 |
/* There are no need to check the state */ |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
119 |
super(true, VM_OPTIONS, null, null); |
34215 | 120 |
} |
121 |
||
122 |
@Override |
|
34216
2818af1ce748
8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
34215
diff
changeset
|
123 |
protected OutputAnalyzer[] executeJCMD(int pid) { |
34215 | 124 |
TimeLimitedRunner runner = new TimeLimitedRunner( |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
125 |
TimeUnit.SECONDS.toMillis(TIMEOUT), |
34215 | 126 |
Utils.TIMEOUT_FACTOR, |
36549
d191b3de2ad3
8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents:
34216
diff
changeset
|
127 |
() -> makeConnection(pid)); |
34215 | 128 |
try { |
129 |
runner.call(); |
|
130 |
} catch (Exception e) { |
|
131 |
throw new Error("Exception during the execution: " + e, e); |
|
132 |
} |
|
133 |
finish(); |
|
34216
2818af1ce748
8138993: JEP-JDK-8046155: Test task: add check for Compiler.directives_print diagnostic command
ppunegov
parents:
34215
diff
changeset
|
134 |
return new OutputAnalyzer[0]; |
34215 | 135 |
} |
136 |
} |
|
137 |
} |