Mercurial > hg > truffle
annotate test/gc/whitebox/TestWBGC.java @ 20541:e3ed86fc15ed
8043766: CMM Testing: 8u40 Decommit auxiliary data structures
Summary: Check that native memory is returned to the system when decommiting memory within the heap with G1.
Reviewed-by: tschatzl, jwilhelm
Contributed-by: Andrey Zakharov <andrey.x.zakharov@oracle.com>
author | tschatzl |
---|---|
date | Mon, 29 Sep 2014 09:59:23 +0200 |
parents | b95d569d10c1 |
children |
rev | line source |
---|---|
20358
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
1 /* |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
4 * |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
8 * |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
13 * accompanied this code). |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
14 * |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
18 * |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
21 * questions. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
22 */ |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
23 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
24 /* |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
25 * @test TestWBGC |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
26 * @bug 8055098 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
27 * @summary Test verify that WB methods isObjectInOldGen and youngGC works correctly. |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
28 * @library /testlibrary /testlibrary/whitebox |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
29 * @build TestWBGC |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
31 * @run driver TestWBGC |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
32 */ |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
33 import com.oracle.java.testlibrary.*; |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
34 import sun.hotspot.WhiteBox; |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
35 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
36 public class TestWBGC { |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
37 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
38 public static void main(String args[]) throws Exception { |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
40 true, |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
41 "-Xbootclasspath/a:.", |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
42 "-XX:+UnlockDiagnosticVMOptions", |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
43 "-XX:+WhiteBoxAPI", |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
44 "-XX:MaxTenuringThreshold=1", |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
45 "-XX:+PrintGC", |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
46 GCYoungTest.class.getName()); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
47 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
48 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
49 System.out.println(output.getStdout()); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
50 output.shouldHaveExitValue(0); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
51 output.shouldContain("WhiteBox Initiated Young GC"); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
52 output.shouldNotContain("Full"); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
53 // To be sure that we don't provoke Full GC additionaly to young |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
54 } |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
55 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
56 public static class GCYoungTest { |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
57 static WhiteBox wb = WhiteBox.getWhiteBox(); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
58 public static Object obj; |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
59 |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
60 public static void main(String args[]) { |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
61 obj = new Object(); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
62 Asserts.assertFalse(wb.isObjectInOldGen(obj)); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
63 wb.youngGC(); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
64 wb.youngGC(); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
65 // 2 young GC is needed to promote object into OldGen |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
66 Asserts.assertTrue(wb.isObjectInOldGen(obj)); |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
67 } |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
68 } |
b95d569d10c1
8055953: [TESTBUG] Fix for 8055098 does not contain unit test
tschatzl
parents:
diff
changeset
|
69 } |