8152950: BasicLauncherTest.java fails due to type error
authordsamersoff
Fri, 27 May 2016 19:31:41 +0300
changeset 38795 38396b00345e
parent 38794 4e7b5866fd50
child 38796 b1009e5edbc0
8152950: BasicLauncherTest.java fails due to type error Summary: Better handle js engine initialization error Reviewed-by: jbachorik
jdk/test/sun/tools/jhsdb/BasicLauncherTest.java
--- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Thu May 26 14:24:50 2016 -0700
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Fri May 27 19:31:41 2016 +0300
@@ -49,14 +49,26 @@
 
 public class BasicLauncherTest {
 
-    private final static String toolName = "jhsdb";
     private static LingeredApp theApp = null;
+    private static boolean useJavaLauncher = false;
 
-    /**
-     *
-     * @return exit code of tool
-     */
-    public static int launchCLHSDB()
+    private static JDKToolLauncher createSALauncher() {
+        JDKToolLauncher launcher = null;
+        if (useJavaLauncher) {
+            // Use java launcher if we need to pass additional parameters to VM
+            // for debugging purpose
+            // e.g. -Xlog:class+load=info:file=/tmp/BasicLauncherTest.log
+            launcher = JDKToolLauncher.createUsingTestJDK("java");
+            launcher.addToolArg("sun.jvm.hotspot.SALauncher");
+        }
+        else {
+            launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+        }
+
+        return launcher;
+    }
+
+    public static void launchCLHSDB()
         throws IOException {
 
         System.out.println("Starting LingeredApp");
@@ -64,7 +76,7 @@
             theApp = LingeredApp.startApp();
 
             System.out.println("Starting clhsdb against " + theApp.getPid());
-            JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
+            JDKToolLauncher launcher = createSALauncher();
             launcher.addToolArg("clhsdb");
             launcher.addToolArg("--pid=" + Long.toString(theApp.getPid()));
 
@@ -84,7 +96,9 @@
 
             toolProcess.waitFor();
 
-            return toolProcess.exitValue();
+            if (toolProcess.exitValue() != 0) {
+                throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue());
+            }
         } catch (Exception ex) {
             throw new RuntimeException("Test ERROR " + ex, ex);
         } finally {
@@ -104,8 +118,8 @@
         try {
             theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
 
-            System.out.println("Starting " + toolName + " " + toolArgs.get(0) + " against " + theApp.getPid());
-            JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
+            System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid());
+            JDKToolLauncher launcher = createSALauncher();
 
             for (String cmd : toolArgs) {
                 launcher.addToolArg(cmd);