From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 8D4CCA045E for ; Fri, 31 May 2019 11:19:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF15C1B955; Fri, 31 May 2019 11:19:03 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id C45C51B94A for ; Fri, 31 May 2019 11:19:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 02:19:01 -0700 X-ExtLoop1: 1 Received: from meijuan2.sh.intel.com ([10.67.119.112]) by fmsmga001.fm.intel.com with ESMTP; 31 May 2019 02:19:00 -0700 From: zhaomeijuan To: dts@dpdk.org Cc: zhaomeijuan Date: Fri, 31 May 2019 17:19:48 +0000 Message-Id: <20190531171948.6944-7-meijuanx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190531171948.6944-1-meijuanx.zhao@intel.com> References: <20190531171948.6944-1-meijuanx.zhao@intel.com> Subject: [dts] [next][PATCH V2 7/7] tests/l2fwd use pktgen API replace old module and fix pep8 issue X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" *.remove old or unused module and code which replace it with pktgen API *.fix pep8 issue Signed-off-by: zhaomeijuan --- 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