use of jdk.testlibrary.ProcessThread in project jdk8u_jdk by JetBrains.
the class JstatdTest method doTest.
public void doTest() throws Throwable {
ProcessThread jstatdThread = null;
try {
while (jstatdThread == null) {
if (!useDefaultPort || withExternalRegistry) {
port = Integer.toString(Utils.getFreePort());
}
if (withExternalRegistry) {
Registry registry = startRegistry();
if (registry == null) {
// The port is already in use. Cancel and try with new one.
continue;
}
}
jstatdThread = tryToSetupJstatdProcess();
}
runToolsAndVerify();
} finally {
cleanUpThread(jstatdThread);
}
// Verify output from jstatd
OutputAnalyzer output = jstatdThread.getOutput();
assertTrue(output.getOutput().isEmpty(), "jstatd should get an empty output, got: " + Utils.NEW_LINE + output.getOutput());
assertNotEquals(output.getExitValue(), 0, "jstatd process exited with unexpected exit code");
}
use of jdk.testlibrary.ProcessThread in project jdk8u_jdk by JetBrains.
the class BasicTests method main.
/*
* The actual test is in the nested class TestMain.
* The responsibility of this class is to:
* 1. Build all needed jars.
* 2. Start the Application class in a separate process.
* 3. Find the pid and shutdown port of the running Application.
* 4. Launches the tests in nested class TestMain that will attach to the Application.
* 5. Shut down the Application.
*/
public static void main(String[] args) throws Throwable {
final String pidFile = "TestsBasic.Application.pid";
ProcessThread processThread = null;
RunnerUtil.ProcessInfo info = null;
try {
buildJars();
processThread = RunnerUtil.startApplication(pidFile);
info = RunnerUtil.readProcessInfo(pidFile);
runTests(info.pid);
} catch (Throwable t) {
System.out.println("TestBasic got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
RunnerUtil.stopApplication(info.shutdownPort, processThread);
}
}
use of jdk.testlibrary.ProcessThread in project jdk8u_jdk by JetBrains.
the class TempDirTest method runExperiment.
/*
* The actual test is in the nested class TestMain.
* The responsibility of this class is to:
* 1. Start the Application class in a separate process.
* 2. Find the pid and shutdown port of the running Application.
* 3. Launches the tests in nested class TestMain that will attach to the Application.
* 4. Shut down the Application.
*/
public static void runExperiment(Path clientTmpDir, Path targetTmpDir) throws Throwable {
System.out.print("### Running tests with overridden tmpdir for");
System.out.print(" client: " + (clientTmpDir == null ? "no" : "yes"));
System.out.print(" target: " + (targetTmpDir == null ? "no" : "yes"));
System.out.println(" ###");
long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
System.out.println("Started after " + elapsedTime + "s");
final String pidFile = "TempDirTest.Application.pid-" + counter++;
ProcessThread processThread = null;
RunnerUtil.ProcessInfo info = null;
try {
String[] tmpDirArg = null;
if (targetTmpDir != null) {
tmpDirArg = new String[] { "-Djava.io.tmpdir=" + targetTmpDir };
}
processThread = RunnerUtil.startApplication(pidFile, tmpDirArg);
info = RunnerUtil.readProcessInfo(pidFile);
launchTests(info.pid, clientTmpDir);
} catch (Throwable t) {
System.out.println("TempDirTest got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
RunnerUtil.stopApplication(info.shutdownPort, processThread);
}
elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
System.out.println("Completed after " + elapsedTime + "s");
}
use of jdk.testlibrary.ProcessThread in project jdk8u_jdk by JetBrains.
the class RunnerUtil method startApplication.
/**
* The Application process must be run concurrently with our tests since
* the tests will attach to the Application.
* We will run the Application process in a separate thread.
*
* The Application must be started with flag "-Xshare:off" for the Retransform
* test in TestBasics to pass on all platforms.
*
* The Application will write its pid and shutdownPort in the given outFile.
*/
public static ProcessThread startApplication(String outFile, String... additionalOpts) throws Throwable {
String classpath = System.getProperty("test.class.path", ".");
String[] myArgs = concat(additionalOpts, new String[] { "-Dattach.test=true", "-classpath", classpath, "Application", outFile });
String[] args = Utils.addTestJavaOpts(myArgs);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
ProcessThread pt = new ProcessThread("runApplication", pb);
pt.start();
return pt;
}
use of jdk.testlibrary.ProcessThread in project jdk8u_jdk by JetBrains.
the class PermissionTest method main.
/*
* The actual test is in the nested class TestMain.
* The responsibility of this class is to:
* 1. Start the Application class in a separate process.
* 2. Find the pid and shutdown port of the running Application.
* 3. Run the tests in TstMain that will attach to the Application.
* 4. Shut down the Application.
*/
public static void main(String[] args) throws Throwable {
final String pidFile = "TestPermission.Application.pid";
ProcessThread processThread = null;
RunnerUtil.ProcessInfo info = null;
try {
processThread = RunnerUtil.startApplication(pidFile);
info = RunnerUtil.readProcessInfo(pidFile);
runTests(info.pid);
} catch (Throwable t) {
System.out.println("TestPermission got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
RunnerUtil.stopApplication(info.shutdownPort, processThread);
}
}
Aggregations