author | dsamersoff |
Sun, 01 May 2016 12:47:00 +0300 | |
changeset 38152 | 80e5da81fb2c |
parent 38083 | 2ffb46735fec |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
1 |
/* |
38083
2ffb46735fec
8154843: GC tests should be correctly marked with @module
mchernov
parents:
35061
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
4 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
8 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
14 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
18 |
* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
22 |
*/ |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
23 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
24 |
/* |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
25 |
* @test TestDisableExplicitGC |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
26 |
* @requires vm.opt.DisableExplicitGC == null |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
27 |
* @summary Verify GC behavior with DisableExplicitGC flag. |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
28 |
* @library /testlibrary |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
38083
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
38083
2ffb46735fec
8154843: GC tests should be correctly marked with @module
mchernov
parents:
35061
diff
changeset
|
30 |
* @modules jdk.management/com.sun.management.internal |
35061 | 31 |
* @run main/othervm -Xlog:gc=debug TestDisableExplicitGC |
32 |
* @run main/othervm/fail -XX:+DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC |
|
33 |
* @run main/othervm -XX:-DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC |
|
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
34 |
*/ |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
35 |
import java.lang.management.GarbageCollectorMXBean; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
36 |
import java.util.List; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29682
diff
changeset
|
37 |
import static jdk.test.lib.Asserts.*; |
29682
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
38 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
39 |
public class TestDisableExplicitGC { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
40 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
41 |
public static void main(String[] args) throws InterruptedException { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
42 |
List<GarbageCollectorMXBean> list = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
43 |
long collectionCountBefore = getCollectionCount(list); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
44 |
System.gc(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
45 |
long collectionCountAfter = getCollectionCount(list); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
46 |
assertLT(collectionCountBefore, collectionCountAfter); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
47 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
48 |
|
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
49 |
private static long getCollectionCount(List<GarbageCollectorMXBean> list) { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
50 |
int collectionCount = 0; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
51 |
for (GarbageCollectorMXBean gcMXBean : list) { |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
52 |
collectionCount += gcMXBean.getCollectionCount(); |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
53 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
54 |
return collectionCount; |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
55 |
} |
5e1737bfb1bb
8026047: [TESTBUG] add regression test for DisableExplicitGC flag
iignatyev
parents:
diff
changeset
|
56 |
} |