< prev index next >
test/sun/tools/jhsdb/BasicLauncherTest.java
Print this page
@@ -38,10 +38,11 @@
import java.io.InputStreamReader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
+import java.util.Optional;
import jdk.testlibrary.JDKToolLauncher;
import jdk.testlibrary.Utils;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
import jdk.test.lib.apps.LingeredApp;
@@ -109,11 +110,12 @@
/**
*
* @param vmArgs - vm and java arguments to launch test app
* @return exit code of tool
*/
- public static void launch(String expectedMessage, List<String> toolArgs)
+ public static void launch(String expectedMessage,
+ Optional<String> unexpectedMessage, List<String> toolArgs)
throws IOException {
System.out.println("Starting LingeredApp");
try {
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
@@ -129,44 +131,50 @@
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);;
output.shouldContain(expectedMessage);
+ unexpectedMessage.ifPresent(output::shouldNotContain);
output.shouldHaveExitValue(0);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
}
- public static void launch(String expectedMessage, String... toolArgs)
+ public static void launch(String expectedMessage,
+ String unexpectedMessage, String... toolArgs)
throws IOException {
- launch(expectedMessage, Arrays.asList(toolArgs));
+ launch(expectedMessage, Optional.ofNullable(unexpectedMessage),
+ Arrays.asList(toolArgs));
}
- public static void launchNotOSX(String expectedMessage, String... toolArgs)
+ public static void launchNotOSX(String expectedMessage,
+ String unexpectedMessage, String... toolArgs)
throws IOException {
if (Platform.isOSX()) {
// Coredump stackwalking is not implemented for Darwin
System.out.println("This test is not expected to work on OS X. Skipping");
return;
}
+
+ launch(expectedMessage, unexpectedMessage, toolArgs);
}
public static void testHeapDump() throws IOException {
File dump = new File("jhsdb.jmap.dump." +
System.currentTimeMillis() + ".hprof");
if (dump.exists()) {
dump.delete();
}
dump.deleteOnExit();
- launch("heap written to", "jmap",
+ launch("heap written to", null, "jmap",
"--binaryheap", "--dumpfile=" + dump.getAbsolutePath());
assertTrue(dump.exists() && dump.isFile(),
"Could not create dump file " + dump.getAbsolutePath());
}
@@ -180,15 +188,16 @@
return;
}
launchCLHSDB();
- launch("compiler detected", "jmap", "--clstats");
- launchNotOSX("No deadlocks found", "jstack");
- launch("compiler detected", "jmap");
- launch("Java System Properties", "jinfo");
- launch("java.threads", "jsnap");
+ launch("compiler detected", null, "jmap", "--clstats");
+ launchNotOSX("No deadlocks found", null, "jstack");
+ launch("compiler detected", null, "jmap");
+ launch("Java System Properties",
+ "System Properties info not available", "jinfo");
+ launch("java.threads", null, "jsnap");
testHeapDump();
// The test throws RuntimeException on error.
// IOException is thrown if LingeredApp can't start because of some bad
< prev index next >