Skip to content

Commit

Permalink
8321713: Harmonize executeTestJvm with create[Limited]TestJavaProcess…
Browse files Browse the repository at this point in the history
…Builder

Reviewed-by: lkorinth, lmesnik
  • Loading branch information
stefank committed Jan 3, 2024
1 parent 06dd735 commit cbe329b
Show file tree
Hide file tree
Showing 89 changed files with 261 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String args[]) throws Throwable {
}

static void checkCompileThresholdScaling(double value, boolean fail) throws Throwable {
OutputAnalyzer out = ProcessTools.executeTestJvm("-XX:CompileThresholdScaling=" + value, "--version");
OutputAnalyzer out = ProcessTools.executeTestJava("-XX:CompileThresholdScaling=" + value, "--version");
out.shouldHaveExitValue(0);
String output = out.getOutput();

Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/compiler/c1/TestPrintC1Statistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void main(String[] args) throws Exception {
options.add("-XX:+PrintC1Statistics");
options.add("--version");

OutputAnalyzer oa = ProcessTools.executeTestJvm(options);
OutputAnalyzer oa = ProcessTools.executeTestJava(options);

oa.shouldHaveExitValue(0).shouldContain("C1 Runtime statistics");
}
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/compiler/c2/cr7200264/TestDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void run() throws Throwable {
}

private List<String> executeApplication() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
"-Xbatch",
"-XX:-TieredCompilation",
"-XX:+PrintCompilation",
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ static void test(int i) {

static {
try {
CLIENT_VM_AVAILABLE = ProcessTools.executeTestJvm(CLIENT_VM_OPTION, VERSION_OPTION)
CLIENT_VM_AVAILABLE = ProcessTools.executeTestJava(CLIENT_VM_OPTION, VERSION_OPTION)
.getOutput().contains("Client");
SERVER_VM_AVAILABLE = ProcessTools.executeTestJvm(SERVER_VM_OPTION, VERSION_OPTION)
SERVER_VM_AVAILABLE = ProcessTools.executeTestJava(SERVER_VM_OPTION, VERSION_OPTION)
.getOutput().contains("Server");
} catch(Throwable t) {
throw new Error("Initialization failed: " + t, t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public class MemLimitTest {

static void do_test(String option, boolean expectSuccess, int expectedValue) throws Exception {
OutputAnalyzer output = ProcessTools.executeTestJvm("-Xmx64m", "-XX:CompileCommand=" + option, "-version");
OutputAnalyzer output = ProcessTools.executeTestJava("-Xmx64m", "-XX:CompileCommand=" + option, "-version");
if (expectSuccess) {
output.shouldHaveExitValue(0);
output.shouldNotContain("error occurred");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@
public class MemStatTest {
public static void main(String[] args) throws Exception {
// default => collect
ProcessTools.executeTestJvm("-XX:CompileCommand=MemStat,*.*", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=MemStat,*.*", "-version")
.shouldHaveExitValue(0)
.shouldNotContain("CompileCommand: An error occurred during parsing")
.shouldContain("CompileCommand: MemStat *.* uintx MemStat = 1"); // should be registered
// collect explicit
ProcessTools.executeTestJvm("-XX:CompileCommand=MemStat,*.*,collect", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=MemStat,*.*,collect", "-version")
.shouldHaveExitValue(0)
.shouldNotContain("CompileCommand: An error occurred during parsing")
.shouldContain("CompileCommand: MemStat *.* uintx MemStat = 1"); // should be registered
// print explicit
ProcessTools.executeTestJvm("-XX:CompileCommand=MemStat,*.*,print", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=MemStat,*.*,print", "-version")
.shouldHaveExitValue(0)
.shouldNotContain("CompileCommand: An error occurred during parsing")
.shouldContain("CompileCommand: MemStat *.* uintx MemStat = 2");
// invalid suboption
ProcessTools.executeTestJvm("-XX:CompileCommand=MemStat,*.*,invalid", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=MemStat,*.*,invalid", "-version")
.shouldNotHaveExitValue(0)
.shouldContain("CompileCommand: An error occurred during parsing")
.shouldContain("Error: Value cannot be read for option 'MemStat'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,50 +37,50 @@

public class OptionTest {
public static void main(String[] args) throws Exception {
ProcessTools.executeTestJvm("-XX:CompileCommand=option,package/class,ccstrlist,ControlIntrinsic,+_getClass", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,package/class,ccstrlist,ControlIntrinsic,+_getClass", "-version")
.shouldHaveExitValue(1)
.shouldContain("CompileCommand: An error occurred during parsing")
.shouldContain("Error: Did not specify any method name")
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

ProcessTools.executeTestJvm("-XX:CompileCommand=option,*,ccstrlist,ControlIntrinsic,+_getClass", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,*,ccstrlist,ControlIntrinsic,+_getClass", "-version")
.shouldHaveExitValue(1)
.shouldContain("CompileCommand: An error occurred during parsing")
.shouldContain("Error: Did not specify any method name")
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

// corner case:
// ccstrlist could be a valid method name, so it is accepted in the well-formed case.
ProcessTools.executeTestJvm("-XX:CompileCommand=option,*.ccstrlist,ccstrlist,ControlIntrinsic,+_getClass", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,*.ccstrlist,ccstrlist,ControlIntrinsic,+_getClass", "-version")
.shouldContain("CompileCommand: ControlIntrinsic *.ccstrlist const char* ControlIntrinsic")
.shouldHaveExitValue(0)
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");


ProcessTools.executeTestJvm("-XX:CompileCommand=option,*.*,ccstrlist,ControlIntrinsic,+_getClass", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,*.*,ccstrlist,ControlIntrinsic,+_getClass", "-version")
.shouldContain("CompileCommand: ControlIntrinsic *.* const char* ControlIntrinsic")
.shouldHaveExitValue(0)
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

ProcessTools.executeTestJvm("-XX:CompileCommand=option,class,PrintIntrinsics", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,class,PrintIntrinsics", "-version")
.shouldHaveExitValue(0)
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

// corner case:
// PrintIntrinsics could be a valid method name, so it is accepted in the well-formed case.
ProcessTools.executeTestJvm("-XX:CompileCommand=option,class.PrintIntrinsics,PrintIntrinsics", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=option,class.PrintIntrinsics,PrintIntrinsics", "-version")
.shouldContain("CompileCommand: PrintIntrinsics class.PrintIntrinsics bool PrintIntrinsics = true")
.shouldHaveExitValue(0)
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

// corner case:
// _dontinline_* is a valid method pattern, so it should be accepted
ProcessTools.executeTestJvm("-XX:CompileCommand=dontinline,*::dontinline_*", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=dontinline,*::dontinline_*", "-version")
.shouldContain("CompileCommand: dontinline *.dontinline_* bool dontinline = true")
.shouldHaveExitValue(0)
.shouldNotContain("# A fatal error has been detected by the Java Runtime Environment");

ProcessTools.executeTestJvm("-XX:CompileCommand=dontinline,*.dontinline", "-version")
ProcessTools.executeTestJava("-XX:CompileCommand=dontinline,*.dontinline", "-version")
.shouldContain("CompileCommand: dontinline *.dontinline bool dontinline = true")
.shouldHaveExitValue(0)
.shouldNotContain("Error: Did not specify any method name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static List<String> getRandomDescriptors(
protected static OutputAnalyzer execute(String fileName) {
OutputAnalyzer output;
try {
output = ProcessTools.executeTestJvm(
output = ProcessTools.executeTestJava(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:CompilerDirectivesLimit=1000",
"-XX:CompilerDirectivesFile=" + fileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public List<OutputAnalyzer> execute() {
vmInputArgs.length + vmOptions.size());
System.arraycopy(vmOptions.toArray(), 0, cmds, vmInputArgs.length,
vmOptions.size());
output = ProcessTools.executeTestJvm(cmds);
output = ProcessTools.executeTestJava(cmds);
} catch (Throwable thr) {
throw new Error("Execution failed: " + thr.getMessage(), thr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private boolean isTieredLevelGreaterThan(int level) {
* @throws Throwable
*/
private void testUseAES() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
.USE_AES, true)));
final String errorMessage = "Case testUseAES failed";
Expand Down Expand Up @@ -103,7 +103,7 @@ private void testUseAES() throws Throwable {
*/
private void testUseAESUseSSE2() throws Throwable {
if (Platform.isX86() || Platform.isX64()) {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
.USE_AES_INTRINSICS, true),
prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2)));
Expand Down Expand Up @@ -132,7 +132,7 @@ private void testUseAESUseSSE2() throws Throwable {
*/
private void testNoUseAESUseSSE2() throws Throwable {
if (Platform.isX86() || Platform.isX64()) {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
.USE_AES, false),
prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2)));
Expand All @@ -158,7 +158,7 @@ private void testNoUseAESUseSSE2() throws Throwable {
* @throws Throwable
*/
private void testNoUseAES() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
.USE_AES, false)));
final String errorMessage = "Case testNoUseAES failed";
Expand All @@ -180,7 +180,7 @@ private void testNoUseAES() throws Throwable {
* @throws Throwable
*/
private void testNoUseAESIntrinsic() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
.USE_AES_INTRINSICS, false)));
final String errorMessage = "Case testNoUseAESIntrinsic failed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void runTestCases() throws Throwable {
* @throws Throwable
*/
private void testUseAESIntrinsics() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
AESIntrinsicsBase.prepareArguments(prepareBooleanFlag(
AESIntrinsicsBase.USE_AES_INTRINSICS, true)));
final String errorMessage = "Case testUseAESIntrinsics failed";
Expand All @@ -89,7 +89,7 @@ private void testUseAESIntrinsics() throws Throwable {
* @throws Throwable
*/
private void testUseAES() throws Throwable {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
AESIntrinsicsBase.prepareArguments(prepareBooleanFlag
(AESIntrinsicsBase.USE_AES, true)));
final String errorMessage = "Case testUseAES failed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class TestMembarDependencies {
public static void main(String args[]) throws Exception {
if (args.length == 0) {
// For debugging, add "-XX:+TraceOptoPipelining"
OutputAnalyzer oa = ProcessTools.executeTestJvm("-XX:+IgnoreUnrecognizedVMOptions",
OutputAnalyzer oa = ProcessTools.executeTestJava("-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-TieredCompilation", "-XX:-BackgroundCompilation", "-XX:+PrintOpto",
"-XX:CompileCommand=compileonly,compiler.membars.TestMembarDependencies::test*",
"-XX:CompileCommand=dontinline,compiler.membars.TestMembarDependencies::test_m1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static OutputAnalyzer runTest(Class<? extends Expr> expr,
new Integer(iterations).toString()
});

OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(vmOpts);
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(vmOpts);

outputAnalyzer.shouldHaveExitValue(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void prepareVMFlags(Class<?> testClass, List<String> additionalFlags) {
private void start() {
try {
// Run "flag" VM with White Box access to determine the test VM flags and if IR verification should be done.
oa = ProcessTools.executeTestJvm(cmds);
oa = ProcessTools.executeTestJava(cmds);
} catch (Exception e) {
throw new TestRunException("Failed to execute TestFramework flag VM", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void start() {
ProcessBuilder process = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
try {
// Calls 'main' of TestVM to run all specified tests with commands 'cmds'.
// Use executeProcess instead of executeTestJvm as we have already added the JTreg VM and
// Use executeProcess instead of executeTestJava as we have already added the JTreg VM and
// Java options in prepareTestVMFlags().
oa = ProcessTools.executeProcess(process);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ public static void main (String args[]) {
private static void check(boolean enabled) {
OutputAnalyzer oa;
try {
oa = ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.",
"-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints",
"-XX:+WhiteBoxAPI",
oa = ProcessTools.executeTestJava(
"-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.",
"-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints",
"-XX:+WhiteBoxAPI",
"-XX:-Inline", "-Xbatch", "-XX:+PrintIdeal", "-XX:LoopUnrollLimit=0",
"-XX:CompileOnly=" + UseCountedLoopSafepoints.class.getName() + "::testMethod",
UseCountedLoopSafepoints.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

public class CheckLoopStripMining {
public static void main(String args[]) throws Exception {
ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",
ProcessTools.executeTestJava("-XX:+UnlockDiagnosticVMOptions",
"-XX:+SafepointTimeout",
"-XX:+SafepointALot",
"-XX:+AbortVMOnSafepointTimeout",
Expand All @@ -54,7 +54,7 @@ public static void main(String args[]) throws Exception {
.shouldHaveExitValue(0)
.stdoutShouldContain("sum: 715827882");

ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",
ProcessTools.executeTestJava("-XX:+UnlockDiagnosticVMOptions",
"-XX:+SafepointTimeout",
"-XX:+SafepointALot",
"-XX:+AbortVMOnSafepointTimeout",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void runTest(String cmdPhases, List<String> expectedPhases, String logFi
options.add("-XX:CompileCommand=PrintIdealPhase," + getTestClass() + "::test," + cmdPhases);
options.add(getTestClass());

OutputAnalyzer oa = ProcessTools.executeTestJvm(options);
OutputAnalyzer oa = ProcessTools.executeTestJava(options);
if (valid) {
oa.shouldHaveExitValue(0)
.shouldContain("CompileCommand: PrintIdealPhase compiler/oracle/PrintIdealPhaseTest$TestMain.test const char* PrintIdealPhase = '"+cmdPhases.replace(',', ' ')+"'")
Expand Down