diff --git a/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java index 6ed9f30d7116b44b4f746ebb40e1631e1f6f6494..9f96baaefbec9d4b94c012a5ed4b2b87cb62417b 100644 --- a/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java +++ b/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java @@ -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 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(); + } + } + } diff --git a/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index 3d2036da72f42d8265616d59a684a413b15864e7..99701aebb61739bbbc5d75c3b3bd7595a495cd3d 100644 --- a/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -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 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 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(); diff --git a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java index dc3b5de7340fb36a80eb3fb63881fc381fd998f5..a929855a8c591673575ecde5fafc0532125776ad 100644 --- a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java +++ b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java @@ -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 args = new ArrayList<>(); args.add("-cp"); args.add(TEST_CLASSES); @@ -179,7 +179,7 @@ public class LocalManagementTest { final AtomicReference pid = new AtomicReference<>(); serverPrc = ProcessTools.startProcess( - "TestApplication", + "TestApplication(" + testId + ")", server, (String line) -> { if (line.startsWith("port:")) { diff --git a/test/sun/management/jmxremote/bootstrap/solaris-amd64/launcher b/test/sun/management/jmxremote/bootstrap/solaris-amd64/launcher new file mode 100644 index 0000000000000000000000000000000000000000..ac766def9e6f529610684844d3e55f8880bcd9db Binary files /dev/null and b/test/sun/management/jmxremote/bootstrap/solaris-amd64/launcher differ diff --git a/test/sun/management/jmxremote/bootstrap/solaris-i586/launcher b/test/sun/management/jmxremote/bootstrap/solaris-i586/launcher deleted file mode 100644 index d68fb14467476f69d2d9ab02a032441524620f04..0000000000000000000000000000000000000000 Binary files a/test/sun/management/jmxremote/bootstrap/solaris-i586/launcher and /dev/null differ diff --git a/test/sun/management/jmxremote/bootstrap/solaris-sparc/launcher b/test/sun/management/jmxremote/bootstrap/solaris-sparc/launcher deleted file mode 100644 index c8d0417cb084b435ec2e3b9422fec87c8a75442b..0000000000000000000000000000000000000000 Binary files a/test/sun/management/jmxremote/bootstrap/solaris-sparc/launcher and /dev/null differ diff --git a/test/sun/management/jmxremote/bootstrap/solaris-sparcv9/launcher b/test/sun/management/jmxremote/bootstrap/solaris-sparcv9/launcher new file mode 100644 index 0000000000000000000000000000000000000000..8ac4061b52023f8ab8a462365e49033092684485 Binary files /dev/null and b/test/sun/management/jmxremote/bootstrap/solaris-sparcv9/launcher differ