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 833F48E56 for ; Wed, 23 Sep 2015 08:40:42 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 22 Sep 2015 23:40:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,577,1437462000"; d="scan'208";a="566738264" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2015 23:40:40 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t8N6ecXF020750; Wed, 23 Sep 2015 14:40:38 +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 t8N6eZ4G017331; Wed, 23 Sep 2015 14:40:37 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t8N6eZso017327; Wed, 23 Sep 2015 14:40:35 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 23 Sep 2015 14:40:32 +0800 Message-Id: <1442990434-17295-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH 1/3] Support check testing environment for test case 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: Wed, 23 Sep 2015 06:40:43 -0000 From: Marvin Liu This module will load supported cases information from dpdk_test_case_checklist.xls. When checked environment not support this case, function case_support will return False. Signed-off-by: Marvin Liu diff --git a/framework/checkCase.py b/framework/checkCase.py index b2e79a0..9e1dca8 100644 --- a/framework/checkCase.py +++ b/framework/checkCase.py @@ -5,6 +5,10 @@ from settings import nic_name_from_type filter_file = r'./conf/dpdk_test_case_checklist.xls' filter_case = [] check_function_dict = {} +support_file = r'./conf/dpdk_support_test_case.xls' +support_case = [] +support_function_dict = {} + class parse_file(): @@ -12,7 +16,10 @@ class parse_file(): try: self.book = xlrd.open_workbook(filter_file) self.sheet = self.book.sheet_by_index(0) + self.support_book = xlrd.open_workbook(support_file) + self.support_sheet = self.support_book.sheet_by_index(0) self.init_check_function_dict() + self.init_support_function_dict() except: pass @@ -20,22 +27,36 @@ class parse_file(): ''' 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']: + 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 + check_function_dict[row_data[i].lower()] = i + + def init_support_function_dict(self): + ''' + init support case function, and skip case message. + ''' + row_data = self.support_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 support_function_dict: + support_function_dict['message'] = [i] + else: + support_function_dict['message'].append(i) + else: + support_function_dict[row_data[i].lower()] = i def set_filter_case(self): - for row in range(self.sheet.nrows): + 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): + for i in range(1, len(row_data) - 2): tmp_filter.append(row_data[i].split(',')) tmp_filter.append(row_data[-2]) @@ -43,12 +64,27 @@ class parse_file(): filter_case.append(tmp_filter) + def set_support_case(self): + for row in range(self.support_sheet.nrows): + row_data = self.support_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]) + + support_case.append(tmp_filter) + + class check_case_skip(): + def __init__(self, Dut): self.dut = Dut self.comments = '' - def check_os(self,os_type): + def check_os(self, os_type): if 'all' == os_type[0].lower(): return True dut_os_type = self.dut.get_os_type() @@ -66,7 +102,7 @@ class check_case_skip(): else: return False - def check_target(self,target): + def check_target(self, target): if 'all' == target[0].lower(): return True if self.dut.target in target: @@ -82,7 +118,7 @@ class check_case_skip(): for key in check_function_dict.keys(): try: if 'message' == key: - continue + continue check_function = getattr(self, 'check_%s' % key) except: print "can't check %s type" % key @@ -91,10 +127,67 @@ class check_case_skip(): else: skip_flage = False break - if skip_flage: + + 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 + + +class check_case_support(check_case_skip): + + def __init__(self, Dut): + self.dut = Dut + self.comments = '' + + def case_support(self, case_name): + support_flag = True + for rule in support_case[1:]: + # check case name + if case_name == rule[0]: + for key in support_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[support_function_dict[key]]): + support_flag = True + else: + support_flag = False + break + + if support_flag is False: + if 'message' in support_function_dict: + for i in support_function_dict['message']: + self.comments += '%s,' % rule[i] + return support_flag + + return support_flag + + +class simple_dut(object): + + def __init__(self, os='', target='', nic=''): + self.ports_info = [{}] + self.os = os + self.target = target + self.ports_info[0]['type'] = nic + + def get_os_type(self): + return self.os + +if __name__ == "__main__": + dut = simple_dut( + os="linux", target='x86_64-native-linuxapp-gcc', nic='8086:1572') + check_case = parse_file() + check_case.set_filter_case() + check_case.set_support_case() + check_case_inst = check_case_skip(dut) + support_case_inst = check_case_support(dut) + print support_case_inst.case_support("l2pkt_detect") + print support_case_inst.comments -- 1.9.3