Let EpollReuseAddrTest also work with kernel versions that not have bugfix release part
This commit is contained in:
parent
ac348956e3
commit
384ba32b56
@ -27,6 +27,7 @@ import io.netty.testsuite.util.TestUtils;
|
|||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
import io.netty.util.ReferenceCountUtil;
|
||||||
import io.netty.util.ResourceLeakDetector;
|
import io.netty.util.ResourceLeakDetector;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -47,17 +48,21 @@ public class EpollReuseAddrTest {
|
|||||||
private static final int BUGFIX;
|
private static final int BUGFIX;
|
||||||
static {
|
static {
|
||||||
String kernelVersion = Native.kernelVersion();
|
String kernelVersion = Native.kernelVersion();
|
||||||
int index = kernelVersion.indexOf("-");
|
int index = kernelVersion.indexOf('-');
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
kernelVersion = kernelVersion.substring(0, index);
|
kernelVersion = kernelVersion.substring(0, index);
|
||||||
}
|
}
|
||||||
String[] versionParts = kernelVersion.split("\\.");
|
String[] versionParts = StringUtil.split(kernelVersion, '.');
|
||||||
if (versionParts.length == 3) {
|
if (versionParts.length <= 3) {
|
||||||
MAJOR = Integer.parseInt(versionParts[0]);
|
MAJOR = Integer.parseInt(versionParts[0]);
|
||||||
MINOR = Integer.parseInt(versionParts[1]);
|
MINOR = Integer.parseInt(versionParts[1]);
|
||||||
|
if (versionParts.length == 3) {
|
||||||
BUGFIX = Integer.parseInt(versionParts[2]);
|
BUGFIX = Integer.parseInt(versionParts[2]);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException();
|
BUGFIX = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Can not parse kernel version " + kernelVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +167,7 @@ public class EpollReuseAddrTest {
|
|||||||
Assert.assertTrue(received2.get());
|
Assert.assertTrue(received2.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerBootstrap createServerBootstrap() {
|
private static ServerBootstrap createServerBootstrap() {
|
||||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||||
bootstrap.group(EpollSocketTestPermutation.EPOLL_BOSS_GROUP, EpollSocketTestPermutation.EPOLL_WORKER_GROUP);
|
bootstrap.group(EpollSocketTestPermutation.EPOLL_BOSS_GROUP, EpollSocketTestPermutation.EPOLL_WORKER_GROUP);
|
||||||
bootstrap.channel(EpollServerSocketChannel.class);
|
bootstrap.channel(EpollServerSocketChannel.class);
|
||||||
@ -172,7 +177,7 @@ public class EpollReuseAddrTest {
|
|||||||
return bootstrap;
|
return bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bootstrap createBootstrap() {
|
private static Bootstrap createBootstrap() {
|
||||||
Bootstrap bootstrap = new Bootstrap();
|
Bootstrap bootstrap = new Bootstrap();
|
||||||
bootstrap.group(EpollSocketTestPermutation.EPOLL_WORKER_GROUP);
|
bootstrap.group(EpollSocketTestPermutation.EPOLL_WORKER_GROUP);
|
||||||
bootstrap.channel(EpollDatagramChannel.class);
|
bootstrap.channel(EpollDatagramChannel.class);
|
||||||
@ -184,7 +189,8 @@ public class EpollReuseAddrTest {
|
|||||||
private static boolean versionEqOrGt(int major, int minor, int bugfix) {
|
private static boolean versionEqOrGt(int major, int minor, int bugfix) {
|
||||||
if (MAJOR > major) {
|
if (MAJOR > major) {
|
||||||
return true;
|
return true;
|
||||||
} else if (MAJOR == major) {
|
}
|
||||||
|
if (MAJOR == major) {
|
||||||
if (MINOR > minor) {
|
if (MINOR > minor) {
|
||||||
return true;
|
return true;
|
||||||
} else if (MINOR == minor) {
|
} else if (MINOR == minor) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user