author | tpivovarova |
Tue, 12 Jul 2016 18:24:48 +0300 | |
changeset 40059 | c2304140ed64 |
parent 38152 | 80e5da81fb2c |
child 40631 | ed82623d7831 |
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 |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
35129
diff
changeset
|
28 |
* @modules java.base/jdk.internal.misc |
40059 | 29 |
* @library /testlibrary /test/lib / |
30 |
* |
|
34214
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
31 |
* @run driver compiler.compilercontrol.parser.DirectiveStressTest |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
32 |
*/ |
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 |
package compiler.compilercontrol.parser; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
35 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
36 |
import compiler.compilercontrol.share.AbstractTestBase; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
37 |
import compiler.compilercontrol.share.JSONFile; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
38 |
import compiler.compilercontrol.share.method.MethodDescriptor; |
40059 | 39 |
import compiler.compilercontrol.share.pool.PoolHelper; |
34214
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
40 |
import compiler.compilercontrol.share.scenario.DirectiveWriter; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
41 |
import jdk.test.lib.OutputAnalyzer; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
42 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
43 |
import java.util.List; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
44 |
import java.util.stream.Collectors; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
45 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
46 |
public class DirectiveStressTest { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
47 |
private static final int AMOUNT = Integer.getInteger( |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
48 |
"compiler.compilercontrol.parser.DirectiveStressTest.amount", |
35129
8b93709bf4e5
8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents:
34214
diff
changeset
|
49 |
999); |
34214
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
50 |
private static final List<MethodDescriptor> DESCRIPTORS |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
51 |
= new PoolHelper().getAllMethods().stream() |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
52 |
.map(pair -> AbstractTestBase.getValidMethodDescriptor( |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
53 |
pair.first)) |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
54 |
.collect(Collectors.toList()); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
55 |
private static final String EXPECTED_MESSAGE = " compiler directives added"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
56 |
|
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
57 |
public static void main(String[] args) { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
58 |
hugeFileTest(); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
59 |
hugeObjectTest(); |
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 |
|
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 |
* Creates file with AMOUNT of options in match block |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
64 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
65 |
private static void hugeObjectTest() { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
66 |
String fileName = "hugeObject.json"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
67 |
try (DirectiveWriter file = new DirectiveWriter(fileName)) { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
68 |
file.write(JSONFile.Element.ARRAY); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
69 |
HugeDirectiveUtil.createMatchObject(DESCRIPTORS, file, AMOUNT); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
70 |
file.end(); // end array block |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
71 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
72 |
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
73 |
output.shouldHaveExitValue(0); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
74 |
output.shouldContain(1 + EXPECTED_MESSAGE); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
75 |
output.shouldNotContain(HugeDirectiveUtil.EXPECTED_ERROR_STRING); |
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 |
|
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 |
* Creates huge valid file with AMOUNT of match directives |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
80 |
*/ |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
81 |
private static void hugeFileTest() { |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
82 |
String fileName = "hugeFile.json"; |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
83 |
HugeDirectiveUtil.createHugeFile(DESCRIPTORS, fileName, AMOUNT); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
84 |
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
85 |
output.shouldHaveExitValue(0); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
86 |
output.shouldContain(AMOUNT + EXPECTED_MESSAGE); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
87 |
output.shouldNotContain(HugeDirectiveUtil.EXPECTED_ERROR_STRING); |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
88 |
} |
41286f248795
8066154: JEP-JDK-8046155: Test task: huge directive file
ppunegov
parents:
diff
changeset
|
89 |
} |