Java Code Examples for jdk.test.lib.process.OutputAnalyzer#shouldNotMatch()

The following examples show how to use jdk.test.lib.process.OutputAnalyzer#shouldNotMatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMultipleXlogArgs.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=debug",
                                                              "-Xlog:logging=trace",
                                                              "-Xlog:defaultmethods=trace",
                                                              "-Xlog:defaultmethods=off",
                                                              "-Xlog:safepoint=info",
                                                              "-Xlog:safepoint=info",
                                                              "-version");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    // -Xlog:logging=trace means that the log configuration will be printed.
    String stdoutConfigLine = "\\[logging *\\] #0: stdout .*";
    // Ensure logging=trace has overwritten logging=debug
    output.shouldMatch(stdoutConfigLine + "logging=trace").shouldNotMatch(stdoutConfigLine + "logging=debug");
    // Make sure safepoint=info is printed exactly once even though we're setting it twice
    output.shouldMatch(stdoutConfigLine + "safepoint=info").shouldNotMatch(stdoutConfigLine + "safepoint=info.*safepoint=info");
    // Shouldn't see defaultmethods at all, because disabled tags are not listed
    output.shouldNotMatch(stdoutConfigLine + "defaultmethods");
    output.shouldHaveExitValue(0);
}
 
Example 2
Source File: TestMetaspaceSizeFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception {
  OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize);
  output.shouldNotMatch("Error occurred during initialization of VM\n.*");

  String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* = (\\d+).*", 1);
  String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* = (\\d+).*", 1);

  return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize),
                            Long.parseLong(stringMetaspaceSize));
}
 
Example 3
Source File: TestCMSClassUnloadingEnabledHWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testWithoutCMSClassUnloading() throws Exception {
  // -XX:-CMSClassUnloadingEnabled is used, so we expect a full GC instead of a concurrent cycle.
  OutputAnalyzer out = runWithoutCMSClassUnloading();

  out.shouldMatch(".*Pause Full.*");
  out.shouldNotMatch(".*Pause Initial Mark.*");
}
 
Example 4
Source File: TestCMSClassUnloadingEnabledHWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testWithCMSClassUnloading() throws Exception {
  // -XX:+CMSClassUnloadingEnabled is used, so we expect a concurrent cycle instead of a full GC.
  OutputAnalyzer out = runWithCMSClassUnloading();

  out.shouldMatch(".*Pause Initial Mark.*");
  out.shouldNotMatch(".*Pause Full.*");
}
 
Example 5
Source File: TestG1ClassUnloadingHWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testWithoutG1ClassUnloading() throws Exception {
  // -XX:-ClassUnloadingWithConcurrentMark is used, so we expect a full GC instead of a concurrent cycle.
  OutputAnalyzer out = runWithoutG1ClassUnloading();

  out.shouldMatch(".*Pause Full.*");
  out.shouldNotMatch(".*Pause Initial Mark.*");
}
 
Example 6
Source File: TestG1ClassUnloadingHWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testWithG1ClassUnloading() throws Exception {
  // -XX:+ClassUnloadingWithConcurrentMark is used, so we expect a concurrent cycle instead of a full GC.
  OutputAnalyzer out = runWithG1ClassUnloading();

  out.shouldMatch(".*Pause Initial Mark.*");
  out.shouldNotMatch(".*Pause Full.*");
}
 
Example 7
Source File: TestVerifyBeforeAndAfterGCFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testVerifyFlags(boolean verifyBeforeGC,
                                   boolean verifyAfterGC,
                                   String[] opts) throws Exception {
    ArrayList<String> vmOpts = new ArrayList<>();
    if (opts != null && (opts.length > 0)) {
        Collections.addAll(vmOpts, opts);
    }

    Collections.addAll(vmOpts, new String[] {
                                   "-Xlog:gc+verify=debug",
                                   "-Xmx5m",
                                   "-Xms5m",
                                   "-Xmn3m",
                                   "-XX:+UnlockDiagnosticVMOptions",
                                   (verifyBeforeGC ? "-XX:+VerifyBeforeGC"
                                                   : "-XX:-VerifyBeforeGC"),
                                   (verifyAfterGC ? "-XX:+VerifyAfterGC"
                                                  : "-XX:-VerifyAfterGC"),
                                   GarbageProducer.class.getName() });
    ProcessBuilder procBuilder =
        ProcessTools.createJavaProcessBuilder(vmOpts.toArray(
                                               new String[vmOpts.size()]));
    OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());

    analyzer.shouldHaveExitValue(0);
    analyzer.shouldNotMatch(VERIFY_BEFORE_GC_CORRUPTED_PATTERN);
    analyzer.shouldNotMatch(VERIFY_AFTER_GC_CORRUPTED_PATTERN);

    if (verifyBeforeGC) {
        analyzer.shouldMatch(VERIFY_BEFORE_GC_PATTERN);
    } else {
        analyzer.shouldNotMatch(VERIFY_BEFORE_GC_PATTERN);
    }

    if (verifyAfterGC) {
        analyzer.shouldMatch(VERIFY_AFTER_GC_PATTERN);
    } else {
        analyzer.shouldNotMatch(VERIFY_AFTER_GC_PATTERN);
    }
}
 
