< prev index next >

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

Print this page
rev 56635 : v2.00 -> v2.05 (CR5/v2.05/8-for-jdk13) patches combined into one; merge with 8229212.patch; merge with jdk-14+11; merge with 8230184.patch; merge with 8230876.patch; merge with jdk-14+15; merge with jdk-14+18.


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8149991
  27  * @summary safepoint+cleanup=info should have output from the code
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @run driver SafepointCleanupTest

  32  */
  33 
  34 import jdk.test.lib.process.OutputAnalyzer;
  35 import jdk.test.lib.process.ProcessTools;
  36 
  37 public class SafepointCleanupTest {




  38     static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
  39         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  40         output.shouldContain("[safepoint,cleanup]");
  41         output.shouldContain("safepoint cleanup tasks");
  42         output.shouldContain("deflating global idle monitors");
  43         output.shouldContain("deflating per-thread idle monitors");
  44         output.shouldContain("updating inline caches");
  45         output.shouldContain("compilation policy safepoint handler");
  46         output.shouldHaveExitValue(0);
  47     }
  48 
  49     static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
  50         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  51         output.shouldNotContain("[safepoint,cleanup]");
  52         output.shouldHaveExitValue(0);
  53     }
  54 
  55     public static void main(String[] args) throws Exception {













  56         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=info",


  57                                                                   InnerClass.class.getName());
  58         analyzeOutputOn(pb);
  59 
  60         pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceSafepointCleanupTime",


  61                                                    InnerClass.class.getName());
  62         analyzeOutputOn(pb);
  63 
  64         pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=off",


  65                                                    InnerClass.class.getName());
  66         analyzeOutputOff(pb);
  67 
  68         pb = ProcessTools.createJavaProcessBuilder("-XX:-TraceSafepointCleanupTime",


  69                                                    InnerClass.class.getName());
  70         analyzeOutputOff(pb);
  71     }
  72 
  73     public static class InnerClass {
  74         public static void main(String[] args) throws Exception {
  75             System.out.println("Safepoint Cleanup test");
  76         }
  77     }
  78 }


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8149991
  27  * @summary safepoint+cleanup=info should have output from the code
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @run driver SafepointCleanupTest
  32  * @run driver SafepointCleanupTest -XX:+AsyncDeflateIdleMonitors
  33  */
  34 
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 import jdk.test.lib.process.ProcessTools;
  37 
  38 public class SafepointCleanupTest {
  39     static final String ASYNC_DISABLE_OPTION = "-XX:-AsyncDeflateIdleMonitors";
  40     static final String ASYNC_ENABLE_OPTION = "-XX:+AsyncDeflateIdleMonitors";
  41     static final String UNLOCK_DIAG_OPTION = "-XX:+UnlockDiagnosticVMOptions";
  42 
  43     static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
  44         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  45         output.shouldContain("[safepoint,cleanup]");
  46         output.shouldContain("safepoint cleanup tasks");
  47         output.shouldContain("deflating global idle monitors");
  48         output.shouldContain("deflating per-thread idle monitors");
  49         output.shouldContain("updating inline caches");
  50         output.shouldContain("compilation policy safepoint handler");
  51         output.shouldHaveExitValue(0);
  52     }
  53 
  54     static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
  55         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  56         output.shouldNotContain("[safepoint,cleanup]");
  57         output.shouldHaveExitValue(0);
  58     }
  59 
  60     public static void main(String[] args) throws Exception {
  61         String async_option;
  62         if (args.length == 0) {
  63             // By default test deflating idle monitors at a safepoint.
  64             async_option = ASYNC_DISABLE_OPTION;
  65         } else {
  66             async_option = args[0];
  67         }
  68         if (!async_option.equals(ASYNC_DISABLE_OPTION) &&
  69             !async_option.equals(ASYNC_ENABLE_OPTION)) {
  70             throw new RuntimeException("Unknown async_option value: '"
  71                                        + async_option + "'");
  72         }
  73 
  74         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=info",
  75                                                                   UNLOCK_DIAG_OPTION,
  76                                                                   async_option,
  77                                                                   InnerClass.class.getName());
  78         analyzeOutputOn(pb);
  79 
  80         pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceSafepointCleanupTime",
  81                                                    UNLOCK_DIAG_OPTION,
  82                                                    async_option,
  83                                                    InnerClass.class.getName());
  84         analyzeOutputOn(pb);
  85 
  86         pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=off",
  87                                                    UNLOCK_DIAG_OPTION,
  88                                                    async_option,
  89                                                    InnerClass.class.getName());
  90         analyzeOutputOff(pb);
  91 
  92         pb = ProcessTools.createJavaProcessBuilder("-XX:-TraceSafepointCleanupTime",
  93                                                    UNLOCK_DIAG_OPTION,
  94                                                    async_option,
  95                                                    InnerClass.class.getName());
  96         analyzeOutputOff(pb);
  97     }
  98 
  99     public static class InnerClass {
 100         public static void main(String[] args) throws Exception {
 101             System.out.println("Safepoint Cleanup test");
 102         }
 103     }
 104 }
< prev index next >