Skip to content

Commit

Permalink
Test for TxQLen
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Morozov <[email protected]>
  • Loading branch information
LK4D4 committed Dec 5, 2014
1 parent f7f54f4 commit 7bedf70
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions link_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package netlink

import (
"github.com/vishvananda/netns"
"testing"

"github.com/vishvananda/netns"
)

const testTxQLen uint32 = 100

func testLinkAddDel(t *testing.T, link Link) {
links, err := LinkList()
if err != nil {
Expand Down Expand Up @@ -46,14 +49,22 @@ func testLinkAddDel(t *testing.T, link Link) {
}

if veth, ok := link.(*Veth); ok {
if veth.TxQLen != testTxQLen {
t.Fatalf("TxQLen is %d, should be %d", veth.TxQLen, testTxQLen)
}

if veth.PeerName != "" {
var peer *Veth
other, err := LinkByName(veth.PeerName)
if err != nil {
t.Fatal("Peer %s not created", veth.PeerName)
}
if _, ok = other.(*Veth); !ok {
if peer, ok = other.(*Veth); !ok {
t.Fatal("Peer %s is incorrect type", veth.PeerName)
}
if peer.TxQLen != testTxQLen {
t.Fatalf("TxQLen of peer is %d, should be %d", peer.TxQLen, testTxQLen)
}
}
}

Expand Down Expand Up @@ -184,7 +195,7 @@ func TestLinkAddDelVeth(t *testing.T) {
tearDown := setUpNetlinkTest(t)
defer tearDown()

testLinkAddDel(t, &Veth{LinkAttrs{Name: "foo"}, "bar"})
testLinkAddDel(t, &Veth{LinkAttrs{Name: "foo", TxQLen: testTxQLen}, "bar"})
}

func TestLinkAddDelBridgeMaster(t *testing.T) {
Expand Down

0 comments on commit 7bedf70

Please sign in to comment.