Skip to content

Commit 5aba4aa

Browse files
committed
[GR-53657] Simplify rerunning subprocess based unit tests.
PullRequest: graal/17600
2 parents af598ad + 0baf81c commit 5aba4aa

File tree

5 files changed

+182
-113
lines changed

5 files changed

+182
-113
lines changed

ci/common.jsonnet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ local common_json = import "../common.json";
146146
"Dumping debug output to '(?P<filename>[^']+)'",
147147
# Keep in sync with com.oracle.svm.hosted.NativeImageOptions#DEFAULT_ERROR_FILE_NAME
148148
" (?P<filename>.+/svm_err_b_\\d+T\\d+\\.\\d+_pid\\d+\\.md)",
149+
# Keep in sync with jdk.graal.compiler.test.SubprocessUtil#makeArgfile
150+
" @(?P<filename>.*SubprocessUtil.*\\.argfile)",
149151
],
150152
},
151153

compiler/mx.compiler/mx_compiler.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -514,24 +514,6 @@ def compiler_gate_runner(suites, unit_test_runs, bootstrap_tests, tasks, extraVM
514514
for r in unit_test_runs:
515515
r.run(suites, tasks, ['-XX:-UseJVMCICompiler'] + _remove_empty_entries(extraVMarguments), extraUnitTestArguments=extraUnitTestArguments)
516516

517-
# Run selected tests (initially those from GR-6581) under -Xcomp
518-
xcompTests = [
519-
'BlackholeDirectiveTest',
520-
'OpaqueDirectiveTest',
521-
'CompiledMethodTest',
522-
'ControlFlowAnchorDirectiveTest',
523-
'ConditionalElimination',
524-
'MarkUnsafeAccessTest',
525-
'PEAAssertionsTest',
526-
'MergeCanonicalizerTest',
527-
'ExplicitExceptionTest',
528-
'GuardedIntrinsicTest',
529-
'HashCodeTest',
530-
'ProfilingInfoTest',
531-
'GraalOSRLockTest'
532-
]
533-
UnitTestRun('XcompUnitTests', [], tags=GraalTags.test).run(['compiler'], tasks, ['-Xcomp', '-XX:-UseJVMCICompiler'] + _remove_empty_entries(extraVMarguments) + xcompTests)
534-
535517
# Run ctw against rt.jar on hosted
536518
ctw_flags = [
537519
'-DCompileTheWorld.Config=Inline=false CompilationFailureAction=ExitVM CompilationBailoutAsFailure=false', '-esa', '-XX:-UseJVMCICompiler', '-XX:+EnableJVMCI',
@@ -713,10 +695,6 @@ def compiler_gate_benchmark_runner(tasks, extraVMarguments=None, prefix='', task
713695
finally:
714696
os.remove(logFile)
715697

716-
# ensure -Xcomp still works
717-
with Task(prefix + 'XCompMode:product', tasks, tags=GraalTags.test, report=task_report_component) as t:
718-
if t: run_vm(_remove_empty_entries(extraVMarguments) + ['-XX:+UseJVMCICompiler', '-Xcomp', '-version'])
719-
720698
# ensure -XX:+PreserveFramePointer still works
721699
with Task(prefix + 'DaCapo_pmd:PreserveFramePointer', tasks, tags=GraalTags.test, report=task_report_component) as t:
722700
if t: _gate_dacapo('pmd', default_iterations, benchVmArgs + ['-Xmx256M', '-XX:+PreserveFramePointer'], threads=4, force_serial_gc=False, set_start_heap_size=False)

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/SubprocessTest.java

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>
118118
vmArgs = filter(vmArgs, vmArgsFilter);
119119
}
120120

121-
String verboseProperty = "debug." + testClass.getName() + ".verbose";
122-
boolean verbose = Boolean.getBoolean(verboseProperty);
123-
if (verbose) {
124-
System.err.println(String.join(" ", vmArgs));
125-
}
126121
List<String> mainClassAndArgs = new LinkedList<>();
127122
mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
128123
String testName = testClass.getName();
@@ -135,33 +130,19 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>
135130
mainClassAndArgs.add("-JUnitVerbose");
136131
}
137132
SubprocessUtil.Subprocess proc = java(vmArgs, mainClassAndArgs);
138-
if (testPredicate != null) {
139-
assertTrue(testPredicate.test(proc.output), proc.toString() + " produced unexpected output:\n\n" + String.join("\n", proc.output));
140-
}
141-
if (verbose) {
142-
for (String line : proc.output) {
143-
System.err.println(line);
144-
}
145-
}
146-
String suffix = "";
147-
if (!Boolean.getBoolean(SubprocessUtil.KEEP_TEMPORARY_ARGUMENT_FILES_PROPERTY_NAME)) {
148-
suffix = String.format("%s%n%nSet -D%s=true to preserve subprocess temp files.", suffix, SubprocessUtil.KEEP_TEMPORARY_ARGUMENT_FILES_PROPERTY_NAME);
149-
}
150-
if (!verbose) {
151-
suffix = String.format("%s%n%nSet -D%s=true for verbose output.", suffix, verboseProperty);
133+
134+
if (testPredicate != null && !testPredicate.test(proc.output)) {
135+
fail("Subprocess produced unexpected output:%n%s", proc.preserveArgfile());
152136
}
153137
int exitCode = proc.exitCode;
154-
if (expectNormalExit) {
155-
assertTrue(exitCode == 0, String.format("%s produced exit code %d, but expected 0.%s", proc, exitCode, suffix));
156-
} else {
157-
assertTrue(exitCode != 0, String.format("%s produced normal exit code %d, but expected abnormal exit%s", proc, exitCode, suffix));
138+
if ((exitCode == 0) != expectNormalExit) {
139+
String expectExitCode = expectNormalExit ? "0" : "non-0";
140+
fail("Subprocess produced exit code %d, but expected %s%n%s", exitCode, expectExitCode, proc.preserveArgfile());
158141
}
142+
143+
// Test passed
159144
if (junitVerbose) {
160-
System.out.println("--- subprocess output:");
161-
for (String line : proc.output) {
162-
System.out.println(line);
163-
}
164-
System.out.println("--- end subprocess output");
145+
System.out.printf("%n%s%n", proc.preserveArgfile());
165146
}
166147
return proc;
167148
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CompilationWrapperTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public static void testHelper(List<Probe> initialOutputProbes,
252252

253253
Subprocess proc = SubprocessUtil.java(vmArgs, mainClassAndArgs);
254254
if (VERBOSE) {
255-
System.out.println(proc);
255+
System.out.printf("%n%s%n", proc.preserveArgfile());
256256
}
257257

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

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

0 commit comments

Comments
 (0)