author | neliasso |
Wed, 16 Dec 2015 15:38:28 +0100 | |
changeset 35129 | 8b93709bf4e5 |
parent 34214 | 41286f248795 |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
34214
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
1 |
/* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
4 |
* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
8 |
* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
13 |
* accompanied this code). |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
14 |
* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
18 |
* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
21 |
* questions. |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
22 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
23 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
24 |
/* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
25 |
* @test |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
26 |
* @bug 8137167 |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
27 |
* @summary Stress directive json parser |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
28 |
* @library /testlibrary /test/lib ../share / |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
29 |
* @run driver compiler.compilercontrol.parser.DirectiveStressTest |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
30 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
31 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
32 |
package compiler.compilercontrol.parser; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
33 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
34 |
import compiler.compilercontrol.share.AbstractTestBase; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
35 |
import compiler.compilercontrol.share.JSONFile; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
36 |
import compiler.compilercontrol.share.method.MethodDescriptor; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
37 |
import compiler.compilercontrol.share.scenario.DirectiveWriter; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
38 |
import jdk.test.lib.OutputAnalyzer; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
39 |
import pool.PoolHelper; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
40 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
41 |
import java.util.List; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
42 |
import java.util.stream.Collectors; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
43 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
44 |
public class DirectiveStressTest { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
45 |
private static final int AMOUNT = Integer.getInteger( |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
46 |
"compiler.compilercontrol.parser.DirectiveStressTest.amount", |
35129
8b93709bf4e5
8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents:
34214
diff
changeset
|
47 |
999); |
34214
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
48 |
private static final List<MethodDescriptor> DESCRIPTORS |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
49 |
= new PoolHelper().getAllMethods().stream() |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
50 |
.map(pair -> AbstractTestBase.getValidMethodDescriptor( |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
51 |
pair.first)) |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
52 |
.collect(Collectors.toList()); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
53 |
private static final String EXPECTED_MESSAGE = " compiler directives added"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
54 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
55 |
public static void main(String[] args) { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
56 |
hugeFileTest(); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
57 |
hugeObjectTest(); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
58 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
59 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
60 |
/* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
61 |
* Creates file with AMOUNT of options in match block |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
62 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
63 |
private static void hugeObjectTest() { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
64 |
String fileName = "hugeObject.json"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
65 |
try (DirectiveWriter file = new DirectiveWriter(fileName)) { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
66 |
file.write(JSONFile.Element.ARRAY); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
67 |
HugeDirectiveUtil.createMatchObject(DESCRIPTORS, file, AMOUNT); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
68 |
file.end(); // end array block |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
69 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
70 |
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
71 |
output.shouldHaveExitValue(0); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
72 |
output.shouldContain(1 + EXPECTED_MESSAGE); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
73 |
output.shouldNotContain(HugeDirectiveUtil.EXPECTED_ERROR_STRING); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
74 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
75 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
76 |
/* |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
77 |
* Creates huge valid file with AMOUNT of match directives |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
78 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
79 |
private static void hugeFileTest() { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
80 |
String fileName = "hugeFile.json"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
81 |
HugeDirectiveUtil.createHugeFile(DESCRIPTORS, fileName, AMOUNT); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
82 |
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
83 |
output.shouldHaveExitValue(0); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
84 |
output.shouldContain(AMOUNT + EXPECTED_MESSAGE); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
85 |
output.shouldNotContain(HugeDirectiveUtil.EXPECTED_ERROR_STRING); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
86 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
87 |
} |