8163805: hotspot/test/serviceability/sa/sadebugd/SADebugDTest.java failed with timed out

Reviewed-by: cjplummer, jcbeyler
This commit is contained in:
Yasumasa Suenaga 2019-05-18 15:42:21 +09:00
parent 8d98b75f47
commit 3b8d8d0a89
2 changed files with 25 additions and 34 deletions
test/hotspot/jtreg
ProblemList.txt
serviceability/sa/sadebugd

@ -114,7 +114,6 @@ serviceability/sa/ClhsdbWhere.java 8193639,8211767 solaris-all,linux-ppc64le,lin
serviceability/sa/DeadlockDetectionTest.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
serviceability/sa/JhsdbThreadInfoTest.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8193639 solaris-all
serviceability/sa/sadebugd/SADebugDTest.java 8163805 generic-all
serviceability/sa/TestClassDump.java 8193639 solaris-all
serviceability/sa/TestClhsdbJstackLock.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
serviceability/sa/TestCpoolForInvokeDynamic.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,50 +32,42 @@
* @run main/othervm SADebugDTest
*/
import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.Reader;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import static jdk.test.lib.Asserts.assertTrue;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.JDKToolLauncher;
import static jdk.test.lib.process.ProcessTools.startProcess;
public class SADebugDTest {
private static final String GOLDEN = "Attaching to process ID %d and starting RMI services, please wait...";
private static final String JAVA_HOME = (System.getProperty("test.jdk") != null)
? System.getProperty("test.jdk") : System.getProperty("java.home");
private static final String JAVA_BIN_DIR
= JAVA_HOME + File.separator + "bin" + File.separator;
private static final String JHSDB = JAVA_BIN_DIR + "jhsdb";
private static final String GOLDEN = "Attaching to process";
public static void main(String[] args) throws Exception {
LingeredApp app = null;
long ourPid = ProcessHandle.current().pid();
try {
app = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + app.getPid());
// The string we are expecting in the debugd ouput
String golden = String.format(GOLDEN, ourPid);
JDKToolLauncher jhsdbLauncher = JDKToolLauncher.createUsingTestJDK("jhsdb");
jhsdbLauncher.addToolArg("debugd");
jhsdbLauncher.addToolArg("--pid");
jhsdbLauncher.addToolArg(Long.toString(app.getPid()));
ProcessBuilder pb = new ProcessBuilder(jhsdbLauncher.getCommand());
// We are going to run 'jhsdb debugd <our pid>'
// The startProcess will block untl the 'golden' string appears in either process' stdout or stderr
// In case of timeout startProcess kills the debugd process
ProcessBuilder pb = new ProcessBuilder();
pb.command(JHSDB, "debugd", String.valueOf(ourPid));
Process debugd = startProcess("debugd", pb, null, (line) -> line.trim().contains(golden), 0, TimeUnit.SECONDS);
// The startProcess will block untl the 'golden' string appears in either process' stdout or stderr
// In case of timeout startProcess kills the debugd process
Process debugd = startProcess("debugd", pb, null, l -> l.contains(GOLDEN), 0, TimeUnit.SECONDS);
// If we are here, this means we have received the golden line and the test has passed
// The debugd remains running, we have to kill it
debugd.destroy();
// If we are here, this means we have received the golden line and the test has passed
// The debugd remains running, we have to kill it
debugd.destroy();
} finally {
if (app != null) {
LingeredApp.stopApp(app);
}
}
}
private static void log(String string) {
System.out.println(string);
}
}