Skip to content

Commit

Permalink
Test update for routing Source Address Selection
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Albert Zhang <[email protected]> (github: zhgwenming)
  • Loading branch information
zhgwenming committed Nov 6, 2014
1 parent 4291a54 commit 58b336a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions netlink/netlink_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,34 @@ func TestAddDelNetworkIp(t *testing.T) {
}
}

func TestAddRouteSourceSelection(t *testing.T) {
tstIp := "127.1.1.1"
tl := testLink{name: "tstEth", linkType: "dummy"}

addLink(t, tl.name, tl.linkType)
defer deleteLink(t, tl.name)

ip := net.ParseIP(tstIp)
mask := net.IPv4Mask(255, 255, 255, 255)
ipNet := &net.IPNet{IP: ip, Mask: mask}

iface, err := net.InterfaceByName(tl.name)
if err != nil {
t.Fatalf("Lost created link %#v", tl)
}

if err := NetworkLinkAddIp(iface, ip, ipNet); err != nil {
t.Fatalf("Could not add IP address %s to interface %#v: %s", ip.String(), iface, err)
}

upLink(t, tl.name)
defer downLink(t, tl.name)

if err := AddRoute("127.0.0.0/8", tstIp, "", tl.name); err != nil {
t.Fatalf("Failed to add route with source address")
}
}

func TestCreateVethPair(t *testing.T) {
if testing.Short() {
return
Expand Down

0 comments on commit 58b336a

Please sign in to comment.