8081037: serviceability/sa/ tests time out on Windows
authorykantser
Wed, 27 May 2015 14:13:20 +0200
changeset 31018 794e08f6dad4
parent 30886 d2a0ec86d6ef
child 31020 1fccb11d53d8
8081037: serviceability/sa/ tests time out on Windows Reviewed-by: jbachorik, sla, dsamersoff
hotspot/test/serviceability/sa/TestClassLoaderStats.java
hotspot/test/serviceability/sa/TestStackTrace.java
--- a/hotspot/test/serviceability/sa/TestClassLoaderStats.java	Thu May 28 11:37:13 2015 -0700
+++ b/hotspot/test/serviceability/sa/TestClassLoaderStats.java	Wed May 27 14:13:20 2015 +0200
@@ -24,11 +24,14 @@
 import jdk.test.lib.Platform;
 import jdk.test.lib.ProcessTools;
 import jdk.test.lib.OutputAnalyzer;
+import jdk.test.lib.apps.LingeredApp;
 
 /*
  * @test
+ * @library /../../test/lib/share/classes
  * @library /testlibrary
  * @build jdk.test.lib.*
+ * @build jdk.test.lib.apps.*
  * @run main TestClassLoaderStats
  */
 public class TestClassLoaderStats {
@@ -39,19 +42,27 @@
             return;
         }
 
-        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
-                "-XX:+UsePerfData",
-                "sun.jvm.hotspot.tools.ClassLoaderStats",
-                Integer.toString(ProcessTools.getProcessId()));
-        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
-        System.out.println(output.getOutput());
+        LingeredApp app = null;
+        try {
+            app = LingeredApp.startApp();
 
-        output.shouldHaveExitValue(0);
-        output.shouldContain("Debugger attached successfully.");
-        // The class loader stats header needs to be presented in the output:
-        output.shouldMatch("class_loader\\W+classes\\W+bytes\\W+parent_loader\\W+alive?\\W+type");
-        output.stderrShouldNotMatch("[E|e]xception");
-        output.stderrShouldNotMatch("[E|e]rror");
+            System.out.println("Attaching sun.jvm.hotspot.tools.ClassLoaderStats to " + app.getPid());
+            ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
+                    "-XX:+UsePerfData",
+                    "sun.jvm.hotspot.tools.ClassLoaderStats",
+                    Long.toString(app.getPid()));
+            OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
+            System.out.println(output.getOutput());
+
+            output.shouldHaveExitValue(0);
+            output.shouldContain("Debugger attached successfully.");
+            // The class loader stats header needs to be presented in the output:
+            output.shouldMatch("class_loader\\W+classes\\W+bytes\\W+parent_loader\\W+alive?\\W+type");
+            output.stderrShouldNotMatch("[E|e]xception");
+            output.stderrShouldNotMatch("[E|e]rror");
+        } finally {
+            app.stopApp();
+        }
     }
 
 }
--- a/hotspot/test/serviceability/sa/TestStackTrace.java	Thu May 28 11:37:13 2015 -0700
+++ b/hotspot/test/serviceability/sa/TestStackTrace.java	Wed May 27 14:13:20 2015 +0200
@@ -24,11 +24,14 @@
 import jdk.test.lib.OutputAnalyzer;
 import jdk.test.lib.Platform;
 import jdk.test.lib.ProcessTools;
+import jdk.test.lib.apps.LingeredApp;
 
 /*
  * @test
+ * @library /../../test/lib/share/classes
  * @library /testlibrary
  * @build jdk.test.lib.*
+ * @build jdk.test.lib.apps.*
  * @run main TestStackTrace
  */
 public class TestStackTrace {
@@ -39,17 +42,25 @@
             return;
         }
 
-        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
-                "-XX:+UsePerfData",
-                "sun.jvm.hotspot.tools.StackTrace",
-                Integer.toString(ProcessTools.getProcessId()));
-        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
-        System.out.println(output.getOutput());
+        LingeredApp app = null;
+        try {
+            app = LingeredApp.startApp();
 
-        output.shouldHaveExitValue(0);
-        output.shouldContain("Debugger attached successfully.");
-        output.stderrShouldNotMatch("[E|e]xception");
-        output.stderrShouldNotMatch("[E|e]rror");
+            System.out.println("Attaching sun.jvm.hotspot.tools.StackTrace to " + app.getPid());
+            ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
+                    "-XX:+UsePerfData",
+                    "sun.jvm.hotspot.tools.StackTrace",
+                    Long.toString(app.getPid()));
+            OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
+            System.out.println(output.getOutput());
+
+            output.shouldHaveExitValue(0);
+            output.shouldContain("Debugger attached successfully.");
+            output.stderrShouldNotMatch("[E|e]xception");
+            output.stderrShouldNotMatch("[E|e]rror");
+        } finally {
+            app.stopApp();
+        }
      }
 
 }