From 7bedf70b9bd69d3f7e74633ec8dc3a86c75fc167 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 4 Dec 2014 18:25:38 -0800 Subject: [PATCH] Test for TxQLen Signed-off-by: Alexander Morozov --- link_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/link_test.go b/link_test.go index 65b7b2b..232ad03 100644 --- a/link_test.go +++ b/link_test.go @@ -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 { @@ -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) + } } } @@ -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) {