8321812: Update GC tests to use execute[Limited]TestJava

Reviewed-by: tschatzl, aboldtch
This commit is contained in:
Stefan Karlsson 2024-01-05 09:12:24 +00:00
parent 868f8745fa
commit 1d1cd32bc3
132 changed files with 471 additions and 664 deletions

View File

@ -66,7 +66,7 @@ public class TestAgeOutput {
}
public static void runTest(String gcArg) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
@ -75,7 +75,6 @@ public class TestAgeOutput {
"-Xmx10M",
"-Xlog:gc+age=trace",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

View File

@ -36,13 +36,12 @@ import jdk.test.lib.process.OutputAnalyzer;
public class TestAllocateHeapAt {
public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:AllocateHeapAt=" + System.getProperty("test.dir", "."),
"-Xlog:gc+heap=info",
"-Xmx32m",
"-Xms32m",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("Output:\n" + output.getOutput());

View File

@ -45,13 +45,12 @@ public class TestAllocateHeapAtError {
f = new File(test_dir, UUID.randomUUID().toString());
} while(f.exists());
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:AllocateHeapAt=" + f.getName(),
"-Xlog:gc+heap=info",
"-Xmx32m",
"-Xms32m",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("Output:\n" + output.getOutput());

View File

@ -60,8 +60,7 @@ public class TestAllocateHeapAtMultiple {
"-Xlog:gc+heap=info",
"-version"});
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeTestJava(flags);
System.out.println("Output:\n" + output.getOutput());

View File

@ -42,12 +42,11 @@ public class TestCardTablePageCommits {
// because of 8kB pages, assume 4 KB pages for all other CPUs.
String Xmx = "-Xmx4m";
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
Xmx,
"-XX:NativeMemoryTracking=detail",
"-XX:+UseParallelGC",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
}
}

View File

