test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] tests/multiple_pthread: fix issue of always send pkts after this suite
@ 2019-12-17  0:11 lihong
  2019-12-17  7:51 ` Zhu, WenhuiX
  2019-12-20  8:05 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: lihong @ 2019-12-17  0:11 UTC (permalink / raw)
  To: dts; +Cc: lihong

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 tests/TestSuite_multiple_pthread.py | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py
index b59f047..6c6a070 100644
--- a/tests/TestSuite_multiple_pthread.py
+++ b/tests/TestSuite_multiple_pthread.py
@@ -36,6 +36,7 @@ import random
 import string
 import utils
 from test_case import TestCase
+from packet import Packet
 
 
 class TestMultiplePthread(TestCase):
@@ -60,27 +61,19 @@ class TestMultiplePthread(TestCase):
         """
         Run before each test case.
         """
-        pass
-
-    def destroy_packets_session(self):
-        """
-        close send packets session.
-        """
-        for i in valports:
-            self.tester.create_session(name="%s" % i).send_expect("^C", "#")
-            self.tester.destroy_session(self.tester.create_session(name="%s" % i))
+        self.send_sessions = []
 
     def send_packet(self):
         """
-        create sessions and Send packets continuous.
+        Send packets continuous.
         """
         for index in valports:
             localPort = self.tester.get_local_port(index)
             iface = self.tester.get_interface(localPort)
-            self.send_packets_session = self.tester.create_session(name="%s" % index)
-            packet = r'sendp([Ether()/IP(src="1.2.3.4", dst="192.168.0.%d")], iface="%s", loop=1)' % (index, iface)
-            self.send_packets_session.send_expect("scapy", ">>>")
-            self.send_packets_session.send_command(packet)
+            pcap_str = 'Ether()/IP(src="1.2.3.4", dst="192.168.0.%d")' % (index)
+            self.pkt = Packet(pcap_str)
+            intf = self.pkt.send_pkt_bg(crb=self.tester, tx_port=iface)
+            self.send_sessions.append(intf)
 
     def get_cores_statistic(self, cmdline):
         """
@@ -91,6 +84,7 @@ class TestMultiplePthread(TestCase):
         m = cmdline.replace('"', '', 2)
         out_list = out.split(m)
         mutiple_pthread_session.send_expect("^C", "#")
+        self.dut.close_session(mutiple_pthread_session)
         return out_list
 
     def verify_before_send_packets(self, out_list):
@@ -159,7 +153,6 @@ class TestMultiplePthread(TestCase):
         # quit application
         self.dut.send_expect("stop", "testpmd> ")
         self.dut.send_expect("quit", "# ", 30)
-        self.destroy_packets_session()
 
     def test_basic_operation(self):
         """
@@ -231,6 +224,8 @@ class TestMultiplePthread(TestCase):
         """
         Run after each test case.
         """
+        if len(self.send_sessions) != 0:
+            self.pkt.stop_send_pkt_bg(self.tester, self.send_sessions)
         self.dut.kill_all()
 
     def tear_down_all(self):
-- 
2.7.4


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

end of thread, other threads:[~2019-12-20  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17  0:11 [dts] [PATCH V1] tests/multiple_pthread: fix issue of always send pkts after this suite lihong
2019-12-17  7:51 ` Zhu, WenhuiX
2019-12-20  8:05 ` 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).