Skip to content

Commit f59ed46

Browse files
committed
[GR-60266] Set compiler max unit test time to 5 mins.
PullRequest: graal/19539
2 parents 0bce35e + 47d6681 commit f59ed46

File tree

9 files changed

+90
-65
lines changed

9 files changed

+90
-65
lines changed

compiler/mx.compiler/mx_compiler.py

+4
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,10 @@ def apply(self, config):
834834
vmArgs.append('-Djdk.graal.TrackNodeSourcePosition=true')
835835
vmArgs.append('-esa')
836836

837+
if '-JUnitMaxTestTime' not in mainClassArgs:
838+
# The max time (in seconds) for any compiler unit test
839+
mainClassArgs.extend(['-JUnitMaxTestTime', '300'])
840+
837841
# Always run unit tests without UseJVMCICompiler unless explicitly requested
838842
if _get_XX_option_value(vmArgs, 'UseJVMCICompiler', None) is None:
839843
vmArgs.append('-XX:-UseJVMCICompiler')

compiler/src/jdk.graal.compiler.hotspot.jdk21.test/src/jdk/graal/compiler/hotspot/jdk21/test/PreviewEnabledTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public void testBody() {
5757

5858
@Test
5959
public void testInSubprocess() throws IOException, InterruptedException {
60-
SubprocessTest.launchSubprocess(getClass(), this::testBody, "--enable-preview");
60+
SubprocessTest.launchSubprocess(getClass(), currentUnitTestName(), this::testBody, "--enable-preview");
6161
}
6262
}

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

+11-21
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,16 @@ public abstract class SubprocessTest extends GraalCompilerTest {
6767
* {@link Subprocess} instance describing the process after its successful termination.
6868
*/
6969
public SubprocessUtil.Subprocess launchSubprocess(Runnable runnable, String... args) throws InterruptedException, IOException {
70-
return launchSubprocess(null, null, true, getClass(), null, runnable, args);
71-
}
72-
73-
/**
74-
* Like {@link #launchSubprocess(Runnable, String...)}, but with an extra {@code testSelector}
75-
* to specify a specific test method to execute in the test class.
76-
*/
77-
public SubprocessUtil.Subprocess launchSubprocess(String testSelector, Runnable runnable, String... args) throws InterruptedException, IOException {
78-
return launchSubprocess(null, null, true, getClass(), testSelector, runnable, args);
70+
return launchSubprocess(null, null, true, getClass(), currentUnitTestName(), runnable, args);
7971
}
8072

8173
public SubprocessUtil.Subprocess launchSubprocess(Predicate<String> vmArgsFilter, Runnable runnable, String... args) throws InterruptedException, IOException {
82-
return launchSubprocess(null, vmArgsFilter, true, getClass(), null, runnable, args);
83-
}
84-
85-
public static SubprocessUtil.Subprocess launchSubprocess(Class<? extends GraalCompilerTest> testClass, Runnable runnable, String... args) throws InterruptedException, IOException {
86-
return launchSubprocess(null, null, true, testClass, null, runnable, args);
74+
return launchSubprocess(null, vmArgsFilter, true, getClass(), currentUnitTestName(), runnable, args);
8775
}
8876

89-
public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>> testPredicate, Predicate<String> vmArgsFilter, boolean expectNormalExit,
90-
Class<? extends GraalCompilerTest> testClass, Runnable runnable, String... args)
77+
public static SubprocessUtil.Subprocess launchSubprocess(Class<? extends GraalCompilerTest> testClass, String testSelector, Runnable runnable, String... args)
9178
throws InterruptedException, IOException {
92-
return launchSubprocess(testPredicate, vmArgsFilter, expectNormalExit, testClass, null, runnable, args);
79+
return launchSubprocess(null, null, true, testClass, testSelector, runnable, args);
9380
}
9481

