author | jlahoda |
Mon, 13 Feb 2017 09:37:26 +0100 | |
changeset 43772 | 4e5350b7be75 |
parent 41705 | 332239c052cc |
permissions | -rw-r--r-- |
30179 | 1 |
/* |
41705
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
4 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
7 |
* published by the Free Software Foundation. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
8 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
13 |
* accompanied this code). |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
14 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
18 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
21 |
* questions. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40667
diff
changeset
|
22 |
*/ |
30179 | 23 |
|
24 |
/* |
|
25 |
* @test TestVerifyBeforeAndAfterGCFlags |
|
26 |
* @key gc |
|
27 |
* @bug 8000831 |
|
28 |
* @summary Runs an simple application (GarbageProducer) with various |
|
29 |
combinations of -XX:{+|-}Verify{After|Before}GC flags and checks that |
|
30 |
output contain or doesn't contain expected patterns |
|
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
35061
diff
changeset
|
31 |
* @modules java.base/jdk.internal.misc |
30179 | 32 |
* @modules java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
33 |
* @library /test/lib |
30179 | 34 |
* @run driver TestVerifyBeforeAndAfterGCFlags |
35 |
*/ |
|
36 |
||
37 |
import java.util.ArrayList; |
|
38 |
import java.util.Collections; |
|
39 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30179
diff
changeset
|
40 |
import jdk.test.lib.Utils; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
41 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
42 |
import jdk.test.lib.process.ProcessTools; |
30179 | 43 |
|
44 |
public class TestVerifyBeforeAndAfterGCFlags { |
|
45 |
||
40667 | 46 |
// VerifyBeforeGC:[Verifying threads heap tenured eden syms strs zone dict metaspace chunks hand code cache ] |
35061 | 47 |
public static final String VERIFY_BEFORE_GC_PATTERN = "Verifying Before GC"; |
30179 | 48 |
// VerifyBeforeGC: VerifyBeforeGC: VerifyBeforeGC: |
49 |
public static final String VERIFY_BEFORE_GC_CORRUPTED_PATTERN = "VerifyBeforeGC:(?!\\[Verifying[^]]+\\])"; |
|
50 |
||
40667 | 51 |
// VerifyAfterGC:[Verifying threads heap tenured eden syms strs zone dict metaspace chunks hand code cache ] |
35061 | 52 |
public static final String VERIFY_AFTER_GC_PATTERN = "Verifying After GC"; |
30179 | 53 |
// VerifyAfterGC: VerifyAfterGC: VerifyAfterGC: |
54 |
public static final String VERIFY_AFTER_GC_CORRUPTED_PATTERN = "VerifyAfterGC:(?!\\[Verifying[^]]+\\])"; |
|
55 |
||
56 |
public static void main(String args[]) throws Exception { |
|
57 |
String[] filteredOpts = Utils.getFilteredTestJavaOpts( |
|
35061 | 58 |
new String[] { "-Xlog:gc+verify=debug", |
30179 | 59 |
"-XX:+UseGCLogFileRotation", |
60 |
"-XX:-DisplayVMOutput", |
|
61 |
"VerifyBeforeGC", |
|
62 |
"VerifyAfterGC" }); |
|
63 |
testVerifyFlags(false, false, filteredOpts); |
|
64 |
testVerifyFlags(true, true, filteredOpts); |
|
65 |
testVerifyFlags(true, false, filteredOpts); |
|
66 |
testVerifyFlags(false, true, filteredOpts); |
|
67 |
} |
|
68 |
||
69 |
public static void testVerifyFlags(boolean verifyBeforeGC, |
|
70 |
boolean verifyAfterGC, |
|
71 |
String[] opts) throws Exception { |
|
72 |
ArrayList<String> vmOpts = new ArrayList<>(); |
|
73 |
if (opts != null && (opts.length > 0)) { |
|
74 |
Collections.addAll(vmOpts, opts); |
|
75 |
} |
|
76 |
||
77 |
Collections.addAll(vmOpts, new String[] { |
|
35061 | 78 |
"-Xlog:gc+verify=debug", |
30179 | 79 |
"-Xmx5m", |
80 |
"-Xms5m", |
|
81 |
"-Xmn3m", |
|
82 |
"-XX:+UnlockDiagnosticVMOptions", |
|
83 |
(verifyBeforeGC ? "-XX:+VerifyBeforeGC" |
|
84 |
: "-XX:-VerifyBeforeGC"), |
|
85 |
(verifyAfterGC ? "-XX:+VerifyAfterGC" |
|
86 |
: "-XX:-VerifyAfterGC"), |
|
87 |
GarbageProducer.class.getName() }); |
|
88 |
ProcessBuilder procBuilder = |
|
89 |
ProcessTools.createJavaProcessBuilder(vmOpts.toArray( |
|
90 |
new String[vmOpts.size()])); |
|
91 |
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); |
|
92 |
||
93 |
analyzer.shouldHaveExitValue(0); |
|
94 |
analyzer.shouldNotMatch(VERIFY_BEFORE_GC_CORRUPTED_PATTERN); |
|
95 |
analyzer.shouldNotMatch(VERIFY_AFTER_GC_CORRUPTED_PATTERN); |
|
96 |
||
97 |
if (verifyBeforeGC) { |
|
98 |
analyzer.shouldMatch(VERIFY_BEFORE_GC_PATTERN); |
|
99 |
} else { |
|
100 |
analyzer.shouldNotMatch(VERIFY_BEFORE_GC_PATTERN); |
|
101 |
} |
|
102 |
||
103 |
if (verifyAfterGC) { |
|
104 |
analyzer.shouldMatch(VERIFY_AFTER_GC_PATTERN); |
|
105 |
} else { |
|
106 |
analyzer.shouldNotMatch(VERIFY_AFTER_GC_PATTERN); |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
public static class GarbageProducer { |
|
111 |
static long[][] garbage = new long[10][]; |
|
112 |
||
113 |
public static void main(String args[]) { |
|
114 |
int j = 0; |
|
115 |
for(int i = 0; i<1000; i++) { |
|
116 |
garbage[j] = new long[10000]; |
|
117 |
j = (j+1)%garbage.length; |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
} |