Skip to content

Commit

Permalink
8317358: G1: Make TestMaxNewSize use createTestJvm
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, sjohanss
  • Loading branch information
lkorinth committed Oct 19, 2023
1 parent 47bb1a1 commit 1a09835
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
Expand Down Expand Up @@ -28,7 +28,8 @@
* @bug 7057939
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @requires vm.gc.Serial
* @key flag-sensitive
* @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
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
Expand All @@ -42,7 +43,8 @@
* @bug 7057939
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @requires vm.gc.Parallel
* @key flag-sensitive
* @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
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
Expand All @@ -56,7 +58,8 @@
* @bug 7057939
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @requires vm.gc.G1
* @key flag-sensitive
* @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
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
Expand All @@ -79,46 +82,23 @@ public class TestMaxNewSize {

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

private static void checkIncompatibleNewSize(String[] flags) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
finalargs.addAll(Arrays.asList(flags));
finalargs.add("-version");

ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Initial young gen size set larger than the maximum young gen size");
}

private static boolean isRunningG1(String[] args) {
for (int i = 0; i < args.length; i++) {
if (args[i].contains("+UseG1GC")) {
return true;
}
}
return false;
}

private static String getMaxNewSize(String[] flags) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
finalargs.addAll(Arrays.asList(flags));
if (isRunningG1(flags)) {
finalargs.add("-XX:G1HeapRegionSize=1M");
}
finalargs.add("-XX:+PrintFlagsFinal");
finalargs.add("-version");

ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs);
ProcessBuilder pb = GCArguments.createTestJvm(finalargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
//System.out.println(stdout);
return getFlagValue("MaxNewSize", stdout);
}

Expand Down

0 comments on commit 1a09835

Please sign in to comment.