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 6DDB92C27 for ; Sat, 1 Apr 2017 09:41:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491032472; x=1522568472; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=b/EDfKcv5P0N6rk6zn7d4uc3sWImZe7dG3wFnnhxwuY=; b=plBAE+7AJZHcFoHAdUToYxGElDZoDW9kXXDwOUG/ckHdRGUqhFkltDcf vXpjctEQNBfP0Qjkf/lIm9CsiAPKOQ==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2017 00:41:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,256,1486454400"; d="scan'208";a="1114257771" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by orsmga001.jf.intel.com with ESMTP; 01 Apr 2017 00:41:11 -0700 From: "xu,huilong" To: dts@dpdk.org Cc: "xu,huilong" Date: Sat, 1 Apr 2017 15:42:31 +0800 Message-Id: <1491032552-118473-4-git-send-email-huilongx.xu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1491032552-118473-1-git-send-email-huilongx.xu@intel.com> References: <1491032552-118473-1-git-send-email-huilongx.xu@intel.com> Subject: [dts] [PATCH 3/4] read compile switch config and compile dpdk before test 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: Sat, 01 Apr 2017 07:41:13 -0000 update list: 1. read compile switch config file 2. set run suite list on this test 3. update compile switch or apple patch 4. compile dpdk and back up dpdk 5. furnish interface for change different dpdk compile switch compile result Signed-off-by: xu,huilong --- framework/dts.py | 2 +- framework/project_dpdk.py | 103 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/framework/dts.py b/framework/dts.py index 369599d..54033fa 100644 --- a/framework/dts.py +++ b/framework/dts.py @@ -345,7 +345,7 @@ def dts_run_target(duts, tester, targets, test_suites): for target in targets: log_handler.info("\nTARGET " + target) result.target = target - + duts[0].set_test_suites(test_suites) try: drivername = settings.load_global_setting(settings.HOST_DRIVER_SETTING) if drivername == "": diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py index a0cb4c2..3e44e70 100644 --- a/framework/project_dpdk.py +++ b/framework/project_dpdk.py @@ -39,8 +39,8 @@ from crb import Crb from dut import Dut from tester import Tester from logger import getLogger -from settings import IXIA, DRIVERS - +from settings import IXIA, DRIVERS, FOLDERS +from config import CompileConf class DPDKdut(Dut): @@ -52,6 +52,7 @@ class DPDKdut(Dut): def __init__(self, crb, serializer): super(DPDKdut, self).__init__(crb, serializer) self.testpmd = None + self.read_compiel_switch = True def set_target(self, target, bind_dev=True): """ @@ -87,6 +88,9 @@ class DPDKdut(Dut): self.bind_interfaces_linux(drivername) self.extra_nic_setup() + def set_test_suites(self, test_suites): + self.test_suites = test_suites + def setup_modules(self, target): """ Install DPDK required kernel module on DUT. @@ -157,16 +161,111 @@ class DPDKdut(Dut): self.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=.*$/" + "CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=n/' config/common_base", "# ", 30) + def get_dpdk_compile_switch(self): + self.default_compile_switch = {} + for line in open(r'conf/common_base'): + try: + key, value = line.strip('\n').split('=') + except ValueError: + continue + if value: + self.default_compile_switch[key] = value + def set_package(self, pkg_name="", patch_list=[]): self.package = pkg_name self.patches = patch_list + def reset_switch(self, switch = 'default'): + if switch == 'default': + for key,value in self.default_compile_switch.items(): + self.send_expect("sed -i -e 's/%s=.*$/%s=%s/' config/common_base" % (key, key, value), "# ") + else: + if switch[0] not in self.default_compile_switch: + print 'switch %s not find in dpdk compilw switch' % switch[0] + raise KeyError + + self.send_expect("sed -i -e 's/%s=.*$/%s=%s/' config/common_base" % (switch[0], switch[0], switch[1]), "# ") + + def copy_patch(self, patch_file): + try: + patch_file = FOLDERS["Depends"] + r'/%s' % patch_file + except: + self.logger.warning(str(FOLDERS)) + patch_file = r'dep/%s' % patch_file + FOLDERS["Depends"] = 'dep' + patch_dst = "/tmp/" + # dpdk patch and build + self.session.copy_file_to(patch_file, patch_dst) + + def hot_fixpatch(self, patchfile, on): + try: + if on: + self.send_expect("patch -p0 < /tmp/%s" % patchfile, "#") + else: + self.send_expect("patch -p0 -R < /tmp/%s" % patchfile, "#") + except Exception, e: + raise ValueError("patch_hotfix_dpdk failure: %s" % e) + def build_install_dpdk(self, target, extra_options=''): """ Build DPDK source code with specified target. """ + if self.read_compiel_switch: + self.get_dpdk_compile_switch() + compile_config = CompileConf() + self.compile_switch = compile_config.load_compile_cfg() + self.read_compiel_switch = False + else: + self.compile_switch = {} + for key, value in self.compile_switch.items(): + if set(value['suite_list']) & set(self.test_suites): + # whether run suite should re-compile dpdk + try: + # try apply dpdk patch + for patch in value['patch_list']: + self.copy_patch(patch) + self.hot_fixpatch(patch, True) + except KeyError: + print 'no patch need apply' + # set compilw switch + for config_name, config_value in value.items(): + if config_name not in ['suite_list', 'patch_list', 'compile_app']: + self.reset_switch([config_name, config_value]) + + build_install_dpdk = getattr(self, 'build_install_dpdk_%s' % self.get_os_type()) + build_install_dpdk(target, extra_options) + try: + # try compile examples + #print 'value is', value + for app in value['compile_app']: + self.build_dpdk_apps('./examples/%s' % app.split(':')[0]) + try: + self.send_expect('cp -rf %s %s' % (app.split(':')[1], self.target + r'/' + app.split(':')[0] + '_' + key), "#") + except IndexError: + print 'not dst path, so not need copy examples' + except KeyError: + print 'no app should compile' + # backup compile result + self.send_expect('cp -rf %s %s' % (self.target, self.target + '_' + key), "#") + try: + for patch in value['patch_list']: + self.hot_fixpatch(patch, False) + except KeyError: + print 'no patch should remove' + self.reset_switch('default') + + #compile default switch build_install_dpdk = getattr(self, 'build_install_dpdk_%s' % self.get_os_type()) build_install_dpdk(target, extra_options) + self.send_expect('mv %s %s' % (self.target, self.target + '_default' ), "#") + self.send_expect('ln -sf %s %s' % (self.target + '_default', self.target), "#") + + def reset_compile_target(self, dst_target='default'): + self.send_expect('rm -rf %s ' % self.target , "#") + if dst_target == 'default': + self.send_expect('ln -sf %s %s' % (self.target + '_default', self.target), "#") + else: + self.send_expect('ln -sf %s %s' % (dst_target, self.target), "#") def build_install_dpdk_linux(self, target, extra_options): """ -- 1.9.3