* [dts] [PATCH] Optimize vlan test suite routine and style
@ 2015-07-14 8:33 Yong Liu
0 siblings, 0 replies; only message in thread
From: Yong Liu @ 2015-07-14 8:33 UTC (permalink / raw)
To: dts
From: Marvin Liu <yong.liu@intel.com>
Start testpmd command move to set_up function which will be called before
every case. Optimize code style too.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index 2f5dfd4..2b3de8a 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -32,11 +32,8 @@
"""
DPDK Test suite.
-
Test the support of VLAN Offload Features by Poll Mode Drivers.
-
"""
-
import dts
import time
@@ -50,8 +47,6 @@ class TestVlan(TestCase):
def set_up_all(self):
"""
Run at the start of each test suite.
-
-
Vlan Prerequistites
"""
global dutRxPortId
@@ -66,32 +61,21 @@ class TestVlan(TestCase):
valports = [_ for _ in ports if self.tester.get_local_port(_) != -1]
dutRxPortId = valports[0]
dutTxPortId = valports[1]
- portMask = dts.create_mask(valports[:2])
+ self.portMask = dts.create_mask(valports[:2])
self.pmdout = PmdOutput(self.dut)
- self.pmdout.start_testpmd("all", "--portmask=%s" % portMask )
-
- self.dut.send_expect("set verbose 1", "testpmd> ")
- out = self.dut.send_expect("set fwd mac", "testpmd> ")
-
- if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]:
- self.dut.send_expect("set promisc all off", "testpmd> ")
- self.dut.send_expect("vlan set filter on %s"%dutRxPortId, "testpmd> ")
-
- self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ")
- self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error")
self.vlan = 51
-
+
def start_tcpdump(self):
port = self.tester.get_local_port(dutTxPortId)
rxItf = self.tester.get_interface(port)
- self.tester.send_expect("rm -rf ./vlan_test.cap","#")
- self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& "%rxItf,"#" )
-
+ self.tester.send_expect("rm -rf ./vlan_test.cap", "#")
+ self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& " % rxItf, "#")
+
def get_tcpdump_package(self):
- self.tester.send_expect("killall tcpdump","#")
- return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap","#")
+ self.tester.send_expect("killall tcpdump", "#")
+ return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap", "#")
def vlan_send_packet(self, vid, num=1):
"""
@@ -109,7 +93,6 @@ class TestVlan(TestCase):
self.dmac = self.dut.get_mac_address(dutRxPortId)
# FIXME send a burst with only num packet
-
self.tester.scapy_append('sendp([Ether(src="%s",dst="%s")/Dot1Q(vlan=%s)/IP(len=46)], iface="%s")' % (self.smac, self.dmac, vid, txItf))
self.tester.scapy_execute()
@@ -118,34 +101,40 @@ class TestVlan(TestCase):
"""
Run before each test case.
"""
- pass
+ self.pmdout.start_testpmd("all", "--portmask=%s" % self.portMask)
+
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ out = self.dut.send_expect("set fwd mac", "testpmd> ")
+ self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error")
+
+ if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]:
+ self.dut.send_expect("set promisc all off", "testpmd> ")
+ self.dut.send_expect("vlan set filter on %s" % dutRxPortId, "testpmd> ")
+
+ self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ")
+
def test_vlan_enable_receipt(self):
"""
Enable receipt of VLAN packets
"""
- if self.nic == "redrockcanyou" :
+ if self.nic == "redrockcanyou":
print dts.RED("fm10k not support this case\n")
return
self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ")
self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ")
self.dut.send_expect("start", "testpmd> ", 120)
out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
-
+
self.start_tcpdump()
self.vlan_send_packet(self.vlan)
out = self.get_tcpdump_package()
self.verify("vlan %d" % self.vlan in out, "Wrong vlan:" + out)
- self.dut.send_expect("stop", "testpmd> ")
-
-
def test_vlan_disable_receipt(self):
"""
Disable receipt of VLAN packets
"""
-
-
self.dut.send_expect("rx_vlan rm %d %s" % (self.vlan, dutRxPortId), "testpmd> ")
self.dut.send_expect("start", "testpmd> ", 120)
self.start_tcpdump()
@@ -153,14 +142,12 @@ class TestVlan(TestCase):
out = self.get_tcpdump_package()
# fm10k switch will redirect package if not send to nic
- if (not((self.nic == "redrockcanyou") and ("%s > %s"%(self.smac, self.dmac) in out))):
+ if(not((self.nic == "redrockcanyou") and ("%s > %s" % (self.smac, self.dmac) in out))):
self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out)
out = self.dut.send_expect("stop", "testpmd> ")
-
def test_vlan_strip_config_on(self):
-
self.dut.send_expect("vlan set strip on %s" % dutRxPortId, "testpmd> ", 20)
self.dut.send_expect("rx_vlan add %d %s" % (self.vlan, dutRxPortId), "testpmd> ", 20)
out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
@@ -171,11 +158,9 @@ class TestVlan(TestCase):
self.vlan_send_packet(self.vlan)
out = self.get_tcpdump_package()
self.verify("vlan %d" % self.vlan not in out, "Wrong vlan:" + out)
- out = self.dut.send_expect("quit", "#", 120)
def test_vlan_strip_config_off(self):
-
- if self.nic == "redrockcanyou" :
+ if self.nic == "redrockcanyou":
print dts.RED("fm10k not support this case\n")
return
self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ", 20)
@@ -194,7 +179,6 @@ class TestVlan(TestCase):
"""
Enable VLAN header insertion in transmitted packets
"""
-
port = self.tester.get_local_port(dutTxPortId,)
intf = self.tester.get_interface(port)
@@ -216,15 +200,12 @@ class TestVlan(TestCase):
if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single", "redrockcanyou"]:
self.dut.send_expect("tx_vlan reset %s" % dutTxPortId, "testpmd> ", 30)
self.dut.send_expect("stop", "testpmd> ", 30)
- else:
- self.dut.send_expect("quit", "# ", 30)
def tear_down(self):
"""
Run after each test case.
"""
- pass
-
+ self.dut.send_expect("quit", "# ", 30)
def tear_down_all(self):
"""
--
1.9.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-14 8:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 8:33 [dts] [PATCH] Optimize vlan test suite routine and style Yong Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).