Skip to content

Commit

Permalink
Ensure we can load the native library or fail the build (#11262)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
normanmaurer committed May 18, 2021
1 parent 8a03a1d commit 6e86631
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public class EpollKQueueIovArrayTest extends IovArrayTest {

@BeforeClass
public static void loadNative() {
Assume.assumeTrue(Epoll.isAvailable());
Epoll.ensureAvailability();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

public class EpollSocketTest extends SocketTest<LinuxSocket> {
@BeforeClass
public static void loadJNI() {
assumeTrue(Epoll.isAvailable());
Epoll.ensureAvailability();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;

import static org.junit.Assume.assumeTrue;

public class LinuxSocketTest {
@BeforeClass
public static void loadJNI() {
assumeTrue(Epoll.isAvailable());
Epoll.ensureAvailability();
}

@Test(expected = IOException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
package io.netty.channel.kqueue;

import io.netty.channel.unix.tests.IovArrayTest;
import org.junit.Assume;
import org.junit.BeforeClass;

public class KQueueIovArrayTest extends IovArrayTest {

@BeforeClass
public static void loadNative() {
Assume.assumeTrue(KQueue.isAvailable());
KQueue.ensureAvailability();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
import java.io.IOException;

import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;

public class KQueueSocketTest extends SocketTest<BsdSocket> {
@BeforeClass
public static void loadJNI() {
assumeTrue(KQueue.isAvailable());
KQueue.ensureAvailability();
}

@Test
Expand Down

0 comments on commit 6e86631

Please sign in to comment.