changeset 54931:13507abf416c

8163805: hotspot/test/serviceability/sa/sadebugd/SADebugDTest.java failed with timed out Reviewed-by: cjplummer, jcbeyler
author ysuenaga
date Sat, 18 May 2019 15:42:21 +0900
parents 43633b8e24c6
children 0f934da77390
files test/hotspot/jtreg/ProblemList.txt test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java
diffstat 2 files changed, 25 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/ProblemList.txt	Fri May 17 12:52:46 2019 -0700
+++ b/test/hotspot/jtreg/ProblemList.txt	Sat May 18 15:42:21 2019 +0900
@@ -114,7 +114,6 @@
 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
--- a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java	Fri May 17 12:52:46 2019 -0700
+++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java	Sat May 18 15:42:21 2019 +0900
@@ -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);
-    }
-
 }