Skip to content

Commit ac82d08

Browse files
committed
test: Improve VirtualThreadPollerNaiveDeadlockTest assumptions
Improve selftest output by throwing the correct exceptions when preconditions are not met. #172
1 parent a05316c commit ac82d08

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

junixsocket-common/src/test/java/org/newsclub/net/unix/domain/VirtualThreadPollerNaiveDeadlockTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.newsclub.net.unix.domain;
1919

2020
import static org.junit.jupiter.api.Assertions.assertTrue;
21-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2221

2322
import java.io.BufferedReader;
2423
import java.io.InputStreamReader;
@@ -40,6 +39,7 @@
4039

4140
import com.kohlschutter.testutil.ForkedVM;
4241
import com.kohlschutter.testutil.ForkedVMRequirement;
42+
import com.kohlschutter.testutil.TestAbortedNotAnIssueException;
4343

4444
/**
4545
* Ensures dependent virtual-thread socket reads can complete when the common pool has a single
@@ -52,7 +52,9 @@ public class VirtualThreadPollerNaiveDeadlockTest {
5252
@Test
5353
@ForkedVMRequirement(forkSupported = true)
5454
public void testWithParallelism1() throws Exception {
55-
assumeTrue(ThreadUtil.isVirtualThreadSupported());
55+
if (!ThreadUtil.isVirtualThreadSupported()) {
56+
throw new TestAbortedNotAnIssueException("Virtual threads not supported");
57+
}
5658

5759
if (ThreadUtil.commonPool().getParallelism() == 1) {
5860
// no need to fork
@@ -117,9 +119,13 @@ public static void main(String[] args) throws Exception {
117119
}
118120

119121
private static void reproduce() throws Exception { // NOPMD.CognitiveComplexity
120-
assumeTrue(ThreadUtil.isVirtualThreadSupported());
121-
assumeTrue(ThreadUtil.commonPool().getParallelism() == 1,
122-
"Test requires -Djava.util.concurrent.ForkJoinPool.common.parallelism=1");
122+
if (!ThreadUtil.isVirtualThreadSupported()) {
123+
throw new TestAbortedNotAnIssueException("Virtual threads not supported");
124+
}
125+
if (ThreadUtil.commonPool().getParallelism() == 1) {
126+
throw new TestAbortedNotAnIssueException(
127+
"Test requires -Djava.util.concurrent.ForkJoinPool.common.parallelism=1");
128+
}
123129

124130
Path socketPath = Files.createTempFile("junixsocket-vtpoll-deadlock-", ".sock");
125131
Files.deleteIfExists(socketPath);

0 commit comments

Comments
 (0)