31 import java.util.regex.Matcher; |
31 import java.util.regex.Matcher; |
32 |
32 |
33 import jdk.test.lib.Asserts; |
33 import jdk.test.lib.Asserts; |
34 import jdk.test.lib.process.OutputAnalyzer; |
34 import jdk.test.lib.process.OutputAnalyzer; |
35 import jdk.test.lib.process.ProcessTools; |
35 import jdk.test.lib.process.ProcessTools; |
|
36 import jtreg.SkippedException; |
|
37 import sun.hotspot.gc.GC; |
36 import sun.hotspot.WhiteBox; |
38 import sun.hotspot.WhiteBox; |
37 |
39 |
38 /* |
40 /* |
39 * @test TestMetaSpaceLog |
41 * @test TestMetaSpaceLog |
40 * @bug 8211123 |
42 * @bug 8211123 |
41 * @summary Ensure that the Metaspace is updated in the log |
43 * @summary Ensure that the Metaspace is updated in the log |
42 * @requires vm.gc=="null" |
|
43 * @key gc |
44 * @key gc |
44 * @library /test/lib |
45 * @library /test/lib |
45 * @modules java.base/jdk.internal.misc |
46 * @modules java.base/jdk.internal.misc |
46 * java.management |
47 * java.management |
47 * |
48 * |
48 * @compile TestMetaSpaceLog.java |
49 * @compile TestMetaSpaceLog.java |
49 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
50 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
50 * @run main gc.logging.TestMetaSpaceLog |
51 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.logging.TestMetaSpaceLog |
51 */ |
52 */ |
52 |
53 |
53 public class TestMetaSpaceLog { |
54 public class TestMetaSpaceLog { |
54 private static Pattern metaSpaceRegexp; |
55 private static Pattern metaSpaceRegexp; |
55 |
56 |
57 // Do this once here. |
58 // Do this once here. |
58 metaSpaceRegexp = Pattern.compile(".*Metaspace: ([0-9]+).*->([0-9]+).*"); |
59 metaSpaceRegexp = Pattern.compile(".*Metaspace: ([0-9]+).*->([0-9]+).*"); |
59 } |
60 } |
60 |
61 |
61 public static void main(String[] args) throws Exception { |
62 public static void main(String[] args) throws Exception { |
62 testMetaSpaceUpdate("UseParallelGC"); |
63 boolean noneGCSupported = true; |
63 testMetaSpaceUpdate("UseG1GC"); |
64 |
64 testMetaSpaceUpdate("UseConcMarkSweepGC"); |
65 if (GC.Parallel.isSupported()) { |
65 testMetaSpaceUpdate("UseSerialGC"); |
66 noneGCSupported = false; |
|
67 testMetaSpaceUpdate("UseParallelGC"); |
|
68 } |
|
69 if (GC.G1.isSupported()) { |
|
70 noneGCSupported = false; |
|
71 testMetaSpaceUpdate("UseG1GC"); |
|
72 } |
|
73 if (GC.ConcMarkSweep.isSupported()) { |
|
74 noneGCSupported = false; |
|
75 testMetaSpaceUpdate("UseConcMarkSweepGC"); |
|
76 } |
|
77 if (GC.Serial.isSupported()) { |
|
78 noneGCSupported = false; |
|
79 testMetaSpaceUpdate("UseSerialGC"); |
|
80 } |
|
81 if (noneGCSupported) { |
|
82 throw new SkippedException("Skipping test because none of Parallel/G1/ConcMarkSweep/Serial is supported."); |
|
83 } |
66 } |
84 } |
67 |
85 |
68 private static void verifyContainsMetaSpaceUpdate(OutputAnalyzer output) { |
86 private static void verifyContainsMetaSpaceUpdate(OutputAnalyzer output) { |
69 // At least one metaspace line from GC should show GC being collected. |
87 // At least one metaspace line from GC should show GC being collected. |
70 boolean foundCollectedMetaSpace = output.asLines().stream() |
88 boolean foundCollectedMetaSpace = output.asLines().stream() |