author | vdeshpande |
Fri, 26 Aug 2016 12:20:09 -0700 | |
changeset 41362 | e09e871860a7 |
parent 39427 | c154eca6daa5 |
permissions | -rw-r--r-- |
33452 | 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.share; |
|
25 |
||
26 |
import compiler.compilercontrol.share.method.MethodDescriptor; |
|
27 |
import compiler.compilercontrol.share.scenario.Command; |
|
28 |
import compiler.compilercontrol.share.scenario.CommandGenerator; |
|
29 |
import compiler.compilercontrol.share.scenario.CompileCommand; |
|
30 |
import compiler.compilercontrol.share.scenario.Scenario; |
|
31 |
import jdk.test.lib.Utils; |
|
32 |
||
33 |
import java.lang.reflect.Executable; |
|
34 |
import java.util.ArrayList; |
|
35 |
import java.util.List; |
|
36 |
||
37 |
public class MultiCommand extends AbstractTestBase { |
|
38 |
private final List<CompileCommand> testCases; |
|
39 |
||
40 |
public MultiCommand(List<CompileCommand> testCases) { |
|
41 |
this.testCases = testCases; |
|
42 |
} |
|
43 |
||
44 |
/** |
|
45 |
* Generates a test containing multiple random commands |
|
46 |
* |
|
47 |
* @param validOnly shows that all commands should be valid |
|
48 |
* @return test instance to run |
|
49 |
*/ |
|
50 |
public static AbstractTestBase generateRandomTest(boolean validOnly) { |
|
51 |
CommandGenerator cmdGen = new CommandGenerator(); |
|
52 |
List<Command> commands = cmdGen.generateCommands(); |
|
53 |
List<CompileCommand> testCases = new ArrayList<>(); |
|
54 |
for (Command cmd : commands) { |
|
55 |
if (validOnly && cmd == Command.NONEXISTENT) { |
|
36610
7b866d93cd34
8150955: RandomValidCommandsTest.java fails with UnsatisfiedLinkError: sun.hotspot.WhiteBox.registerNatives
ppunegov
parents:
33452
diff
changeset
|
56 |
// replace with a valid command |
7b866d93cd34
8150955: RandomValidCommandsTest.java fails with UnsatisfiedLinkError: sun.hotspot.WhiteBox.registerNatives
ppunegov
parents:
33452
diff
changeset
|
57 |
cmd = Command.EXCLUDE; |
33452 | 58 |
} |
59 |
Executable exec = Utils.getRandomElement(METHODS).first; |
|
60 |
MethodDescriptor md; |
|
61 |
if (validOnly) { |
|
62 |
md = AbstractTestBase.getValidMethodDescriptor(exec); |
|
63 |
} else { |
|
64 |
md = AbstractTestBase.METHOD_GEN.generateRandomDescriptor(exec); |
|
65 |
} |
|
66 |
CompileCommand cc = cmdGen.generateCompileCommand(cmd, md, null); |
|
67 |
testCases.add(cc); |
|
68 |
} |
|
69 |
return new MultiCommand(testCases); |
|
70 |
} |
|
71 |
||
72 |
@Override |
|
73 |
public void test() { |
|
74 |
Scenario.Builder builder = Scenario.getBuilder(); |
|
36796 | 75 |
builder.addFlag("-Xmixed"); |
39427
c154eca6daa5
8158754: compilercontrol tests: RandomCommandsTest.java and RandomValidCommandsTest.java - fail in PIT
iignatyev
parents:
38715
diff
changeset
|
76 |
builder.addFlag("-XX:+UnlockDiagnosticVMOptions"); |
38715
f8a3a82dfaf0
8157717: MultiCommand breaks directives amount limit
neliasso
parents:
36796
diff
changeset
|
77 |
builder.addFlag("-XX:CompilerDirectivesLimit=101"); |
33452 | 78 |
for (CompileCommand cc : testCases) { |
79 |
cc.print(); |
|
80 |
builder.add(cc); |
|
81 |
} |
|
82 |
Scenario scenario = builder.build(); |
|
83 |
scenario.execute(); |
|
84 |
} |
|
85 |
} |