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 8009BA0679 for ; Sun, 28 Apr 2019 05:06:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7433F1B4C8; Sun, 28 Apr 2019 05:06:34 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 2072E1B4A1 for ; Sun, 28 Apr 2019 05:06:30 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2019 20:06:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,404,1549958400"; d="scan'208";a="139434664" Received: from zhaohy_test.sh.intel.com ([10.67.118.211]) by orsmga006.jf.intel.com with ESMTP; 27 Apr 2019 20:06:28 -0700 From: Haiyang Zhao To: dts@dpdk.org Cc: Haiyang Zhao Date: Sun, 28 Apr 2019 03:05:05 +0000 Message-Id: <20190428030509.11490-3-haiyangx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190428030509.11490-1-haiyangx.zhao@intel.com> References: <20190428030509.11490-1-haiyangx.zhao@intel.com> Subject: [dts] [next][PATCH V1 3/7] tests/link_flowctrl 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" 1.replace etgen to pktgen API which support both trex and ixia. 2.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..67ac979 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