@ -58,7 +58,7 @@ public class TestNumWorkerOutput {
}
public static void runTest(String gcArg) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
@ -67,7 +67,6 @@ public class TestNumWorkerOutput {
"-Xmx10M",
"-XX:+PrintGCDetails",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

View File

@ -48,9 +48,7 @@ public class TestPLABAdaptToMinTLABSize {
Collections.addAll(testArguments, extraArgs);
testArguments.add("-version");
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(testArguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeTestJava(testArguments);
System.out.println(output.getStderr());

View File

@ -96,12 +96,11 @@ public class TestSmallHeap {
private static void verifySmallHeapSize(String gc, long expectedMaxHeap) throws Exception {
long minMaxHeap = 4 * 1024 * 1024;
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = ProcessTools.executeLimitedTestJava(
gc,
"-Xmx" + minMaxHeap,
"-XX:+PrintFlagsFinal",
VerifyHeapSize.class.getName());
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
expectedMaxHeap = Math.max(expectedMaxHeap, minMaxHeap);

View File

@ -37,13 +37,12 @@ import jdk.test.lib.process.OutputAnalyzer;
public class TestVerifyDuringStartup {
public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-Xlog:gc+verify=debug",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("Output:\n" + output.getOutput());

View File

@ -57,8 +57,7 @@ public class TestVerifySilently {
"-XX:+VerifyAfterGC",
(verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),
TestVerifySilentlyRunSystemGC.class.getName()});
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmOpts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(vmOpts);
System.out.println("Output:\n" + output.getOutput());
return output;

View File

@ -59,8 +59,7 @@ public class TestVerifySubSet {
"-Xlog:gc+verify=debug",
"-XX:VerifySubSet="+subset,
TestVerifySubSetRunSystemGC.class.getName()});
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmOpts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(vmOpts);
System.out.println("Output:\n" + output.getOutput());
return output;

View File

@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
/**
@ -81,4 +82,20 @@ public final class GCArguments {
static public ProcessBuilder createTestJavaProcessBuilder(String... arguments) {
return ProcessTools.createTestJavaProcessBuilder(withDefaults(arguments));
}
static public OutputAnalyzer executeLimitedTestJava(List<String> arguments) throws Exception {
return executeLimitedTestJava(arguments.toArray(String[]::new));
}
static public OutputAnalyzer executeLimitedTestJava(String... arguments) throws Exception {
return ProcessTools.executeLimitedTestJava(withDefaults(arguments));
}
static public OutputAnalyzer executeTestJava(List<String> arguments) throws Exception {
return executeTestJava(arguments.toArray(String[]::new));
}
static public OutputAnalyzer executeTestJava(String... arguments) throws Exception {
return ProcessTools.executeTestJava(withDefaults(arguments));
}
}

View File

@ -65,11 +65,9 @@ public class TestAggressiveHeap {
" *bool +UseParallelGC *= *true +\\{product\\} *\\{command line\\}";
private static void testFlag() throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeTestJava(
option, heapSizeOption, "-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
String value = output.firstMatch(parallelGCPattern);

View File

@ -41,17 +41,13 @@ import jdk.test.lib.Platform;
public class TestCompressedClassFlags {
public static void main(String[] args) throws Exception {
if (Platform.is64bit()) {
OutputAnalyzer output = runJava("-XX:CompressedClassSpaceSize=1g",
"-XX:-UseCompressedClassPointers",
"-version");
OutputAnalyzer output = GCArguments.executeTestJava(
"-XX:CompressedClassSpaceSize=1g",
"-XX:-UseCompressedClassPointers",
"-version");
output.shouldContain("warning");
output.shouldNotContain("error");
output.shouldHaveExitValue(0);
}
}
private static OutputAnalyzer runJava(String ... args) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(args);
return new OutputAnalyzer(pb.start());
}
}

View File

@ -40,14 +40,13 @@ import jdk.test.lib.process.OutputAnalyzer;
public class TestDisableDefaultGC {
public static void main(String[] args) throws Exception {
// Start VM, disabling all possible default GCs
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder("-XX:-UseSerialGC",
"-XX:-UseParallelGC",
"-XX:-UseG1GC",
"-XX:-UseZGC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:-UseShenandoahGC",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava("-XX:-UseSerialGC",
"-XX:-UseParallelGC",
"-XX:-UseG1GC",
"-XX:-UseZGC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:-UseShenandoahGC",
"-version");
output.shouldMatch("Garbage collector not selected");
output.shouldHaveExitValue(1);
}

View File

@ -78,8 +78,7 @@ public class TestG1ConcMarkStepDurationMillis {
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis="+expectedValue, "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(vmOpts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(vmOpts);
output.shouldHaveExitValue(expectedResult == PASS ? 0 : 1);
String stdout = output.getStdout();

View File

@ -69,8 +69,7 @@ public class TestG1ConcRefinementThreads {
}
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(vmOpts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(vmOpts);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();

View File

@ -53,8 +53,7 @@ public class TestG1HeapRegionSize {
flagList.add("-XX:+PrintFlagsFinal");
flagList.add("-version");
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flagList);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(flagList);
output.shouldHaveExitValue(exitValue);
if (exitValue == 0) {

View File

@ -63,8 +63,7 @@ public class TestG1PercentageOptions {
};
private static void check(String flag, boolean is_valid) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder("-XX:+UseG1GC", flag, "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava("-XX:+UseG1GC", flag, "-version");
if (is_valid) {
output.shouldHaveExitValue(0);
} else {

View File

@ -48,8 +48,7 @@ public class TestG1RemSetFlags {
flagList.add("-XX:+PrintFlagsFinal");
flagList.add("-version");
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flagList);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(flagList);
output.shouldHaveExitValue(exitValue);
}

View File

@ -48,11 +48,10 @@ public class TestHeapFreeRatio {
}
private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeTestJava(
"-Xminf" + min,
"-Xmaxf" + max,
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
switch (type) {
case VALID:

View File

@ -41,14 +41,13 @@ import jdk.test.lib.process.OutputAnalyzer;
public class TestInitialTenuringThreshold {
public static void runWithThresholds(int initial, int max, boolean shouldfail) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeTestJava(
"-XX:+UseParallelGC",
"-XX:InitialTenuringThreshold=" + String.valueOf(initial),
"-XX:MaxTenuringThreshold=" + String.valueOf(max),
"-version"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (shouldfail) {
output.shouldHaveExitValue(1);
} else {
@ -58,14 +57,13 @@ public class TestInitialTenuringThreshold {
public static void main(String args[]) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeTestJava(
// some value below the default value of InitialTenuringThreshold of 7
"-XX:+UseParallelGC",
"-XX:MaxTenuringThreshold=1",
"-version"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
// successful tests
runWithThresholds(0, 10, false);

View File

@ -115,9 +115,8 @@ class TestMaxHeapSizeTools {
}
private static void getNewOldSize(String gcflag, long[] values) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(gcflag,
OutputAnalyzer output = GCArguments.executeTestJava(gcflag,
"-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
@ -208,8 +207,7 @@ class TestMaxHeapSizeTools {
finalargs.add(classname);
finalargs.addAll(Arrays.asList(arguments));
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(finalargs.toArray(String[]::new));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(finalargs.toArray(String[]::new));
output.shouldHaveExitValue(0);
return output;
@ -308,8 +306,7 @@ class TestMaxHeapSizeTools {
}
private static void expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(flags);
shouldContainOrNot(output, hasWarning, "Warning");
shouldContainOrNot(output, hasError, "Error");
output.shouldHaveExitValue(errorcode);

View File

@ -98,8 +98,7 @@ public class TestMaxMinHeapFreeRatioFlags {
Boolean.toString(shrinkHeapInSteps)
);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(0);
}
@ -123,8 +122,7 @@ public class TestMaxMinHeapFreeRatioFlags {
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
"-version"
);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(1);
analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
}

View File

@ -95,8 +95,7 @@ public class TestMaxNewSize {
finalargs.add("-XX:+PrintFlagsFinal");
finalargs.add("-version");
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeTestJava(finalargs);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
return getFlagValue("MaxNewSize", stdout);

View File

@ -61,8 +61,7 @@ public class TestMaxRAMFlags {
args.add("-XX:+PrintFlagsFinal");
args.add("-version");
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(args);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
@ -84,8 +83,7 @@ public class TestMaxRAMFlags {
args.add("-XX:+PrintFlagsFinal");
args.add("-version");
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(args);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
return (new Long(getFlagValue("HeapBaseMinAddress", stdout)).longValue());

View File

@ -102,8 +102,7 @@ public class TestMinAndInitialSurvivorRatioFlags {
Boolean.toString(useAdaptiveSizePolicy)
);
vmOptions.removeIf((String p) -> p.isEmpty());
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(0);
}

View File

@ -82,8 +82,7 @@ public class TestNewRatioFlag {
Integer.toString(ratio)
);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(0);
System.out.println(analyzer.getOutput());
}

View File

@ -133,7 +133,7 @@ public class TestNewSizeFlags {
long heapSize, long maxHeapSize,
long expectedNewSize, long expectedMaxNewSize,
LinkedList<String> options, boolean failureExpected) throws Exception {
OutputAnalyzer analyzer = startVM(options, newSize, maxNewSize, heapSize, maxHeapSize, expectedNewSize, expectedMaxNewSize);
OutputAnalyzer analyzer = executeLimitedTestJava(options, newSize, maxNewSize, heapSize, maxHeapSize, expectedNewSize, expectedMaxNewSize);
if (failureExpected) {
analyzer.shouldHaveExitValue(1);
@ -144,7 +144,7 @@ public class TestNewSizeFlags {
}
}
private static OutputAnalyzer startVM(LinkedList<String> options,
private static OutputAnalyzer executeLimitedTestJava(LinkedList<String> options,
long newSize, long maxNewSize,
long heapSize, long maxHeapSize,
long expectedNewSize, long expectedMaxNewSize) throws Exception, IOException {
@ -166,9 +166,7 @@ public class TestNewSizeFlags {
Long.toString(maxHeapSize)
);
vmOptions.removeIf(String::isEmpty);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
return analyzer;
return GCArguments.executeLimitedTestJava(vmOptions);
}
/**

View File

@ -65,14 +65,13 @@ public class TestNewSizeThreadIncrease {
}
static void runNewSizeThreadIncreaseTest(String expectedValue, boolean isNewsizeChanged) throws Exception {
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder("-XX:+UseSerialGC",
"-Xms96M",
"-Xmx128M",
"-XX:NewRatio=2",
"-Xlog:gc+heap+ergo=debug",
"-XX:NewSizeThreadIncrease="+expectedValue,
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava("-XX:+UseSerialGC",
"-Xms96M",
"-Xmx128M",
"-XX:NewRatio=2",
"-Xlog:gc+heap+ergo=debug",
"-XX:NewSizeThreadIncrease="+expectedValue,
GCTest.class.getName());
output.shouldHaveExitValue(0);

View File

@ -161,8 +161,7 @@ public class TestObjectTenuringFlags {
}
Collections.addAll(vmOpts, "-XX:+UseParallelGC", "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(vmOpts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(vmOpts);
if (shouldFail) {
output.shouldHaveExitValue(1);

View File

@ -56,10 +56,9 @@ public class TestParallelGCThreads {
private static final String printFlagsFinalPattern = " *uint *" + flagName + " *:?= *(\\d+) *\\{product\\} *";
public static void testDefaultValue() throws Exception {
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeLimitedTestJava(
"-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
String value = output.firstMatch(printFlagsFinalPattern, 1);
try {
@ -94,12 +93,11 @@ public class TestParallelGCThreads {
for (String gc : supportedGC) {
// Make sure the VM does not allow ParallelGCThreads set to 0
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeLimitedTestJava(
"-XX:+Use" + gc + "GC",
"-XX:ParallelGCThreads=0",
"-XX:+PrintFlagsFinal",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(1);
// Do some basic testing to ensure the flag updates the count
@ -124,8 +122,7 @@ public class TestParallelGCThreads {
}
public static long getParallelGCThreadCount(String... flags) throws Exception {
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(flags);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
return FlagsValue.getFlagLongValue("ParallelGCThreads", stdout);

View File

@ -77,9 +77,7 @@ public class TestParallelRefProc {
result.addAll(Arrays.asList(args));
result.add("-XX:+PrintFlagsFinal");
result.add("-version");
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(result);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(result);
output.shouldHaveExitValue(0);

View File

@ -44,12 +44,11 @@ public class TestSelectDefaultGC {
public static void testDefaultGC(boolean actAsServer) throws Exception {
// Start VM without specifying GC
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeLimitedTestJava(
"-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine",
"-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine",
"-XX:+PrintFlagsFinal",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
final boolean isServer = actAsServer;

View File

@ -60,14 +60,13 @@ public class TestSmallInitialHeapWithLargePageAndNUMA {
long initHeap = heapAlignment;
long maxHeap = heapAlignment * 2;
ProcessBuilder pb_enabled = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(
"-XX:+UseParallelGC",
"-Xms" + String.valueOf(initHeap),
"-Xmx" + String.valueOf(maxHeap),
"-XX:+UseNUMA",
"-XX:+PrintFlagsFinal",
"-version");
OutputAnalyzer analyzer = new OutputAnalyzer(pb_enabled.start());
if (largePageOrNumaEnabled(analyzer)) {
// We reach here, if both NUMA and HugeTLB are supported.

View File

@ -87,8 +87,7 @@ public class TestSurvivorRatioFlag {
Integer.toString(ratio)
);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(0);
}

View File

@ -116,8 +116,7 @@ public class TestTargetSurvivorRatioFlag {
vmOptions.add("-XX:TargetSurvivorRatio=" + ratio);
vmOptions.add("-version");
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(1);
analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
@ -151,8 +150,7 @@ public class TestTargetSurvivorRatioFlag {
Integer.toString(ratio)
);
ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOptions);
analyzer.shouldHaveExitValue(0);

View File

@ -40,32 +40,29 @@ public class TestUnrecognizedVMOptionsHandling {
public static void main(String args[]) throws Exception {
// The first two JAVA processes are expected to fail, but with a correct VM option suggestion
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer outputWithError = GCArguments.executeLimitedTestJava(
"-XX:+UseDynamicNumberOfGcThreads",
"-version"
);
OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
outputWithError.shouldContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");
if (outputWithError.getExitValue() == 0) {
throw new RuntimeException("Not expected to get exit value 0");
}
pb = GCArguments.createLimitedTestJavaProcessBuilder(
outputWithError = GCArguments.executeLimitedTestJava(
"-XX:MaxiumHeapSize=500m",
"-version"
);
outputWithError = new OutputAnalyzer(pb.start());
outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?");
if (outputWithError.getExitValue() == 0) {
throw new RuntimeException("Not expected to get exit value 0");
}
// The last JAVA process should run successfully for the purpose of sanity check
pb = GCArguments.createLimitedTestJavaProcessBuilder(
OutputAnalyzer outputWithNoError = GCArguments.executeLimitedTestJava(
"-XX:+UseDynamicNumberOfGCThreads",
"-version"
);
OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start());
outputWithNoError.shouldNotContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");
outputWithNoError.shouldHaveExitValue(0);
}

View File

@ -93,8 +93,7 @@ class TestUseCompressedOopsErgoTools {
finalargs.add(classname);
finalargs.addAll(Arrays.asList(arguments));
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(finalargs);
output.shouldHaveExitValue(0);
return output;
}
@ -157,8 +156,7 @@ class TestUseCompressedOopsErgoTools {
}
private static String expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = GCArguments.executeLimitedTestJava(flags);
output.shouldHaveExitValue(errorcode);
return output.getStdout();
}

View File

@ -59,9 +59,8 @@ public class TestUseCompressedOopsFlagsWithUlimit {
// Convert bytes to kbytes for ulimit -v
var ulimit_prefix = "ulimit -v " + (ulimit / 1024);
String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJavaProcessBuilder(args.toArray(String[]::new)));
ProcessBuilder pb = new ProcessBuilder("sh", "-c", ulimit_prefix + ";" + cmd);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJavaProcessBuilder(args));
OutputAnalyzer output = ProcessTools.executeProcess("sh", "-c", ulimit_prefix + ";" + cmd);
output.shouldHaveExitValue(0);
String stdout = output.getStdout();

View File

@ -39,11 +39,10 @@ import jdk.test.lib.process.OutputAnalyzer;
public class TestUseNUMAInterleaving {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(
OutputAnalyzer output = GCArguments.executeTestJava(
"-XX:+UseNUMA",
"-XX:+PrintFlagsFinal",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
boolean isNUMAEnabled
= Boolean.parseBoolean(output.firstMatch(NUMA_FLAG_PATTERN, 1));

View File

@ -99,8 +99,7 @@ public class TestVerifyBeforeAndAfterGCFlags {
: "-XX:-VerifyAfterGC"),
GarbageProducer.class.getName(),
doFullGC ? "t" : "f" });
ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(vmOpts);
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
OutputAnalyzer analyzer = GCArguments.executeLimitedTestJava(vmOpts);
analyzer.shouldHaveExitValue(0);
analyzer.shouldNotMatch(VERIFY_BEFORE_GC_CORRUPTED_PATTERN);

View File

@ -45,7 +45,7 @@ public class TestG1ClassUnloadingHWM {
private static long YoungGenSize = 32 * 1024 * 1024;
private static OutputAnalyzer run(boolean enableUnloading) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
return ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
@ -57,7 +57,6 @@ public class TestG1ClassUnloadingHWM {
TestG1ClassUnloadingHWM.AllocateBeyondMetaspaceSize.class.getName(),
"" + MetaspaceSize,
"" + YoungGenSize);
return new OutputAnalyzer(pb.start());
}
public static OutputAnalyzer runWithG1ClassUnloading() throws Exception {

View File

@ -37,15 +37,13 @@ import jdk.test.lib.process.ProcessTools;
public class TestDieDefault {
public static void passWith(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
OutputAnalyzer out = ProcessTools.executeLimitedTestJava(args);
out.shouldNotContain("OutOfMemoryError");
out.shouldHaveExitValue(0);
}
public static void failWith(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
OutputAnalyzer out = ProcessTools.executeLimitedTestJava(args);
out.shouldContain("OutOfMemoryError");
if (out.getExitValue() == 0) {
throw new IllegalStateException("Should have failed with non-zero exit code");

View File

@ -38,8 +38,7 @@ import jdk.test.lib.process.ProcessTools;
public class TestDieWithHeapDump {
public static void passWith(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
OutputAnalyzer out = ProcessTools.executeLimitedTestJava(args);
out.shouldNotContain("OutOfMemoryError");
out.shouldHaveExitValue(0);
}

View File

@ -39,16 +39,14 @@ public class TestDieWithOnError {
static String ON_ERR_MSG = "Epsilon error handler message";
public static void passWith(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
OutputAnalyzer out = ProcessTools.executeLimitedTestJava(args);
out.shouldNotContain("OutOfMemoryError");
out.stdoutShouldNotMatch("^" + ON_ERR_MSG);
out.shouldHaveExitValue(0);
}
public static void failWith(String... args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
OutputAnalyzer out = ProcessTools.executeLimitedTestJava(args);
out.shouldContain("OutOfMemoryError");
if (out.getExitValue() == 0) {
throw new IllegalStateException("Should have failed with non-zero exit code");

View File

@ -68,16 +68,16 @@ public class TestDynamicNumberOfGCThreads {
String[] baseArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", GCTest.class.getName()};
// Base test with gc and +UseDynamicNumberOfGCThreads:
ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(baseArgs);
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(baseArgs);
verifyDynamicNumberOfGCThreads(output);
// Turn on parallel reference processing
String[] parRefProcArg = {"-XX:+ParallelRefProcEnabled", "-XX:-ShowMessageBoxOnError"};
String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length];
System.arraycopy(parRefProcArg, 0, parRefArgs, 0, parRefProcArg.length);
System.arraycopy(baseArgs, 0, parRefArgs, parRefProcArg.length, baseArgs.length);
pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(parRefArgs);
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
output = ProcessTools.executeLimitedTestJava(parRefArgs);
verifyDynamicNumberOfGCThreads(output);
}
static class GCTest {

View File

@ -70,13 +70,13 @@ public class TestInitialGCThreadLogging {
private static void testInitialGCThreadLogging(String gcFlag, String threadName) throws Exception {
// Base test with gc and +UseDynamicNumberOfGCThreads:
ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UnlockExperimentalVMOptions",
"-XX:+" + gcFlag,
"-Xmx10M",
"-XX:+UseDynamicNumberOfGCThreads",
"-Xlog:gc+task=trace",
"-version");
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()), threadName);
verifyDynamicNumberOfGCThreads(output, threadName);
}
}

View File

@ -49,9 +49,8 @@ public class Test2GbHeap {
testArguments.add("-Xmx2g");
testArguments.add("-version");
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments);
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(testArguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
}
}

View File

@ -43,17 +43,16 @@ import jdk.test.lib.process.ProcessTools;
public class TestAllocationFailure {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-XX:+G1GCAllocationFailureALot",
"-XX:G1GCAllocationFailureALotCount=100",
"-XX:G1GCAllocationFailureALotInterval=1",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc",
GCTestWithAllocationFailure.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-XX:+G1GCAllocationFailureALot",
"-XX:G1GCAllocationFailureALotCount=100",
"-XX:G1GCAllocationFailureALotInterval=1",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc",
GCTestWithAllocationFailure.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
output.shouldContain("(Evacuation Failure:");
output.shouldHaveExitValue(0);

View File

@ -80,7 +80,7 @@ class TestEagerReclaimHumongousRegionsReclaimRegionFast {
public class TestEagerReclaimHumongousRegions {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseG1GC",
"-Xms128M",
"-Xmx128M",
@ -90,8 +90,6 @@ public class TestEagerReclaimHumongousRegions {
Pattern p = Pattern.compile("Full GC");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
int found = 0;
Matcher m = p.matcher(output.getStdout());
while (m.find()) { found++; }

View File

@ -119,7 +119,7 @@ class TestEagerReclaimHumongousRegionsClearMarkBitsReclaimRegionFast {
public class TestEagerReclaimHumongousRegionsClearMarkBits {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseG1GC",
"-Xms128M",
"-Xmx128M",
@ -132,7 +132,6 @@ public class TestEagerReclaimHumongousRegionsClearMarkBits {
"-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
"-XX:+G1VerifyBitmaps",
TestEagerReclaimHumongousRegionsClearMarkBitsReclaimRegionFast.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
}
}

View File

@ -54,7 +54,7 @@ public class TestEagerReclaimHumongousRegionsLog {
}
public static void runTest() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
@ -65,7 +65,6 @@ public class TestEagerReclaimHumongousRegionsLog {
"-Xmx128M",
"-Xlog:gc+phases=trace,gc+heap=info",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

View File

@ -92,7 +92,7 @@ class TestEagerReclaimHumongousRegionsWithRefsReclaimRegionFast {
public class TestEagerReclaimHumongousRegionsWithRefs {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseG1GC",
"-Xms128M",
"-Xmx128M",
@ -102,8 +102,6 @@ public class TestEagerReclaimHumongousRegionsWithRefs {
Pattern p = Pattern.compile("Full GC");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
int found = 0;
Matcher m = p.matcher(output.getStdout());
while (m.find()) {

View File

@ -54,8 +54,7 @@ public class TestG1SkipCompaction {
"-XX:G1HeapRegionSize=1m",
GCTest.class.getName()
};
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(arguments);
System.out.println(output.getStdout());
String pattern = ".*skip compaction region.*";

View File

@ -41,16 +41,14 @@ import java.util.LinkedList;
public class TestG1TraceEagerReclaimHumongousObjects {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xms128M",
"-Xmx128M",
"-Xmn16M",
"-XX:G1HeapRegionSize=1M",
"-Xlog:gc+phases=trace,gc+humongous=trace",
"-XX:+UnlockExperimentalVMOptions",
GCWithHumongousObjectTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xms128M",
"-Xmx128M",
"-Xmn16M",
"-XX:G1HeapRegionSize=1M",
"-Xlog:gc+phases=trace,gc+humongous=trace",
"-XX:+UnlockExperimentalVMOptions",
GCWithHumongousObjectTest.class.getName());
System.out.println(output.getStdout());
// As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.

View File

@ -218,28 +218,25 @@ public class TestGCLogMessages {
private void testNormalLogs() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
GCTest.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, allLogMessages, Level.OFF);
output.shouldHaveExitValue(0);
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+phases=debug",
GCTest.class.getName());
output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+phases=debug",
GCTest.class.getName());
output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, allLogMessages, Level.DEBUG);
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+phases=trace",
GCTest.class.getName());
output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+phases=trace",
GCTest.class.getName());
output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, allLogMessages, Level.TRACE);
output.shouldHaveExitValue(0);
}
@ -253,11 +250,10 @@ public class TestGCLogMessages {
};
private void testConcurrentRefinementLogs() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+refine+stats=debug",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
"-Xlog:gc+refine+stats=debug",
GCTest.class.getName());
checkMessagesAtLevel(output, concRefineMessages, Level.DEBUG);
}
@ -272,29 +268,27 @@ public class TestGCLogMessages {
};
private void testWithEvacuationFailureLogs() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-XX:+G1GCAllocationFailureALot",
"-XX:G1GCAllocationFailureALotCount=100",
"-XX:G1GCAllocationFailureALotInterval=1",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+phases=debug",
GCTestWithAllocationFailure.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-XX:+G1GCAllocationFailureALot",
"-XX:G1GCAllocationFailureALotCount=100",
"-XX:G1GCAllocationFailureALotInterval=1",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+phases=debug",
GCTestWithAllocationFailure.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, exhFailureMessages, Level.DEBUG);
output.shouldHaveExitValue(0);
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-Xms32M",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+phases=trace",
GCTestWithAllocationFailure.class.getName());
output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-Xms32M",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+phases=trace",
GCTestWithAllocationFailure.class.getName());
output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, exhFailureMessages, Level.TRACE);
output.shouldHaveExitValue(0);
}
@ -305,29 +299,27 @@ public class TestGCLogMessages {
};
private void testWithConcurrentStart() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xbootclasspath/a:.",
"-Xlog:gc*=debug",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
GCTestWithConcurrentStart.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
"-Xbootclasspath/a:.",
"-Xlog:gc*=debug",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
GCTestWithConcurrentStart.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, concurrentStartMessages, Level.TRACE);
output.shouldHaveExitValue(0);
}
private void testExpandHeap() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xbootclasspath/a:.",
"-Xlog:gc+ergo+heap=debug",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
GCTest.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-Xmx10M",
"-Xbootclasspath/a:.",
"-Xlog:gc+ergo+heap=debug",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Expand the heap. requested expansion amount: ");
output.shouldContain("B expansion amount: ");
output.shouldHaveExitValue(0);

View File

@ -45,7 +45,7 @@ public class TestHumongousAllocConcurrentStart {
private static final int initiatingHeapOccupancyPercent = 50; // %
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeTestJava(
"-XX:+UseG1GC",
"-Xms" + heapSize + "m",
"-Xmx" + heapSize + "m",
@ -54,7 +54,6 @@ public class TestHumongousAllocConcurrentStart {
"-Xlog:gc",
HumongousObjectAllocator.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Pause Young (Concurrent Start) (G1 Humongous Allocation)");
output.shouldNotContain("Full GC");
output.shouldHaveExitValue(0);

View File

@ -47,7 +47,7 @@ public class TestHumongousAllocNearlyFullRegion {
private static final int heapRegionSize = 1; // MB
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseG1GC",
"-Xms" + heapSize + "m",
"-Xmx" + heapSize + "m",
@ -55,7 +55,6 @@ public class TestHumongousAllocNearlyFullRegion {
"-Xlog:gc",
HumongousObjectAllocator.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Pause Young (Concurrent Start) (G1 Humongous Allocation)");
output.shouldHaveExitValue(0);
}

View File

@ -106,8 +106,7 @@ public class TestHumongousCodeCacheRoots {
finalargs.add(classname);
finalargs.addAll(Arrays.asList(arguments));
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(finalargs);
output.shouldHaveExitValue(0);
return output;
}

View File

@ -56,7 +56,7 @@ public class TestHumongousConcurrentStartUndo {
private static final int YoungSize = HeapSize / 8;
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-XX:+UseG1GC",
"-Xms" + HeapSize + "m",
@ -70,7 +70,6 @@ public class TestHumongousConcurrentStartUndo {
"-Xlog:gc*",
EdenObjectAllocatorWithHumongousAllocation.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Pause Young (Concurrent Start) (G1 Humongous Allocation)");
output.shouldContain("Concurrent Undo Cycle");
output.shouldContain("Concurrent Mark Cycle");

View File

@ -120,12 +120,9 @@ public class TestLargePageUseForAuxMemory {
static void testVM(String what, long heapsize, boolean cardsShouldUseLargePages, boolean bitmapShouldUseLargePages) throws Exception {
System.out.println(what + " heapsize " + heapsize + " card table should use large pages " + cardsShouldUseLargePages + " " +
"bitmaps should use large pages " + bitmapShouldUseLargePages);
ProcessBuilder pb;
// Test with large page enabled.
pb = ProcessTools.createLimitedTestJavaProcessBuilder(getOpts(heapsize, true));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(getOpts(heapsize, true));
// Only expect large page size if large pages are enabled.
if (largePagesEnabled(output)) {
@ -138,9 +135,8 @@ public class TestLargePageUseForAuxMemory {
output.shouldHaveExitValue(0);
// Test with large page disabled.
pb = ProcessTools.createLimitedTestJavaProcessBuilder(getOpts(heapsize, false));
output = ProcessTools.executeLimitedTestJava(getOpts(heapsize, false));
output = new OutputAnalyzer(pb.start());
checkSmallTables(output, smallPageSize);
checkBitmap(output, smallPageSize);
output.shouldHaveExitValue(0);

View File

@ -85,29 +85,26 @@ public class TestLargePageUseForHeap {
}
static void testVM(long regionSize) throws Exception {
ProcessBuilder pb;
// Test with large page enabled.
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + regionSize,
"-Xmx128m",
"-Xlog:gc+init,pagesize,gc+heap+coops=debug",
"-XX:+UseLargePages",
"-version");
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + regionSize,
"-Xmx128m",
"-Xlog:gc+init,pagesize,gc+heap+coops=debug",
"-XX:+UseLargePages",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
boolean largePageEnabled = checkLargePageEnabled(output);
checkHeap(output, largePageEnabled ? largePageSize : smallPageSize);
output.shouldHaveExitValue(0);
// Test with large page disabled.
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + regionSize,
"-Xmx128m",
"-Xlog:gc+init,pagesize,gc+heap+coops=debug",
"-XX:-UseLargePages",
"-version");
output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + regionSize,
"-Xmx128m",
"-Xlog:gc+init,pagesize,gc+heap+coops=debug",
"-XX:-UseLargePages",
"-version");
output = new OutputAnalyzer(pb.start());
checkHeap(output, smallPageSize);
output.shouldHaveExitValue(0);
}

View File

@ -50,9 +50,7 @@ public class TestMarkStackSizes {
Collections.addAll(testArguments, extraArgs);
testArguments.add("-version");
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(testArguments);
System.out.println(output.getStderr());

View File

@ -109,9 +109,7 @@ public class TestMixedGCLiveThreshold {
basicOpts.add(GCTest.class.getName());
ProcessBuilder procBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(basicOpts);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
return analyzer;
return ProcessTools.executeLimitedTestJava(basicOpts);
}
private static boolean regionsSelectedForRebuild(String output) throws Exception {

View File

@ -40,7 +40,7 @@ public class TestOneEdenRegionAfterGC {
private static long YoungGenSize = 32 * 1024 * 1024;
private static OutputAnalyzer run() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
return ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-Xmn" + YoungGenSize,
"-Xmx512M",
@ -50,7 +50,6 @@ public class TestOneEdenRegionAfterGC {
"-Xlog:gc,gc+ergo*=trace",
TestOneEdenRegionAfterGC.Allocate.class.getName(),
"" + YoungGenSize);
return new OutputAnalyzer(pb.start());
}
public static void main(String args[]) throws Exception {

View File

@ -59,8 +59,7 @@ public class TestPLABOutput {
GCTest.class.getName()
};
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(arguments);
output.shouldHaveExitValue(0);

View File

@ -62,8 +62,7 @@ public class TestPLABSizeBounds {
testArguments.add("-XX:OldPLABSize=" + plabSize);
testArguments.add(GCTest.class.getName());
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(testArguments);
if (shouldSucceed) {
output.shouldHaveExitValue(0);

View File

@ -40,24 +40,22 @@ import jdk.test.lib.process.ProcessTools;
public class TestPeriodicLogMessages {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:G1PeriodicGCInterval=0",
"-Xlog:gc+init,gc+periodic=debug",
"-Xmx10M",
GCTest.class.getName());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:G1PeriodicGCInterval=0",
"-Xlog:gc+init,gc+periodic=debug",
"-Xmx10M",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Periodic GC: Disabled");
output.shouldNotContain("Checking for periodic GC");
output.shouldHaveExitValue(0);
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:G1PeriodicGCInterval=100",
"-Xlog:gc+init,gc+periodic=debug",
"-Xmx10M",
GCTest.class.getName());
output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:G1PeriodicGCInterval=100",
"-Xlog:gc+init,gc+periodic=debug",
"-Xmx10M",
GCTest.class.getName());
output = new OutputAnalyzer(pb.start());
output.shouldContain("Periodic GC: Enabled");
output.shouldContain("Periodic GC Interval: 100ms");
output.shouldContain("Checking for periodic GC");

View File

@ -69,8 +69,7 @@ public class TestPrintRegionRememberedSetInfo {
finalargs.add(RunAndWaitForMarking.class.getName());
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(finalargs);
output.shouldHaveExitValue(0);
String result = output.getStdout();

View File

@ -44,14 +44,12 @@ import jdk.test.lib.process.ProcessTools;
public class TestRemsetLoggingThreads {
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+remset+exit=trace",
"-XX:G1ConcRefinementThreads=" + refinementThreads,
"-XX:ParallelGCThreads=" + workerThreads,
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-Xlog:gc+remset+exit=trace",
"-XX:G1ConcRefinementThreads=" + refinementThreads,
"-XX:ParallelGCThreads=" + workerThreads,
"-version");
String pattern = "Concurrent refinement threads times \\(s\\)$";
Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

View File

@ -77,8 +77,7 @@ public class TestRemsetLoggingTools {
finalargs.add(VerifySummaryOutput.class.getName());
finalargs.add(String.valueOf(numGCs));
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(finalargs);
output.shouldHaveExitValue(0);

View File

@ -50,8 +50,6 @@ public class TestSharedArchiveWithPreTouch {
final List<String> BaseOptions = Arrays.asList(new String[] {"-XX:+UseG1GC", "-XX:+AlwaysPreTouch",
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + ArchiveFileName });
ProcessBuilder pb;
List<String> dump_args = new ArrayList<String>(BaseOptions);
if (Platform.is64bit()) {
@ -59,8 +57,8 @@ public class TestSharedArchiveWithPreTouch {
}
dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump", "-Xlog:cds" }));
pb = ProcessTools.createLimitedTestJavaProcessBuilder(dump_args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(dump_args);
try {
output.shouldContain("Loading classes to share");
output.shouldHaveExitValue(0);
@ -72,8 +70,7 @@ public class TestSharedArchiveWithPreTouch {
}
load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-version" }));
pb = ProcessTools.createLimitedTestJavaProcessBuilder(load_args.toArray(new String[0]));
output = new OutputAnalyzer(pb.start());
output = ProcessTools.executeLimitedTestJava(load_args.toArray(new String[0]));
output.shouldContain("sharing");
output.shouldHaveExitValue(0);
} catch (RuntimeException e) {

View File

@ -88,9 +88,8 @@ public class TestShrinkAuxiliaryData {
}
private void performTest(List<String> opts) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(opts);
OutputAnalyzer output = ProcessTools.executeTestJava(opts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
System.err.println(output.getStderr());
output.shouldHaveExitValue(0);

View File

@ -61,7 +61,7 @@ public class TestShrinkDefragmentedHeap {
private static final int REGION_SIZE = 1 * 1024 * 1024;
public static void main(String[] args) throws Exception, Throwable {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:InitialHeapSize=" + INITIAL_HEAP_SIZE,
"-Xmn" + MINIMAL_YOUNG_SIZE,
"-Xmx" + MAXIMUM_HEAP_SIZE,
@ -74,7 +74,6 @@ public class TestShrinkDefragmentedHeap {
GCTest.class.getName()
);
OutputAnalyzer output = ProcessTools.executeProcess(pb);
output.shouldHaveExitValue(0);
}

View File

@ -40,17 +40,16 @@ import jdk.test.whitebox.WhiteBox;
public class TestSkipRebuildRemsetPhase {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xbootclasspath/a:.",
"-XX:+UseG1GC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:G1MixedGCLiveThresholdPercent=20",
"-Xlog:gc+marking=debug,gc+phases=debug,gc+remset+tracking=trace",
"-Xms10M",
"-Xmx10M",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xbootclasspath/a:.",
"-XX:+UseG1GC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:G1MixedGCLiveThresholdPercent=20",
"-Xlog:gc+marking=debug,gc+phases=debug,gc+remset+tracking=trace",
"-Xms10M",
"-Xmx10M",
GCTest.class.getName());
output.shouldContain("Skipping Remembered Set Rebuild.");
output.shouldContain("No Remembered Sets to update after rebuild");
output.shouldHaveExitValue(0);

View File

@ -178,10 +178,7 @@ public class TestVerifyGCType {
basicOpts.add(TriggerGCs.class.getName());
ProcessBuilder procBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(basicOpts);
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
return analyzer;
return ProcessTools.executeLimitedTestJava(basicOpts);
}
private static void verifyCollection(String name, boolean expectBefore, boolean expectDuring, boolean expectAfter, String data) {

View File

@ -34,7 +34,7 @@ import java.nio.file.Paths;
* Since the generation depends on current host architecture it cannot be done as part of pre-compilation step
*/
public class ClassLoaderGenerator {
public static void main(String[] args) throws IOException {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new Error("Test Bug: Expected region size wasn't provided as command line argument");
@ -47,7 +47,7 @@ public class ClassLoaderGenerator {
}
public static void generateClassLoader(long regionSize, Path wrkDir) throws IOException {
public static void generateClassLoader(long regionSize, Path wrkDir) throws Exception {
// Generating simple classloader
String finalSimpleClassLoaderPrototype = TestHumongousClassLoader.GENERIC_PROTOTYPE
.replace("${Methods}",

View File

@ -75,12 +75,11 @@ public enum G1SampleClass {
* @param wrkDir working dir where generated classes are put and compiled
* @param classNamePrefix prefix for service classes (ones we use to create chain of inheritance)
* @return a class with instances of the specified size loaded in specified class loader
* @throws IOException
* @throws ClassNotFoundException
* @throws Exception
*/
public Class<?> getCls(ClassLoader classLoader, Path wrkDir, String classNamePrefix)
throws IOException, ClassNotFoundException {
throws Exception {
return Helpers.generateCompileAndLoad(classLoader, Helpers.enumNameToClassName(name()) + "Class",
expectedInstanceSize(), wrkDir, classNamePrefix);
}

View File

@ -140,9 +140,7 @@ public class TestHumongousClassLoader {
public abstract void provoke();
}
public static void main(String[] args) throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException, NoSuchMethodException, InvocationTargetException {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new Error("Test Bug: Expected GC type wasn't provided as command line argument");
}

View File

@ -82,8 +82,7 @@ public class TestHumongousNonArrayAllocation {
private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final String CLASS_NAME_PREFIX = TestHumongousNonArrayAllocation.class.getSimpleName() + "_";
public static void main(String[] args) throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new Error("Test Bug: Expected class name wasn't provided as command line argument");

View File

@ -90,8 +90,7 @@ public class TestLogging {
Collections.addAll(testOpts, extraFlags);
testOpts.add(RunMixedGC.class.getName());
System.out.println(testOpts);
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testOpts);
return new OutputAnalyzer(pb.start());
return ProcessTools.executeLimitedTestJava(testOpts);
}
}

View File

@ -181,7 +181,7 @@ public class TestG1NUMATouchRegions {
return;
}
ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xbootclasspath/a:.",
"-Xlog:pagesize,gc+heap+region=trace",
"-XX:+UseG1GC",
@ -195,7 +195,6 @@ public class TestG1NUMATouchRegions {
largePagesSetting,
"-XX:G1HeapRegionSize=" + regionSizeInMB + "m",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
// Check NUMA availability.
if (status == NUMASupportStatus.NOT_CHECKED) {

View File

@ -48,18 +48,17 @@ public class TestPinnedObjectTypes {
}
private static void testPinning(String type, boolean shouldSucceed) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-XX:-CreateCoredumpOnCrash",
"-Xmx32M",
"-Xmn16M",
"-Xlog:gc",
TestObjectPin.class.getName(),
type);
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-XX:-CreateCoredumpOnCrash",
"-Xmx32M",
"-Xmn16M",
"-Xlog:gc",
TestObjectPin.class.getName(),
type);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
if (shouldSucceed) {
output.shouldHaveExitValue(0);
@ -84,4 +83,3 @@ class TestObjectPin {
wb.pinObject(o);
}
}

View File

@ -64,19 +64,18 @@ public class TestPinnedObjectsEvacuation {
}
private static void testPinnedEvacuation(int younGCsBeforeUnpin, int expectedSkipEvents, int expectedDropEvents, int expectedReclaimEvents) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-Xmx32M",
"-Xmn16M",
"-XX:G1NumCollectionsKeepPinned=2",
"-XX:+VerifyAfterGC",
"-Xlog:gc,gc+ergo+cset=trace",
TestObjectPin.class.getName(),
String.valueOf(younGCsBeforeUnpin));
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-Xmx32M",
"-Xmn16M",
"-XX:G1NumCollectionsKeepPinned=2",
"-XX:+VerifyAfterGC",
"-Xlog:gc,gc+ergo+cset=trace",
TestObjectPin.class.getName(),
String.valueOf(younGCsBeforeUnpin));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
output.shouldHaveExitValue(0);
@ -128,4 +127,3 @@ class TestObjectPin {
wb.youngGC();
}
}

View File

@ -257,24 +257,23 @@ public class TestPinnedOldObjectsEvacuation {
int expectedDropEvents,
int expectedMarkingReclaimEvents,
int expectedRetainedReclaimEvents) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-Xmx32M",
"-Xmn16M",
"-XX:MarkSweepDeadRatio=0",
"-XX:G1NumCollectionsKeepPinned=3",
"-XX:+UnlockExperimentalVMOptions",
// Take all old regions to make sure that the pinned one is included in the collection set.
"-XX:G1MixedGCLiveThresholdPercent=100",
"-XX:G1HeapWastePercent=0",
"-XX:+VerifyAfterGC",
"-Xlog:gc,gc+ergo+cset=trace",
TestObjectPin.class.getName(),
String.valueOf(youngGCsBeforeUnpin));
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-Xmx32M",
"-Xmn16M",
"-XX:MarkSweepDeadRatio=0",
"-XX:G1NumCollectionsKeepPinned=3",
"-XX:+UnlockExperimentalVMOptions",
// Take all old regions to make sure that the pinned one is included in the collection set.
"-XX:G1MixedGCLiveThresholdPercent=100",
"-XX:G1HeapWastePercent=0",
"-XX:+VerifyAfterGC",
"-Xlog:gc,gc+ergo+cset=trace",
TestObjectPin.class.getName(),
String.valueOf(youngGCsBeforeUnpin));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
output.shouldHaveExitValue(0);
@ -334,4 +333,3 @@ class TestObjectPin {
wb.youngGC();
}
}

View File

@ -42,8 +42,7 @@ import java.util.stream.Collectors;
public class TestDeprecatedPrintFlags {
public static void testPrintGC() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGC", DoGC.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+PrintGC", DoGC.class.getName());
output.shouldContain("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead.");
output.shouldNotContain("PrintGCDetails");
output.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
@ -52,8 +51,7 @@ public class TestDeprecatedPrintFlags {
}
public static void testPrintGCDetails() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGCDetails", DoGC.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+PrintGCDetails", DoGC.class.getName());
output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
output.shouldNotContain("PrintGC is deprecated");
output.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
@ -63,8 +61,7 @@ public class TestDeprecatedPrintFlags {
public static void testXloggc() throws Exception {
String fileName = "gc-test.log";
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xloggc:" + fileName, DoGC.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xloggc:" + fileName, DoGC.class.getName());
output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead.");
output.shouldNotContain("PrintGCDetails");
output.shouldNotContain("PrintGC");
@ -80,8 +77,7 @@ public class TestDeprecatedPrintFlags {
public static void testXloggcWithPrintGCDetails() throws Exception {
String fileName = "gc-test.log";
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGCDetails", "-Xloggc:" + fileName, DoGC.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+PrintGCDetails", "-Xloggc:" + fileName, DoGC.class.getName());
output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead.");
output.shouldNotContain("PrintGC is deprecated");

View File

@ -73,9 +73,9 @@ public class TestGCId {
}
private static void testGCId(String gcFlag) throws Exception {
ProcessBuilder pb_default =
ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xlog:gc", "-Xmx10M", GCTest.class.getName());
verifyContainsGCIDs(new OutputAnalyzer(pb_default.start()));
OutputAnalyzer output =
ProcessTools.executeLimitedTestJava("-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xlog:gc", "-Xmx10M", GCTest.class.getName());
verifyContainsGCIDs(output);
}
static class GCTest {

View File

@ -93,24 +93,24 @@ public class TestMetaSpaceLog {
}
private static void testMetaSpaceUpdate() throws Exception {
ProcessBuilder pb =
ProcessTools.createTestJavaProcessBuilder(
"-Xlog:gc*",
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xmx1000M",
"-Xms1000M",
StressMetaSpace.class.getName());
OutputAnalyzer output = null;
try {
output = new OutputAnalyzer(pb.start());
output = ProcessTools.executeTestJava(
"-Xlog:gc*",
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xmx1000M",
"-Xms1000M",
StressMetaSpace.class.getName());
verifyContainsMetaSpaceUpdate(output);
} catch (Exception e) {
// For error diagnosis: print and throw.
e.printStackTrace();
output.reportDiagnosticSummary();
if (output != null) {
output.reportDiagnosticSummary();
}
throw e;
}
}

View File

@ -67,11 +67,10 @@ public class TestPrintReferences {
}
public static void testRefs() throws Exception {
ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:gc+ref+phases=debug",
"-XX:+UseG1GC",
"-Xmx32M",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xlog:gc+ref+phases=debug",
"-XX:+UseG1GC",
"-Xmx32M",
GCTest.class.getName());
checkRefsLogFormat(output);
@ -95,14 +94,13 @@ public class TestPrintReferences {
}
public static void testPhases(boolean parallelRefProcEnabled) throws Exception {
ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:gc+phases+ref=debug",
"-XX:+UseG1GC",
"-Xmx32M",
"-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled",
"-XX:-UseDynamicNumberOfGCThreads",
"-XX:ParallelGCThreads=2",
GCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xlog:gc+phases+ref=debug",
"-XX:+UseG1GC",
"-Xmx32M",
"-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled",
"-XX:-UseDynamicNumberOfGCThreads",
"-XX:ParallelGCThreads=2",
GCTest.class.getName());
checkLogFormat(output, parallelRefProcEnabled);
checkLogValue(output);

View File

@ -77,9 +77,8 @@ public class CompressedClassSpaceSizeInJmapHeap {
}
private static void run(ProcessBuilder pb) throws Exception {
Process p = pb.start();
p.waitFor();
int exitValue = p.exitValue();
OutputAnalyzer output = ProcessTools.executeProcess(pb);
int exitValue = output.getExitValue();
if (exitValue != 0) {
throw new Exception("jmap -heap exited with error code: " + exitValue);
}

View File

@ -84,13 +84,12 @@ public class TestMetaspaceSizeFlags {
}
private static OutputAnalyzer run(long maxMetaspaceSize, long metaspaceSize) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
return ProcessTools.executeLimitedTestJava(
"-XX:MaxMetaspaceSize=" + maxMetaspaceSize,
"-XX:MetaspaceSize=" + metaspaceSize,
"-XX:-UseLargePages", // Prevent us from using 2GB large pages on solaris + sparc.
"-XX:+PrintFlagsFinal",
"-version");
return new OutputAnalyzer(pb.start());
}
private static class MetaspaceFlags {

View File

@ -119,8 +119,7 @@ public class TestSizeTransitions {
System.out.println(" " + a);
}
final ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(jvmArgs);
final OutputAnalyzer output = new OutputAnalyzer(pb.start());
final OutputAnalyzer output = ProcessTools.executeLimitedTestJava(jvmArgs);
System.out.println(output.getStdout());
output.shouldHaveExitValue(0);

View File

@ -41,8 +41,7 @@ import jdk.test.lib.process.OutputAnalyzer;
public class HeapChangeLogging {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", HeapFiller.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", HeapFiller.class.getName());
String stdout = output.getStdout();
System.out.println(stdout);
Matcher stdoutMatcher = Pattern.compile(".*\\(Allocation Failure\\) [0-9]+[KMG]->[0-9]+[KMG]\\([0-9]+[KMG]\\)", Pattern.MULTILINE).matcher(stdout);

View File

@ -56,14 +56,13 @@ public class TestEvilSyncBug {
for (int c = 0; c < NUM_RUNS; c++) {
Callable<Void> task = () -> {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xms128m",
OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xms128m",
"-Xmx128m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCHeuristics=aggressive",
"TestEvilSyncBug", "test");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
return null;
};

View File

@ -127,6 +127,7 @@
*/
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
@ -141,11 +142,7 @@ public class TestJcmdHeapDump {
jcmd.addToolArg(dumpFileName);
try {
ProcessBuilder pb = new ProcessBuilder(jcmd.getCommand());
Process jcmdProc = pb.start();
OutputAnalyzer output = new OutputAnalyzer(jcmdProc);
jcmdProc.waitFor();
OutputAnalyzer output = ProcessTools.executeProcess(jcmd.getCommand());
output.shouldHaveExitValue(0);
} catch (Exception e) {
throw new RuntimeException("Test failed: " + e);

View File

@ -41,9 +41,8 @@ public class TestObjItrWithHeapDump {
String[] cmds = Arrays.copyOf(args, args.length + 2);
cmds[args.length] = TestObjItrWithHeapDump.class.getName();
cmds[args.length + 1] = "test";
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(cmds);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("Class Histogram (before full gc)");
output.shouldContain("Class Histogram (after full gc)");

View File

@ -42,9 +42,8 @@ public class TestPeriodicGC {
String[] cmds = Arrays.copyOf(args, args.length + 2);
cmds[args.length] = TestPeriodicGC.class.getName();
cmds[args.length + 1] = "test";
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(cmds);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
if (periodic && !output.getOutput().contains("Trigger: Time since last GC")) {
throw new AssertionError(msg + ": Should have periodic GC in logs");

View File

@ -55,27 +55,25 @@ public class TestAllocLargeObj {
}
{
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = ProcessTools.executeLimitedTestJava(
"-Xmx16m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
TestAllocLargeObj.class.getName(),
"test");
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(1);
analyzer.shouldContain("java.lang.OutOfMemoryError: Java heap space");
}
{
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = ProcessTools.executeLimitedTestJava(
"-Xmx1g",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
TestAllocLargeObj.class.getName(),
"test");
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
analyzer.shouldNotContain("java.lang.OutOfMemoryError: Java heap space");
}

View File

@ -50,27 +50,25 @@ public class TestAllocLargerThanHeap {
}
{
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = ProcessTools.executeLimitedTestJava(
"-Xmx16m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
TestAllocLargerThanHeap.class.getName(),
"test");
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(1);
analyzer.shouldContain("java.lang.OutOfMemoryError: Java heap space");
}
{
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
OutputAnalyzer analyzer = ProcessTools.executeLimitedTestJava(
"-Xmx1g",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
TestAllocLargerThanHeap.class.getName(),
"test");
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
analyzer.shouldNotContain("java.lang.OutOfMemoryError: Java heap space");
}

Some files were not shown because too many files have changed in this diff Show More