diff --git a/transport-native-io_uring/src/main/c/netty_io_uring_native.c b/transport-native-io_uring/src/main/c/netty_io_uring_native.c index 736b333e27..02bd7186bd 100644 --- a/transport-native-io_uring/src/main/c/netty_io_uring_native.c +++ b/transport-native-io_uring/src/main/c/netty_io_uring_native.c @@ -187,6 +187,34 @@ static void netty_io_uring_ring_buffer_exit(JNIEnv *env, jclass clazz, close(ringFd); } +static jboolean netty_io_uring_probe(JNIEnv *env, jclass clazz, jint ring_fd, jintArray ops) { + jboolean supported = JNI_FALSE; + struct io_uring_probe *probe; + size_t mallocLen = sizeof(*probe) + 256 * sizeof(struct io_uring_probe_op); + probe = malloc(mallocLen); + memset(probe, 0, mallocLen); + + if (sys_io_uring_register(ring_fd, IORING_REGISTER_PROBE, probe, 256) < 0) { + netty_unix_errors_throwRuntimeExceptionErrorNo(env, "failed to probe via sys_io_uring_register(....) ", errno); + goto done; + } + + jsize opsLen = (*env)->GetArrayLength(env, ops); + jint *opsElements = (*env)->GetIntArrayElements(env, ops, 0); + for (int i = 0; i < opsLen; i++) { + int op = opsElements[i]; + if (op > probe->last_op || (probe->ops[op].flags & IO_URING_OP_SUPPORTED) == 0) { + goto done; + } + } + // all supported + supported = JNI_TRUE; +done: + free(probe); + return supported; +} + + static jobjectArray netty_io_uring_setup(JNIEnv *env, jclass clazz, jint entries) { struct io_uring_params p; memset(&p, 0, sizeof(p)); @@ -500,6 +528,7 @@ static const jint statically_referenced_fixed_method_table_size = sizeof(statica static const JNINativeMethod method_table[] = { {"ioUringSetup", "(I)[[J", (void *) netty_io_uring_setup}, + {"ioUringProbe", "(I[I)Z", (void *) netty_io_uring_probe}, {"ioUringExit", "(JIJIJII)V", (void *) netty_io_uring_ring_buffer_exit}, {"createFile", "()I", (void *) netty_create_file}, {"ioUringEnter", "(IIII)I", (void *) netty_io_uring_enter}, diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUring.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUring.java index 86223c0fb3..9f199d4938 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUring.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUring.java @@ -39,6 +39,7 @@ public final class IOUring { // Noop } }); + Native.checkAllIOSupported(ringBuffer.fd()); } catch (Throwable t) { cause = t; } finally { diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/Native.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/Native.java index 26dab418c7..25d153911d 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/Native.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/Native.java @@ -26,6 +26,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory; import java.io.IOException; import java.nio.channels.Selector; +import java.util.Arrays; import java.util.Locale; final class Native { @@ -117,6 +118,20 @@ final class Native { static final int IORING_ENTER_GETEVENTS = NativeStaticallyReferencedJniMethods.ioringEnterGetevents(); static final int IOSQE_ASYNC = NativeStaticallyReferencedJniMethods.iosqeAsync(); + private static final int[] REQUIRED_IORING_OPS = { + IORING_OP_POLL_ADD, + IORING_OP_TIMEOUT, + IORING_OP_ACCEPT, + IORING_OP_READ, + IORING_OP_WRITE, + IORING_OP_POLL_REMOVE, + IORING_OP_CONNECT, + IORING_OP_CLOSE, + IORING_OP_WRITEV, + IORING_OP_SENDMSG, + IORING_OP_RECVMSG + }; + static RingBuffer createRingBuffer(int ringSize) { return createRingBuffer(ringSize, DEFAULT_USE_IOSEQ_ASYNC, new Runnable() { @Override @@ -164,6 +179,14 @@ final class Native { return createRingBuffer(DEFAULT_RING_SIZE, DEFAULT_USE_IOSEQ_ASYNC, submissionCallback); } + static void checkAllIOSupported(int ringFd) { + if (!ioUringProbe(ringFd, REQUIRED_IORING_OPS)) { + throw new UnsupportedOperationException("Not all operations are supported: " + + Arrays.toString(REQUIRED_IORING_OPS)); + } + } + + private static native boolean ioUringProbe(int ringFd, int[] ios); private static native long[][] ioUringSetup(int entries); public static native int ioUringEnter(int ringFd, int toSubmit, int minComplete, int flags); diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/RingBuffer.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/RingBuffer.java index 67f5bfcfb2..5f28d386ee 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/RingBuffer.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/RingBuffer.java @@ -25,6 +25,10 @@ final class RingBuffer { this.ioUringCompletionQueue = ioUringCompletionQueue; } + int fd() { + return ioUringCompletionQueue.ringFd; + } + IOUringSubmissionQueue ioUringSubmissionQueue() { return this.ioUringSubmissionQueue; } diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringCompositeBufferGatheringWriteTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringCompositeBufferGatheringWriteTest.java index e2bd3b2788..1b23040f0b 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringCompositeBufferGatheringWriteTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringCompositeBufferGatheringWriteTest.java @@ -19,11 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.CompositeBufferGatheringWriteTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringCompositeBufferGatheringWriteTest extends CompositeBufferGatheringWriteTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramConnectNotExistsTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramConnectNotExistsTest.java index 1b485f51e6..e03f92a713 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramConnectNotExistsTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramConnectNotExistsTest.java @@ -18,11 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.DatagramConnectNotExistsTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramConnectNotExistsTest extends DatagramConnectNotExistsTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagramSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastIPv6Test.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastIPv6Test.java index 306ffbbd89..79f25e83f5 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastIPv6Test.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastIPv6Test.java @@ -18,11 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.DatagramMulticastIPv6Test; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramMulticastIPv6Test extends DatagramMulticastIPv6Test { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagram(internetProtocolFamily()); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastTest.java index dde2378a83..ea646a0901 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramMulticastTest.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.DatagramMulticastTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramMulticastTest extends DatagramMulticastTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagram(internetProtocolFamily()); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6MappedTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6MappedTest.java index b577c48ef2..6829228207 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6MappedTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6MappedTest.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation.BootstrapComboFactory; import io.netty.testsuite.transport.socket.DatagramUnicastIPv6MappedTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramUnicastIPv6MappedTest extends DatagramUnicastIPv6MappedTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagram(internetProtocolFamily()); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6Test.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6Test.java index 6c52152a8e..efad03d657 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6Test.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastIPv6Test.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.DatagramUnicastIPv6Test; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramUnicastIPv6Test extends DatagramUnicastIPv6Test { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagram(internetProtocolFamily()); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastTest.java index 445dc05666..ba78ae0124 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDatagramUnicastTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.channel.socket.InternetProtocolFamily; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.DatagramUnicastTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringDatagramUnicastTest extends DatagramUnicastTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.datagram(InternetProtocolFamily.IPv4); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDetectPeerCloseWithReadTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDetectPeerCloseWithReadTest.java index 8e29858499..aa5d8ce54b 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDetectPeerCloseWithReadTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringDetectPeerCloseWithReadTest.java @@ -19,8 +19,17 @@ import io.netty.channel.Channel; import io.netty.channel.EventLoopGroup; import io.netty.channel.ServerChannel; import io.netty.channel.unix.tests.DetectPeerCloseWithoutReadTest; +import org.junit.BeforeClass; + +import static org.junit.Assume.assumeTrue; public class IOUringDetectPeerCloseWithReadTest extends DetectPeerCloseWithoutReadTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected EventLoopGroup newGroup() { return new IOUringEventLoopGroup(2); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringEventLoopTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringEventLoopTest.java index 01e3164f82..7c9a85a489 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringEventLoopTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringEventLoopTest.java @@ -20,12 +20,20 @@ import io.netty.channel.EventLoop; import io.netty.channel.EventLoopGroup; import io.netty.channel.ServerChannel; import io.netty.testsuite.transport.AbstractSingleThreadEventLoopTest; +import org.junit.BeforeClass; import org.junit.Test; import java.util.concurrent.TimeUnit; +import static org.junit.Assume.assumeTrue; + public class IOUringEventLoopTest extends AbstractSingleThreadEventLoopTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected EventLoopGroup newEventLoopGroup() { return new IOUringEventLoopGroup(1); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketAutoReadTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketAutoReadTest.java index 493757b871..3add123468 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketAutoReadTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketAutoReadTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketAutoReadTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketAutoReadTest extends SocketAutoReadTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketChannelNotYetConnectedTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketChannelNotYetConnectedTest.java index 2dbbd257b8..ebe4f2b60f 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketChannelNotYetConnectedTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketChannelNotYetConnectedTest.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketChannelNotYetConnectedTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketChannelNotYetConnectedTest extends SocketChannelNotYetConnectedTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.clientSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java index 4d36ee48bf..6d4afa5ac6 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketCloseForciblyTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketCloseForciblyTest extends SocketCloseForciblyTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConditionalWritabilityTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConditionalWritabilityTest.java index c980e63cc8..0fc8f98af9 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConditionalWritabilityTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConditionalWritabilityTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketConditionalWritabilityTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketConditionalWritabilityTest extends SocketConditionalWritabilityTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectTest.java index 6e348748fa..7dc233f014 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketConnectTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketConnectTest extends SocketConnectTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectionAttemptTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectionAttemptTest.java index f5f6727674..b6b9efeb16 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectionAttemptTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketConnectionAttemptTest.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketConnectionAttemptTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketConnectionAttemptTest extends SocketConnectionAttemptTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.clientSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketDataReadInitialStateTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketDataReadInitialStateTest.java index e043d6d314..6f3bcc761d 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketDataReadInitialStateTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketDataReadInitialStateTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketDataReadInitialStateTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketDataReadInitialStateTest extends SocketDataReadInitialStateTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketEchoTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketEchoTest.java index 96360b1830..8e86215638 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketEchoTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketEchoTest.java @@ -19,11 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation.BootstrapComboFactory; import io.netty.testsuite.transport.socket.SocketEchoTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketEchoTest extends SocketEchoTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketExceptionHandlingTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketExceptionHandlingTest.java index f94bdbb90b..80f95ac461 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketExceptionHandlingTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketExceptionHandlingTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketExceptionHandlingTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketExceptionHandlingTest extends SocketExceptionHandlingTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketFixedLengthEchoTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketFixedLengthEchoTest.java index d4c400a68b..731a51b12b 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketFixedLengthEchoTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketFixedLengthEchoTest.java @@ -27,6 +27,11 @@ import static org.junit.Assume.assumeTrue; public class IOUringSocketFixedLengthEchoTest extends SocketFixedLengthEchoTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketGatheringWriteTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketGatheringWriteTest.java index 88872197ed..d68d399eb3 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketGatheringWriteTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketGatheringWriteTest.java @@ -19,11 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketGatheringWriteTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketGatheringWriteTest extends SocketGatheringWriteTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketHalfClosedTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketHalfClosedTest.java index e69ffb1808..4fe3362d91 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketHalfClosedTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketHalfClosedTest.java @@ -21,12 +21,21 @@ import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketHalfClosedTest; import io.netty.util.internal.PlatformDependent; import org.junit.Assume; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketHalfClosedTest extends SocketHalfClosedTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketMultipleConnectTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketMultipleConnectTest.java index 153e336718..6800da55d2 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketMultipleConnectTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketMultipleConnectTest.java @@ -21,12 +21,20 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketMultipleConnectTest; +import org.junit.BeforeClass; import java.util.ArrayList; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketMultipleConnectTest extends SocketMultipleConnectTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { List> factories diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketObjectEchoTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketObjectEchoTest.java index 1cbaab17b1..0491cf6d6f 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketObjectEchoTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketObjectEchoTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketObjectEchoTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketObjectEchoTest extends SocketObjectEchoTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketReadPendingTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketReadPendingTest.java index d67a5886e0..b6c65c120d 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketReadPendingTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketReadPendingTest.java @@ -19,10 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketReadPendingTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketReadPendingTest extends SocketReadPendingTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketRstTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketRstTest.java index e7e5d08c87..839a8d86dc 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketRstTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketRstTest.java @@ -21,14 +21,22 @@ import io.netty.channel.Channel; import io.netty.channel.unix.Errors; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketRstTest; +import org.junit.BeforeClass; import java.io.IOException; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; public class IOUringSocketRstTest extends SocketRstTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputByPeerTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputByPeerTest.java index 9119f2f1a3..6daad130c1 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputByPeerTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputByPeerTest.java @@ -18,10 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketShutdownOutputByPeerTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketShutdownOutputByPeerTest extends SocketShutdownOutputByPeerTest { + + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.serverSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputBySelfTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputBySelfTest.java index 038b23cad6..2bd1923fe0 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputBySelfTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketShutdownOutputBySelfTest.java @@ -18,11 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketShutdownOutputBySelfTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketShutdownOutputBySelfTest extends SocketShutdownOutputBySelfTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.clientSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslClientRenegotiateTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslClientRenegotiateTest.java index 4302cf4d90..49fe51acfa 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslClientRenegotiateTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslClientRenegotiateTest.java @@ -20,15 +20,23 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.handler.ssl.SslContext; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketSslClientRenegotiateTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketSslClientRenegotiateTest extends SocketSslClientRenegotiateTest { public IOUringSocketSslClientRenegotiateTest(SslContext serverCtx, SslContext clientCtx, boolean delegate) { super(serverCtx, clientCtx, delegate); } + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslEchoTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslEchoTest.java index ee2ff6730c..c480ec0276 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslEchoTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslEchoTest.java @@ -20,9 +20,12 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.handler.ssl.SslContext; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketSslEchoTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketSslEchoTest extends SocketSslEchoTest { public IOUringSocketSslEchoTest( SslContext serverCtx, SslContext clientCtx, Renegotiation renegotiation, @@ -34,6 +37,11 @@ public class IOUringSocketSslEchoTest extends SocketSslEchoTest { autoRead, useChunkedWriteHandler, useCompositeByteBuf); } + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslGreetingTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslGreetingTest.java index 5d4d145aca..0634094597 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslGreetingTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslGreetingTest.java @@ -20,15 +20,23 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.handler.ssl.SslContext; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketSslGreetingTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketSslGreetingTest extends SocketSslGreetingTest { public IOUringSocketSslGreetingTest(SslContext serverCtx, SslContext clientCtx, boolean delegate) { super(serverCtx, clientCtx, delegate); } + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslSessionReuseTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslSessionReuseTest.java index eb9183c19a..c76f15cacc 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslSessionReuseTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketSslSessionReuseTest.java @@ -20,15 +20,23 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.handler.ssl.SslContext; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketSslSessionReuseTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketSslSessionReuseTest extends SocketSslSessionReuseTest { public IOUringSocketSslSessionReuseTest(SslContext serverCtx, SslContext clientCtx) { super(serverCtx, clientCtx); } + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStartTlsTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStartTlsTest.java index 86581ae796..4d2270a9b8 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStartTlsTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStartTlsTest.java @@ -20,15 +20,23 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.handler.ssl.SslContext; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketStartTlsTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketStartTlsTest extends SocketStartTlsTest { public IOUringSocketStartTlsTest(SslContext serverCtx, SslContext clientCtx) { super(serverCtx, clientCtx); } + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStringEchoTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStringEchoTest.java index 4b2a37a92a..ee7d7a02a3 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStringEchoTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketStringEchoTest.java @@ -19,11 +19,19 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketStringEchoTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringSocketStringEchoTest extends SocketStringEchoTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringWriteBeforeRegisteredTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringWriteBeforeRegisteredTest.java index 9bb92f5bce..02960bd75b 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringWriteBeforeRegisteredTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringWriteBeforeRegisteredTest.java @@ -18,11 +18,19 @@ package io.netty.channel.uring; import io.netty.bootstrap.Bootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.WriteBeforeRegisteredTest; +import org.junit.BeforeClass; import java.util.List; +import static org.junit.Assume.assumeTrue; + public class IOUringWriteBeforeRegisteredTest extends WriteBeforeRegisteredTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Override protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.clientSocket(); diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IovArraysTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IovArraysTest.java index 649c6f4269..31b78535aa 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IovArraysTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IovArraysTest.java @@ -18,18 +18,24 @@ package io.netty.channel.uring; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.unix.IovArray; +import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.junit.Assume.assumeTrue; public class IovArraysTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Test public void test() { - IOUring.ensureAvailability(); ByteBuf buf = Unpooled.directBuffer(1).writeZero(1); IovArrays arrays = new IovArrays(2); try { diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java index 4c7d6f3bb8..ac3a6c8cbb 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java @@ -19,6 +19,7 @@ import io.netty.channel.unix.Buffer; import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Assume; +import org.junit.BeforeClass; import org.junit.Test; import java.net.Inet6Address; @@ -26,12 +27,17 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import static org.junit.Assume.assumeTrue; + public class SockaddrInTest { + @BeforeClass + public static void loadJNI() { + assumeTrue(IOUring.isAvailable()); + } + @Test public void testIp4() throws Exception { - Assume.assumeTrue(IOUring.isAvailable()); - ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(64); try { long memoryAddress = Buffer.memoryAddress(buffer); @@ -49,8 +55,6 @@ public class SockaddrInTest { @Test public void testIp6() throws Exception { - Assume.assumeTrue(IOUring.isAvailable()); - ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(64); try { long memoryAddress = Buffer.memoryAddress(buffer); @@ -71,8 +75,6 @@ public class SockaddrInTest { @Test public void testWriteIp4ReadIpv6Mapped() throws Exception { - Assume.assumeTrue(IOUring.isAvailable()); - ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(64); try { long memoryAddress = Buffer.memoryAddress(buffer);