9582
private static List<String> filter(List<String> args, Predicate<String> vmArgsFilter) {
@@ -102,6 +89,11 @@ private static List<String> filter(List<String> args, Predicate<String> vmArgsFi
10289
return result;
10390
}
10491

92+
/**
93+
* Sentinel value meaning all tests in the specified test class are to be run.
94+
*/
95+
public static final String ALL_TESTS = "ALL_TESTS";
96+
10597
public boolean isRecursiveLaunch() {
10698
return isRecursiveLaunch(getClass());
10799
}
@@ -131,10 +123,8 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>
131123

132124
List<String> mainClassAndArgs = new LinkedList<>();
133125
mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
134-
String testName = testClass.getName();
135-
if (testSelector != null) {
136-
testName += "#" + testSelector;
137-
}
126+
assert testSelector != null : "must pass the name of the current unit test";
127+
String testName = testSelector.equals(ALL_TESTS) ? testClass.getName() : testClass.getName() + "#" + testSelector;
138128
mainClassAndArgs.add(testName);
139129
boolean junitVerbose = getProcessCommandLine().contains("-JUnitVerbose");
140130
if (junitVerbose) {

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/ReadEliminationCodeEmissionTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static int accessVolatile1Snippet(A a) {
6060

6161
@Test
6262
public void accessVolatile1() {
63-
runTest("accessVolatile1", new A(12));
63+
runTest(currentUnitTestName(), new A(12));
6464
}
6565

6666
public void runTest(String baseName, Object... args) {
@@ -120,7 +120,7 @@ public void runTest(String baseName, Object... args) {
120120
"-Dgraal.Dump=:5"};
121121
}
122122
try {
123-
subprocess = launchSubprocess(baseName, run, vmArgs);
123+
subprocess = launchSubprocess(run, vmArgs);
124124
} catch (InterruptedException | IOException e) {
125125
throw new RuntimeException(e);
126126
}

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

+23-22
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static Object fieldReadBarrierSnippet(TestObject t) {
9292

9393
@Test
9494
public void fieldReadBarrier() {
95-
runTest("fieldReadBarrier", new TestObject());
95+
runTest(new TestObject());
9696
}
9797

9898
public static void fieldWriteBarrierSnippet(TestObject t, Object value) {
@@ -101,7 +101,7 @@ public static void fieldWriteBarrierSnippet(TestObject t, Object value) {
101101

102102
@Test
103103
public void fieldWriteBarrier() {
104-
runTest("fieldWriteBarrier", new TestObject(), "string");
104+
runTest(new TestObject(), "string");
105105
}
106106

107107
public static void volatileFieldWriteBarrierSnippet(TestObject t, Object value) {
@@ -110,7 +110,7 @@ public static void volatileFieldWriteBarrierSnippet(TestObject t, Object value)
110110

111111
@Test
112112
public void volatileFieldWriteBarrier() {
113-
runTest("volatileFieldWriteBarrier", new TestObject(), "string");
113+
runTest(new TestObject(), "string");
114114
}
115115

116116
public static void arrayWriteBarrierSnippet(Object[] t, Object value) {
@@ -119,7 +119,7 @@ public static void arrayWriteBarrierSnippet(Object[] t, Object value) {
119119

120120
@Test
121121
public void arrayWriteBarrier() {
122-
runTest("arrayWriteBarrier", new Object[1], "string");
122+
runTest(new Object[1], "string");
123123
}
124124

125125
public static void volatileArrayWriteBarrierSnippet(Object[] t, Object value) {
@@ -131,7 +131,7 @@ public static void volatileArrayWriteBarrierSnippet(Object[] t, Object value) {
131131

132132
@Test
133133
public void volatileArrayWriteBarrier() {
134-
runTest("volatileArrayWriteBarrier", new Object[1], "string");
134+
runTest(new Object[1], "string");
135135
}
136136

137137
public static void fieldWriteNullBarrierSnippet(TestObject t) {
@@ -140,7 +140,7 @@ public static void fieldWriteNullBarrierSnippet(TestObject t) {
140140

141141
@Test
142142
public void fieldWriteNullBarrier() {
143-
runTest("fieldWriteNullBarrier", new TestObject());
143+
runTest(new TestObject());
144144
}
145145

146146
public static void volatileFieldWriteNullBarrierSnippet(TestObject t) {
@@ -149,7 +149,7 @@ public static void volatileFieldWriteNullBarrierSnippet(TestObject t) {
149149

150150
@Test
151151
public void volatileFieldWriteNullBarrier() {
152-
runTest("volatileFieldWriteNullBarrier", new TestObject());
152+
runTest(new TestObject());
153153
}
154154

155155
public static void arrayWriteNullBarrierSnippet(Object[] t) {
@@ -158,7 +158,7 @@ public static void arrayWriteNullBarrierSnippet(Object[] t) {
158158

159159
@Test
160160
public void arrayWriteNullBarrier() {
161-
runTest("arrayWriteNullBarrier", new Object[]{new Object[1]});
161+
runTest(new Object[]{new Object[1]});
162162
}
163163

164164
public static Object valueCompareAndSwapBarrierSnippet(TestObject t1, Object value) {
@@ -174,7 +174,7 @@ public void valueCompareAndSwapBarrier() {
174174
assertTrue(graph.getNodes().filter(ValueCompareAndSwapNode.class).isNotEmpty(), "expected ValueCompareAndSwapNode");
175175
return true;
176176
};
177-
runTest("valueCompareAndSwapBarrier", nodePredicate, supply(TestObject::new), "string");
177+
runTest(nodePredicate, supply(TestObject::new), "string");
178178
}
179179

180180
public static boolean logicCompareAndSwapBarrierSnippet(TestObject t1, Object value) {
@@ -190,7 +190,7 @@ public void logicCompareAndSwapBarrier() {
190190
assertTrue(graph.getNodes().filter(LogicCompareAndSwapNode.class).isNotEmpty(), "expected LogicCompareAndSwapNode");
191191
return true;
192192
};
193-
runTest("logicCompareAndSwapBarrier", nodePredicate, supply(TestObject::new), "string");
193+
runTest(nodePredicate, supply(TestObject::new), "string");
194194
}
195195

196196
public static Object getAndSetBarrierSnippet(TestObject t1, Object value) {
@@ -206,7 +206,7 @@ public void getAndSetBarrier() {
206206
assertTrue(graph.getNodes().filter(LoweredAtomicReadAndWriteNode.class).isNotEmpty(), "expected LoweredAtomicReadAndWriteNode");
207207
return true;
208208
};
209-
runTest("getAndSetBarrier", nodePredicate, supply(TestObject::new), "string");
209+
runTest(nodePredicate, supply(TestObject::new), "string");
210210
}
211211

212212
public static boolean phantomRefersToBarrierSnippet(PhantomReference<Object> phantom, Object value) {
@@ -216,7 +216,7 @@ public static boolean phantomRefersToBarrierSnippet(PhantomReference<Object> pha
216216
@Test
217217
public void phantomRefersToBarrier() {
218218
ReferenceQueue<Object> queue = new ReferenceQueue<>();
219-
runTest("phantomRefersToBarrier", new PhantomReference<>("string", queue), "string");
219+
runTest(new PhantomReference<>("string", queue), "string");
220220
}
221221

222222
public static boolean weakRefersToBarrierSnippet(WeakReference<Object> weak, Object value) {
@@ -225,7 +225,7 @@ public static boolean weakRefersToBarrierSnippet(WeakReference<Object> weak, Obj
225225

226226
@Test
227227
public void weakRefersToBarrier() {
228-
runTest("weakRefersToBarrier", new WeakReference<>("string"), "string");
228+
runTest(new WeakReference<>("string"), "string");
229229
}
230230

231231
public static Object referenceGetBarrierSnippet(WeakReference<Object> weak) {
@@ -234,7 +234,7 @@ public static Object referenceGetBarrierSnippet(WeakReference<Object> weak) {
234234

235235
@Test
236236
public void referenceGetBarrier() {
237-
runTest("referenceGetBarrier", new WeakReference<>("string"));
237+
runTest(new WeakReference<>("string"));
238238
}
239239

240240
public static TestObject objectAllocationBarrierSnippet() {
@@ -243,7 +243,7 @@ public static TestObject objectAllocationBarrierSnippet() {
243243

244244
@Test
245245
public void objectAllocationBarrier() {
246-
runTest("objectAllocationBarrier");
246+
runTest();
247247
}
248248

249249
public static String stringAllocationBarrierSnippet() {
@@ -252,7 +252,7 @@ public static String stringAllocationBarrierSnippet() {
252252

253253
@Test
254254
public void stringAllocationBarrier() {
255-
runTest("stringAllocationBarrier");
255+
runTest();
256256
}
257257

258258
private static TestObject obj6 = new TestObject(6);
@@ -265,7 +265,7 @@ public static Object testuuvCAESnippet() {
265265

266266
@Test
267267
public void testuuvCAE() {
268-
runTest("testuuvCAE");
268+
runTest();
269269
}
270270

271271
public static Object threadHandleBarrierSnippet() {
@@ -274,7 +274,7 @@ public static Object threadHandleBarrierSnippet() {
274274

275275
@Test
276276
public void threadHandleBarrier() {
277-
runTest("threadHandleBarrier");
277+
runTest();
278278
}
279279

280280
@Override
@@ -286,11 +286,12 @@ protected void checkLowTierGraph(StructuredGraph graph) {
286286

287287
Predicate<StructuredGraph> graphPredicate;
288288

289-
public void runTest(String baseName, Object... args) {
290-
runTest(baseName, null, args);
289+
public void runTest(Object... args) {
290+
runTest(null, args);
291291
}
292292

293-
public void runTest(String baseName, Predicate<StructuredGraph> predicate, Object... args) {
293+
public void runTest(Predicate<StructuredGraph> predicate, Object... args) {
294+
String baseName = currentUnitTestName();
294295
String snippetName = baseName + "Snippet";
295296
String methodSpec = getClass().getName() + "::" + snippetName;
296297
Method m = getMethod(snippetName);
@@ -350,7 +351,7 @@ public void runTest(String baseName, Predicate<StructuredGraph> predicate, Objec
350351
"-XX:LogFile=" + logName};
351352
}
352353
try {
353-
subprocess = launchSubprocess(baseName, run, vmArgs);
354+
subprocess = launchSubprocess(run, vmArgs);
354355
} catch (InterruptedException | IOException e) {
355356
throw new RuntimeException(e);
356357
}

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

+24-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import java.util.Collections;
3030
import java.util.List;
3131

32-
import jdk.graal.compiler.core.test.SubprocessTest;
3332
import org.junit.Test;
3433

34+
import jdk.graal.compiler.core.test.SubprocessTest;
3535
import jdk.internal.vm.annotation.Contended;
3636

3737
@SuppressWarnings("unused")
@@ -70,12 +70,30 @@ public void runSubprocessTest(String... args) throws IOException, InterruptedExc
7070
}, newArgs.toArray(new String[0]));
7171
}
7272

73+
// Checkstyle: stop method name check
7374
@Test
74-
public void testG1() throws IOException, InterruptedException {
75-
String[] sizes = {"-XX:G1HeapRegionSize=1M", "-XX:G1HeapRegionSize=2M", "-XX:G1HeapRegionSize=4M", "-XX:G1HeapRegionSize=8M"};
76-
for (String size : sizes) {
77-
runSubprocessTest("-XX:+UseG1GC", "-XX:+EnableContended", "-XX:-RestrictContended", "-Xmx128m", "-XX:ContendedPaddingWidth=8192", size);
78-
}
75+
public void testG1_1M() throws IOException, InterruptedException {
76+
testG1("-XX:G1HeapRegionSize=1M");
77+
}
78+
79+
@Test
80+
public void testG1_2M() throws IOException, InterruptedException {
81+
testG1("-XX:G1HeapRegionSize=2M");
82+
}
83+
84+
@Test
85+
public void testG1_4M() throws IOException, InterruptedException {
86+
testG1("-XX:G1HeapRegionSize=4M");
87+
}
88+
89+
@Test
90+
public void testG1_8M() throws IOException, InterruptedException {
91+
testG1("-XX:G1HeapRegionSize=9M");
92+
}
93+
// Checkstyle: resume method name check
94+
95+
public void testG1(String size) throws IOException, InterruptedException {
96+
runSubprocessTest("-XX:+UseG1GC", "-XX:+EnableContended", "-XX:-RestrictContended", "-Xmx128m", "-XX:ContendedPaddingWidth=8192", size);
7997
}
8098

8199
@Test

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030
import java.lang.reflect.Constructor;
3131
import java.util.List;
3232

33+
import org.junit.Assert;
34+
import org.junit.Test;
35+
import org.objectweb.asm.ClassWriter;
36+
import org.objectweb.asm.FieldVisitor;
37+
import org.objectweb.asm.MethodVisitor;
38+
3339
import com.oracle.truffle.api.impl.asm.Opcodes;
40+
3441
import jdk.graal.compiler.core.test.SubprocessTest;
3542
import jdk.graal.compiler.nodes.StructuredGraph;
3643
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
@@ -40,11 +47,6 @@
4047
import jdk.graal.compiler.test.AddExports;
4148
import jdk.internal.vm.annotation.Stable;
4249
import jdk.vm.ci.meta.ResolvedJavaMethod;
43-
import org.junit.Assert;
44-
import org.junit.Test;
45-
import org.objectweb.asm.ClassWriter;
46-
import org.objectweb.asm.FieldVisitor;
47-
import org.objectweb.asm.MethodVisitor;
4850

4951
/**
5052
* Assert that a barrier is inserted at the end of a constructor that writes to Stable fields or if
@@ -89,7 +91,7 @@ public void checkAlwaysSafeConstructors() throws NoSuchMethodException {
8991

9092
@Test
9193
public void runCheckStableWriteConstructors() throws IOException, InterruptedException {
92-
launchSubprocess("runCheckStableWriteConstructors", this::checkStableWriteConstructors, "--add-opens=java.base/java.lang=ALL-UNNAMED");
94+
launchSubprocess(this::checkStableWriteConstructors, "--add-opens=java.base/java.lang=ALL-UNNAMED");
9395
}
9496

9597
private void checkStableWriteConstructors() {

0 commit comments

Comments
 (0)