Example 8
Source File: ProblematicFrameTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName());
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldNotContain("Exception in thread");
    output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)");
}
 
Example 9
Source File: JcmdAsserts.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void assertRecordingNotRunning(OutputAnalyzer output, String name) {
    output.shouldNotMatch(".*" + name + ".*running");
}
 
Example 10
Source File: JcmdAsserts.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void assertRecordingNotRunning(OutputAnalyzer output, String name) {
    output.shouldNotMatch(".*" + name + ".*running");
}
 
Example 11
Source File: PrintTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run(CommandExecutor executor) {
    MonitorThread mThread = new MonitorThread();
    mThread.start();
    LockThread lThread = new LockThread();
    lThread.start();

    /* Wait for threads to get ready */
    waitForBarrier(readyBarrier);

    /* Execute */
    OutputAnalyzer output = executor.execute("Thread.print" + (jucLocks ? " -l=true" : ""));

    /* Signal that we've got the thread dump */
    waitForBarrier(doneBarrier);

    /*
     * Example output (trimmed) with arrows indicating the rows we are looking for:
     *
     *     ...
     *     "Thread-2" #24 prio=5 os_prio=0 tid=0x00007f913411f800 nid=0x4fc9 waiting on condition [0x00007f91fbffe000]
     *        java.lang.Thread.State: WAITING (parking)
     *       at sun.misc.Unsafe.park(Native Method)
     *       - parking to wait for  <0x000000071a0868a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
     *       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
     *       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
     *       at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:234)
     *       at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:362)
     *       at Print.waitForBarrier(Print.java:26)
     *       at Print.access$000(Print.java:18)
     *       at Print$LockThread.run(Print.java:58)
     *
     * -->    Locked ownable synchronizers:
     * -->    - <0x000000071a294930> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
     *
     *     "Thread-1" #23 prio=5 os_prio=0 tid=0x00007f913411e800 nid=0x4fc8 waiting on condition [0x00007f9200113000]
     *        java.lang.Thread.State: WAITING (parking)
     *       at sun.misc.Unsafe.park(Native Method)
     *       - parking to wait for  <0x000000071a0868a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
     *       at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
     *       at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
     *       at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:234)
     *       at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:362)
     *       at Print.waitForBarrier(Print.java:26)
     *       at Print.access$000(Print.java:18)
     *       at Print$MonitorThread.run(Print.java:42)
     * -->   - locked <0x000000071a294390> (a java.lang.Object)
     *
     *        Locked ownable synchronizers:
     *       - None
     *
     *     "MainThread" #22 prio=5 os_prio=0 tid=0x00007f923015b000 nid=0x4fc7 in Object.wait() [0x00007f9200840000]
     *        java.lang.Thread.State: WAITING (on object monitor)
     *       at java.lang.Object.wait(Native Method)
     *       - waiting on <0x000000071a70ad98> (a java.lang.UNIXProcess)
     *       at java.lang.Object.wait(Object.java:502)
     *        at java.lang.UNIXProcess.waitFor(UNIXProcess.java:397)
     *        - locked <0x000000071a70ad98> (a java.lang.UNIXProcess)
     *        at jdk.test.lib.dcmd.JcmdExecutor.executeImpl(JcmdExecutor.java:32)
     *       at jdk.test.lib.dcmd.CommandExecutor.execute(CommandExecutor.java:24)
     * -->   at Print.run(Print.java:74)
     *       at Print.file(Print.java:112)
     *     ...

     */
    output.shouldMatch(".*at " + Pattern.quote(PrintTest.class.getName()) + "\\.run.*");
    output.shouldMatch(".*- locked <0x\\p{XDigit}+> \\(a " + Pattern.quote(mThread.lock.getClass().getName()) + "\\).*");

    String jucLockPattern1 = ".*Locked ownable synchronizers:.*";
    String jucLockPattern2 = ".*- <0x\\p{XDigit}+> \\(a " + Pattern.quote(lThread.lock.getClass().getName()) + ".*";

    if (jucLocks) {
        output.shouldMatch(jucLockPattern1);
        output.shouldMatch(jucLockPattern2);
    } else {
        output.shouldNotMatch(jucLockPattern1);
        output.shouldNotMatch(jucLockPattern2);
    }
}