test suite reviews and discussions
 help / color / mirror / Atom feed
From: "huilong,xu" <huilongx.xu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH V2 4/5] add case skip result when case running
Date: Fri,  7 Aug 2015 15:44:56 +0800	[thread overview]
Message-ID: <1438933497-1741-5-git-send-email-huilongx.xu@intel.com> (raw)
In-Reply-To: <1438933497-1741-1-git-send-email-huilongx.xu@intel.com>

From: huilong xu <huilongx.xu@intel.com>

1. add parse_file class for get check case info form execl file, and send check function list from tabel head.
2. add case_skip class for check case is skip or running.
   a)from talbe head get check function list. excep "case name", "wq request", "comments"
   b)when add a new check rule in excel file, you must add a check function in this clase, the function name is "check_rule" and parameter is a list.
     eg, add kernel rule in excel table head. you need add function check_kernerl(self,kernel_type) if you not add the function, it will ignore this rule.

Signed-off-by: huilong xu <huilongx.xu@intel.com>

diff --git a/framework/checkCase.py b/framework/checkCase.py
new file mode 100644
index 0000000..b2e79a0
--- /dev/null
+++ b/framework/checkCase.py
@@ -0,0 +1,100 @@
+import xlrd
+
+from settings import nic_name_from_type
+
+filter_file = r'./conf/dpdk_test_case_checklist.xls'
+filter_case = []
+check_function_dict = {}
+
+class parse_file():
+
+    def __init__(self):
+        try:
+            self.book = xlrd.open_workbook(filter_file)
+            self.sheet = self.book.sheet_by_index(0)
+            self.init_check_function_dict()
+        except:
+            pass
+
+    def init_check_function_dict(self):
+        '''
+        init check case functio, and skip case message.
+        '''
+        row_data  = self.sheet.row_values(0)
+        for i in range(1,len(row_data)):
+            if  row_data[i].lower() in ['wq number', 'comments']:
+                if 'message' not in check_function_dict:
+                    check_function_dict['message'] = [i]
+                else:
+                    check_function_dict['message'].append(i)
+            else:
+                check_function_dict[row_data[i].lower()] = i       
+
+    def set_filter_case(self):
+        for row in range(self.sheet.nrows):   
+            row_data = self.sheet.row_values(row)
+            # add case name
+            tmp_filter = [row_data[0]]
+            for i in range(1,len(row_data) - 2):
+                tmp_filter.append(row_data[i].split(','))
+
+            tmp_filter.append(row_data[-2])
+            tmp_filter.append(row_data[-1])
+
+            filter_case.append(tmp_filter)
+
+class check_case_skip():
+    def __init__(self, Dut):
+        self.dut = Dut
+        self.comments = ''
+
+    def check_os(self,os_type):
+        if 'all' == os_type[0].lower():
+            return True
+        dut_os_type = self.dut.get_os_type()
+        if dut_os_type in os_type:
+            return True
+        else:
+            return False
+
+    def check_nic(self, nic_type):
+        if 'all' == nic_type[0].lower():
+            return True
+        dut_nic_type = nic_name_from_type(self.dut.ports_info[0]['type'])
+        if dut_nic_type in nic_type:
+            return True
+        else:
+            return False
+
+    def check_target(self,target):
+        if 'all' == target[0].lower():
+            return True
+        if self.dut.target in target:
+            return True
+        else:
+            return False
+
+    def case_skip(self, case_name):
+        skip_flage = False
+        for rule in filter_case[1:]:
+            # check case name
+            if case_name == rule[0]:
+                for key in check_function_dict.keys():
+                    try:
+                        if 'message' == key:
+                            continue 
+                        check_function = getattr(self, 'check_%s' % key)
+                    except:
+                        print "can't check %s type" % key
+                    if check_function(rule[check_function_dict[key]]):
+                        skip_flage = True
+                    else:
+                        skip_flage = False
+                        break
+                if skip_flage: 
+                    if 'message' in check_function_dict:
+                        for i in check_function_dict['message']:
+                            self.comments += '%s,' % rule[i]
+                    return skip_flage
+                
+        return skip_flage
-- 
1.7.4.4

  parent reply	other threads:[~2015-08-07  7:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07  7:44 [dts] [PATCH V2 0/5] add check case list for skip the case, when the case can't test huilong,xu
2015-08-07  7:44 ` [dts] [PATCH V2 1/5] add check case list huilong,xu
2015-08-07  7:44 ` [dts] [PATCH V2 2/5] add N/A result in test report huilong,xu
2015-08-07  7:44 ` [dts] [PATCH V2 3/5] add case skip result when case running huilong,xu
2015-08-07  7:44 ` huilong,xu [this message]
2015-08-07  7:44 ` [dts] [PATCH V2 5/5] add check case function in run case module huilong,xu
2015-08-10  3:17 ` [dts] [PATCH V2 0/5] add check case list for skip the case, when the case can't test 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=1438933497-1741-5-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).