提交 09791083 编写于 作者: J jbachorik

8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be...

8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
Reviewed-by: sla
上级 0f824339
......@@ -32,6 +32,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.Phaser;
......@@ -131,6 +132,10 @@ public final class ProcessTools {
phs.awaitAdvanceInterruptibly(0, timeout, unit);
}
} catch (TimeoutException | InterruptedException e) {
System.err.println("Failed to start a process (thread dump follows)");
for(Map.Entry<Thread, StackTraceElement[]> s : Thread.getAllStackTraces().entrySet()) {
printStack(s.getKey(), s.getValue());
}
stdoutTask.cancel(true);
stderrTask.cancel(true);
throw e;
......@@ -250,4 +255,15 @@ public final class ProcessTools {
return new ProcessBuilder(args.toArray(new String[args.size()]));
}
private static void printStack(Thread t, StackTraceElement[] stack) {
System.out.println("\t" + t +
" stack: (length = " + stack.length + ")");
if (t != null) {
for (StackTraceElement stack1 : stack) {
System.out.println("\t" + stack1);
}
System.out.println();
}
}
}
......@@ -25,7 +25,11 @@ import java.io.File;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
......@@ -36,7 +40,7 @@ import jdk.testlibrary.ProcessTools;
* @bug 6434402 8004926
* @library /lib/testlibrary
* @build TestManager TestApplication CustomLauncherTest
* @run main CustomLauncherTest
* @run main/othervm CustomLauncherTest
* @author Jaroslav Bachorik
*/
public class CustomLauncherTest {
......@@ -67,6 +71,9 @@ public class CustomLauncherTest {
ARCH = "amd64";
break;
}
case "sparc":
ARCH = "sparcv9";
break;
default: {
ARCH = osarch;
}
......@@ -101,7 +108,10 @@ public class CustomLauncherTest {
File.separator + "launcher";
final FileSystem FS = FileSystems.getDefault();
final boolean hasLauncher = Files.isExecutable(FS.getPath(LAUNCHER));
Path launcherPath = FS.getPath(LAUNCHER);
final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&&
Files.isReadable(launcherPath);
if (!hasLauncher) {
System.out.println("Launcher [" + LAUNCHER + "] does not exist. Skipping the test.");
return;
......@@ -114,7 +124,17 @@ public class CustomLauncherTest {
Process serverPrc = null, clientPrc = null;
final Set<PosixFilePermission> launcherOrigPerms =
Files.getPosixFilePermissions(launcherPath, LinkOption.NOFOLLOW_LINKS);
try {
// It is impossible to store an executable file in the source control
// We need to set the executable flag here
if (!Files.isExecutable(launcherPath)) {
Set<PosixFilePermission> perms = new HashSet<>(launcherOrigPerms);
perms.add(PosixFilePermission.OWNER_EXECUTE);
Files.setPosixFilePermissions(launcherPath, perms);
}
System.out.println("Starting custom launcher:");
System.out.println("=========================");
System.out.println(" launcher : " + LAUNCHER);
......@@ -177,6 +197,8 @@ public class CustomLauncherTest {
throw new Error("Test failed");
}
} finally {
// Let's restore the original launcher permissions
Files.setPosixFilePermissions(launcherPath, launcherOrigPerms);
if (clientPrc != null) {
clientPrc.destroy();
clientPrc.waitFor();
......
......@@ -42,7 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
* TestManager will attempt a connection to the address obtained from
* both agent properties and jvmstat buffer.
* @build TestManager TestApplication
* @run main/timeout=300 LocalManagementTest
* @run main/othervm/timeout=300 LocalManagementTest
*/
import jdk.testlibrary.ProcessTools;
......@@ -77,14 +77,14 @@ public class LocalManagementTest {
}
private static boolean test1() throws Exception {
return doTest("-Dcom.sun.management.jmxremote");
return doTest("1", "-Dcom.sun.management.jmxremote");
}
private static boolean test2() throws Exception {
Path agentPath = findAgent();
if (agentPath != null) {
String agent = agentPath.toString();
return doTest("-javaagent:" + agent);
return doTest("2", "-javaagent:" + agent);
} else {
return false;
}
......@@ -94,7 +94,7 @@ public class LocalManagementTest {
* no args (blank) - manager should attach and start agent
*/
private static boolean test3() throws Exception {
return doTest(null);
return doTest("3", null);
}
/**
......@@ -136,7 +136,7 @@ public class LocalManagementTest {
* use DNS-only name service
*/
private static boolean test5() throws Exception {
return doTest("-Dsun.net.spi.namservice.provider.1=\"dns,sun\"");
return doTest("5", "-Dsun.net.spi.namservice.provider.1=\"dns,sun\"");
}
private static Path findAgent() {
......@@ -160,7 +160,7 @@ public class LocalManagementTest {
return Files.isRegularFile(path) && Files.isReadable(path);
}
private static boolean doTest(String arg) throws Exception {
private static boolean doTest(String testId, String arg) throws Exception {
List<String> args = new ArrayList<>();
args.add("-cp");
args.add(TEST_CLASSES);
......@@ -179,7 +179,7 @@ public class LocalManagementTest {
final AtomicReference<String> pid = new AtomicReference<>();
serverPrc = ProcessTools.startProcess(
"TestApplication",
"TestApplication(" + testId + ")",
server,
(String line) -> {
if (line.startsWith("port:")) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册