From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 20225E72 for ; Mon, 21 Dec 2015 14:44:13 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 21 Dec 2015 05:44:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,459,1444719600"; d="scan'208";a="621614525" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 21 Dec 2015 05:44:13 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id tBLDiAVU024550; Mon, 21 Dec 2015 21:44:10 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tBLDi8ud006672; Mon, 21 Dec 2015 21:44:10 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id tBLDi8Y7006668; Mon, 21 Dec 2015 21:44:08 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 21 Dec 2015 21:44:06 +0800 Message-Id: <1450705446-6636-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] framework tester: support parameter in integrity function 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: , X-List-Received-Date: Mon, 21 Dec 2015 13:44:14 -0000 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 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