test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH]sriov-mirror: merge it from DTF to dts
@ 2016-05-06  2:59 Lijuan Tu
  2016-05-23 20:46 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: Lijuan Tu @ 2016-05-06  2:59 UTC (permalink / raw)
  To: qian.q.xu, dts; +Cc: Lijuan Tu

Signed-off-by: Lijuan Tu <lijuanx.a.tu@intel.com>
---
 tests/TestSuite_sriov_kvm.py | 183 +++++++++++++++++++++++++++++++++----------
 1 file changed, 142 insertions(+), 41 deletions(-)

diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py
index cd3d9c3..cc63804 100644
--- a/tests/TestSuite_sriov_kvm.py
+++ b/tests/TestSuite_sriov_kvm.py
@@ -9,15 +9,14 @@ Test userland 10Gb PMD.
 """
 
 import re
-import pdb
 import time
+from functools import wraps
 
 import dts
 from qemu_kvm import QEMUKvm
 from test_case import TestCase
 
 from pmd_output import PmdOutput
-
 FRAME_SIZE_64 = 64
 VM_CORES_MASK = 'all'
 
@@ -106,10 +105,14 @@ class TestSriovKvm(TestCase):
         tester_port = dut.ports_map[dut_dest_port]
         if not ether_ip.get('ether'):
             ether['dest_mac'] = dut.get_mac_address(dut_dest_port)
+            if not re.match(r'([0-9A-F]{2}:){5}[0-9A-F]{2}', ether['dest_mac']):
+                ether['dest_mac'] = dut.testpmd.get_port_mac(dest_port)
             ether['src_mac'] = dut.tester.get_mac(tester_port)
         else:
             if not ether_ip['ether'].get('dest_mac'):
                 ether['dest_mac'] = dut.get_mac_address(dut_dest_port)
+                if not re.match(r'([0-9A-F]{2}:){5}[0-9A-F]{2}', ether['dest_mac']):
+                    ether['dest_mac'] = dut.testpmd.get_port_mac(dest_port)
             else:
                 ether['dest_mac'] = ether_ip['ether']['dest_mac']
             if not ether_ip['ether'].get('src_mac'):
@@ -210,7 +213,7 @@ class TestSriovKvm(TestCase):
                                               for _ in self.get_stats(dut, dest_port, "rx")]
         if not src_port:
             itf = self.tester.get_interface(
-                dut.ports_map[dut_ports[dest_port]])
+                self.dut.ports_map[dut_ports[dest_port]])
         else:
             itf = src_port
 
@@ -291,8 +294,8 @@ class TestSriovKvm(TestCase):
         self.port1.unbind_driver()
         self.port1_pci = self.dut.ports_info[p1]['pci']
 
-        vf0_prop = {'prop_host': self.port0_pci}
-        vf1_prop = {'prop_host': self.port1_pci}
+        vf0_prop = {'opt_host': self.port0_pci}
+        vf1_prop = {'opt_host': self.port1_pci}
 
         # set up VM0 ENV
         self.vm0 = QEMUKvm(self.dut, 'vm0', 'sriov_kvm')
@@ -307,10 +310,14 @@ class TestSriovKvm(TestCase):
         self.setup_2vm_2vf_env_flag = 1
 
     def destroy_2vm_2pf_env(self):
+        self.vm_dut_0.close()
+        self.vm_dut_0.logger.logger_exit()
         self.vm0.stop()
         self.port0.bind_driver('igb_uio')
         self.vm0 = None
 
+        self.vm_dut_1.close()
+        self.vm_dut_1.logger.logger_exit()
         self.vm1.stop()
         self.port1.bind_driver('igb_uio')
         self.vm1 = None
@@ -332,8 +339,8 @@ class TestSriovKvm(TestCase):
 
             time.sleep(1)
 
-            vf0_prop = {'prop_host': self.sriov_vfs_port[0].pci}
-            vf1_prop = {'prop_host': self.sriov_vfs_port[1].pci}
+            vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+            vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
 
             for port_id in self.dut_ports:
                 if port_id == self.used_dut_port:
@@ -369,10 +376,16 @@ class TestSriovKvm(TestCase):
             raise Exception(e)
 
     def destroy_2vm_2vf_env(self):
+        if getattr(self, 'vm_dut_0', None):
+            self.vm_dut_0.close()
+            self.vm_dut_0.logger.logger_exit()
         if getattr(self, 'vm0', None):
             self.vm0.stop()
             self.vm0 = None
 
+        if getattr(self, 'vm_dut_1', None):
+            self.vm_dut_1.close()
+            self.vm_dut_1.logger.logger_exit()
         if getattr(self, 'vm1', None):
             self.vm1.stop()
             self.vm1 = None
@@ -406,10 +419,10 @@ class TestSriovKvm(TestCase):
 
             time.sleep(1)
 
-            vf0_prop = {'prop_host': self.sriov_vfs_port[0].pci}
-            vf1_prop = {'prop_host': self.sriov_vfs_port[1].pci}
-            vf2_prop = {'prop_host': self.sriov_vfs_port[2].pci}
-            vf3_prop = {'prop_host': self.sriov_vfs_port[3].pci}
+            vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+            vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
+            vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
+            vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
 
             for port_id in self.dut_ports:
                 if port_id == self.used_dut_port:
@@ -458,18 +471,30 @@ class TestSriovKvm(TestCase):
             raise Exception(e)
 
     def destroy_4vm_4vf_env(self):
+        if getattr(self, 'vm_dut_0', None):
+            self.vm_dut_0.close()
+            self.vm_dut_0.logger.logger_exit()
         if getattr(self, 'vm0', None):
             self.vm0.stop()
             self.vm0 = None
 
+        if getattr(self, 'vm_dut_1', None):
+            self.vm_dut_1.close()
+            self.vm_dut_1.logger.logger_exit()
         if getattr(self, 'vm1', None):
             self.vm1.stop()
             self.vm1 = None
 
+        if getattr(self, 'vm_dut_2', None):
+            self.vm_dut_2.close()
+            self.vm_dut_2.logger.logger_exit()
         if getattr(self, 'vm2', None):
             self.vm2.stop()
             self.vm2 = None
 
+        if getattr(self, 'vm_dut_3', None):
+            self.vm_dut_3.close()
+            self.vm_dut_3.logger.logger_exit()
         if getattr(slef, 'vm3', None):
             self.vm3.stop()
             self.vm3 = None
@@ -584,8 +609,9 @@ class TestSriovKvm(TestCase):
 
         mirror_rule_cmd = "reset port %d mirror-rule %d" % (port, rule_id)
         out = self.dut.send_expect("%s" % mirror_rule_cmd, "testpmd> ")
-        self.verify("Bad arguments" not in out,
-                    "Reset port %d mirror rule failed!")
+        self.verify(
+            "Bad arguments" not in out,
+            "Reset port %d mirror rule failed!")
 
         self.remove_port_ruleid(port, rule_id)
 
@@ -629,7 +655,22 @@ class TestSriovKvm(TestCase):
 
         self.setup_2vm_prerequisite_flag = 0
 
-    def stop_test_setup_two_vm_pf_env(self):
+    def skip_func(func):
+        @wraps(func)
+        def skip_nic(*args, **kwargs):
+            self = args[0]
+            if func.__name__ == "test_setup_two_vm_pf_env":
+                self.dut.logger.info("This func is just for internal test!")
+                return func
+            if self.nic.startswith('fortville'):
+                self.dut.logger.info("NIC is [ %s ], skip this case [ %s ]" %
+                            (self.nic, func.__name__))
+                return func
+            return func(*args, **kwargs)
+        return skip_nic
+
+    @skip_func
+    def test_setup_two_vm_pf_env(self):
         self.setup_2vm_2pf_env()
 
         out = self.vm_dut_0.send_expect("ifconfig", '# ')
@@ -644,6 +685,7 @@ class TestSriovKvm(TestCase):
 
         self.destroy_2vm_2pf_env()
 
+    @skip_func
     def test_two_vms_intervm_communication(self):
         self.setup_2vm_2vf_env()
 
@@ -697,12 +739,18 @@ class TestSriovKvm(TestCase):
         packet_num = 10
 
         rule_id = self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on')
+        host_start_stats = self.host_testpmd.get_pmd_stats(port_id_0)
+        vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
         self.send_packet(
             self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=packet_num)
         vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
+        vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
+        host_end_stats = self.host_testpmd.get_pmd_stats(port_id_0)
 
         vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
+        vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
+        host_ret_stats = self.calculate_stats(host_start_stats, host_end_stats)
 
         self.verify(vm1_ret_stats['RX-packets'] == packet_num and
                     vm1_ret_stats['TX-packets'] == packet_num,
@@ -744,12 +792,15 @@ class TestSriovKvm(TestCase):
 
         self.vm1_testpmd.execute_cmd('set fwd rxonly')
         self.vm1_testpmd.execute_cmd('start')
+        host_start_stats = self.host_testpmd.get_pmd_stats(port_id_0)
         vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
         vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         self.vm0_testpmd.execute_cmd('start tx_first')
+        host_end_stats = self.host_testpmd.get_pmd_stats(port_id_0)
         vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
 
+        host_ret_stats = self.calculate_stats(host_start_stats, host_end_stats)
         vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
         vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
 
@@ -758,6 +809,10 @@ class TestSriovKvm(TestCase):
 
         self.reset_port_mirror_rule(port_id_0, rule_id)
 
+    def get_vm_testpmd_by_mask(self, mask):
+        vm_id = int(mask, base=16) - 1
+        return getattr(self, "vm%d_testpmd" % vm_id)
+
     def test_two_vms_vlan_mirror(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -767,10 +822,15 @@ class TestSriovKvm(TestCase):
         vf_mask = '0x1'
         packet_num = 10
 
-        self.host_testpmd.execute_cmd(
-            'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
+        if self.nic.startswith('fortville'):
+            vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask)
+            vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0))
+        else:
+            self.host_testpmd.execute_cmd(
+                'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
         rule_id = self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 on')
 
+        vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
         ether_ip = {}
         ether_ip['dot1q'] = {'vlan': '%d' % vlan_id}
@@ -781,8 +841,10 @@ class TestSriovKvm(TestCase):
             count=packet_num,
             **ether_ip)
         vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
+        vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
 
         vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
+        vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
 
         self.verify(vm1_ret_stats['RX-packets'] == packet_num and
                     vm1_ret_stats['TX-packets'] == packet_num,
@@ -799,8 +861,12 @@ class TestSriovKvm(TestCase):
         vf_mask = '0x2'
         packet_num = 10
 
-        self.host_testpmd.execute_cmd(
-            'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
+        if self.nic.startswith("fortville"):
+            vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask)
+            vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0))
+        else:
+            self.host_testpmd.execute_cmd(
+                'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
         self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on')
         self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % vlan_id)
 
@@ -897,12 +963,13 @@ class TestSriovKvm(TestCase):
         vf_mask = '0x2'
         packet_num = 1
 
+        if self.nic.startswith('fortville'):
+            vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask)
+        else:
+            self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" %
+                                          (vlan_id, port_id_0, vf_mask))
         self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on')
         self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on')
-        self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" %
-                                      (vlan_id, port_id_0, vf_mask))
-        self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % vlan_id)
-        self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on')
 
         self.vm1_testpmd.execute_cmd('set fwd rxonly')
         self.vm1_testpmd.execute_cmd('start')
@@ -924,6 +991,7 @@ class TestSriovKvm(TestCase):
         self.vm0_testpmd.execute_cmd('start')
         vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
+        host_start_stats = self.host_testpmd.get_pmd_stats(port_id_0)
         self.send_packet(
             self.vm_dut_0,
             self.vm0_dut_ports,
@@ -931,9 +999,11 @@ class TestSriovKvm(TestCase):
             count=packet_num)
         vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
+        host_end_stats = self.host_testpmd.get_pmd_stats(port_id_0)
 
         vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
         vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
+        host_ret_stats = self.calculate_stats(host_start_stats, host_end_stats)
 
         self.verify(vm0_ret_stats['RX-packets'] == packet_num and
                     vm0_ret_stats['TX-packets'] == packet_num and
@@ -978,8 +1048,11 @@ class TestSriovKvm(TestCase):
         packet_num = 10
 
         for vf_mac in ["00:11:22:33:44:55", "00:55:44:33:22:11"]:
-            self.host_testpmd.execute_cmd("mac_addr add port %d vf %d %s" %
-                                          (port_id_0, vf_num, vf_mac))
+            if self.nic.startswith('niantic'):
+                set_mac_cmd = "mac_addr add port %d vf %d %s"
+            elif self.nic.startswith('fortville'):
+                set_mac_cmd = "set port %d vf %d %s exact-mac-vlan on"
+            self.host_testpmd.execute_cmd(set_mac_cmd % (port_id_0, vf_num, vf_mac))
 
             vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
             ether_ip = {}
@@ -999,6 +1072,7 @@ class TestSriovKvm(TestCase):
                         "Add exact MAC %s failed btween VF0 and VF1" % vf_mac +
                         "when add multi exact MAC address on VF!")
 
+    @skip_func
     def test_two_vms_enalbe_or_disable_one_uta_mac_on_vf(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -1045,6 +1119,7 @@ class TestSriovKvm(TestCase):
                     "Disable one uta MAC failed between VM0 and VM1 " +
                     "when enable or disable one uta MAC address on VF!")
 
+    @skip_func
     def test_two_vms_add_multi_uta_mac_on_vf(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -1073,15 +1148,22 @@ class TestSriovKvm(TestCase):
                         "Add MULTI uta MAC %s failed between VM0 and VM1 " % vf_mac +
                         "when add multi uta MAC address on VF!")
 
+    @skip_func
     def test_two_vms_add_or_remove_uta_mac_on_vf(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
 
         port_id_0 = 0
-        vf_mac = "00:55:44:33:22:11"
         packet_num = 10
+        on_time = 0
 
         for switch in ['on', 'off', 'on']:
+            if switch == 'on':
+                if on_time == 0:
+                    vf_mac = "00:55:44:33:22:11"
+                    on_time += 1
+                else:
+                    vf_mac = "00:11:22:33:44:55"
             self.host_testpmd.execute_cmd("set port %d uta %s %s" %
                                           (port_id_0, vf_mac, switch))
 
@@ -1108,6 +1190,7 @@ class TestSriovKvm(TestCase):
                             "Remove MULTI uta MAC %s failed between VM0 and VM1 " % vf_mac +
                             "when add or remove multi uta MAC address on VF!")
 
+    @skip_func
     def test_two_vms_pause_rx_queues(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -1140,6 +1223,7 @@ class TestSriovKvm(TestCase):
                             "Pause RX queues failed between VM0 and VM1 " +
                             "when enable or pause RX queues on VF!")
 
+    @skip_func
     def test_two_vms_pause_tx_queuse(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -1175,6 +1259,7 @@ class TestSriovKvm(TestCase):
                             "Pause TX queues failed between VM0 and VM1 " +
                             "when enable or pause TX queues on VF!")
 
+    @skip_func
     def test_two_vms_prevent_rx_broadcast_on_vf(self):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
@@ -1214,24 +1299,40 @@ class TestSriovKvm(TestCase):
         self.setup_2vm_2vf_env()
         self.setup_two_vm_common_prerequisite()
 
-        for command in ["set port 0 vf 65 tx on",
-                        "set port 2 vf -1 tx off",
-                        "set port 0 vf 0 rx oneee",
-                        "set port 0 vf 0 rx offdd",
-                        "set port 0 vf 64 rxmode BAM on",
-                        "set port 0 vf 64 rxmode BAM off",
-                        "set port 0 uta 00:11:22:33:44 on",
-                        "set port 7 uta 00:55:44:33:22:11 off",
-                        "set port 0 vf 34 rxmode ROPE on",
-                        "mac_addr add port 0 vf 65 00:55:44:33:22:11",
-                        "mac_addr add port 5 vf 0 00:55:44:88:22:11",
-                        "set port 0 mirror-rule 0xf uplink-mirror dst-pool 1 on",
-                        "set port 0 mirror-rule 2 vlan-mirror 9 dst-pool 1 on",
-                        "set port 0 mirror-rule 0 downlink-mirror 0xf dst-pool 2 off",
-                        "reset port 0 mirror-rule 4",
-                        "reset port 0xff mirror-rule 0"]:
+        public_commands = ["set port 0 vf 65 tx on",
+                            "set port 2 vf -1 tx off",
+                            "set port 0 vf 0 rx oneee",
+                            "set port 0 vf 0 rx offdd",
+                            "set port 0 vf 64 rxmode BAM on",
+                            "set port 0 vf 64 rxmode BAM off",
+                            "set port 0 uta 00:11:22:33:44 on",
+                            "set port 7 uta 00:55:44:33:22:11 off",
+                            "set port 0 vf 34 rxmode ROPE on",
+                            "mac_addr add port 0 vf 65 00:55:44:33:22:11",
+                            "mac_addr add port 5 vf 0 00:55:44:88:22:11",
+                            "set port 0 mirror-rule 0 downlink-mirror 0xf dst-pool 2 off",
+                            "reset port 0xff mirror-rule 0"]
+        niantic_specify_commands = ["set port 0 mirror-rule 0xf uplink-mirror dst-pool 1 on",
+                                    "set port 0 mirror-rule 2 vlan-mirror 9 dst-pool 1 on",
+                                    "reset port 0 mirror-rule 4"]
+        fortville_specify_commands = ["set port 0 mirror-rule 2 vlan-mirror 65 dst-pool 1 on"]
+
+        if self.nic.startswith('nantic'):
+            verify_commands = public_commands + \
+                              niantic_specify_commands
+        elif self.nic.startswith('fortville'):
+            verify_commands = public_commands + \
+                              fortville_specify_commands
+        else:
+            verify_commands = public_commands
+
+        for command in verify_commands:
             output = self.host_testpmd.execute_cmd(command)
+            print output
             error = False
 
             for error_regx in [r'Bad', r'bad', r'failed', r'-[0-9]+', r'error', r'Invalid']:
                 ret_regx = re.search(error_regx, output)
-- 
1.9.3

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

end of thread, other threads:[~2016-05-23 20:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-06  2:59 [dts] [PATCH]sriov-mirror: merge it from DTF to dts Lijuan Tu
2016-05-23 20:46 ` Liu, Yong

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