Skip to content

Commit

Permalink
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
Browse files Browse the repository at this point in the history
Disable ZapUnusedHeapArea and VerifyBeforeExit for gc/arguments tests.

Reviewed-by: mdoerr
Backport-of: b85ebc1
  • Loading branch information
GoeLin committed Jun 22, 2022
1 parent c10e0de commit d12c2e2
Show file tree
Hide file tree
Showing 29 changed files with 153 additions and 54 deletions.
79 changes: 79 additions & 0 deletions test/hotspot/jtreg/gc/arguments/GCArguments.java
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package gc.arguments;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;

/**
* Helper class for adding options to child processes that should be
* used by all of the argument tests in this package. The default
* options are added at the front, to allow them to be overridden by
* explicit options from any particular test.
*/

public final class GCArguments {

// Avoid excessive execution time.
static private void disableZapUnusedHeapArea(List<String> arguments) {
// Develop option, only available in debug builds.
if (Platform.isDebugBuild()) {
arguments.add("-XX:-ZapUnusedHeapArea");
}
}

// Avoid excessive execution time.
static private void disableVerifyBeforeExit(List<String> arguments) {
// Diagnostic option, default enabled in debug builds.
if (Platform.isDebugBuild()) {
arguments.add("-XX:-VerifyBeforeExit");
}
}

static private void addDefaults(List<String> arguments) {
disableZapUnusedHeapArea(arguments);
disableVerifyBeforeExit(arguments);
}

static private String[] withDefaults(String[] arguments) {
List<String> augmented = new ArrayList<String>();
addDefaults(augmented);
Collections.addAll(augmented, arguments);
return augmented.toArray(new String[augmented.size()]);
}

static public ProcessBuilder createJavaProcessBuilder(String... arguments) {
return createJavaProcessBuilder(false, arguments);
}

static public ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions,
String... arguments) {
return ProcessTools.createJavaProcessBuilder(addTestVmAndJavaOptions,
withDefaults(arguments));
}

}
3 changes: 2 additions & 1 deletion test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java
Expand Up @@ -30,6 +30,7 @@
* @requires vm.gc.Parallel
* @summary Test argument processing for -XX:+AggressiveHeap.
* @library /test/lib
* @library /
* @modules java.base java.management
* @run driver gc.arguments.TestAggressiveHeap
*/
Expand Down Expand Up @@ -66,7 +67,7 @@ public static void main(String args[]) throws Exception {
" *bool +UseParallelGC *= *true +\\{product\\} *\\{command line\\}";

private static void testFlag() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
option, heapSizeOption, "-XX:+PrintFlagsFinal", "-version");

