# HG changeset patch # User iignatyev # Date 1497915875 25200 # Mon Jun 19 16:44:35 2017 -0700 # Node ID 52a8c8af54b05f750ae797fc38dc6f211bf843e9 # Parent b0d1ada042b6483574757be5016737b900291f4d imported patch 8182565 diff --git a/test/lib/testlibrary/jdk/testlibrary/Utils.java b/test/lib/testlibrary/jdk/testlibrary/Utils.java --- a/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -217,63 +217,6 @@ } /** - * Uses "jcmd -l" to search for a jvm pid. This function will wait - * forever (until jtreg timeout) for the pid to be found. - * @param key Regular expression to search for - * @return The found pid. - */ - public static int waitForJvmPid(String key) throws Throwable { - final long iterationSleepMillis = 250; - System.out.println("waitForJvmPid: Waiting for key '" + key + "'"); - System.out.flush(); - while (true) { - int pid = tryFindJvmPid(key); - if (pid >= 0) { - return pid; - } - Thread.sleep(iterationSleepMillis); - } - } - - /** - * Searches for a jvm pid in the output from "jcmd -l". - * - * Example output from jcmd is: - * 12498 sun.tools.jcmd.JCmd -l - * 12254 /tmp/jdk8/tl/jdk/JTwork/classes/com/sun/tools/attach/Application.jar - * - * @param key A regular expression to search for. - * @return The found pid, or -1 if Enot found. - * @throws Exception If multiple matching jvms are found. - */ - public static int tryFindJvmPid(String key) throws Throwable { - OutputAnalyzer output = null; - try { - JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd"); - jcmdLauncher.addToolArg("-l"); - output = ProcessTools.executeProcess(jcmdLauncher.getCommand()); - output.shouldHaveExitValue(0); - - // Search for a line starting with numbers (pid), follwed by the key. - Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n"); - Matcher matcher = pattern.matcher(output.getStdout()); - - int pid = -1; - if (matcher.find()) { - pid = Integer.parseInt(matcher.group(1)); - System.out.println("findJvmPid.pid: " + pid); - if (matcher.find()) { - throw new Exception("Found multiple JVM pids for key: " + key); - } - } - return pid; - } catch (Throwable t) { - System.out.println(String.format("Utils.findJvmPid(%s) failed: %s", key, t)); - throw t; - } - } - - /** * Adjusts the provided timeout value for the TIMEOUT_FACTOR * @param tOut the timeout value to be adjusted * @return The timeout value adjusted for the value of "test.timeout.factor"