test suite reviews and discussions
 help / color / mirror / Atom feed
From: zhaomeijuan <meijuanx.zhao@intel.com>
To: dts@dpdk.org
Cc: zhaomeijuan <meijuanx.zhao@intel.com>
Subject: [dts] [next][PATCH V2 7/7] tests/l2fwd use pktgen API replace old module and fix pep8 issue
Date: Fri, 31 May 2019 17:19:48 +0000	[thread overview]
Message-ID: <20190531171948.6944-7-meijuanx.zhao@intel.com> (raw)
In-Reply-To: <20190531171948.6944-1-meijuanx.zhao@intel.com>

*.remove old or unused module and code  which 
replace it with pktgen API 
*.fix pep8 issue

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_l2fwd.py | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/tests/TestSuite_l2fwd.py b/tests/TestSuite_l2fwd.py
index 659d5f7..4908fb7 100644
--- a/tests/TestSuite_l2fwd.py
+++ b/tests/TestSuite_l2fwd.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -28,15 +28,16 @@
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 """
 DPDK Test suite.
 Test Layer-2 Forwarding support
 """
-
+import os
+import time
 import utils
 from test_case import TestCase
 from settings import HEADER_SIZE
+from pktgen import PacketGeneratorHelper
 
 
 class TestL2fwd(TestCase):
@@ -79,6 +80,16 @@ class TestL2fwd(TestCase):
 
         self.result_table_create(self.table_header)
 
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
+
     def set_up(self):
         """
         Run before each test case.
@@ -163,16 +174,18 @@ class TestL2fwd(TestCase):
             payload_size = frame_size - self.headers_size
 
             tgen_input = []
+            cnt = 1
             for port in xrange(self.number_of_ports):
                 rx_port = self.tester.get_local_port(self.dut_ports[port % self.number_of_ports])
                 tx_port = self.tester.get_local_port(self.dut_ports[(port + 1) % self.number_of_ports])
                 destination_mac = self.dut.get_mac_address(self.dut_ports[(port + 1) % self.number_of_ports])
-                self.tester.scapy_append('wrpcap("l2fwd_%d.pcap", [Ether(dst="%s")/IP()/UDP()/("X"*%d)])' % (
-                    port, destination_mac, payload_size))
-
-                tgen_input.append((tx_port, rx_port, "l2fwd_%d.pcap" % port))
-
-            self.tester.scapy_execute()
+                pcap = os.sep.join([self.output_path, "l2fwd_{0}_{1}.pcap".format(port, cnt)])
+                self.tester.scapy_append('wrpcap("%s", [Ether(dst="%s")/IP()/UDP()/("X"*%d)])' % (
+                    pcap, destination_mac, payload_size))
+                tgen_input.append((tx_port, rx_port, pcap))
+                time.sleep(3)
+                self.tester.scapy_execute()
+                cnt += 1
 
             for queues in self.test_queues:
 
@@ -189,7 +202,14 @@ class TestL2fwd(TestCase):
                 self.logger.info(info)
                 self.rst_report(info, annex=True)
                 self.rst_report(command_line + "\n\n", frame=True, annex=True)
-                _, pps = self.tester.traffic_generator_throughput(tgen_input)
+
+                # clear streams before add new streams
+                self.tester.pktgen.clear_streams()
+                # run packet generator
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                                    None, self.tester.pktgen)
+                _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
+
                 Mpps = pps / 1000000.0
                 queues['Mpps'][frame_size] = Mpps
                 queues['pct'][frame_size] = Mpps * 100 / float(self.wirespeed(
-- 
2.17.1


  parent reply	other threads:[~2019-05-31  9:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 17:19 [dts] [next][PATCH V2 1/7] tests/checksum_offload use pktgen API replace old module and fix some issue zhaomeijuan
2019-05-31 17:19 ` [dts] [next][PATCH V2 2/7] tests/distributor " zhaomeijuan
2019-05-31 17:19 ` [dts] [next][PATCH V2 3/7] tests/efd use pktgen API replace old module and fix pep8 issue zhaomeijuan
2019-05-31 17:19 ` [dts] [next][PATCH V2 4/7] tests/fm10k_perf use pktgen API replace old module and fix some issue zhaomeijuan
2019-05-31 17:19 ` [dts] [next][PATCH V2 5/7] tests/ipfrag " zhaomeijuan
2019-05-31 17:19 ` [dts] [next][PATCH V2 6/7] tests/kni " zhaomeijuan
2019-05-31 17:19 ` zhaomeijuan [this message]
2019-06-05  1:40 ` [dts] [next][PATCH V2 1/7] tests/checksum_offload " Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190531171948.6944-7-meijuanx.zhao@intel.com \
    --to=meijuanx.zhao@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).