提交 20d4d888 编写于 作者: K ksrini

8023978: [TEST_BUG] launcher tests must exclude platforms without server vm

Reviewed-by: dholmes, mchung
上级 6bb7a48a
...@@ -89,10 +89,6 @@ public class ExecutionEnvironment extends TestHelper { ...@@ -89,10 +89,6 @@ public class ExecutionEnvironment extends TestHelper {
static final File testJarFile = new File("EcoFriendly.jar"); static final File testJarFile = new File("EcoFriendly.jar");
static final String LIBJVM = TestHelper.isWindows
? "jvm.dll"
: "libjvm" + (TestHelper.isMacOSX ? ".dylib" : ".so");
public ExecutionEnvironment() { public ExecutionEnvironment() {
createTestJar(); createTestJar();
} }
...@@ -192,7 +188,7 @@ public class ExecutionEnvironment extends TestHelper { ...@@ -192,7 +188,7 @@ public class ExecutionEnvironment extends TestHelper {
tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath()); tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
verifyJavaLibraryPathGeneric(tr); verifyJavaLibraryPathGeneric(tr);
} else { } else { // Solaris
// no override // no override
env.clear(); env.clear();
env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE); env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
...@@ -236,25 +232,26 @@ public class ExecutionEnvironment extends TestHelper { ...@@ -236,25 +232,26 @@ public class ExecutionEnvironment extends TestHelper {
} }
/* /*
* ensures we have indeed exec'ed the correct vm of choice, all VMs support * ensures we have indeed exec'ed the correct vm of choice if it exists
* -server, however 32-bit VMs support -client and -server.
*/ */
@Test @Test
void testVmSelection() { void testVmSelection() {
TestResult tr = null; TestResult tr = null;
if (is32Bit) { if (haveClientVM) {
tr = doExec(javaCmd, "-client", "-version"); tr = doExec(javaCmd, "-client", "-version");
if (!tr.matches(".*Client VM.*")) { if (!tr.matches(".*Client VM.*")) {
flagError(tr, "the expected vm -client did not launch"); flagError(tr, "the expected vm -client did not launch");
} }
} }
if (haveServerVM) {
tr = doExec(javaCmd, "-server", "-version"); tr = doExec(javaCmd, "-server", "-version");
if (!tr.matches(".*Server VM.*")) { if (!tr.matches(".*Server VM.*")) {
flagError(tr, "the expected vm -server did not launch"); flagError(tr, "the expected vm -server did not launch");
} }
} }
}
/* /*
* checks to see there is no extra libjvm.so than needed * checks to see there is no extra libjvm.so than needed
......
...@@ -208,6 +208,10 @@ public class Test7029048 extends TestHelper { ...@@ -208,6 +208,10 @@ public class Test7029048 extends TestHelper {
System.out.println("Note: applicable on neither Windows nor MacOSX"); System.out.println("Note: applicable on neither Windows nor MacOSX");
return; return;
} }
if (!TestHelper.haveServerVM) {
System.out.println("Note: test relies on server vm, not found, exiting");
return;
}
// create our test jar first // create our test jar first
ExecutionEnvironment.createTestJar(); ExecutionEnvironment.createTestJar();
......
...@@ -67,11 +67,15 @@ public class TestHelper { ...@@ -67,11 +67,15 @@ public class TestHelper {
static final String JAVAHOME = System.getProperty("java.home"); static final String JAVAHOME = System.getProperty("java.home");
static final String JAVA_BIN; static final String JAVA_BIN;
static final String JAVA_JRE_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 boolean isSDK = JAVAHOME.endsWith("jre");
static final String javaCmd; static final String javaCmd;
static final String javawCmd; static final String javawCmd;
static final String javacCmd; static final String javacCmd;
static final String jarCmd; static final String jarCmd;
static final boolean haveServerVM;
static final boolean haveClientVM;
static final JavaCompiler compiler; static final JavaCompiler compiler;
...@@ -88,6 +92,9 @@ public class TestHelper { ...@@ -88,6 +92,9 @@ public class TestHelper {
System.getProperty("os.name", "unknown").startsWith("SunOS"); System.getProperty("os.name", "unknown").startsWith("SunOS");
static final boolean isLinux = static final boolean isLinux =
System.getProperty("os.name", "unknown").startsWith("Linux"); 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"); static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc");
...@@ -124,12 +131,19 @@ public class TestHelper { ...@@ -124,12 +131,19 @@ public class TestHelper {
throw new RuntimeException("arch model is not 32 or 64 bit ?"); throw new RuntimeException("arch model is not 32 or 64 bit ?");
} }
compiler = ToolProvider.getSystemJavaCompiler(); compiler = ToolProvider.getSystemJavaCompiler();
File binDir = (isSDK) File binDir = (isSDK)
? new File((new File(JAVAHOME)).getParentFile(), "bin") ? new File((new File(JAVAHOME)).getParentFile(), "bin")
: new File(JAVAHOME, "bin"); : new File(JAVAHOME, "bin");
JAVA_BIN = binDir.getAbsolutePath(); JAVA_BIN = binDir.getAbsolutePath();
JAVA_JRE_BIN = new File((new File(JAVAHOME)).getParentFile(), JAVA_JRE_BIN = new File(JAVAHOME, "bin").getAbsolutePath();
(isSDK) ? "jre/bin" : "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) File javaCmdFile = (isWindows)
? new File(binDir, "java.exe") ? new File(binDir, "java.exe")
: new File(binDir, "java"); : new File(binDir, "java");
...@@ -168,6 +182,21 @@ public class TestHelper { ...@@ -168,6 +182,21 @@ public class TestHelper {
throw new RuntimeException("java <" + javacCmd + throw new RuntimeException("java <" + javacCmd +
"> must exist and should be executable"); "> 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 { void run(String[] args) throws Exception {
int passed = 0, failed = 0; int passed = 0, failed = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册