test/jdk/java/nio/channels/unixdomain/Basic.java
branchunixdomainchannels
changeset 59054 42bcf3042cd8
parent 59052 15e9a570c6e6
child 59073 832b8a28e17f
equal deleted inserted replaced
59052:15e9a570c6e6 59054:42bcf3042cd8
    43     static boolean nagle;
    43     static boolean nagle;
    44 
    44 
    45     public static void main(String args[]) throws Exception {
    45     public static void main(String args[]) throws Exception {
    46         if (args.length != 3)
    46         if (args.length != 3)
    47             usage();
    47             usage();
       
    48 	if (!supported()) {
       
    49 	    System.out.println("Unix domain channels not supported");
       
    50 	    return;
       
    51 	}
    48         sockRxBufsize = getInt(args[0]);
    52         sockRxBufsize = getInt(args[0]);
    49         sockTxBufsize = getInt(args[1]);
    53         sockTxBufsize = getInt(args[1]);
    50         if (args[2].equals("nagle-on"))
    54         if (args[2].equals("nagle-on"))
    51             nagle = true;
    55             nagle = true;
    52         else if (args[2].equals("nagle-off"))
    56         else if (args[2].equals("nagle-off"))
    55         warmup();
    59         warmup();
    56         test(128, 1000);
    60         test(128, 1000);
    57         test(8 * 1024, 10000);
    61         test(8 * 1024, 10000);
    58         test(16 * 1024, 10000);
    62         test(16 * 1024, 10000);
    59         test(32 * 1024, 10000);
    63         test(32 * 1024, 10000);
    60         // repeat
    64     }
    61         System.out.println("---- Repeating all tests again -----");
    65 
    62         test(128, 1000);
    66     static boolean supported() {
    63         test(16 * 1024, 10000);
    67 	try {
    64         test(32 * 1024, 10000);
    68 	    SocketChannel.open(StandardProtocolFamily.UNIX);
       
    69 	} catch (UnsupportedAddressTypeException e) {
       
    70 	    return false;
       
    71 	} catch (Exception e) {
       
    72 	    return true; // continue test to see what problem is
       
    73 	}
       
    74 	return true;
    65     }
    75     }
    66 
    76 
    67     static int getInt(String s) {
    77     static int getInt(String s) {
    68         if (s.equalsIgnoreCase("default"))
    78         if (s.equalsIgnoreCase("default"))
    69             return -1;
    79             return -1;