8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
authorksrini
Tue, 19 Nov 2013 07:10:06 -0800
changeset 21812 c43ac963db3d
parent 21811 4810bf82fa69
child 21813 f7e97f5bb5a2
8023978: [TEST_BUG] launcher tests must exclude platforms without server vm Reviewed-by: dholmes, mchung
jdk/test/tools/launcher/ExecutionEnvironment.java
jdk/test/tools/launcher/Test7029048.java
jdk/test/tools/launcher/TestHelper.java
--- a/jdk/test/tools/launcher/ExecutionEnvironment.java	Tue Nov 19 15:09:48 2013 +0000
+++ b/jdk/test/tools/launcher/ExecutionEnvironment.java	Tue Nov 19 07:10:06 2013 -0800
@@ -89,10 +89,6 @@
 
     static final File testJarFile = new File("EcoFriendly.jar");
 
-    static final String LIBJVM = TestHelper.isWindows
-            ? "jvm.dll"
-            : "libjvm" + (TestHelper.isMacOSX ? ".dylib" : ".so");
-
     public ExecutionEnvironment() {
         createTestJar();
     }
@@ -192,7 +188,7 @@
 
             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
             verifyJavaLibraryPathGeneric(tr);
-        } else {
+        } else { // Solaris
             // no override
             env.clear();
             env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
@@ -236,23 +232,24 @@
     }
 
     /*
-     * ensures we have indeed exec'ed the correct vm of choice, all VMs support
-     * -server, however 32-bit VMs support -client and -server.
+     * ensures we have indeed exec'ed the correct vm of choice if it exists
      */
     @Test
     void testVmSelection() {
 
         TestResult tr = null;
 
-        if (is32Bit) {
+        if (haveClientVM) {
             tr = doExec(javaCmd, "-client", "-version");
             if (!tr.matches(".*Client VM.*")) {
                 flagError(tr, "the expected vm -client did not launch");
             }
         }
-        tr = doExec(javaCmd, "-server", "-version");
-        if (!tr.matches(".*Server VM.*")) {
-            flagError(tr, "the expected vm -server did not launch");
+        if (haveServerVM) {
+            tr = doExec(javaCmd, "-server", "-version");
+            if (!tr.matches(".*Server VM.*")) {
+                flagError(tr, "the expected vm -server did not launch");
+            }
         }
     }
 
--- a/jdk/test/tools/launcher/Test7029048.java	Tue Nov 19 15:09:48 2013 +0000
+++ b/jdk/test/tools/launcher/Test7029048.java	Tue Nov 19 07:10:06 2013 -0800
@@ -208,6 +208,10 @@
             System.out.println("Note: applicable on neither Windows nor MacOSX");
             return;
         }
+        if (!TestHelper.haveServerVM) {
+            System.out.println("Note: test relies on server vm, not found, exiting");
+            return;
+        }
         // create our test jar first
         ExecutionEnvironment.createTestJar();
 
--- a/jdk/test/tools/launcher/TestHelper.java	Tue Nov 19 15:09:48 2013 +0000
+++ b/jdk/test/tools/launcher/TestHelper.java	Tue Nov 19 07:10:06 2013 -0800
@@ -67,11 +67,15 @@
     static final String JAVAHOME = System.getProperty("java.home");
     static final String JAVA_BIN;
     static final String JAVA_JRE_BIN;
+    static final String JAVA_LIB;
+    static final String JAVA_JRE_LIB;
     static final boolean isSDK = JAVAHOME.endsWith("jre");
     static final String javaCmd;
     static final String javawCmd;
     static final String javacCmd;
     static final String jarCmd;
+    static final boolean haveServerVM;
+    static final boolean haveClientVM;
 
     static final JavaCompiler compiler;
 
@@ -88,6 +92,9 @@
             System.getProperty("os.name", "unknown").startsWith("SunOS");
     static final boolean isLinux =
             System.getProperty("os.name", "unknown").startsWith("Linux");
+    static final String LIBJVM = isWindows
+                        ? "jvm.dll"
+                        : "libjvm" + (isMacOSX ? ".dylib" : ".so");
 
     static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc");
 
@@ -124,12 +131,19 @@
             throw new RuntimeException("arch model is not 32 or 64 bit ?");
         }
         compiler = ToolProvider.getSystemJavaCompiler();
+
         File binDir = (isSDK)
                 ? new File((new File(JAVAHOME)).getParentFile(), "bin")
                 : new File(JAVAHOME, "bin");
         JAVA_BIN = binDir.getAbsolutePath();
-        JAVA_JRE_BIN = new File((new File(JAVAHOME)).getParentFile(),
-                        (isSDK) ? "jre/bin" : "bin").getAbsolutePath();
+        JAVA_JRE_BIN = new File(JAVAHOME, "bin").getAbsolutePath();
+
+        File libDir = (isSDK)
+                ? new File((new File(JAVAHOME)).getParentFile(), "lib")
+                : new File(JAVAHOME, "lib");
+        JAVA_LIB = libDir.getAbsolutePath();
+        JAVA_JRE_LIB = new File(JAVAHOME, "lib").getAbsolutePath();
+
         File javaCmdFile = (isWindows)
                 ? new File(binDir, "java.exe")
                 : new File(binDir, "java");
@@ -168,6 +182,21 @@
             throw new RuntimeException("java <" + javacCmd +
                     "> must exist and should be executable");
         }
+
+        haveClientVM = haveVmVariant("client");
+        haveServerVM = haveVmVariant("server");
+    }
+    private static boolean haveVmVariant(String type) {
+        if (isWindows) {
+            File vmDir = new File(JAVA_JRE_BIN, type);
+            File jvmFile = new File(vmDir, LIBJVM);
+            return jvmFile.exists();
+        } else {
+            File vmDir = new File(JAVA_JRE_LIB, type);
+            File vmArchDir = new File(vmDir, getJreArch());
+            File jvmFile = new File(vmArchDir, LIBJVM);
+            return jvmFile.exists();
+        }
     }
     void run(String[] args) throws Exception {
         int passed = 0, failed = 0;