changeset 8465:2ece51774dfa

8081037: serviceability/sa/ tests time out on Windows Reviewed-by: jbachorik, sla, dsamersoff
author ykantser
date Wed, 27 May 2015 14:13:20 +0200
parents e34d0b105465
children 6c95d9792c36
files test/serviceability/sa/TestClassLoaderStats.java test/serviceability/sa/TestStackTrace.java
diffstat 2 files changed, 44 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/test/serviceability/sa/TestClassLoaderStats.java	Thu May 28 11:37:13 2015 -0700
+++ b/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/test/serviceability/sa/TestStackTrace.java	Thu May 28 11:37:13 2015 -0700
+++ b/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();
+        }
      }
 
 }