summaryrefslogtreecommitdiff
path: root/src/net/interface_unix_test.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2015-06-23 21:40:33 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2015-06-27 00:39:30 +0000
commit258bf65d8b157bfe311ce70c93dd854022a25c9d (patch)
treebc248520f7297c884d21aee39d1af197b18d5735 /src/net/interface_unix_test.go
parentaea348a3af088bc3bc05c5ee5cfc567215008f6f (diff)
downloadgo-git-258bf65d8b157bfe311ce70c93dd854022a25c9d.tar.gz
net: relax IP interface address determination on linux
Linux allows to have a peer IP address on IP interface over ethernet link encapsulation, though it only installs a static route with the peer address as an on-link nexthop. Fixes #11338. Change-Id: Ie2583737e4c7cec39baabb89dd732463d3f10a61 Reviewed-on: https://go-review.googlesource.com/11352 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/net/interface_unix_test.go')
-rw-r--r--src/net/interface_unix_test.go45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/net/interface_unix_test.go b/src/net/interface_unix_test.go
index 84bf06cbce..93b3b79afd 100644
--- a/src/net/interface_unix_test.go
+++ b/src/net/interface_unix_test.go
@@ -54,8 +54,8 @@ func TestPointToPointInterface(t *testing.T) {
local, remote := "169.254.0.1", "169.254.0.254"
ip := ParseIP(remote)
for i := 0; i < 3; i++ {
- ti := &testInterface{}
- if err := ti.setPointToPoint(5963+i, local, remote); err != nil {
+ ti := &testInterface{local: local, remote: remote}
+ if err := ti.setPointToPoint(5963 + i); err != nil {
t.Skipf("test requries external command: %v", err)
}
if err := ti.setup(); err != nil {
@@ -69,17 +69,18 @@ func TestPointToPointInterface(t *testing.T) {
t.Fatal(err)
}
for _, ifi := range ift {
- if ti.name == ifi.Name {
- ifat, err := ifi.Addrs()
- if err != nil {
+ if ti.name != ifi.Name {
+ continue
+ }
+ ifat, err := ifi.Addrs()
+ if err != nil {
+ ti.teardown()
+ t.Fatal(err)
+ }
+ for _, ifa := range ifat {
+ if ip.Equal(ifa.(*IPNet).IP) {
ti.teardown()
- t.Fatal(err)
- }
- for _, ifa := range ifat {
- if ip.Equal(ifa.(*IPNet).IP) {
- ti.teardown()
- t.Fatalf("got %v; want %v", ip, local)
- }
+ t.Fatalf("got %v", ifa)
}
}
}
@@ -99,12 +100,14 @@ func TestInterfaceArrivalAndDeparture(t *testing.T) {
t.Skip("must be root")
}
+ local, remote := "169.254.0.1", "169.254.0.254"
+ ip := ParseIP(remote)
for i := 0; i < 3; i++ {
ift1, err := Interfaces()
if err != nil {
t.Fatal(err)
}
- ti := &testInterface{}
+ ti := &testInterface{local: local, remote: remote}
if err := ti.setBroadcast(5682 + i); err != nil {
t.Skipf("test requires external command: %v", err)
}
@@ -128,6 +131,22 @@ func TestInterfaceArrivalAndDeparture(t *testing.T) {
ti.teardown()
t.Fatalf("got %v; want gt %v", len(ift2), len(ift1))
}
+ for _, ifi := range ift2 {
+ if ti.name != ifi.Name {
+ continue
+ }
+ ifat, err := ifi.Addrs()
+ if err != nil {
+ ti.teardown()
+ t.Fatal(err)
+ }
+ for _, ifa := range ifat {
+ if ip.Equal(ifa.(*IPNet).IP) {
+ ti.teardown()
+ t.Fatalf("got %v", ifa)
+ }
+ }
+ }
if err := ti.teardown(); err != nil {
t.Fatal(err)
} else {