Ensure we can load the native library or fail the build (#11262)

Motivation:

We used assumeTrue(...) in some places before to detect if we could load the native library but this could lead to the sitation that we not notice if we break native loading.

Modifications:

Always fail if we cant load the native library

Result:

Ensure we not cause any regression in the native loading code in the future
This commit is contained in:
Norman Maurer 2021-05-18 08:14:32 +02:00 committed by GitHub
parent 8a03a1db7d
commit 6e866317d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 10 deletions

View File

@ -23,6 +23,6 @@ public class EpollKQueueIovArrayTest extends IovArrayTest {
@BeforeClass @BeforeClass
public static void loadNative() { public static void loadNative() {
Assume.assumeTrue(Epoll.isAvailable()); Epoll.ensureAvailability();
} }
} }

View File

@ -27,12 +27,11 @@ import java.io.IOException;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
public class EpollSocketTest extends SocketTest<LinuxSocket> { public class EpollSocketTest extends SocketTest<LinuxSocket> {
@BeforeClass @BeforeClass
public static void loadJNI() { public static void loadJNI() {
assumeTrue(Epoll.isAvailable()); Epoll.ensureAvailability();
} }
@Test @Test

View File

@ -22,12 +22,10 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import static org.junit.Assume.assumeTrue;
public class LinuxSocketTest { public class LinuxSocketTest {
@BeforeClass @BeforeClass
public static void loadJNI() { public static void loadJNI() {
assumeTrue(Epoll.isAvailable()); Epoll.ensureAvailability();
} }
@Test(expected = IOException.class) @Test(expected = IOException.class)

View File

@ -16,13 +16,12 @@
package io.netty.channel.kqueue; package io.netty.channel.kqueue;
import io.netty.channel.unix.tests.IovArrayTest; import io.netty.channel.unix.tests.IovArrayTest;
import org.junit.Assume;
import org.junit.BeforeClass; import org.junit.BeforeClass;
public class KQueueIovArrayTest extends IovArrayTest { public class KQueueIovArrayTest extends IovArrayTest {
@BeforeClass @BeforeClass
public static void loadNative() { public static void loadNative() {
Assume.assumeTrue(KQueue.isAvailable()); KQueue.ensureAvailability();
} }
} }

View File

@ -25,12 +25,11 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
public class KQueueSocketTest extends SocketTest<BsdSocket> { public class KQueueSocketTest extends SocketTest<BsdSocket> {
@BeforeClass @BeforeClass
public static void loadJNI() { public static void loadJNI() {
assumeTrue(KQueue.isAvailable()); KQueue.ensureAvailability();
} }
@Test @Test