test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] tests/TestSuite_metering_and_policing:Modify scripts to run less time
@ 2019-08-23  9:06 zhang,yan
  2019-08-23  9:04 ` Zhu, WenhuiX
  2019-09-04  5:00 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: zhang,yan @ 2019-08-23  9:06 UTC (permalink / raw)
  To: dts; +Cc: zhang,yan

Optimize scapy open and close mode.

Signed-off-by: zhang,yan <yanx.a.zhang@intel.com>
---
 tests/TestSuite_metering_and_policing.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_metering_and_policing.py b/tests/TestSuite_metering_and_policing.py
index c4c83d6..77da805 100644
--- a/tests/TestSuite_metering_and_policing.py
+++ b/tests/TestSuite_metering_and_policing.py
@@ -45,6 +45,22 @@ from dut import Dut
 
 
 class TestMeteringAndPolicing(TestCase):
+    scapyCmds = []
+
+    def start_scapy(self):
+        self.tester.scapy_foreground()
+        self.tester.send_expect('scapy', '>>> ', 10)
+        self.scapy_status = True
+
+    def end_scapy(self):
+        self.tester.send_expect("exit()", "#")
+        self.scapy_status = False
+
+    def scapy_execute(self, timeout=60):
+        for cmd in self.scapyCmds:
+            self.tester.send_expect(cmd, ">>> ", timeout)
+
+        self.scapyCmds = []
 
     def copy_config_files_to_dut(self):
         """
@@ -219,10 +235,10 @@ class TestMeteringAndPolicing(TestCase):
             if protocol == "UDP":
                 proto_str = "nh=17"
 
-        self.tester.scapy_append(
+        self.scapyCmds.append(
             'sendp([Ether(dst="%s")/%s(src="%s",dst="%s",%s)/%s(sport=%d,dport=%d)/Raw(load="P"*%d)], iface="%s")'
             % (self.dut_p0_mac, tag, src_ip, dst_ip, proto_str, protocol, fwd_port, fwd_port, pktsize, source_port))
-        self.tester.scapy_execute()
+        self.scapy_execute()
 
     def send_packet_and_check(self, ip_ver, protocol, fwd_port, pktsize, expect_port):
         """
@@ -296,6 +312,7 @@ class TestMeteringAndPolicing(TestCase):
         self.dut_p0_mac = self.dut.get_mac_address(self.dut_ports[0])
         self.port_id = len(self.dut_ports)
         self.copy_config_files_to_dut()
+        self.start_scapy()
 
     def set_up(self):
         """
@@ -653,4 +670,5 @@ class TestMeteringAndPolicing(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        if self.scapy_status:
+            self.end_scapy()
-- 
2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-04  5:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23  9:06 [dts] [PATCH V1] tests/TestSuite_metering_and_policing:Modify scripts to run less time zhang,yan
2019-08-23  9:04 ` Zhu, WenhuiX
2019-09-04  5:00 ` Tu, Lijuan

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).