test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [next][PATCH V1 1/7] tests/checksum_offload
@ 2019-04-28 10:47 zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 2/7] tests/distributor zhaomeijuan
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unused module and  code 
which replace it with pktgen API 
*.fix pep-8 issue 
*.quit task before start another 
*.enable pmd verbose function 
*.add enable rx cksum

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_checksum_offload.py | 58 +++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 15 deletions(-)

diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 6541ba5..be66479 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -37,13 +37,18 @@ Test support of RX/TX Checksum Offload Features by Poll Mode Drivers.
 """
 
 import string
+import os
 import re
-import rst
+#import rst
+from rst import RstReport
 import utils
 
 from test_case import TestCase
 from pmd_output import PmdOutput
+# from packet import Packet
 from test_capabilities import DRIVER_TEST_LACK_CAPA
+from pktgen import PacketGeneratorHelper
+
 
 class TestChecksumOffload(TestCase):
 
@@ -59,6 +64,15 @@ class TestChecksumOffload(TestCase):
         self.pmdout = PmdOutput(self.dut)
         self.portMask = utils.create_mask([self.dut_ports[0]])
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
+        # 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):
         """
@@ -181,10 +195,10 @@ class TestChecksumOffload(TestCase):
             self.tester.scapy_append('sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface))
 
         self.tester.scapy_execute()
-	p = self.tester.load_tcpdump_sniff_packets(inst)
-	nr_packets=len(p)
-	reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
-	out = string.join(reslist, ",")
+        p = self.tester.load_tcpdump_sniff_packets(inst)
+        nr_packets=len(p)
+        reslist = [p[i].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
+        out = string.join(reslist, ",")
         packets_received = out.split(',')
         self.verify(len(packets_sent) == len(packets_received), "Unexpected Packets Drop")
 
@@ -260,7 +274,7 @@ class TestChecksumOffload(TestCase):
 
         result = dict()
         
-	self.checksum_enablehw(self.dut_ports[0])
+        self.checksum_enablehw(self.dut_ports[0])
 
         # get the packet checksum value
         result = self.get_chksum_values(pkts_ref)
@@ -279,7 +293,7 @@ class TestChecksumOffload(TestCase):
                     'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46)' % mac,
                     'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46)' % mac}
 
-	if self.kdriver in DRIVER_TEST_LACK_CAPA['sctp_tx_offload']:
+        if self.kdriver in DRIVER_TEST_LACK_CAPA['sctp_tx_offload']:
             del pkts_good['IP/SCTP']
             del pkts_bad['IP/SCTP']
             del pkts_ref['IP/SCTP']
@@ -361,19 +375,33 @@ class TestChecksumOffload(TestCase):
         Pps = dict()
         Pct = dict()
         dmac = self.dut.get_mac_address(self.dut_ports[0])
+        dmac1 = self.dut.get_mac_address(self.dut_ports[1])
 
         result = [2, lcore, ptype, mode]
         for size in size_list:
             flow = flow_format % (dmac, size)
-            self.tester.scapy_append('wrpcap("test.pcap", [%s])' % flow)
+            pcap = os.sep.join([self.output_path, "test.pcap"])
+            self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap,flow))
             self.tester.scapy_execute()
+            flow = flow_format % (dmac1, size)
+            pcap = os.sep.join([self.output_path, "test1.pcap"])
+            self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap,flow))
+            self.tester.scapy_execute()
+ 
             tgenInput = []
+            pcap = os.sep.join([self.output_path, "test.pcap"])
             tgenInput.append(
-                (self.tester.get_local_port(self.dut_ports[0]), self.tester.get_local_port(self.dut_ports[1]), "test.pcap"))
+                (self.tester.get_local_port(self.dut_ports[0]), self.tester.get_local_port(self.dut_ports[1]), pcap))
+            pcap = os.sep.join([self.output_path, "test1.pcap"])
             tgenInput.append(
-                (self.tester.get_local_port(self.dut_ports[1]), self.tester.get_local_port(self.dut_ports[0]), "test.pcap"))
-            Bps[str(size)], Pps[
-                str(size)] = self.tester.traffic_generator_throughput(tgenInput)
+                (self.tester.get_local_port(self.dut_ports[1]), self.tester.get_local_port(self.dut_ports[0]), pcap))
+
+            # 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)
+            Bps[str(size)], Pps[str(size)] = self.tester.pktgen.measure_throughput(stream_ids=streams)
             self.verify(Pps[str(size)] > 0, "No traffic detected")
             Pps[str(size)] /= 1E6
             Pct[str(size)] = (Pps[str(size)] * 100) / \
