test/jdk/jdk/jfr/jcmd/JcmdHelper.java
changeset 50226 408021edf22f
parent 50113 caf115bb98ad
equal deleted inserted replaced
50225:2942ae532175 50226:408021edf22f
    41         long timeoutAt = System.currentTimeMillis() + 10000;
    41         long timeoutAt = System.currentTimeMillis() + 10000;
    42         while (true) {
    42         while (true) {
    43             OutputAnalyzer output = jcmdCheck(name, false);
    43             OutputAnalyzer output = jcmdCheck(name, false);
    44             try {
    44             try {
    45                 // The expected output can look like this:
    45                 // The expected output can look like this:
    46                 // Recording: recording=1 name="Recording 1" (running)
    46                 // Recording 1: name=1 (running)
    47                 output.shouldMatch("^Recording: recording=\\d+\\s+name=\"" + name
    47                 output.shouldMatch("^Recording \\d+: name=" + name
    48                         + "\".*\\W{1}running\\W{1}");
    48                         + " .*\\W{1}running\\W{1}");
    49                 return;
    49                 return;
    50             } catch (RuntimeException e) {
    50             } catch (RuntimeException e) {
    51                 if (System.currentTimeMillis() > timeoutAt) {
    51                 if (System.currentTimeMillis() > timeoutAt) {
    52                     Asserts.fail("Recording not started: " + name);
    52                     Asserts.fail("Recording not started: " + name);
    53                 }
    53                 }
    54                 Thread.sleep(100);
       
    55             }
       
    56         }
       
    57     }
       
    58 
       
    59     // Wait until default recording's state became running
       
    60     public static void waitUntilDefaultRecordingRunning() throws Exception {
       
    61         while (true) {
       
    62             OutputAnalyzer output = jcmd("JFR.check", "recording=0");
       
    63             try {
       
    64                 output.shouldContain("Recording: recording=0 name=\"HotSpot default\" (running)");
       
    65                 return;
       
    66             } catch (RuntimeException e) {
       
    67                 Thread.sleep(100);
    54                 Thread.sleep(100);
    68             }
    55             }
    69         }
    56         }
    70     }
    57     }
    71 
    58