OutputAnalyzer output = new OutputAnalyzer(pb.start());
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @bug 8054823
* @key gc
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run driver gc.arguments.TestArrayAllocatorMallocLimit
Expand All @@ -52,7 +53,7 @@ public static void main(String [] args) throws Exception {
private static final String printFlagsFinalPattern = " *size_t *" + flagName + " *:?= *(\\d+) *\\{experimental\\} *";

public static void testDefaultValue() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");

OutputAnalyzer output = new OutputAnalyzer(pb.start());
Expand All @@ -78,7 +79,7 @@ public static void testDefaultValue() throws Exception {
public static void testSetValue() throws Exception {
long flagValue = 2048;

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "-XX:+PrintFlagsFinal", "-version");

OutputAnalyzer output = new OutputAnalyzer(pb.start());
Expand Down
Expand Up @@ -33,6 +33,7 @@
* @summary Tests that VM prints a warning when -XX:CompressedClassSpaceSize
* is used together with -XX:-UseCompressedClassPointers
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestCompressedClassFlags
Expand All @@ -50,7 +51,7 @@ public static void main(String[] args) throws Exception {
}

private static OutputAnalyzer runJava(String ... args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(args);
return new OutputAnalyzer(pb.start());
}
}
15 changes: 8 additions & 7 deletions test/hotspot/jtreg/gc/arguments/TestDisableDefaultGC.java
Expand Up @@ -29,6 +29,7 @@
* @bug 8068579
* @key gc
* @library /test/lib
* @library /
* @requires vm.gc=="null"
* @modules java.base/jdk.internal.misc
* java.management
Expand All @@ -41,13 +42,13 @@
public class TestDisableDefaultGC {
public static void main(String[] args) throws Exception {
// Start VM, disabling all possible default GCs
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseSerialGC",
"-XX:-UseParallelGC",
"-XX:-UseG1GC",
"-XX:-UseConcMarkSweepGC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:-UseZGC",
"-version");
ProcessBuilder pb = GCArguments.createJavaProcessBuilder("-XX:-UseSerialGC",
"-XX:-UseParallelGC",
"-XX:-UseG1GC",
"-XX:-UseConcMarkSweepGC",
"-XX:+UnlockExperimentalVMOptions",
"-XX:-UseZGC",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldMatch("Garbage collector not selected");
output.shouldHaveExitValue(1);
Expand Down
Expand Up @@ -29,6 +29,7 @@
* @requires vm.gc.G1
* @summary Tests argument processing for double type flag, G1ConcMarkStepDurationMillis
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestG1ConcMarkStepDurationMillis
Expand Down Expand Up @@ -79,7 +80,7 @@ private static void runG1ConcMarkStepDurationMillisTest(String expectedValue, in

Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis="+expectedValue, "-XX:+PrintFlagsFinal", "-version");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());

output.shouldHaveExitValue(expectedResult == PASS ? 0 : 1);
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @requires vm.gc.G1
* @summary Tests argument processing for G1ConcRefinementThreads
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestG1ConcRefinementThreads
Expand Down Expand Up @@ -70,7 +71,7 @@ private static void runG1ConcRefinementThreadsTest(String[] passedOpts,
}
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());

output.shouldHaveExitValue(0);
Expand Down
3 changes: 2 additions & 1 deletion test/hotspot/jtreg/gc/arguments/TestG1HeapRegionSize.java
Expand Up @@ -32,6 +32,7 @@
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @library /test/lib
* @library /
* @run main gc.arguments.TestG1HeapRegionSize
*/

Expand All @@ -53,7 +54,7 @@ private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int
flagList.add("-XX:+PrintFlagsFinal");
flagList.add("-version");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagList.toArray(new String[0]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flagList.toArray(new String[0]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(exitValue);

Expand Down
3 changes: 2 additions & 1 deletion test/hotspot/jtreg/gc/arguments/TestG1PercentageOptions.java
Expand Up @@ -30,6 +30,7 @@
* @requires vm.gc.G1
* @summary Test argument processing of various percentage options
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run driver gc.arguments.TestG1PercentageOptions
Expand Down Expand Up @@ -65,7 +66,7 @@ private static final class OptionDescription {

private static void check(String flag, boolean is_valid) throws Exception {
String[] flags = new String[] { "-XX:+UseG1GC", flag, "-version" };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (is_valid) {
output.shouldHaveExitValue(0);
Expand Down
3 changes: 2 additions & 1 deletion test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java
Expand Up @@ -29,6 +29,7 @@
* @bug 8025661
* @summary Test parsing of -Xminf and -Xmaxf
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main/othervm gc.arguments.TestHeapFreeRatio
Expand All @@ -48,7 +49,7 @@ enum Validation {
}

private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
"-Xminf" + min,
"-Xmaxf" + max,
"-version");
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @requires vm.gc.Parallel
* @summary Tests argument processing for initial tenuring threshold
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main/othervm gc.arguments.TestInitialTenuringThreshold
Expand All @@ -42,7 +43,7 @@
public class TestInitialTenuringThreshold {

public static void runWithThresholds(int initial, int max, boolean shouldfail) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
"-XX:+UseParallelGC",
"-XX:InitialTenuringThreshold=" + String.valueOf(initial),
"-XX:MaxTenuringThreshold=" + String.valueOf(max),
Expand All @@ -59,7 +60,7 @@ public static void runWithThresholds(int initial, int max, boolean shouldfail) t


public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
// some value below the default value of InitialTenuringThreshold of 7
"-XX:MaxTenuringThreshold=1",
"-version"
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java
Expand Up @@ -98,7 +98,7 @@ private static long align_up(long value, long alignment) {
}

private static void getNewOldSize(String gcflag, long[] values) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag,
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(gcflag,
"-XX:+PrintFlagsFinal", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
Expand Down Expand Up @@ -179,7 +179,7 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname,
finalargs.add(classname);
finalargs.addAll(Arrays.asList(arguments));

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(new String[0]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

Expand Down Expand Up @@ -279,7 +279,7 @@ private static void shouldContainOrNot(OutputAnalyzer output, boolean contains,
}

private static void expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
shouldContainOrNot(output, hasWarning, "Warning");
shouldContainOrNot(output, hasError, "Error");
Expand Down
Expand Up @@ -100,7 +100,7 @@ public static void positiveTest(int minRatio, boolean useXminf,
Boolean.toString(shrinkHeapInSteps)
);

ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
analyzer.shouldHaveExitValue(0);
}
Expand All @@ -125,7 +125,7 @@ public static void negativeTest(int minRatio, boolean useXminf,
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
"-version"
);
ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
analyzer.shouldHaveExitValue(1);
analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
Expand Down
8 changes: 6 additions & 2 deletions test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java
Expand Up @@ -31,6 +31,7 @@
* processing.
* @requires vm.gc.Serial
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestMaxNewSize -XX:+UseSerialGC
Expand All @@ -45,6 +46,7 @@
* processing.
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestMaxNewSize -XX:+UseParallelGC
Expand All @@ -59,6 +61,7 @@
* processing.
* @requires vm.gc.G1
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestMaxNewSize -XX:+UseG1GC
Expand All @@ -72,6 +75,7 @@
* @comment Graal does not support CMS
* @requires vm.gc.ConcMarkSweep & !vm.graal.enabled
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @run main gc.arguments.TestMaxNewSize -XX:+UseConcMarkSweepGC
Expand Down Expand Up @@ -104,7 +108,7 @@ private static void checkIncompatibleNewSize(String[] flags) throws Exception {
finalargs.addAll(Arrays.asList(flags));
finalargs.add("-version");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(new String[0]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Initial young gen size set larger than the maximum young gen size");
}
Expand All @@ -127,7 +131,7 @@ private static String getMaxNewSize(String[] flags) throws Exception {
finalargs.add("-XX:+PrintFlagsFinal");
finalargs.add("-version");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(new String[0]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
Expand Down
Expand Up @@ -104,7 +104,7 @@ public static void testSurvivorRatio(int survivorRatio,
Boolean.toString(useAdaptiveSizePolicy)
);
vmOptions.removeIf((String p) -> p.isEmpty());
ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
analyzer.shouldHaveExitValue(0);
}
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java
Expand Up @@ -84,7 +84,7 @@ public static void testNewRatio(int ratio, LinkedList<String> options) throws Ex
Integer.toString(ratio)
);

ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
analyzer.shouldHaveExitValue(0);
System.out.println(analyzer.getOutput());
Expand Down

1 comment on commit d12c2e2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.