mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
improve TestJcmdTimestamp.java. add '-f <file>
' case
This commit is contained in:
parent
f0c99b0af8
commit
eaea764daf
@ -26,24 +26,26 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.Duration;
|
||||
|
||||
import jdk.test.lib.Asserts;
|
||||
import jdk.test.lib.dcmd.FileJcmdExecutor;
|
||||
import jdk.test.lib.dcmd.PidJcmdExecutor;
|
||||
import jdk.test.lib.dcmd.JcmdExecutor;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary test jcmd generic flag "-T" to make sure dignostic coommand is timestamped
|
||||
*
|
||||
* @library /test/lib
|
||||
*
|
||||
* @run main/othervm TestJcmdTimestamp
|
||||
*/
|
||||
public class TestJcmdTimestamp {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestJcmdTimestamp("VM.version", true /* -T */, true /* expectTimestamp */);
|
||||
TestJcmdTimestamp("VM.version", false /* -T */, false /* expectTimestamp */);
|
||||
TestJcmdTimestamp(new PidJcmdExecutor(), "-T VM.version", true /* expectTimestamp */);
|
||||
TestJcmdTimestamp(new PidJcmdExecutor(), "VM.version", false /* expectTimestamp */);
|
||||
TestJcmdTimestamp(new FileJcmdExecutor(), "-T VM.version", true /* expectTimestamp */);
|
||||
TestJcmdTimestamp(new FileJcmdExecutor(), "VM.version", false /* expectTimestamp */);
|
||||
}
|
||||
|
||||
|
||||
// timestamp should be there and it should be recent
|
||||
public static void assertTimestamp(final String line) throws java.time.format.DateTimeParseException {
|
||||
final String timePattern = "yyyy-MM-dd HH:mm:ss";
|
||||
@ -55,11 +57,11 @@ public class TestJcmdTimestamp {
|
||||
}
|
||||
|
||||
|
||||
private static void TestJcmdTimestamp(final String command, boolean flaged, boolean expectTimestamp) throws Exception {
|
||||
final OutputAnalyzer output = flaged
|
||||
? JcmdBase.jcmd(new String[] {"-T", command})
|
||||
: JcmdBase.jcmd(new String[] {command});
|
||||
private static void TestJcmdTimestamp(final JcmdExecutor executor,
|
||||
final String command,
|
||||
final boolean expectTimestamp) throws Exception {
|
||||
|
||||
OutputAnalyzer output = executor.execute(command);
|
||||
output.shouldHaveExitValue(0);
|
||||
|
||||
final String secondLine = output.getOutput().split("\\r?\\n")[1];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user