8317228: GC: Make TestXXXHeapSizeFlags use createTestJvm
Reviewed-by: sjohanss, ayang
This commit is contained in:
parent
5521560abd
commit
7ca0ae9415
@ -32,7 +32,8 @@
|
||||
# intermittent: flaky test, known to fail intermittently
|
||||
# randomness: test uses randomness, test cases differ from run to run
|
||||
# cgroups: test uses cgroups
|
||||
keys=stress headful intermittent randomness cgroups
|
||||
# flag-sensitive: test is sensitive to certain flags and might fail when flags are passed using -vmoptions and -javaoptions
|
||||
keys=stress headful intermittent randomness cgroups flag-sensitive
|
||||
|
||||
groups=TEST.groups TEST.quick-groups
|
||||
|
||||
|
@ -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
|
||||
@ -26,8 +26,9 @@ package gc.arguments;
|
||||
/*
|
||||
* @test TestG1HeapSizeFlags
|
||||
* @bug 8006088
|
||||
* @requires vm.gc.G1
|
||||
* @summary Tests argument processing for initial and maximum heap size for the G1 collector
|
||||
* @key flag-sensitive
|
||||
* @requires vm.gc.G1 & vm.opt.x.Xmx == null & vm.opt.x.Xms == null & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
|
@ -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
|
||||
@ -23,10 +23,10 @@
|
||||
|
||||
package gc.arguments;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
@ -115,7 +115,7 @@ class TestMaxHeapSizeTools {
|
||||
}
|
||||
|
||||
private static void getNewOldSize(String gcflag, long[] values) throws Exception {
|
||||
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(gcflag,
|
||||
ProcessBuilder pb = GCArguments.createTestJvm(gcflag,
|
||||
"-XX:+PrintFlagsFinal", "-version");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
@ -208,7 +208,7 @@ class TestMaxHeapSizeTools {
|
||||
finalargs.add(classname);
|
||||
finalargs.addAll(Arrays.asList(arguments));
|
||||
|
||||
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(String[]::new));
|
||||
ProcessBuilder pb = GCArguments.createTestJvm(finalargs.toArray(String[]::new));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
|
||||
@ -308,7 +308,7 @@ class TestMaxHeapSizeTools {
|
||||
}
|
||||
|
||||
private static void expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
|
||||
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flags);
|
||||
ProcessBuilder pb = GCArguments.createTestJvm(flags);
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
shouldContainOrNot(output, hasWarning, "Warning");
|
||||
shouldContainOrNot(output, hasError, "Error");
|
||||
|
@ -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
|
||||
@ -28,7 +28,8 @@ package gc.arguments;
|
||||
* @bug 8006088
|
||||
* @summary Tests argument processing for initial and maximum heap size for the
|
||||
* parallel collectors.
|
||||
* @requires vm.gc.Parallel
|
||||
* @key flag-sensitive
|
||||
* @requires vm.gc.Parallel & vm.opt.x.Xmx == null & vm.opt.x.Xms == null & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
|
@ -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
|
||||
@ -27,6 +27,8 @@ package gc.arguments;
|
||||
* @test TestSerialHeapSizeFlags
|
||||
* @bug 8006088
|
||||
* @summary Tests argument processing for initial and maximum heap size for the Serial collector
|
||||
* @key flag-sensitive
|
||||
* @requires vm.gc.Serial & vm.opt.x.Xmx == null & vm.opt.x.Xms == null & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
|
@ -47,9 +47,10 @@ import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.foreign.CABI;
|
||||
|
||||
import jdk.test.whitebox.code.Compiler;
|
||||
import jdk.test.whitebox.cpuinfo.CPUInfo;
|
||||
import jdk.test.whitebox.gc.GC;
|
||||
@ -83,6 +84,10 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public void putAll(Map<String, String> map) {
|
||||
map.entrySet().forEach(e -> put(e.getKey(), () -> e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,6 +140,7 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
map.put("jdk.containerized", this::jdkContainerized);
|
||||
map.put("vm.flagless", this::isFlagless);
|
||||
map.put("jdk.foreign.linker", this::jdkForeignLinker);
|
||||
map.putAll(xOptFlags()); // -Xmx4g -> @requires vm.opt.x.Xmx == "4g" )
|
||||
vmGC(map); // vm.gc.X = true/false
|
||||
vmGCforCDS(map); // may set vm.gc
|
||||
vmOptFinalFlags(map);
|
||||
@ -662,9 +668,7 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
return "" + result;
|
||||
}
|
||||
|
||||
List<String> allFlags = new ArrayList<String>();
|
||||
Collections.addAll(allFlags, System.getProperty("test.vm.opts", "").trim().split("\\s+"));
|
||||
Collections.addAll(allFlags, System.getProperty("test.java.opts", "").trim().split("\\s+"));
|
||||
List<String> allFlags = allFlags().toList();
|
||||
|
||||
// check -XX flags
|
||||
var ignoredXXFlags = Set.of(
|
||||
@ -711,6 +715,31 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
return "" + result;
|
||||
}
|
||||
|
||||
private Stream<String> allFlags() {
|
||||
return Stream.of((System.getProperty("test.vm.opts", "") + " " + System.getProperty("test.java.opts", "")).trim().split("\\s+"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses extra options, options that start with -X excluding the
|
||||
* bare -X option (as it is not considered an extra option).
|
||||
* Ignores extra options not starting with -X
|
||||
*
|
||||
* This could be improved to handle extra options not starting
|
||||
* with -X as well as "standard" options.
|
||||
*/
|
||||
private Map<String, String> xOptFlags() {
|
||||
return allFlags()
|
||||
.filter(s -> s.startsWith("-X") && !s.startsWith("-XX:") && !s.equals("-X"))
|
||||
.map(s -> s.replaceFirst("-", ""))
|
||||
.map(flag -> flag.splitWithDelimiters("[:0123456789]", 2))
|
||||
.collect(Collectors.toMap(a -> "vm.opt.x." + a[0],
|
||||
a -> (a.length == 1)
|
||||
? "true" // -Xnoclassgc
|
||||
: (a[1].equals(":")
|
||||
? a[2] // ["-XshowSettings", ":", "system"]
|
||||
: a[1] + a[2]))); // ["-Xmx", "4", "g"]
|
||||
}
|
||||
|
||||
/*
|
||||
* A string indicating the foreign linker that is currently being used. See jdk.internal.foreign.CABI
|
||||
* for valid values.
|
||||
|
Loading…
Reference in New Issue
Block a user