test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] framework tester: support parameter in integrity function
Date: Mon, 21 Dec 2015 21:44:06 +0800	[thread overview]
Message-ID: <1450705446-6636-1-git-send-email-yong.liu@intel.com> (raw)

In some cases, there's a need to configure random packet settings like
destination mac address. Params should be list of packet.config_layer's
arguments. Here's one sample.

params=[("ether", {'dst': 'ff:ff:ff:ff:ff:ff', 'src':
"00:20:00:00:00:00"})]

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/tester.py b/framework/tester.py
index e47160f..210d54f 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -460,7 +460,7 @@ class Tester(Crb):
         else:
             return None
 
-    def check_random_pkts(self, portList, pktnum=2000, interval=0.01, allow_miss=True):
+    def check_random_pkts(self, portList, pktnum=2000, interval=0.01, allow_miss=True, params=None):
         """
         Send several random packets and check rx packets matched
         """
@@ -485,6 +485,11 @@ class Tester(Crb):
                 pkt = pkt_c(pkt_type=pkt_type,
                             pkt_len=random.randint(64, 1514),
                             ran_payload=True)
+                # config packet if has parameters
+                if params and len(portList) == len(params):
+                    for param in params:
+                        layer, config = param
+                        pkt.config_layer(layer, config)
                 # sequence saved in layer4 source port
                 if "TCP" in pkt_type:
                     pkt.config_layer('tcp', {'src': num % 65536})
@@ -499,11 +504,10 @@ class Tester(Crb):
 
             # only report when recevied number not matched
             if len(pkts) != len(recv_pkts):
-                if allow_miss is False:
-                    return False
-
                 print "Pkt number not matched,%d sent and %d received\n" \
                        % (len(pkts), len(recv_pkts))
+                if allow_miss is False:
+                    return False
 
             # check each received packet content
             for idx in range(len(recv_pkts)):
-- 
1.9.3

                 reply	other threads:[~2015-12-21 13:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450705446-6636-1-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).