From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 164E458EF for ; Mon, 13 Jul 2015 07:46:11 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 12 Jul 2015 22:46:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,459,1432623600"; d="scan'208";a="605024137" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 12 Jul 2015 22:46:10 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t6D5k83j018156; Mon, 13 Jul 2015 13:46:08 +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 t6D5k6Y5005505; Mon, 13 Jul 2015 13:46:08 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t6D5k56l005501; Mon, 13 Jul 2015 13:46:05 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 13 Jul 2015 13:46:04 +0800 Message-Id: <1436766364-5469-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] Optimize rescan_ports function with read cache option 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, 13 Jul 2015 05:46:12 -0000 From: Marvin Liu When read_cache enabled, skip rescan ports when there's available port infor. Only update cache file and PORT_INFO_CACHE_KEY after rescan ports function. Signed-off-by: Marvin Liu diff --git a/framework/dut.py b/framework/dut.py index aaaaf36..bbc6274 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -513,6 +513,17 @@ class Dut(Crb): return False def rescan_ports(self): + """ + Rescan ports information + """ + if self.read_cache and self.load_serializer_ports(): + return + + if self.ports_info: + self.rescan_ports_uncached() + self.save_serializer_ports() + + def rescan_ports_uncached(self): unknow_interface = RED('Skipped: unknow_interface') for port_info in self.ports_info: @@ -540,7 +551,7 @@ class Dut(Crb): def load_serializer_ports(self): cached_ports_info = self.serializer.load(self.PORT_INFO_CACHE_KEY) if cached_ports_info is None: - return + return None self.ports_info = cached_ports_info @@ -564,7 +575,6 @@ class Dut(Crb): if not self.read_cache or self.ports_info is None: self.scan_ports_uncached() - self.save_serializer_ports() def scan_ports_cached(self): """ -- 1.9.3