Also test link-local ping on connected sockets.

The ping6 binary uses connect+send sockets, but the test code
only uses sendto. Test both.

Bug: 29370996
Test: all_tests.py passes on android-4.4
Change-Id: I8296e96d9d4edf4715322731f7bfb36e291a2631
diff --git a/net/test/ping6_test.py b/net/test/ping6_test.py
index cf9e2c2..ff39e84 100755
--- a/net/test/ping6_test.py
+++ b/net/test/ping6_test.py
@@ -615,15 +615,16 @@
       upstream net:
         5e45789 net: ipv6: Fix ping to link-local addresses.
     """
-    s = net_test.IPv6PingSocket()
     for mode in ["oif", "ucast_oif", None]:
       s = net_test.IPv6PingSocket()
       for netid in self.NETIDS:
+        s2 = net_test.IPv6PingSocket()
         dst = self._RouterAddress(netid, 6)
         self.assertTrue(dst.startswith("fe80:"))
 
         if mode:
           self.SelectInterface(s, netid, mode)
+          self.SelectInterface(s2, netid, mode)
           scopeid = 0
         else:
           scopeid = self.ifindices[netid]
@@ -637,11 +638,21 @@
           self.assertRaisesErrno(
               errno.EINVAL,
               s.sendto, net_test.IPV6_PING, (dst, 55, 0, otherscopeid))
+          self.assertRaisesErrno(
+              errno.EINVAL,
+              s.connect, (dst, 55, 0, otherscopeid))
 
+        # Try using both sendto and connect/send.
+        # If we get a reply, we sent the packet out on the right interface.
         s.sendto(net_test.IPV6_PING, (dst, 123, 0, scopeid))
-        # If we got a reply, we sent the packet out on the right interface.
         self.assertValidPingResponse(s, net_test.IPV6_PING)
 
+        # IPV6_UNICAST_IF doesn't work on connected sockets.
+        if mode != "ucast_oif":
+          s2.connect((dst, 123, 0, scopeid))
+          s2.send(net_test.IPV6_PING)
+          self.assertValidPingResponse(s2, net_test.IPV6_PING)
+
   def testMappedAddressFails(self):
     s = net_test.IPv6PingSocket()
     s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))