Also handle the case of missing shared lib for sctp

This commit is contained in:
norman 2012-05-22 09:36:14 +02:00
parent 0a95ce8104
commit 128309367c

View File

@ -15,8 +15,11 @@
*/ */
package io.netty.testsuite.util; package io.netty.testsuite.util;
import java.io.IOException;
import java.util.Locale; import java.util.Locale;
import com.sun.nio.sctp.SctpChannel;
public class SctpTestUtil { public class SctpTestUtil {
//io.netty.util.SocketAddresses.LOCALHOST interface has MTU SIZE issues with SCTP, we have to use local loop back interface for testing //io.netty.util.SocketAddresses.LOCALHOST interface has MTU SIZE issues with SCTP, we have to use local loop back interface for testing
public final static String LOOP_BACK = "127.0.0.1"; public final static String LOOP_BACK = "127.0.0.1";
@ -29,6 +32,18 @@ public class SctpTestUtil {
public static boolean isSctpSupported() { public static boolean isSctpSupported() {
String os = System.getProperty("os.name").toLowerCase(Locale.UK); String os = System.getProperty("os.name").toLowerCase(Locale.UK);
if (os.equals("unix") || os.equals("linux") || os.equals("sun") || os.equals("solaris")) { if (os.equals("unix") || os.equals("linux") || os.equals("sun") || os.equals("solaris")) {
try {
SctpChannel.open();
} catch (IOException e) {
// ignore
} catch (UnsupportedOperationException e) {
// This exception may get thrown if the OS does not have
// the shared libs installed.
System.out.print("Not supported: " + e.getMessage());
return false;
}
return true; return true;
} }
return false; return false;