@@ -390,6 +418,7 @@ class TestChecksumOffload(TestCase):
         """
         # Verify that enough ports are available
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports for testing")
+        self.dut.send_expect("quit", "#")
 
         # sizes = [64, 128, 256, 512, 1024]
         sizes = [64, 128]
@@ -406,16 +435,15 @@ class TestChecksumOffload(TestCase):
         portMask = utils.create_mask([self.dut_ports[0], self.dut_ports[1]])
         for mode in ["sw", "hw"]:
             self.logger.info("%s performance" % mode)
-            rst.write_text(mode + " Performance" + '\r\n')
             tblheader = ["Ports", "S/C/T", "Packet Type", "Mode"]
             for size in sizes:
                 tblheader.append("%sB mpps" % str(size))
                 tblheader.append("%sB %%   " % str(size))
             self.result_table_create(tblheader)
             self.pmdout.start_testpmd(
-                lcore, "--portmask=%s" % self.portMask, socket=self.ports_socket)
+                lcore, "--portmask=%s" % self.portMask + " --enable-rx-cksum " +
+                                  "--port-topology=loop", socket=self.ports_socket)
 
-            self.dut.send_expect("set verbose 1", "testpmd> ")
             self.dut.send_expect("set fwd csum", "testpmd> ")
             if mode == "hw":
                 self.checksum_enablehw(self.dut_ports[0])
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 2/7] tests/distributor
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 3/7] tests/efd zhaomeijuan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unused module and code 
which replace it with pktgen API 
*.overwrite ip method

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_distributor.py | 60 +++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 23 deletions(-)

diff --git a/tests/TestSuite_distributor.py b/tests/TestSuite_distributor.py
index a900f5e..30d5d76 100644
--- a/tests/TestSuite_distributor.py
+++ b/tests/TestSuite_distributor.py
@@ -34,20 +34,21 @@ DPDK Test suite.
 """
 import re
 import utils
+import os
 from test_case import TestCase
-from etgen import IxiaPacketGenerator
+from pktgen import PacketGeneratorHelper
 
+class TestDistributor(TestCase):
 
-class TestDistributor(TestCase, IxiaPacketGenerator):
     def set_up_all(self):
         """
         Run at the start of each test suite.
         """
         self.tester.extend_external_packet_generator(TestDistributor, self)
 
-        out = self.dut.send_expect("make -C test -j", "#")
-        self.verify("Error" not in out, "Compilation error")
-        self.verify("No such" not in out, "Compilation error")
+        #out = self.dut.send_expect("make -C test -j", "#")
+        #self.verify("Error" not in out, "Compilation error")
+        #self.verify("No such" not in out, "Compilation error")
 
         # reduce tx queues for enable many workers
         self.dut.send_expect("sed -i -e 's/.*txRings = .*/\\tconst uint16_t rxRings = 1, txRings = 1;/' ./examples/distributor/main.c", "#")
@@ -57,6 +58,15 @@ class TestDistributor(TestCase, IxiaPacketGenerator):
 
         self.dut_ports = self.dut.get_ports()
         self.app = "./examples/distributor/build/distributor_app"
+        # 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):
         """
@@ -106,13 +116,16 @@ class TestDistributor(TestCase, IxiaPacketGenerator):
         # output port is calculated from overall ports number
         cmd_fmt = "%s -c %s -n %d -w %s -- -p 0x1"
         socket = self.dut.get_numa_id(self.dut_ports[0])
-
-        self.tester.scapy_append('wrpcap("distributor.pcap", [Ether()/IP()/("X"*26)])')
+        
+        pcap = os.sep.join([self.output_path, "distributor.pcap"])
+        self.tester.scapy_append('wrpcap("%s", [Ether()/IP()/("X"*26)])' % pcap)
         self.tester.scapy_execute()
         tgen_input = []
         rx_port = self.tester.get_local_port(self.dut_ports[0])
         tx_port = self.tester.get_local_port(self.dut_ports[0])
-        tgen_input.append((tx_port, rx_port, "distributor.pcap"))
+        
+        pcap = os.sep.join([self.output_path, "distributor.pcap"])
+        tgen_input.append((tx_port, rx_port, pcap))
 
         self.result_table_create(table_header)
         for worker_num in workers:
@@ -128,8 +141,14 @@ class TestDistributor(TestCase, IxiaPacketGenerator):
 
             self.dut.send_expect(cmd, "doing packet RX", timeout=30)
 
-            self.tester.ixia_packet_gen.hook_transmission_func = self.hook_transmission_func
-            _, pps = self.tester.traffic_generator_throughput(tgen_input, delay=2)
+            self.app_output = self.dut.session.get_session_before(timeout=2)
+            
+            # 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)
 
             self.dut.send_expect("^C", "#")
 
@@ -255,19 +274,14 @@ class TestDistributor(TestCase, IxiaPacketGenerator):
         cycles = lines[2].split()[3]
         return int(cycles)
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipIdle")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipRandom")
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {
+            'dst': {'mask': '255.240.0.0', 'action': 'inc'}
+        },}
+
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 3/7] tests/efd
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 2/7] tests/distributor zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 4/7] tests/fm10k_perf zhaomeijuan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unused module and code which
  replace it with pktgen API 
*.overwrite ip method

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

diff --git a/tests/TestSuite_efd.py b/tests/TestSuite_efd.py
index 2c80464..229c78f 100644
--- a/tests/TestSuite_efd.py
+++ b/tests/TestSuite_efd.py
@@ -34,20 +34,20 @@ DPDK Test suite.
 """
 import re
 import utils
+import os
 from test_case import TestCase
-from etgen import IxiaPacketGenerator
+from pktgen import PacketGeneratorHelper
 
-
-class TestEFD(TestCase, IxiaPacketGenerator):
+class TestEFD(TestCase):
     def set_up_all(self):
         """
         Run at the start of each test suite.
         """
         self.tester.extend_external_packet_generator(TestEFD, self)
 
-        out = self.dut.send_expect("make -C test -j", "#")
-        self.verify("Error" not in out, "Compilation error")
-        self.verify("No such" not in out, "Compilation error")
+        #out = self.dut.send_expect("make -C test -j", "#")
+        #self.verify("Error" not in out, "Compilation error")
+        #self.verify("No such" not in out, "Compilation error")
 
         out = self.dut.build_dpdk_apps("./examples/server_node_efd")
         self.verify("Error" not in out, "Compilation error")
