Test for TxQLen

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2014-12-04 18:25:38 -08:00
parent f7f54f4512
commit 7bedf70b9b
1 changed files with 14 additions and 3 deletions

View File

@ -1,10 +1,13 @@
package netlink package netlink
import ( import (
"github.com/vishvananda/netns"
"testing" "testing"
"github.com/vishvananda/netns"
) )
const testTxQLen uint32 = 100
func testLinkAddDel(t *testing.T, link Link) { func testLinkAddDel(t *testing.T, link Link) {
links, err := LinkList() links, err := LinkList()
if err != nil { if err != nil {
@ -46,14 +49,22 @@ func testLinkAddDel(t *testing.T, link Link) {
} }
if veth, ok := link.(*Veth); ok { if veth, ok := link.(*Veth); ok {
if veth.TxQLen != testTxQLen {
t.Fatalf("TxQLen is %d, should be %d", veth.TxQLen, testTxQLen)
}
if veth.PeerName != "" { if veth.PeerName != "" {
var peer *Veth
other, err := LinkByName(veth.PeerName) other, err := LinkByName(veth.PeerName)
if err != nil { if err != nil {
t.Fatal("Peer %s not created", veth.PeerName) 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) 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)
}
} }
} }
@ -184,7 +195,7 @@ func TestLinkAddDelVeth(t *testing.T) {
tearDown := setUpNetlinkTest(t) tearDown := setUpNetlinkTest(t)
defer tearDown() defer tearDown()
testLinkAddDel(t, &Veth{LinkAttrs{Name: "foo"}, "bar"}) testLinkAddDel(t, &Veth{LinkAttrs{Name: "foo", TxQLen: testTxQLen}, "bar"})
} }
func TestLinkAddDelBridgeMaster(t *testing.T) { func TestLinkAddDelBridgeMaster(t *testing.T) {