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 9630BA0096 for ; Mon, 3 Jun 2019 10:31:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2DE531B958; Mon, 3 Jun 2019 10:31:28 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id AFAA31B945 for ; Mon, 3 Jun 2019 10:31:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 01:31:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,546,1549958400"; d="scan'208";a="181081884" Received: from zhaohy_tester.sh.intel.com ([10.240.179.16]) by fmsmga002.fm.intel.com with ESMTP; 03 Jun 2019 01:31:24 -0700 From: Haiyang Zhao To: dts@dpdk.org Cc: Haiyang Zhao Date: Mon, 3 Jun 2019 16:31:05 +0000 Message-Id: <20190603163109.19706-3-haiyangx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603163109.19706-1-haiyangx.zhao@intel.com> References: <20190603163109.19706-1-haiyangx.zhao@intel.com> Subject: [dts] [next][PATCH V2 3/7] tests/link_flowctrl: replace etgen with pktgen 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" *.replace etgen with pktgen API which support both trex and ixia. *.replace print to logger.info to record the necessary debug information. Signed-off-by: Haiyang Zhao --- tests/TestSuite_link_flowctrl.py | 52 +++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/tests/TestSuite_link_flowctrl.py b/tests/TestSuite_link_flowctrl.py index 0057b46..0192498 100644 --- a/tests/TestSuite_link_flowctrl.py +++ b/tests/TestSuite_link_flowctrl.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 @@ -36,11 +36,13 @@ Test for Ethernet Link Flow Control Features by Poll Mode Drivers import utils import re +import os from time import sleep from test_case import TestCase from pmd_output import PmdOutput from settings import HEADER_SIZE +from pktgen import PacketGeneratorHelper class TestLinkFlowctrl(TestCase): @@ -77,6 +79,15 @@ class TestLinkFlowctrl(TestCase): self.pmdout = PmdOutput(self.dut) self.pmdout.start_testpmd("all", "--portmask=%s" % self.portMask) + # 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 pause_frame_loss_test(self, rx_flow_control='off', tx_flow_control='off', @@ -86,7 +97,9 @@ class TestLinkFlowctrl(TestCase): tester_rx_port = self.tester.get_local_port(self.tx_port) tgenInput = [] - tgenInput.append((tester_tx_port, tester_rx_port, "test.pcap")) + pcap = os.sep.join([self.output_path, "test.pcap"]) + + tgenInput.append((tester_tx_port, tester_rx_port, pcap)) self.dut.send_expect("set flow_ctrl rx %s tx %s 300 50 10 1 mac_ctrl_frame_fwd %s autoneg on %d " % ( rx_flow_control, @@ -96,18 +109,23 @@ class TestLinkFlowctrl(TestCase): "testpmd> ") self.dut.send_expect("set fwd csum", "testpmd> ") - self.dut.send_expect("start", "testpmd> ") - - self.tester.scapy_append('wrpcap("test.pcap",[Ether()/IP()/UDP()/("X"*%d)])' % - TestLinkFlowctrl.payload_size) + self.dut.send_expect("start", "testpmd> ", 60) + pcap = os.sep.join([self.output_path, "test.pcap"]) + self.tester.scapy_append('wrpcap("%s",[Ether()/IP()/UDP()/("X"*%d)])' % + (pcap,TestLinkFlowctrl.payload_size)) self.tester.scapy_execute() - # Run traffic generator - result = self.tester.traffic_generator_loss(tgenInput, 100) + # clear streams before add new streams + self.tester.pktgen.clear_streams() + # run packet generator + streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100, + None, self.tester.pktgen) + result = self.tester.pktgen.measure_loss(stream_ids=streams) + self.dut.send_expect("stop", "testpmd> ") - return result + return result[0]/100 def get_testpmd_port_stats(self, ports): """ @@ -184,9 +202,9 @@ class TestLinkFlowctrl(TestCase): Verifies the test results (use pause_frame_test before) against the expected behavior. """ - print "Result (port, rx, tx) %s, expected rx %s, expected fwd %s" % (result, + self.logger.info("Result (port, rx, tx) %s, expected rx %s, expected fwd %s" % (result, expected_rx, - expected_fwd) + expected_fwd)) if expected_rx: self.verify(result[self.rx_port][0] == TestLinkFlowctrl.frames_to_sent, @@ -339,7 +357,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='on', pause_frame_fwd='on') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result <= 0.01, "Link flow control fail, the loss percent is more than 1%") @@ -353,7 +371,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='on', pause_frame_fwd='off') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result <= 0.01, "Link flow control fail, the loss percent is more than 1%") @@ -367,7 +385,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='on', pause_frame_fwd='off') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result <= 0.01, "Link flow control fail, the loss percent is more than 1%") @@ -381,7 +399,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='off', pause_frame_fwd='on') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result >= 0.5, "Link flow control fail, the loss percent is less than 50%") @@ -395,7 +413,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='off', pause_frame_fwd='off') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result >= 0.5, "Link flow control fail, the loss percent is less than 50%") @@ -409,7 +427,7 @@ class TestLinkFlowctrl(TestCase): tx_flow_control='on', pause_frame_fwd='off') - print "Packet loss: %.3f%%" % result + self.logger.info("Packet loss: %.3f%%" % result) self.verify(result <= 0.01, "Link flow control fail, the loss percent is more than 1%") -- 2.17.1