Skip to content

Commit 2d84684

Browse files
committed
vsock: Fix SocketChannelTest failure
If vsock is not completely supported on the running platform, the new SocketChannelTest.testConnectCloseImmediatelyNonBlocking may fail with a ConnectionResetSocketException. Ignore that error, and log a message.
1 parent 36f74c4 commit 2d84684

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

junixsocket-vsock/src/test/java/org/newsclub/net/unix/vsock/SocketChannelTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
import java.nio.channels.ServerSocketChannel;
2525
import java.nio.channels.SocketChannel;
2626

27+
import org.junit.jupiter.api.Test;
2728
import org.newsclub.net.unix.AFSocketCapability;
2829
import org.newsclub.net.unix.AFSocketCapabilityRequirement;
2930
import org.newsclub.net.unix.AFVSOCKSocketAddress;
31+
import org.newsclub.net.unix.ConnectionResetSocketException;
3032
import org.newsclub.net.unix.InvalidSocketException;
3133

3234
import com.kohlschutter.annotations.compiletime.SuppressFBWarnings;
@@ -100,4 +102,16 @@ protected boolean handleConnect(SocketChannel sc, SocketAddress sa) throws IOExc
100102
MessageType.TEST_ABORTED_SHORT_WITH_ISSUES, msg, summaryImportantMessage(msg)).initCause(
101103
ex);
102104
}
105+
106+
@Override
107+
@Test
108+
public void testConnectCloseImmediatelyNonBlocking() throws Exception {
109+
try {
110+
super.testConnectCloseImmediatelyNonBlocking();
111+
} catch (ConnectionResetSocketException e) {
112+
String msg = "VSOCK may not be available";
113+
throw (TestAbortedWithImportantMessageException) new TestAbortedWithImportantMessageException(
114+
MessageType.TEST_ABORTED_INFORMATIONAL, msg, summaryImportantMessage(msg)).initCause(e);
115+
}
116+
}
103117
}

0 commit comments

Comments
 (0)