@@ -56,6 +56,17 @@ class TestEFD(TestCase, IxiaPacketGenerator):
         self.dut_ports = self.dut.get_ports()
         self.node_app = "./examples/server_node_efd/node/%s/node" % self.target
         self.server_app = "./examples/server_node_efd/server/%s/server" % self.target
+        
+        # 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):
         """
@@ -165,22 +176,23 @@ class TestEFD(TestCase, IxiaPacketGenerator):
 
     def _efd_perf_evaluate(self, node_num, flow_num):
         # extended flow number into etgen module
-        self.tester.ixia_packet_gen.flow_num = flow_num
-
+        
         # output port is calculated from overall ports number
         server_cmd_fmt = "%s -c %s -n %d -w %s -w %s -- -p 0x3 -n %d -f %s"
         node_cmd_fmt = "%s -c %s -n %d --proc-type=secondary -- -n %d"
         socket = self.dut.get_numa_id(self.dut_ports[0])
 
-        self.tester.scapy_append('wrpcap("efd.pcap", [Ether()/IP(src="0.0.0.0", dst="0.0.0.0")/("X"*26)])')
+        pcap = os.sep.join([self.output_path, "efd.pcap"])
+        self.tester.scapy_append('wrpcap("%s", [Ether()/IP(src="0.0.0.0", dst="0.0.0.0")/("X"*26)])' % pcap)
         self.tester.scapy_execute()
 
         tgen_input = []
         rx_port = self.tester.get_local_port(self.dut_ports[0])
         tx_port = self.tester.get_local_port(self.dut_ports[1])
-
-        tgen_input.append((tx_port, rx_port, "efd.pcap"))
-        tgen_input.append((rx_port, tx_port, "efd.pcap"))
+        
+        pcap = os.sep.join([self.output_path, "efd.pcap"])
+        tgen_input.append((tx_port, rx_port, pcap))
+        tgen_input.append((rx_port, tx_port, pcap))
 
         cores = self.dut.get_core_list("1S/%dC/1T" % (node_num + 2), socket)
 
@@ -203,8 +215,13 @@ class TestEFD(TestCase, IxiaPacketGenerator):
             node_sessions.append(node_session)
             node_session.send_expect(node_cmd, "Finished Process Init", timeout=30)
 
-        _, pps = self.tester.traffic_generator_throughput(tgen_input, delay=10)
-
+        # 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)
+        
         for node_session in node_sessions:
             node_session.send_expect("^C", "#")
             self.dut.close_session(node_session)
@@ -214,21 +231,15 @@ class TestEFD(TestCase, IxiaPacketGenerator):
         pps /= 1000000.0
         return pps
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipIdle")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipIncrHost")
-        # increase number equal to flow number
-        self.add_tcl_cmd("ip config -destIpAddrRepeatCount %d" % self.flow_num)
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {
+            # self.flow_num not used by this suite
+#             'dst': {'range': self.flow_num, 'action': 'inc'}
+            'dst': {'range': 64, 'action': 'inc'}
+        },}
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 4/7] tests/fm10k_perf
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 2/7] tests/distributor zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 3/7] tests/efd zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 5/7] tests/ipfrag zhaomeijuan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unuse module and code
  which replace it with pktgen API 
*.fix syntax error 
*.overwrite ip method

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_fm10k_perf.py | 134 ++++++++++++++++++++++++----------
 1 file changed, 96 insertions(+), 38 deletions(-)

diff --git a/tests/TestSuite_fm10k_perf.py b/tests/TestSuite_fm10k_perf.py
index b358f8a..e6b672a 100644
--- a/tests/TestSuite_fm10k_perf.py
+++ b/tests/TestSuite_fm10k_perf.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
@@ -37,13 +37,14 @@ Layer-3 forwarding test script.
 import utils
 import string
 import re
+import os
 from test_case import TestCase
 from exception import VerifyFailure
 from settings import HEADER_SIZE
-from etgen import IxiaPacketGenerator
 from utils import *
+from pktgen import PacketGeneratorHelper
 
-class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
+class TestFM10kL3fwd(TestCase):
 
     path = "./examples/l3fwd/build/"
 
@@ -139,6 +140,16 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
                                    'data': []}
 
         self.rebuild_l3fwd()
+        
+        # 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 rebuild_l3fwd(self):
         pat = re.compile("P([0123])")
@@ -288,20 +299,33 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
 
         header_row = ["Frame", "mode", "S/C/T", "Mpps", "% linerate", "latency_max(us)", "latency_min(us)", "latency_avg(us)"]
         self.l3fwd_test_results['header'] = header_row
-        utils.result_table_create(header_row)
+        self.result_table_create(header_row)
         self.l3fwd_test_results['data'] = []
 
-	mac = ["02:00:00:00:00:00", "02:00:00:00:00:01"]
+        mac = ["02:00:00:00:00:00", "02:00:00:00:00:01"]
         for frame_size in TestFM10kL3fwd.frame_sizes:
 
             # Prepare traffic flow
             payload_size = frame_size -  \
                 HEADER_SIZE['ip'] - HEADER_SIZE['eth']
+            flows = []
+            pcaps = {}
             for _port in range(2):
                 dmac = self.dut.get_mac_address(valports[_port])
-                flows = ['Ether(dst="%s", src="%s")/%s/("X"*%d)' % (dmac, mac[_port], flow, payload_size) for flow in self.flows()[_port *2:(_port +1)*2]]
-                self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' %(valports[_port],string.join(flows,',')))
-            self.tester.scapy_execute() 
+                cnt = 0
+                for layer in self.flows()[_port *2:(_port +1)*2]:
+                    flow = 'Ether(dst="%s", src="%s")/%s/("X"*%d)' % (
+                                        dmac, mac[_port], flow, payload_size)
+                    flows.append(flow)
+                    pcap = os.sep.join([
+                                self.output_path, 
+                                "dst{0}_{1}.pcap".format(valports[_port], cnt)])
+                    self.tester.scapy_append('wrpcap("%s", [%s])' %(pcap, flow))
+                    self.tester.scapy_execute()
+                    if valports[_port] not in pcaps:
+                        pcaps[valports[_port]] = []
+                    pcaps[valports[_port]].append(pcap)
+                    cnt += 1
 
             self.rst_report("Flows for 2 ports, %d frame size.\n" % (frame_size),
                        annex=True)
@@ -365,17 +389,34 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
                             txIntf = self.tester.get_local_port(valports[rxPort - 1])
 
                         rxIntf = self.tester.get_local_port(valports[rxPort])
-                        if rxPort % 2 == 0: 
-                            tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort+1]))
-                        else: 
-                            tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort-1]))
+                        port_id = valports[rxPort+1] if rxPort % 2 == 0 else \
+                                  valports[rxPort-1]
+                        for pcap in pcaps[port_id]:
+                            tgenInput.append((txIntf, rxIntf, pcap))
+
+                    
+                    vm_config = self.set_fields()
+                    # clear streams before add new streams
+                    self.tester.pktgen.clear_streams()
+                    # run packet generator
+                    streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
+                                            vm_config, self.tester.pktgen)
+                    _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
+                    
 
-                    _, pps = self.tester.traffic_generator_throughput(tgenInput)
                     self.verify(pps > 0, "No traffic detected")
                     pps /= 1000000.0
                     linerate = self.wirespeed(self.nic, frame_size, 2)
                     pct = pps * 100 / linerate
-                    latencys = self.tester.traffic_generator_latency(tgenInput)
+                    
+                    
+                    # clear streams before add new streams
+                    self.tester.pktgen.clear_streams()
+                    # run packet generator
+                    streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
+                                                 vm_config, self.tester.pktgen)
+                    latencys = self.tester.pktgen.measure_latency(stream_ids=streams)
+                    
 
                     index += 1
 
@@ -403,11 +444,26 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
             # Prepare traffic flow
             payload_size = frame_size -  \
                 HEADER_SIZE['ip'] - HEADER_SIZE['eth']
+            pcaps = {}
+            flows = []
             for _port in range(2):
-                dmac = self.dut.get_mac_address(valports[_port])
-                flows = ['Ether(dst="%s")/%s/("X"*%d)' % (dmac, flow, payload_size) for flow in self.flows()[_port *2:(_port +1)*2]]
-                self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' %(valports[_port],string.join(flows,',')))
-            self.tester.scapy_execute()
+                index = valports[_port]
+                dmac = self.dut.get_mac_address(index)
+                cnt = 0
+                for layer in self.flows()[_port *2:(_port +1)*2]:
+                    flow = 'Ether(dst="%s")/%s/("X"*%d)' % (
+                                                    dmac, layer, payload_size)
+                    flows.append(flow)
+                    pcap = os.sep.join([
+                                self.output_path, 
+                                "dst{0}_{1}.pcap".format(index, cnt)])
+                    self.tester.scapy_append('wrpcap("%s", [%s])' % (
+                                                pcap, flow))
+                    self.tester.scapy_execute()
+                    if index not in pcaps:
+                        pcaps[index] = []
+                    pcaps[index].append(pcap)
+                    cnt += 1
 
             self.rst_report("Flows for 2 ports, %d frame size.\n" % (frame_size),
                        annex=True)
@@ -472,12 +528,23 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
                                 txIntf = self.tester.get_local_port(valports[rxPort - 1])
 
                             rxIntf = self.tester.get_local_port(valports[rxPort])
-                            if rxPort % 2 == 0:
-                                tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort+1]))
-                            else:
-                                tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort-1]))
-
-                        zero_loss_rate, tx_pkts, rx_pkts = self.tester.run_rfc2544(tgenInput, delay=5, permit_loss_rate=0.01)
+                            
+                            port_id = valports[rxPort+1] if rxPort % 2 == 0 else \
+                                      valports[rxPort-1]
+                            for pcap in pcaps[port_id]:
+                                tgenInput.append((txIntf, rxIntf, pcap))
+
+                        
+                        vm_config = self.set_fields()
+                        # clear streams before add new streams
+                        self.tester.pktgen.clear_streams()
+                        # run packet generator
+                        streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 
+                                            100, vm_config, self.tester.pktgen)
+                        # set traffic option
+                        traffic_opt = {'pdr': 0.01, 'duration': 5}
+                        zero_loss_rate, tx_pkts, rx_pkts = self.tester.pktgen.measure_rfc2544(stream_ids=streams, options=traffic_opt)
+                        
                         loss_pkts = tx_pkts - rx_pkts
                         self.dut.send_expect("^C", "#")
 
@@ -539,20 +606,11 @@ class TestFM10kL3fwd(TestCase, IxiaPacketGenerator):
         # remove setting for scatter
         self.dut.send_expect("sed -i -e '/.enable_scatter= .*$/d' %s" % self.main_file, "# ")
 
-
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipRandom")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipIdle")
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {'src': {'action': 'random'}},}
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 5/7] tests/ipfrag
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
                   ` (2 preceding siblings ...)
  2019-04-28 10:47 ` [dts] [next][PATCH V1 4/7] tests/fm10k_perf zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 6/7] tests/kni zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 7/7] tests/l2fwd zhaomeijuan
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unused module and code
 which  replace it with pktgen API 
*.change max framesize as 1518 
*.quit task before start another

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_ipfrag.py | 68 ++++++++++++++++++++++++++-------------
 1 file changed, 45 insertions(+), 23 deletions(-)

diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index 9f47a2c..c23e05b 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -38,8 +38,11 @@ import utils
 import string
 import re
 import time
+import os
 from settings import HEADER_SIZE
 from packet import Packet
+from pktgen import PacketGeneratorHelper
+
 
 lpm_table_ipv4 = [
     "{IPv4(100,10,0,0), 16, P1}",
@@ -84,7 +87,6 @@ class TestIpfrag(TestCase):
 
         # Based on h/w type, choose how many ports to use
         ports = self.dut.get_ports()
-        print ports
 
         # Verify that enough ports are available
         self.verify(len(ports) >= 2, "Insufficient ports for testing")
@@ -109,14 +111,12 @@ l3fwd_ipv4_route_array[] = {\\\n"
             rtLpmTbl[idx] = pat.sub(self.portRepl, rtLpmTbl[idx])
             lpmStr_ipv4 = lpmStr_ipv4 + ' ' * 4 + rtLpmTbl[idx] + ",\\\n"
         lpmStr_ipv4 = lpmStr_ipv4 + "};"
-        print lpmStr_ipv4
         lpmStr_ipv6 = "static struct l3fwd_ipv6_route l3fwd_ipv6_route_array[] = {\\\n"
         rtLpmTbl = list(lpm_table_ipv6)
         for idx in range(len(rtLpmTbl)):
             rtLpmTbl[idx] = pat.sub(self.portRepl, rtLpmTbl[idx])
             lpmStr_ipv6 = lpmStr_ipv6 + ' ' * 4 + rtLpmTbl[idx] + ",\\\n"
         lpmStr_ipv6 = lpmStr_ipv6 + "};"
-        print lpmStr_ipv6
         self.dut.send_expect(r"sed -i '/l3fwd_ipv4_route_array\[\].*{/,/^\}\;/c\\%s' examples/ip_fragmentation/main.c" % lpmStr_ipv4, "# ")
         self.dut.send_expect(r"sed -i '/l3fwd_ipv6_route_array\[\].*{/,/^\}\;/c\\%s' examples/ip_fragmentation/main.c" % lpmStr_ipv6, "# ")
         # make application
@@ -139,6 +139,16 @@ l3fwd_ipv4_route_array[] = {\\\n"
         self.txItf = self.tester.get_interface(self.tester.get_local_port(P0))
         self.rxItf = self.tester.get_interface(self.tester.get_local_port(P1))
         self.dmac = self.dut.get_mac_address(P0)
+        
+        # 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 functional_check_ipv4(self, pkt_sizes, burst=1, flag=None):
         """
