mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
Reviewed-by: dsamersoff
This commit is contained in:
parent
6e0ea9d21c
commit
b577a431bd
10 changed files with 59 additions and 5 deletions
|
@ -23,20 +23,22 @@
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import jdk.test.lib.OutputAnalyzer;
|
||||
import jdk.test.lib.ProcessTools;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of diagnostic command GC.run_finalization
|
||||
* @library /testlibrary
|
||||
* @library /test/lib/share/classes
|
||||
* @modules java.base/sun.misc
|
||||
* java.compiler
|
||||
* java.management
|
||||
* jdk.jvmstat/sun.jvmstat.monitor
|
||||
* @build jdk.test.lib.*
|
||||
* @build jdk.test.lib.dcmd.*
|
||||
* @build jdk.test.lib.process.*
|
||||
* @build RunFinalizationTest FinalizationRunner
|
||||
* @run main RunFinalizationTest
|
||||
*/
|
||||
|
@ -50,8 +52,21 @@ public class RunFinalizationTest {
|
|||
javaArgs.add(TEST_APP_NAME);
|
||||
ProcessBuilder testAppPb = ProcessTools.createJavaProcessBuilder(javaArgs.toArray(new String[javaArgs.size()]));
|
||||
|
||||
OutputAnalyzer out = ProcessTools.executeProcess(testAppPb);
|
||||
out.stderrShouldNotMatch("^" + FinalizationRunner.FAILED + ".*")
|
||||
.stdoutShouldMatch("^" + FinalizationRunner.PASSED + ".*");
|
||||
final AtomicBoolean failed = new AtomicBoolean();
|
||||
final AtomicBoolean passed = new AtomicBoolean();
|
||||
|
||||
Process runner = ProcessTools.startProcess(
|
||||
"FinalizationRunner",
|
||||
testAppPb,
|
||||
l -> {
|
||||
failed.compareAndSet(false, l.contains(FinalizationRunner.FAILED));
|
||||
passed.compareAndSet(false, l.contains(FinalizationRunner.PASSED));
|
||||
}
|
||||
);
|
||||
runner.waitFor();
|
||||
|
||||
if (failed.get() || !passed.get()) {
|
||||
throw new Error("RunFinalizationTest failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,10 @@ package jdk.test.lib;
|
|||
* multiple times, then the line number won't provide enough context to
|
||||
* understand the failure.
|
||||
* </pre>
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib}
|
||||
*/
|
||||
@Deprecated
|
||||
public class Asserts {
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,11 @@ import java.io.FileNotFoundException;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class JDKToolFinder {
|
||||
|
||||
private JDKToolFinder() {
|
||||
|
|
|
@ -46,7 +46,10 @@ import java.util.List;
|
|||
* Process p = pb.start();
|
||||
* }
|
||||
* </pre>
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib}
|
||||
*/
|
||||
@Deprecated
|
||||
public class JDKToolLauncher {
|
||||
private final String executable;
|
||||
private final List<String> vmArgs = new ArrayList<String>();
|
||||
|
|
|
@ -41,7 +41,11 @@ public final class OutputAnalyzer {
|
|||
*
|
||||
* @param process Process to analyze
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib/process}
|
||||
*/
|
||||
@Deprecated
|
||||
public OutputAnalyzer(Process process) throws IOException {
|
||||
OutputBuffer output = ProcessTools.getOutput(process);
|
||||
exitValue = process.exitValue();
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
|
||||
package jdk.test.lib;
|
||||
|
||||
/**
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib/process}
|
||||
*/
|
||||
@Deprecated
|
||||
public class OutputBuffer {
|
||||
private final String stdout;
|
||||
private final String stderr;
|
||||
|
|
|
@ -25,6 +25,11 @@ package jdk.test.lib;
|
|||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib}
|
||||
*/
|
||||
@Deprecated
|
||||
public class Platform {
|
||||
private static final String osName = System.getProperty("os.name");
|
||||
private static final String dataModel = System.getProperty("sun.arch.data.model");
|
||||
|
|
|
@ -31,6 +31,11 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib/process}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ProcessTools {
|
||||
|
||||
private ProcessTools() {
|
||||
|
|
|
@ -27,6 +27,11 @@ import java.io.OutputStream;
|
|||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib/process}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class StreamPumper implements Runnable {
|
||||
|
||||
private static final int BUF_SIZE = 256;
|
||||
|
|
|
@ -55,7 +55,11 @@ import sun.misc.Unsafe;
|
|||
|
||||
/**
|
||||
* Common library for various test helper functions.
|
||||
*
|
||||
* @deprecated This class is deprecated. Use the one from
|
||||
* {@code <root>/test/lib/share/classes/jdk/test/lib}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class Utils {
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue