< prev index next >

test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java

Print this page

21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 8133885
27  * @summary monitorinflation=trace should have logging from each of the statements in the code
28  * @requires vm.flagless
29  * @library /test/lib
30  * @modules java.base/jdk.internal.misc
31  *          java.management
32  * @run driver MonitorInflationTest
33  */
34 
35 import jdk.test.lib.process.OutputAnalyzer;
36 import jdk.test.lib.process.ProcessTools;
37 
38 public class MonitorInflationTest {
39     static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
40         OutputAnalyzer output = new OutputAnalyzer(pb.start());
41         output.shouldContain("inflate(has_locker):");
42         output.shouldContain("type='MonitorInflationTest$Waiter'");
43         output.shouldContain("I've been waiting.");
44         output.shouldHaveExitValue(0);
45     }
46 
47     static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
48         OutputAnalyzer output = new OutputAnalyzer(pb.start());
49         output.shouldNotContain("[monitorinflation]");
50         output.shouldHaveExitValue(0);
51     }
52 
53     public static void main(String[] args) throws Exception {
54         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=trace",
55                                                                   InnerClass.class.getName());
56         analyzeOutputOn(pb);
57 
58         pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=off",
59                                                    InnerClass.class.getName());
60         analyzeOutputOff(pb);
61     }

21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 8133885
27  * @summary monitorinflation=trace should have logging from each of the statements in the code
28  * @requires vm.flagless
29  * @library /test/lib
30  * @modules java.base/jdk.internal.misc
31  *          java.management
32  * @run driver MonitorInflationTest
33  */
34 
35 import jdk.test.lib.process.OutputAnalyzer;
36 import jdk.test.lib.process.ProcessTools;
37 
38 public class MonitorInflationTest {
39     static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
40         OutputAnalyzer output = new OutputAnalyzer(pb.start());
41         output.shouldContain("inflate(locked):");
42         output.shouldContain("type='MonitorInflationTest$Waiter'");
43         output.shouldContain("I've been waiting.");
44         output.shouldHaveExitValue(0);
45     }
46 
47     static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
48         OutputAnalyzer output = new OutputAnalyzer(pb.start());
49         output.shouldNotContain("[monitorinflation]");
50         output.shouldHaveExitValue(0);
51     }
52 
53     public static void main(String[] args) throws Exception {
54         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=trace",
55                                                                   InnerClass.class.getName());
56         analyzeOutputOn(pb);
57 
58         pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=off",
59                                                    InnerClass.class.getName());
60         analyzeOutputOff(pb);
61     }
< prev index next >