8050922: add additional diagnostic to java/net/MulticastSocket/TestInterfaces
authormsheppar
Fri, 18 Jul 2014 01:39:42 +0100
changeset 25654 bab08a81b601
parent 25653 41e5fa7ce490
child 25655 c9705c72e753
8050922: add additional diagnostic to java/net/MulticastSocket/TestInterfaces Summary: add additional diagnostic output for failed netwrok interface Reviewed-by: chegar
jdk/test/java/net/MulticastSocket/TestInterfaces.java
--- a/jdk/test/java/net/MulticastSocket/TestInterfaces.java	Sat Jul 12 01:36:25 2014 +0200
+++ b/jdk/test/java/net/MulticastSocket/TestInterfaces.java	Fri Jul 18 01:39:42 2014 +0100
@@ -28,6 +28,8 @@
  *          same InetAddress set by MulticastSocket.setInterface
  */
 import java.net.*;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.io.IOException;
 
@@ -47,6 +49,7 @@
             /*
              * Test MulticastSocket.getInterface
              */
+            System.out.println("Testing network interface " + ni);
             Enumeration addrs = ni.getInetAddresses();
             while (addrs.hasMoreElements()) {
                 InetAddress ia = (InetAddress)addrs.nextElement();
@@ -64,6 +67,8 @@
 
                 InetAddress curr = soc.getInterface();
                 if (!curr.equals(ia)) {
+                    System.err.println("NetworkInterface under test " + ni);
+                    displayInterfaceInformation(ni);
                     System.err.println("MulticastSocket.getInterface returned: " + curr);
                     System.err.println("Failed! Expected: " + ia);
                     failures++;
@@ -96,6 +101,10 @@
             if (!curr.equals(ni)) {
                 System.err.println("MulticastSocket.getNetworkInterface returned: " + curr);
                 System.err.println("Failed! Expected: " + ni);
+                System.err.println("NetworkInterface details for curr variable ");
+                displayInterfaceInformation(curr);
+                System.err.println("NetworkInterface details for ni variable ");
+                displayInterfaceInformation(ni) ;
                 failures++;
             } else {
                 System.out.println("Passed.");
@@ -110,4 +119,23 @@
 
     }
 
+    static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
+        System.err.println("Display name: " + netint.getDisplayName());
+        System.err.println("Name: " + netint.getName());
+        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
+
+        for (InetAddress inetAddress : Collections.list(inetAddresses))
+            System.err.println("InetAddress: " + inetAddress);
+
+        System.err.println("Up? " + netint.isUp());
+        System.err.println("Loopback? " + netint.isLoopback());
+        System.err.println("PointToPoint? " + netint.isPointToPoint());
+        System.err.println("Supports multicast? " + netint.supportsMulticast());
+        System.err.println("Virtual? " + netint.isVirtual());
+        System.err.println("Hardware address: " +
+                Arrays.toString(netint.getHardwareAddress()));
+        System.err.println("MTU: " + netint.getMTU());
+        System.err.println("Index: " + netint.getIndex());
+        System.err.println();
+    }
 }