@@ -200,9 +210,9 @@ l3fwd_ipv4_route_array[] = {\\\n"
         for size in pkt_sizes[::burst]:
             # simulate to set TG properties
             if flag == 'frag':
-                # each packet max len: 1522 - 18 (eth) - 40 (ipv6) - 8 (ipv6 ext hdr) = 1456
-                expPkts = (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) / 1456
-                if (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) % 1456:
+                # each packet max len: 1518 - 18 (eth) - 40 (ipv6) - 8 (ipv6 ext hdr) = 1452
+                expPkts = (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) / 1452
+                if (size - HEADER_SIZE['eth'] - HEADER_SIZE['ipv6']) % 1452:
                     expPkts += 1
                 val = 0
             else:
@@ -296,35 +306,47 @@ l3fwd_ipv4_route_array[] = {\\\n"
 
         portmask = utils.create_mask([P0, P1])
 
+        self.dut.send_expect("^c", "# ", 120)
         self.dut.send_expect("examples/ip_fragmentation/build/ip_fragmentation -c %s -n %d -- -p %s -q %s" % (
             core_mask, self.dut.get_memory_channels(), portmask, num_pthreads), "IP_FRAG:", 120)
 
         result = [2, lcore, num_pthreads]
         for size in size_list:
             dmac = self.dut.get_mac_address(P0)
-            flows = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.10.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
-                     'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.20.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
-                     'Ether(dst="%s")/IPv6(dst="101:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58),
-                     'Ether(dst="%s")/IPv6(dst="201:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)]
-            self.tester.scapy_append('wrpcap("test1.pcap", [%s])' % string.join(flows, ','))
+            flows_p0 = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.10.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
+                        'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.20.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
+                        'Ether(dst="%s")/IPv6(dst="101:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58),
+                        'Ether(dst="%s")/IPv6(dst="201:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)]
 
             # reserved for rx/tx bidirection test
             dmac = self.dut.get_mac_address(P1)
-            flows = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.30.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
-                     'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.40.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
-                     'Ether(dst="%s")/IPv6(dst="301:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58),
-                     'Ether(dst="%s")/IPv6(dst="401:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)]
-            self.tester.scapy_append('wrpcap("test2.pcap", [%s])' % string.join(flows, ','))
-
-            self.tester.scapy_execute()
-
+            flows_p1 = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.30.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
+                        'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.40.0.1", flags=0)/("X"*%d)' % (dmac, size - 38),
+                        'Ether(dst="%s")/IPv6(dst="301:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58),
+                        'Ether(dst="%s")/IPv6(dst="401:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)]
+            flow_len = len(flows_p0)
             tgenInput = []
-            tgenInput.append((self.tester.get_local_port(P0), self.tester.get_local_port(P1), "test1.pcap"))
-            tgenInput.append((self.tester.get_local_port(P1), self.tester.get_local_port(P0), "test2.pcap"))
-
+            for i in range(flow_len):
+                
+                pcap0 = os.sep.join([self.output_path, "p0_{}.pcap".format(i)])
+                self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap0, flows_p0[i]))
+                pcap1 = os.sep.join([self.output_path, "p1_{}.pcap".format(i)])
+                self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap1, flows_p1[i]))
+                self.tester.scapy_execute()
+
+                tgenInput.append((self.tester.get_local_port(P0), self.tester.get_local_port(P1), pcap0))
+                tgenInput.append((self.tester.get_local_port(P1), self.tester.get_local_port(P0), pcap1))
+                
             factor = (size + 1517) / 1518
             # wireSpd = 2 * 10000.0 / ((20 + size) * 8)
