use of jdk.testlibrary.JDKToolLauncher in project jdk8u_jdk by JetBrains.
the class JstatdTest method runJstat.
/**
* Depending on test settings command line can look like:
*
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname/serverName 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port/serverName 250 5
*/
private OutputAnalyzer runJstat() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
launcher.addVMArg("-XX:+UsePerfData");
launcher.addVMArg("-Duser.language=en");
launcher.addToolArg("-gcutil");
launcher.addToolArg(jstatdPid + "@" + getDestination());
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_SAMPLES));
String[] cmd = launcher.getCommand();
log("Start jstat", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
return output;
}
use of jdk.testlibrary.JDKToolLauncher in project jdk8u_jdk by JetBrains.
the class MultiDead method parentProcess.
private static void parentProcess() throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java").addToolArg("MultiDead").addToolArg("child");
ProcessBuilder pb = new ProcessBuilder(launcher.getCommand());
AtomicReference<Process> child = new AtomicReference<>();
AtomicBoolean stopFlag = new AtomicBoolean(false);
Thread th = new Thread(() -> {
for (int i = 0; i < CHILDREN_COUNT; ++i) {
System.out.println("child #" + (i + 1) + " of " + CHILDREN_COUNT);
long start = System.nanoTime();
try {
child.set(pb.start());
child.get().waitFor();
if (stopFlag.get()) {
break;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (System.nanoTime() - start > MILLISECONDS.toNanos(CHILD_TIMEOUT)) {
System.err.println("Machine is too slow, " + "skipping the test...");
break;
}
}
});
th.start();
th.join(TIMEOUT);
stopFlag.set(true);
if (th.isAlive()) {
if (child.get() != null) {
child.get().destroyForcibly();
}
throw new RuntimeException("Failed to complete on time.");
}
}
use of jdk.testlibrary.JDKToolLauncher in project jdk8u_jdk by JetBrains.
the class JaxbMarshallTest method compileXjcGeneratedClasses.
// Compile java classes with javac tool
void compileXjcGeneratedClasses() throws Exception {
JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString());
javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString());
javacLauncher.addToolArg(xjcResultDir.resolve("package-info.java").toString());
System.out.println("Compiling xjc generated classes: " + Arrays.asList(javacLauncher.getCommand()));
ProcessBuilder pb = new ProcessBuilder(javacLauncher.getCommand());
pb.inheritIO();
pb.directory(testWorkDir.toFile());
Process p = pb.start();
p.waitFor();
p.destroy();
}
use of jdk.testlibrary.JDKToolLauncher in project jdk8u_jdk by JetBrains.
the class JaxbMarshallTest method runXjc.
// Compile schema file into java classes definitions
void runXjc(String xsdFileName) throws Exception {
// Prepare process builder to run schemagen tool and save its output
JDKToolLauncher xjcLauncher = JDKToolLauncher.createUsingTestJDK("xjc");
xjcLauncher.addToolArg(xsdFileName);
System.out.println("Executing xjc command: " + Arrays.asList(xjcLauncher.getCommand()));
ProcessBuilder pb = new ProcessBuilder(xjcLauncher.getCommand());
// Set xjc work directory with the input java file
pb.directory(testWorkDir.toFile());
pb.inheritIO();
Process p = pb.start();
p.waitFor();
p.destroy();
}
use of jdk.testlibrary.JDKToolLauncher in project jdk8u_jdk by JetBrains.
the class TestJstatdUsage method testUsage.
private static void testUsage(String option) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstatd");
launcher.addToolArg(option);
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
output.shouldContain("usage: jstatd [-nr] [-p port] [-n rminame]");
output.shouldHaveExitValue(1);
}
Aggregations