Skip to content

Commit

Permalink
[GR-53657] Simplify rerunning subprocess based unit tests.
Browse files Browse the repository at this point in the history
PullRequest: graal/17600
  • Loading branch information
dougxc committed Apr 27, 2024
2 parents af598ad + 0baf81c commit 5aba4aa
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 113 deletions.
2 changes: 2 additions & 0 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ local common_json = import "../common.json";
"Dumping debug output to '(?P<filename>[^']+)'",
# Keep in sync with com.oracle.svm.hosted.NativeImageOptions#DEFAULT_ERROR_FILE_NAME
" (?P<filename>.+/svm_err_b_\\d+T\\d+\\.\\d+_pid\\d+\\.md)",
# Keep in sync with jdk.graal.compiler.test.SubprocessUtil#makeArgfile
" @(?P<filename>.*SubprocessUtil.*\\.argfile)",
],
},

Expand Down
22 changes: 0 additions & 22 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,24 +514,6 @@ def compiler_gate_runner(suites, unit_test_runs, bootstrap_tests, tasks, extraVM
for r in unit_test_runs:
r.run(suites, tasks, ['-XX:-UseJVMCICompiler'] + _remove_empty_entries(extraVMarguments), extraUnitTestArguments=extraUnitTestArguments)

# Run selected tests (initially those from GR-6581) under -Xcomp
xcompTests = [
'BlackholeDirectiveTest',
'OpaqueDirectiveTest',
'CompiledMethodTest',
'ControlFlowAnchorDirectiveTest',
'ConditionalElimination',
'MarkUnsafeAccessTest',
'PEAAssertionsTest',
'MergeCanonicalizerTest',
'ExplicitExceptionTest',
'GuardedIntrinsicTest',
'HashCodeTest',
'ProfilingInfoTest',
'GraalOSRLockTest'
]
UnitTestRun('XcompUnitTests', [], tags=GraalTags.test).run(['compiler'], tasks, ['-Xcomp', '-XX:-UseJVMCICompiler'] + _remove_empty_entries(extraVMarguments) + xcompTests)

# Run ctw against rt.jar on hosted
ctw_flags = [
'-DCompileTheWorld.Config=Inline=false CompilationFailureAction=ExitVM CompilationBailoutAsFailure=false', '-esa', '-XX:-UseJVMCICompiler', '-XX:+EnableJVMCI',
Expand Down Expand Up @@ -713,10 +695,6 @@ def compiler_gate_benchmark_runner(tasks, extraVMarguments=None, prefix='', task
finally:
os.remove(logFile)

# ensure -Xcomp still works
with Task(prefix + 'XCompMode:product', tasks, tags=GraalTags.test, report=task_report_component) as t:
if t: run_vm(_remove_empty_entries(extraVMarguments) + ['-XX:+UseJVMCICompiler', '-Xcomp', '-version'])

# ensure -XX:+PreserveFramePointer still works
with Task(prefix + 'DaCapo_pmd:PreserveFramePointer', tasks, tags=GraalTags.test, report=task_report_component) as t:
if t: _gate_dacapo('pmd', default_iterations, benchVmArgs + ['-Xmx256M', '-XX:+PreserveFramePointer'], threads=4, force_serial_gc=False, set_start_heap_size=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>
vmArgs = filter(vmArgs, vmArgsFilter);
}

String verboseProperty = "debug." + testClass.getName() + ".verbose";
boolean verbose = Boolean.getBoolean(verboseProperty);
if (verbose) {
System.err.println(String.join(" ", vmArgs));
}
List<String> mainClassAndArgs = new LinkedList<>();
mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
String testName = testClass.getName();
Expand All @@ -135,33 +130,19 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>
mainClassAndArgs.add("-JUnitVerbose");
}
SubprocessUtil.Subprocess proc = java(vmArgs, mainClassAndArgs);
if (testPredicate != null) {
assertTrue(testPredicate.test(proc.output), proc.toString() + " produced unexpected output:\n\n" + String.join("\n", proc.output));
}
if (verbose) {
for (String line : proc.output) {
System.err.println(line);
}
}
String suffix = "";
if (!Boolean.getBoolean(SubprocessUtil.KEEP_TEMPORARY_ARGUMENT_FILES_PROPERTY_NAME)) {
suffix = String.format("%s%n%nSet -D%s=true to preserve subprocess temp files.", suffix, SubprocessUtil.KEEP_TEMPORARY_ARGUMENT_FILES_PROPERTY_NAME);
}
if (!verbose) {
suffix = String.format("%s%n%nSet -D%s=true for verbose output.", suffix, verboseProperty);

if (testPredicate != null && !testPredicate.test(proc.output)) {
fail("Subprocess produced unexpected output:%n%s", proc.preserveArgfile());
}
int exitCode = proc.exitCode;
if (expectNormalExit) {
assertTrue(exitCode == 0, String.format("%s produced exit code %d, but expected 0.%s", proc, exitCode, suffix));
} else {
assertTrue(exitCode != 0, String.format("%s produced normal exit code %d, but expected abnormal exit%s", proc, exitCode, suffix));
if ((exitCode == 0) != expectNormalExit) {
String expectExitCode = expectNormalExit ? "0" : "non-0";
fail("Subprocess produced exit code %d, but expected %s%n%s", exitCode, expectExitCode, proc.preserveArgfile());
}

// Test passed
if (junitVerbose) {
System.out.println("--- subprocess output:");
for (String line : proc.output) {
System.out.println(line);
}
System.out.println("--- end subprocess output");
System.out.printf("%n%s%n", proc.preserveArgfile());
}
return proc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static void testHelper(List<Probe> initialOutputProbes,

Subprocess proc = SubprocessUtil.java(vmArgs, mainClassAndArgs);
if (VERBOSE) {
System.out.println(proc);
System.out.printf("%n%s%n", proc.preserveArgfile());
}

try {
Expand All @@ -274,7 +274,7 @@ public static void testHelper(List<Probe> initialOutputProbes,
for (Probe probe : probes) {
String error = probe.test();
if (error != null) {
Assert.fail(String.format("Did not find expected occurrences of '%s' in output of command: %s%n%s", probe.substring, error, proc));
Assert.fail(String.format("Did not find expected occurrences of '%s' in output of command: %s%n%s", probe.substring, error, proc.preserveArgfile()));
}
}

Expand Down Expand Up @@ -317,7 +317,7 @@ public void verify(ZipEntry entry, ZipFile file) throws IOException {
for (ZipProbe probe : zipProbes) {
String error = probe.test();
if (error != null) {
Assert.fail(String.format("Did not find expected occurrences of '%s' files in %s: %s%n%s", probe.suffix, entries, error, proc));
Assert.fail(String.format("Did not find expected occurrences of '%s' files in %s: %s%n%s", probe.suffix, entries, error, proc.preserveArgfile()));
}
}
} finally {
Expand Down
Loading

0 comments on commit 5aba4aa

Please sign in to comment.