Skip to content

Commit 1a09835

Browse files
committed
8317358: G1: Make TestMaxNewSize use createTestJvm
Reviewed-by: tschatzl, sjohanss
1 parent 47bb1a1 commit 1a09835

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,8 @@
2828
* @bug 7057939
2929
* @summary Make sure that MaxNewSize always has a useful value after argument
3030
* processing.
31-
* @requires vm.gc.Serial
31+
* @key flag-sensitive
32+
* @requires vm.gc.Serial & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null
3233
* @library /test/lib
3334
* @library /
3435
* @modules java.base/jdk.internal.misc
@@ -42,7 +43,8 @@
4243
* @bug 7057939
4344
* @summary Make sure that MaxNewSize always has a useful value after argument
4445
* processing.
45-
* @requires vm.gc.Parallel
46+
* @key flag-sensitive
47+
* @requires vm.gc.Parallel & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null
4648
* @library /test/lib
4749
* @library /
4850
* @modules java.base/jdk.internal.misc
@@ -56,7 +58,8 @@
5658
* @bug 7057939
5759
* @summary Make sure that MaxNewSize always has a useful value after argument
5860
* processing.
59-
* @requires vm.gc.G1
61+
* @key flag-sensitive
62+
* @requires vm.gc.G1 & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null
6063
* @library /test/lib
6164
* @library /
6265
* @modules java.base/jdk.internal.misc
@@ -79,46 +82,23 @@ public class TestMaxNewSize {
7982

8083
private static void checkMaxNewSize(String[] flags, int heapsize) throws Exception {
8184
BigInteger actual = new BigInteger(getMaxNewSize(flags));
82-
System.out.println(actual);
83-
if (actual.compareTo(new BigInteger((new Long(heapsize)).toString())) == 1) {
85+
System.out.println("asserting: " + actual + " <= " + heapsize);
86+
if (actual.compareTo(new BigInteger("" + heapsize)) > 0) {
8487
throw new RuntimeException("MaxNewSize value set to \"" + actual +
8588
"\", expected otherwise when running with the following flags: " + Arrays.asList(flags).toString());
8689
}
8790
}
8891

89-
private static void checkIncompatibleNewSize(String[] flags) throws Exception {
90-
ArrayList<String> finalargs = new ArrayList<String>();
91-
finalargs.addAll(Arrays.asList(flags));
92-
finalargs.add("-version");
93-
94-
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs);
95-
OutputAnalyzer output = new OutputAnalyzer(pb.start());
96-
output.shouldContain("Initial young gen size set larger than the maximum young gen size");
97-
}
98-
99-
private static boolean isRunningG1(String[] args) {
100-
for (int i = 0; i < args.length; i++) {
101-
if (args[i].contains("+UseG1GC")) {
102-
return true;
103-
}
104-
}
105-
return false;
106-
}
107-
10892
private static String getMaxNewSize(String[] flags) throws Exception {
10993
ArrayList<String> finalargs = new ArrayList<String>();
11094
finalargs.addAll(Arrays.asList(flags));
111-
if (isRunningG1(flags)) {
112-
finalargs.add("-XX:G1HeapRegionSize=1M");
113-
}
11495
finalargs.add("-XX:+PrintFlagsFinal");
11596
finalargs.add("-version");
11697

117-
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs);
98+
ProcessBuilder pb = GCArguments.createTestJvm(finalargs);
11899
OutputAnalyzer output = new OutputAnalyzer(pb.start());
119100
output.shouldHaveExitValue(0);
120101
String stdout = output.getStdout();
121-
//System.out.println(stdout);
122102
return getFlagValue("MaxNewSize", stdout);
123103
}
124104

0 commit comments

Comments
 (0)