test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH v2]tests sriov_kvm: test vlan mirror with random vlan id
@ 2016-06-24  8:40 Lijuan Tu
  2016-06-29  1:00 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: Lijuan Tu @ 2016-06-24  8:40 UTC (permalink / raw)
  To: dts; +Cc: Lijuan Tu

vlan 0 is not a validated vlan id.
validated vlan id is between 1 to 4095

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

diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py
index cc63804..7903317 100644
--- a/tests/TestSuite_sriov_kvm.py
+++ b/tests/TestSuite_sriov_kvm.py
@@ -11,6 +11,7 @@ Test userland 10Gb PMD.
 import re
 import time
 from functools import wraps
+import random
 
 import dts
 from qemu_kvm import QEMUKvm
@@ -19,6 +20,7 @@ from test_case import TestCase
 from pmd_output import PmdOutput
 FRAME_SIZE_64 = 64
 VM_CORES_MASK = 'all'
+MAX_VLAN = 4095
 
 
 class TestSriovKvm(TestCase):
@@ -76,7 +78,7 @@ class TestSriovKvm(TestCase):
                     'dest_mac':False
                     'src_mac':"52:00:00:00:00:00"
                 }
-            'dot1q':
+            'vlan':
                 {
                     'vlan':1
                 }
@@ -93,7 +95,7 @@ class TestSriovKvm(TestCase):
         """
         ret_ether_ip = {}
         ether = {}
-        dot1q = {}
+        vlan = {}
         ip = {}
         udp = {}
 
@@ -120,13 +122,13 @@ class TestSriovKvm(TestCase):
             else:
                 ether['src_mac'] = ether_ip["ether"]["src_mac"]
 
-        if not ether_ip.get('dot1q'):
+        if not ether_ip.get('vlan'):
             pass
         else:
-            if not ether_ip['dot1q'].get('vlan'):
-                dot1q['vlan'] = '1'
+            if not ether_ip['vlan'].get('vlan'):
+                vlan['vlan'] = '1'
             else:
-                dot1q['vlan'] = ether_ip['dot1q']['vlan']
+                vlan['vlan'] = ether_ip['vlan']['vlan']
 
         if not ether_ip.get('ip'):
             ip['dest_ip'] = "10.239.129.88"
@@ -155,7 +157,7 @@ class TestSriovKvm(TestCase):
                 udp['src_port'] = ether_ip['udp']['src_port']
 
         ret_ether_ip['ether'] = ether
-        ret_ether_ip['dot1q'] = dot1q
+        ret_ether_ip['vlan'] = vlan
         ret_ether_ip['ip'] = ip
         ret_ether_ip['udp'] = udp
 
@@ -183,7 +185,7 @@ class TestSriovKvm(TestCase):
                     'dest_mac':False
                     'src_mac':"52:00:00:00:00:00"
                 }
-            'dot1q':
+            'vlan':
                 {
                     'vlan':1
                 }
@@ -234,9 +236,9 @@ class TestSriovKvm(TestCase):
             self.tester.scapy_append(
                 'srcmac="%s"' % ret_ether_ip['ether']['src_mac'])
 
-            if ether_ip.get('dot1q'):
+            if ether_ip.get('vlan'):
                 self.tester.scapy_append(
-                    'vlanvalue=%d' % int(ret_ether_ip['dot1q']['vlan']))
+                    'vlanvalue=%d' % int(ret_ether_ip['vlan']['vlan']))
             self.tester.scapy_append(
                 'destip="%s"' % ret_ether_ip['ip']['dest_ip'])
             self.tester.scapy_append(
@@ -245,7 +247,7 @@ class TestSriovKvm(TestCase):
                 'destport=%d' % ret_ether_ip['udp']['dest_port'])
             self.tester.scapy_append(
                 'srcport=%d' % ret_ether_ip['udp']['src_port'])
-            if not ret_ether_ip.get('dot1q'):
+            if not ret_ether_ip.get('vlan'):
                 send_cmd = 'sendp([Ether(dst=nutmac, src=srcmac)/' + \
                     'IP(dst=destip, src=srcip, len=%s)/' % pktlen + \
                     'UDP(sport=srcport, dport=destport)/' + \
@@ -628,6 +630,8 @@ class TestSriovKvm(TestCase):
                 self.reset_port_mirror_rule(port, rule_id)
 
     def setup_two_vm_common_prerequisite(self):
+        self.host_testpmd.execute_cmd('port stop all')
+        self.host_testpmd.execute_cmd('port start all')
         self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
         self.vm0_testpmd = PmdOutput(self.vm_dut_0)
         self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
@@ -821,36 +825,39 @@ class TestSriovKvm(TestCase):
         vlan_id = 0
         vf_mask = '0x1'
         packet_num = 10
+        random_vlan = random.randint(1, MAX_VLAN - 1)
+        vlan_ids = [0, 1, random_vlan, MAX_VLAN]
 
-        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')
+        for vlan_id in vlan_ids:
+            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, '%d dst-pool 1 on' % vlan_id)
 
-        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}
-        self.send_packet(
-            self.vm_dut_0,
-            self.vm0_dut_ports,
-            port_id_0,
-            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)
+            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['vlan'] = {'vlan': '%d' % vlan_id}
+            self.send_packet(
+                self.vm_dut_0,
+                self.vm0_dut_ports,
+                port_id_0,
+                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)
+            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,
-                    "Vlan mirror failed between VM0 and VM1!")
+            self.verify(vm1_ret_stats['RX-packets'] == packet_num and
+                        vm1_ret_stats['TX-packets'] == packet_num,
+                        "Vlan mirror failed between VM0 and VM1!")
 
-        self.reset_port_mirror_rule(port_id_0, rule_id)
+            self.reset_port_mirror_rule(port_id_0, rule_id)
 
     def test_two_vms_vlan_and_pool_mirror(self):
         self.setup_2vm_2vf_env()
@@ -886,7 +893,7 @@ class TestSriovKvm(TestCase):
 
         vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
         ether_ip = {}
-        ether_ip['dot1q'] = {'vlan': '%d' % vlan_id}
+        ether_ip['vlan'] = {'vlan': '%d' % vlan_id}
         self.send_packet(
             self.vm_dut_1,
             self.vm1_dut_ports,
@@ -1016,7 +1023,7 @@ class TestSriovKvm(TestCase):
         self.vm0_testpmd.execute_cmd('start')
 
         ether_ip = {}
-        ether_ip['dot1q'] = {'vlan': '%d' % vlan_id}
+        ether_ip['vlan'] = {'vlan': '%d' % vlan_id}
         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.send_packet(
-- 
1.9.3

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

end of thread, other threads:[~2016-06-29  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24  8:40 [dts] [PATCH v2]tests sriov_kvm: test vlan mirror with random vlan id Lijuan Tu
2016-06-29  1:00 ` 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).