From 53fcd0928b67a57ed1025dd4cad3df50ea020642 Mon Sep 17 00:00:00 2001 From: zshi Date: Thu, 3 Nov 2016 16:46:19 +0800 Subject: dovetail tool: ensure sub_testcase_list and testcase are not None JIRA: DOVETAIL-52 1) save return value of testcase.sub_testcase() in sub_testcase_list for multiple calls later 2) ensure sub_testcase_list is not called with None value 3) ensure testcase is not called with None value 4) identify None testcase with 'Undefined' in dovetail_report.txt Change-Id: Ifcf0c0846dc788575310f29932a4757752f1e3a3 Signed-off-by: zshi --- dovetail/report.py | 27 ++++++++++++++++++--------- dovetail/run.py | 4 ++++ 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'dovetail') diff --git a/dovetail/report.py b/dovetail/report.py index 9ea90231..eae8d180 100644 --- a/dovetail/report.py +++ b/dovetail/report.py @@ -38,14 +38,21 @@ class Report: @classmethod def generate(cls, scenario_yaml): report = '' + split_line = '+-----------------------------------------------------' + split_line += '---------------------+\n' report += '\n\ +==========================================================================+\n\ -| report |\n\ -+--------------------------------------------------------------------------+\n' +| report |\n' + report += split_line report += '|scenario: %s\n' % scenario_yaml['name'] for testcase_name in scenario_yaml['testcase_list']: testcase = Testcase.get(testcase_name) + if testcase is None: + report += '| [testcase]: %s\t\t\t\t[Undefined]\n' % \ + (testcase_name) + report += split_line + continue report += '| [testcase]: %s\t\t\t\t[%s]\n' % \ (testcase_name, get_pass_str(testcase.passed())) report += '| |-objective: %s\n' % testcase.objective() @@ -54,8 +61,7 @@ class Report: report += '| |-%s \t\t [%s]\n' % \ (subtest, get_pass_str(testcase.sub_testcase_passed(subtest))) - report += '+-----------------------------------------------------' - report += '---------------------+\n' + report += split_line logger.info(report) cls.save(report) @@ -224,23 +230,26 @@ class ResultChecker: class FunctestChecker: def check(cls, testcase, db_result): + sub_testcase_list = testcase.sub_testcase() + if not db_result: - for sub_testcase in testcase.sub_testcase(): - testcase.sub_testcase_passed(sub_testcase, False) + if sub_testcase_list is not None: + for sub_testcase in sub_testcase_list: + testcase.sub_testcase_passed(sub_testcase, False) return testcase.passed(db_result['criteria'] == 'PASS') - if testcase.sub_testcase() is None: + if sub_testcase_list is None: return if testcase.testcase['passed'] is True: - for sub_testcase in testcase.sub_testcase(): + for sub_testcase in sub_testcase_list: testcase.sub_testcase_passed(sub_testcase, True) return all_passed = True - for sub_testcase in testcase.sub_testcase(): + for sub_testcase in sub_testcase_list: logger.debug('check sub_testcase:%s' % sub_testcase) if sub_testcase in db_result['details']['errors']: testcase.sub_testcase_passed(sub_testcase, False) diff --git a/dovetail/run.py b/dovetail/run.py index 39dec07c..310ef2aa 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -37,6 +37,10 @@ def run_test(scenario): for testcase_name in scenario['testcase_list']: logger.info('>>[testcase]: %s' % (testcase_name)) testcase = Testcase.get(testcase_name) + if testcase is None: + logger.error('testcase %s is not defined in testcase folder, \ + skipping' % (testcase_name)) + continue run_testcase = True if testcase.exceed_max_retry_times(): -- cgit 1.2.3-korg