From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4098A0613 for ; Wed, 28 Aug 2019 11:16:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90C3E29CB; Wed, 28 Aug 2019 11:16:05 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 6A1F61B05 for ; Wed, 28 Aug 2019 11:16:03 +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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2019 02:16:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,440,1559545200"; d="scan'208";a="197514077" Received: from unknown (HELO dpdk-wenjielx-dtspatch135.sh.intel.com) ([10.240.176.135]) by fmsmga001.fm.intel.com with ESMTP; 28 Aug 2019 02:16:01 -0700 From: changqingxwu To: dts@dpdk.org Cc: changqingxwu Date: Wed, 28 Aug 2019 17:20:35 +0800 Message-Id: <1566984035-79983-1-git-send-email-changqingx.wu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V1] test:add test suite about multicast 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" Signed-off-by: changqingxwu --- tests/TestSuite_multicast.py | 147 +++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 tests/TestSuite_multicast.py diff --git a/tests/TestSuite_multicast.py b/tests/TestSuite_multicast.py new file mode 100644 index 0000000..bcdb0bc --- /dev/null +++ b/tests/TestSuite_multicast.py @@ -0,0 +1,147 @@ +# + +""" +DPDK Test suite. + +multicast test script. +""" + +import time +from test_case import TestCase +import utils + +routeTbl = [ + ["224.0.0.101", "P1"], ["224.0.0.102", "P2"], + ["224.0.0.103", "P1,P2"], ["224.0.0.104", "P3"], + ["224.0.0.105", "P1,P3"], ["224.0.0.106", "P2,P3"], + ["224.0.0.107", "P1,P2,P3"], ["224.0.0.108", "P4"], + ["224.0.0.109", "P1,P4"], ["224.0.0.110", "P2,P4"], + ["224.0.0.111", "P1,P2,P4"], ["224.0.0.112", "P3,P4"], + ["224.0.0.113", "P1,P3,P4"], ["224.0.0.114", "P2,P3,P4"], + ["224.0.0.115", "P1,P2,P3,P4"] +] + +trafficFlow = { + "F1": ["TG0", "TG0", "10.100.0.1", "224.0.0.101"], + "F2": ["TG0", "TG1", "10.100.0.2", "224.0.0.104"], + "F3": ["TG0", "TG0,TG1", "10.100.0.3", "224.0.0.105"], + "F4": ["TG1", "TG1", "11.100.0.1", "224.0.0.104"], + "F5": ["TG1", "TG0", "11.100.0.2", "224.0.0.101"], + "F6": ["TG1", "TG0,TG1", "11.100.0.3", "224.0.0.105"] +} + +measureTarget = [ + ["1S/1C/1T", "F1,F4", "ipv4_multicast -c %s -n 3 -- -p %s -q 2"], + ["1S/1C/2T", "F1,F4", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"], + ["1S/2C/1T", "F1,F4", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"], + ["1S/1C/1T", "F2,F5", "ipv4_multicast -c %s -n 3 -- -p %s -q 2"], + ["1S/1C/2T", "F2,F5", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"], + ["1S/2C/1T", "F2,F5", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"], + ["1S/1C/1T", "F3,F6", "ipv4_multicast -c %s -n 3 -- -p %s -q 2"], + ["1S/1C/2T", "F3,F6", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"], + ["1S/2C/1T", "F3,F6", "ipv4_multicast -c %s -n 3 -- -p %s -q 1"] +] + + +class TestMulticast(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + Multicast Prerequisites + """ + global dutPorts + # Based on h/w type, choose how many ports to use + dutPorts = self.dut.get_ports(self.nic) + # Verify that enough ports are available + self.verify(len(dutPorts) >= 4, "Insufficient ports for testing") + + # Verify that enough threads are available + cores = self.dut.get_core_list("1S/2C/2T") + self.verify(cores is not None, "Insufficient cores for speed testing") + + global P1, P3, TG0, TG1, TGs + # prepare port mapping TG0<=>P1, TG1<=>P3 + P1 = dutPorts[0] + P2 = dutPorts[1] + P3 = dutPorts[2] + P4 = dutPorts[3] + TGs = [P1, P3] + TG0 = self.tester.get_local_port(TGs[0]) + TG1 = self.tester.get_local_port(TGs[1]) + + # Prepare multicast route table, replace P(x) port pattern + repStr = "static struct mcast_group_params mcast_group_table[] = {\\\n" + for [ip, ports] in routeTbl: + mask = 0 + for _ in ports.split(','): + mask = mask | (1 << eval(_)) + entry = '{' + 'RTE_IPV4(' + ip.replace('.', ',') + '),' + str(mask) + '}' + repStr = repStr + ' ' * 4 + entry + ",\\\n" + repStr = repStr + "};" + + self.dut.send_expect(r"sed -i '/mcast_group_table\[\].*{/,/^\}\;/c\\%s' examples/ipv4_multicast/main.c" % repStr, "# ") + + # make application + out = self.dut.send_expect("make -C examples/ipv4_multicast", "#") + self.verify("Error" not in out, "compilation error 1") + self.verify("No such file" not in out, "compilation error 2") + + def set_up(self): + """ + Run before each test case. + """ + pass + + def test_multicast_forwarding(self): + """ + IP4 Multicast Forwarding F1~F6 + """ + cores = self.dut.get_core_list("1S/2C/1T") + coremask = utils.create_mask(cores) + payload = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + self.dut.send_expect("examples/ipv4_multicast/build/ipv4_multicast -c %s -n 4 -- -p %s -q 2" % ( + coremask, '0x5'), "IPv4_MULTICAST:", 60) + + for flow in trafficFlow.keys(): + for tx_port in trafficFlow[flow][0].split(","): + for rx_port in trafficFlow[flow][1].split(","): + sniff_src = "not 00:00:00:00:00:00" + + inst = self.tester.tcpdump_sniff_packets(intf=self.tester.get_interface(eval(rx_port)), timeout=5, + count=1, filters=[{"layer": "ether", "config": {"src": sniff_src}}] ) + dmac = self.dut.get_mac_address(TGs[int(trafficFlow[flow][0][2])]) + + self.tester.scapy_append('sendp([Ether(src="00:00:00:00:00:00", dst="%s")/IP(dst="%s",src="%s")\ + /Raw(load="%s")], iface="%s")' % ( + dmac, trafficFlow[flow][3], trafficFlow[flow][2], payload, self.tester.get_interface(eval(tx_port)))) + self.tester.scapy_execute() + time.sleep(5) # Wait for the sniffer to finish. + + pkts = self.tester.load_tcpdump_sniff_packets(inst) + for packet in pkts: + result = str(packet.pktgen.pkt.show) + + print result + self.verify("Ether" in result, "No packet received") + self.verify("src=" + trafficFlow[flow][2] + " dst=" + trafficFlow[flow][3] in result, + "Wrong IP address") + self.verify("load='%s'" % payload in result, "Wrong payload") + splitIP = trafficFlow[flow][3].rsplit(".") + expectedMac = "01:00:5e:%s:%s:%s" % (str(int(splitIP[1], 8) & 0b01111111).zfill(2), + str(int(splitIP[2], 8)).zfill(2), str(int(splitIP[3], 8)).zfill(2)) + self.verify("dst=%s" % expectedMac in result, "Wrong MAC address") + + self.dut.send_expect("^C", "#") + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.send_expect("^C", "#") + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() -- 2.17.2