tests/TestSuite_multiple_pthread.py: Updated test_positive() and teardown() functions.
diff mbox series

Message ID 1601026132-29371-1-git-send-email-usurekha@marvell.com
State Superseded
Headers show
Series
  • tests/TestSuite_multiple_pthread.py: Updated test_positive() and teardown() functions.
Related show

Commit Message

usurekha@marvell.com Sept. 25, 2020, 9:28 a.m. UTC
From: usurekha <usurekha@marvell.com>

Added script to get the available max cpu depends on DUT config.
Did modifications in teardown() to close the tester scapy sessions properly.

Signed-off-by: usurekha <usurekha@marvell.com>
---
 tests/TestSuite_multiple_pthread.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py
index 5d4a1f6..2af8196 100644
--- a/tests/TestSuite_multiple_pthread.py
+++ b/tests/TestSuite_multiple_pthread.py
@@ -62,7 +62,7 @@  class TestMultiplePthread(TestCase):
         """
         Run before each test case.
         """
-        self.send_sessions = []
+        self.send_sessions = None
 
     def send_packet(self):
         """
@@ -73,8 +73,7 @@  class TestMultiplePthread(TestCase):
             iface = self.tester.get_interface(localPort)
             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)
+            self.send_sessions = self.pkt.send_pkt_bg(crb=self.tester, tx_port=iface)
 
     def get_cores_statistic(self, cmdline):
         """
@@ -176,7 +175,14 @@  class TestMultiplePthread(TestCase):
         Test an random parameter from an defined table which has a couple of valid lcore parameters.
         """
         n = self.cores
-        CONFIG_RTE_MAX_LCORE = 128
+        # Get max available core depends on DUT configuration
+        cores = self.dut.get_core_list('all')
+        config_max_lcore = self.dut.get_def_rte_config('CONFIG_RTE_MAX_LCORE')
+        if config_max_lcore:
+            CONFIG_RTE_MAX_LCORE = min(int(config_max_lcore), len(cores) + 1)
+        else:
+            CONFIG_RTE_MAX_LCORE = len(cores) + 1
+
         test_list = [
                      {"lcores": "(%s,%s)@(%s,%s)" % (n[0], CONFIG_RTE_MAX_LCORE-1, n[1], n[2]),
                       "cpu_list":[CONFIG_RTE_MAX_LCORE-1],
@@ -230,8 +236,8 @@  class TestMultiplePthread(TestCase):
         """
         Run after each test case.
         """
-        if len(self.send_sessions) != 0:
-            self.pkt.stop_send_pkt_bg(self.send_sessions)
+        if self.send_sessions:
+                self.pkt.stop_send_pkt_bg(self.send_sessions)
         self.dut.kill_all()
 
     def tear_down_all(self):