test suite reviews and discussions
 help / color / mirror / Atom feed
From: "xu,huilong" <huilongx.xu@intel.com>
To: dts@dpdk.org
Cc: "xu,huilong" <huilongx.xu@intel.com>
Subject: [dts] [PATCH 3/4] read compile switch config and compile dpdk before test
Date: Sat,  1 Apr 2017 15:42:31 +0800	[thread overview]
Message-ID: <1491032552-118473-4-git-send-email-huilongx.xu@intel.com> (raw)
In-Reply-To: <1491032552-118473-1-git-send-email-huilongx.xu@intel.com>

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 <huilongx.xu@intel.com>
---
 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

  parent reply	other threads:[~2017-04-01  7:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01  7:42 [dts] [PATCH 0/4] compile dpdk different config with different test suite by dts framework befor run test suite xu,huilong
2017-04-01  7:42 ` [dts] [PATCH 1/4] add dpdk all compile switch xu,huilong
2017-04-01  8:02   ` Liu, Yong
2017-04-01  7:42 ` [dts] [PATCH 2/4] add compile config file template and parse compile config class xu,huilong
2017-04-01  7:42 ` xu,huilong [this message]
2017-04-01  7:42 ` [dts] [PATCH 4/4] add example for test suite xu,huilong
2017-04-01  8:20 ` [dts] [PATCH 0/4] compile dpdk different config with different test suite by dts framework befor run " Liu, Yong
2017-04-01  8:31   ` Xu, HuilongX
2017-04-01  8:54     ` Liu, Yong

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=1491032552-118473-4-git-send-email-huilongx.xu@intel.com \
    --to=huilongx.xu@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).