unixdomainchannels: test updates unixdomainchannels
authormichaelm
Thu, 14 Nov 2019 08:27:28 +0000
branchunixdomainchannels
changeset 59073 832b8a28e17f
parent 59054 42bcf3042cd8
child 59074 7917f95f74c4
unixdomainchannels: test updates
test/jdk/java/nio/channels/unixdomain/Basic.java
test/jdk/java/nio/channels/unixdomain/SocketOptions.java
--- a/test/jdk/java/nio/channels/unixdomain/Basic.java	Wed Nov 13 11:37:09 2019 +0000
+++ b/test/jdk/java/nio/channels/unixdomain/Basic.java	Thu Nov 14 08:27:28 2019 +0000
@@ -45,6 +45,7 @@
     public static void main(String args[]) throws Exception {
         if (args.length != 3)
             usage();
+
 	if (!supported()) {
 	    System.out.println("Unix domain channels not supported");
 	    return;
--- a/test/jdk/java/nio/channels/unixdomain/SocketOptions.java	Wed Nov 13 11:37:09 2019 +0000
+++ b/test/jdk/java/nio/channels/unixdomain/SocketOptions.java	Thu Nov 14 08:27:28 2019 +0000
@@ -42,10 +42,25 @@
 public class SocketOptions {
 
     public static void main(String args[]) throws Exception {
+        if (!supported()) {
+            System.out.println("Unix domain channels not supported");
+            return;
+        }
         test(ServerSocketChannel.open(StandardProtocolFamily.UNIX));
         test(SocketChannel.open(StandardProtocolFamily.UNIX));
     }
 
+    static boolean supported() {
+	try {
+	    SocketChannel.open(StandardProtocolFamily.UNIX);
+	} catch (UnsupportedAddressTypeException e) {
+	    return false;
+	} catch (Exception e) {
+	    return true; // continue test to see what problem is
+	}
+	return true;
+    }
+
     @SuppressWarnings("unchecked")
     public static void test(NetworkChannel chan) throws IOException {
         System.out.println("Checking: " + chan.getClass());