-            Bps[str(size)], Pps[str(size)] = self.tester.traffic_generator_throughput(tgenInput)
+            
+            # 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)
+            Bps[str(size)], Pps[str(size)] = self.tester.pktgen.measure_throughput(stream_ids=streams)
+             
             self.verify(Pps[str(size)] > 0, "No traffic detected")
             Pps[str(size)] *= 1.0 / factor / 1000000
             Pct[str(size)] = (1.0 * Bps[str(size)] * 100) / (2 * 10000000000)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 6/7] tests/kni
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
                   ` (3 preceding siblings ...)
  2019-04-28 10:47 ` [dts] [next][PATCH V1 5/7] tests/ipfrag zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  2019-04-28 10:47 ` [dts] [next][PATCH V1 7/7] tests/l2fwd zhaomeijuan
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

*.remove old or unused module and code 
which replace it with pktgen API 
*.fix syntax error 
*.replace print with logger

Signed-off-by: zhaomeijuan <meijuanx.zhao@intel.com>
---
 tests/TestSuite_kni.py | 154 ++++++++++++++++++++++++++++-------------
 1 file changed, 104 insertions(+), 50 deletions(-)

diff --git a/tests/TestSuite_kni.py b/tests/TestSuite_kni.py
index 2581802..d95fc06 100644
--- a/tests/TestSuite_kni.py
+++ b/tests/TestSuite_kni.py
@@ -1,7 +1,7 @@
 # <COPYRIGHT_TAG>
 # BSD LICENSE
 #
-# Copyright(c) 2010-2015 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
@@ -38,8 +38,10 @@ Test Kernel NIC Interface.
 
 import utils
 import re
+import os
 import time
 from random import randint
+from pktgen import PacketGeneratorHelper
 
 dut_ports = []
 port_virtual_interaces = []
@@ -271,6 +273,16 @@ class TestKni(TestCase):
         self.dut.send_expect("service iptables stop", "# ")
         self.dut.send_expect("service firewalld stop", "# ")
 
+        # 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.
@@ -316,9 +328,9 @@ class TestKni(TestCase):
         if kthread_mode == 'single':
             kthread_mask = utils.create_mask(self.config['kernel_cores'])
             out = self.dut.send_expect(
-                "taskset -p %s `pgrep -fl kni_single | awk '{print $1}'`" % kthread_mask, "#")
+                "taskset -p `pgrep -fl kni_single | awk '{print $1}'`", "#")
             self.verify(
-                'new affinity mask' in out, 'Unable to set core affinity')
+                'current affinity mask' in out, 'Unable to set core affinity')
 
         return out_kni
 
@@ -767,22 +779,22 @@ class TestKni(TestCase):
             self.tester.scapy_append('srcmac = "%s"' % tx_mac)
 
             self.tester.scapy_append(
-                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/UDP()/("X"*28)],iface="%s")' % tx_interface)
+                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/UDP()/("X"*28)],iface="%s",count=200)' % tx_interface)
             self.tester.scapy_append(
-                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/TCP()/("X"*28)],iface="%s")' % tx_interface)
+                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/TCP()/("X"*28)],iface="%s",count=200)' % tx_interface)
             self.tester.scapy_append(
-                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/ICMP()/("X"*28)],iface="%s")' % tx_interface)
+                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/ICMP()/("X"*28)],iface="%s",count=200)' % tx_interface)
             self.tester.scapy_append(
-                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/("X"*38)],iface="%s")' % tx_interface)
+                'sendp([Ether(src = srcmac,dst=dstmac)/IP()/("X"*38)],iface="%s",count=200)' % tx_interface)
             self.tester.scapy_append(
-                'sendp([Ether(src = srcmac,dst=dstmac)/("X"*46)],iface="%s")' % tx_interface)
+                'sendp([Ether(src = srcmac,dst=dstmac)/("X"*46)],iface="%s",count=200)' % tx_interface)
             self.tester.scapy_execute()
 
             out = self.dut.send_expect("ifconfig %s" % virtual_interface, "# ")
             m = re.search(rx_match, out)
             rx_packets = int(m.group(1))
 
-            self.verify(rx_packets == (previous_rx_packets + 5),
+            self.verify(rx_packets == (previous_rx_packets + 1000),
                         "Rx statistics error in iface %s" % virtual_interface)
 
         self.dut.kill_all()
@@ -836,7 +848,7 @@ class TestKni(TestCase):
             total_cores = len(self.config['tx_cores'] + self.config[
                               'rx_cores'] + self.config['kernel_cores'])
             if total_cores > self.dut_physical_cores():
-                print utils.RED("Skiping step %s (%d cores needed, got %d)" %
+                self.logger.info("Skiping step %s (%d cores needed, got %d)" %
                               (step['config'], total_cores,
                                self.dut_physical_cores())
                               )
@@ -862,14 +874,20 @@ class TestKni(TestCase):
                     self.tester.scapy_append('dstmac = "%s"' % rx_mac)
                     self.tester.scapy_append(
                         'flows = [Ether(dst=dstmac)/IP()/("X"*%d)]' % payload_size)
-                    self.tester.scapy_append(
-                        'wrpcap("tester%d.pcap",flows)' % tx_port)
+                    pcap = os.sep.join([self.output_path, "tester{0}.pcap".format(tx_port)])
+                    self.tester.scapy_append('wrpcap("%s",flows)' % pcap)
                     self.tester.scapy_execute()
-                    tgen_input.append(
-                        (tx_port, tx_port, "tester%d.pcap" % tx_port))
+                    tgen_input.append((tx_port, tx_port, pcap))
 
                 time.sleep(1)
-                _, 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)
+                
                 pps_results.append(float(pps) / 1000000)
 
             ports_number = len(self.config['ports'])
@@ -888,8 +906,9 @@ class TestKni(TestCase):
         self.result_table_create(bridge_perf_results_header)
 
         self.tester.scapy_append('srcmac="00:00:00:00:00:01"')
+        pcap = os.sep.join([self.output_path, "kni.pcap"])
         self.tester.scapy_append(
-            'wrpcap("kni.pcap", [Ether(src=srcmac, dst="ff:ff:ff:ff:ff:ff")/IP(len=46)/UDP()/("X"*18)])')
+            'wrpcap("%s", [Ether(src=srcmac, dst="ff:ff:ff:ff:ff:ff")/IP(len=46)/UDP()/("X"*18)])' % pcap)
         self.tester.scapy_execute()
 
         for step in bridge_performance_steps:
@@ -899,7 +918,7 @@ class TestKni(TestCase):
             total_cores = len(self.config['tx_cores'] + self.config[
                               'rx_cores'] + self.config['kernel_cores'])
             if total_cores > self.dut_physical_cores():
-                print utils.RED("Skiping step %s (%d cores needed, got %d)" %
+                self.logger.info("Skiping step %s (%d cores needed, got %d)" %
                               (step['config'], total_cores,
                                self.dut_physical_cores())
                               )
@@ -933,13 +952,18 @@ class TestKni(TestCase):
             rx_port = self.tester.get_local_port(self.config['ports'][1])
 
             tgenInput = []
-            tgenInput.append((tx_port, rx_port, "kni.pcap"))
+            tgenInput.append((tx_port, rx_port, pcap))
 
             if step['flows'] == 2:
-                tgenInput.append((rx_port, tx_port, "kni.pcap"))
-
+                tgenInput.append((rx_port, tx_port, pcap))
             time.sleep(1)
-            _, pps = self.tester.traffic_generator_throughput(tgenInput)
+
+            # 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)
+            _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
             step['pps'] = float(pps) / 10 ** 6
 
             results_row = [step['kthread_mode'], step['flows'],
@@ -963,8 +987,9 @@ class TestKni(TestCase):
         dut_ports = self.dut.get_ports(self.nic)
 
         self.tester.scapy_append('srcmac="00:00:00:00:00:01"')
+        pcap = os.sep.join([self.output_path, "kni.pcap"])
         self.tester.scapy_append(
-            'wrpcap("kni.pcap", [Ether(src=srcmac, dst="ff:ff:ff:ff:ff:ff")/IP(len=46)/UDP()/("X"*18)])')
+            'wrpcap("%s", [Ether(src=srcmac, dst="ff:ff:ff:ff:ff:ff")/IP(len=46)/UDP()/("X"*18)])' % pcap)
         self.tester.scapy_execute()
 
         white_list = self.make_white_list(self.target, self.nic)
@@ -993,13 +1018,19 @@ class TestKni(TestCase):
         rx_port = self.tester.get_local_port(dut_ports[1])
 
         for flows in range(1, flows_without_kni + 1):
-            tgenInput = []
-            tgenInput.append((tx_port, rx_port, "kni.pcap"))
+            tgen_input = []
+            tgen_input.append((tx_port, rx_port, pcap))
 
             if flows == 2:
-                tgenInput.append((rx_port, tx_port, "kni.pcap"))
-
-            _, pps = self.tester.traffic_generator_throughput(tgenInput)
+                tgen_input.append((rx_port, tx_port, pcap))
+
+            # 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)
+            
             self.result_table_add([flows, float(pps) / 10 ** 6])
 
         self.dut.send_expect("ifconfig br1 down", "# ")
@@ -1071,10 +1102,9 @@ class TestKni(TestCase):
                 # Test one port
                 tx_port = self.tester.get_local_port(self.config['ports'][0])
                 rx_mac = self.dut.get_mac_address(self.config['ports'][0])
-                self.tester.scapy_append('flows = []')
-
-                self.tester.scapy_append('flows = []')
+                
                 port_iterator = 0
+                cnt = 0
                 for port in self.config['port_details']:
                     port_number = port['port']
 
@@ -1091,18 +1121,26 @@ class TestKni(TestCase):
                             src_ip_subnet + 1) % num_interfaces_per_port
                         dst_ip_subnet += port_iterator * \
                             num_interfaces_per_port
+                        self.tester.scapy_append('flows = []')
                         self.tester.scapy_append(
                             'flows.append(Ether(dst="%s")/IP(src="192.170.%d.2",dst="192.170.%d.2")/("X"*%d))' %
                             (rx_mac, src_ip_subnet, dst_ip_subnet, payload_size))
                         src_ip_subnet += 1
-
-                    tgen_input.append((tx_port, tx_port, "routePerf.pcap"))
-
-                self.tester.scapy_append('wrpcap("routePerf.pcap",flows)')
-                self.tester.scapy_execute()
-
-                time.sleep(1)
-                _, pps = self.tester.traffic_generator_throughput(tgen_input)
+                        pcap = os.sep.join([self.output_path, 
+                                            "routePerf_{0}.pcap".format(cnt)])
+                        self.tester.scapy_append('wrpcap("%s",flows)' % pcap)
+                        self.tester.scapy_execute()
+                        tgen_input.append((tx_port, tx_port, pcap))
+                        cnt += 1
+                        time.sleep(1)
+
+                # 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)
+                
                 resutls_row.append(float(pps) / 10 ** 6)
 
             self.result_table_add(resutls_row)
@@ -1136,7 +1174,6 @@ class TestKni(TestCase):
             # Enables the interfaces
             information = self.dut.send_expect(
                 "./usertools/dpdk-devbind.py --status | grep '%s'" % port, "# ")
-            print information
             data = information.split(' ')
             for field in data:
                 if field.rfind("if=") != -1:
@@ -1169,33 +1206,50 @@ class TestKni(TestCase):
             self.tester.scapy_append('flows = []')
             self.tester.scapy_append(
                 'flows.append(Ether(dst="%s")/IP(src="192.170.100.2",dst="192.170.100.2")/("X"*%d))' % (rx_mac, payload_size))
-            self.tester.scapy_append('wrpcap("routePerf_1.pcap",flows)')
+            pcap = os.sep.join([self.output_path, "routePerf_1.pcap"])
+            self.tester.scapy_append('wrpcap("%s",flows)' % pcap)
             self.tester.scapy_execute()
 
             tgen_input = []
-            tgen_input.append((tx_port, tx_port, "routePerf_1.pcap"))
+            tgen_input.append((tx_port, tx_port, pcap))
 
             # Get throughput with 1 port
-            _, 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)
+            
             one_port_resutls_row.append(float(pps) / 10 ** 6)
             self.result_table_add(one_port_resutls_row)
 
             # Prepare test with 'ports_without_kni' ports
-            self.tester.scapy_append('flows = []')
+            cnt = 0
             for port in range(ports_without_kni):
                 rx_mac = self.dut.get_mac_address(dut_ports[port])
                 tx_port = self.tester.get_local_port(dut_ports[port])
+                self.tester.scapy_append('flows = []')
                 self.tester.scapy_append(
                     'flows.append(Ether(dst="%s")/IP(src="192.170.%d.2",dst="192.170.%d.2")/("X"*%d))' %
-                    (rx_mac, 100 + port, 100 + (port + 1) % ports_without_kni, payload_size))
-                tgen_input.append((tx_port, tx_port, "routePerf_%d.pcap" % ports_without_kni))
-
-            self.tester.scapy_append(
-                'wrpcap("routePerf_%d.pcap",flows)' % ports_without_kni)
-            self.tester.scapy_execute()
+                    (rx_mac, 100 + port, 100 + (port + 1) % ports_without_kni,
+                     payload_size))
+                pcap = os.sep.join([self.output_path, 
+                    "routePerf_{0}_{1}.pcap".format(ports_without_kni, cnt)])
+                tgen_input.append((tx_port, tx_port, pcap))
+                self.tester.scapy_append('wrpcap("%s",flows)' % pcap)
+                self.tester.scapy_execute()
+                cnt += 1
 
             # Get throughput with 'ports_without_kni' ports
-            _, 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)
+            
             two_port_resutls_row.append(float(pps) / 10 ** 6)
             self.result_table_add(two_port_resutls_row)
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [next][PATCH V1 7/7] tests/l2fwd
  2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
                   ` (4 preceding siblings ...)
  2019-04-28 10:47 ` [dts] [next][PATCH V1 6/7] tests/kni zhaomeijuan
@ 2019-04-28 10:47 ` zhaomeijuan
  5 siblings, 0 replies; 7+ messages in thread
From: zhaomeijuan @ 2019-04-28 10:47 UTC (permalink / raw)
  To: dts; +Cc: zhaomeijuan

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

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

diff --git a/tests/TestSuite_l2fwd.py b/tests/TestSuite_l2fwd.py
index 659d5f7..7d31452 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,16 +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):
 
@@ -78,6 +78,16 @@ class TestL2fwd(TestCase):
             self.table_header.append("% linerate")
 
         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):
         """
@@ -163,16 +173,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 +201,15 @@ 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-28  2:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 10:47 [dts] [next][PATCH V1 1/7] tests/checksum_offload zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 2/7] tests/distributor zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 3/7] tests/efd zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 4/7] tests/fm10k_perf zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 5/7] tests/ipfrag zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 6/7] tests/kni zhaomeijuan
2019-04-28 10:47 ` [dts] [next][PATCH V1 7/7] tests/l2fwd zhaomeijuan

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).