From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 5BAAB2C0C for ; Thu, 4 Aug 2016 15:18:44 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 04 Aug 2016 06:18:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,470,1464678000"; d="scan'208";a="1008358580" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 04 Aug 2016 06:18:42 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u74DIe8r030458; Thu, 4 Aug 2016 21:18:40 +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 u74DIcgS014741; Thu, 4 Aug 2016 21:18:40 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u74DIcHT014737; Thu, 4 Aug 2016 21:18:38 +0800 From: Marvin Liu To: dts@dpdk.org Cc: Marvin Liu Date: Thu, 4 Aug 2016 21:18:31 +0800 Message-Id: <1470316714-14698-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1470316714-14698-1-git-send-email-yong.liu@intel.com> References: <1470316714-14698-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 1/4] framework dts: fix program exit when exception raised 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: Thu, 04 Aug 2016 13:18:45 -0000 After handled test suite exception, dts should continue to next suite. Remove global configuration file object, it will be passed as parameter. When exit from suite, should call tear_down_all to stop everything. Signed-off-by: Marvin Liu diff --git a/framework/dts.py b/framework/dts.py index 6077a04..e9879e5 100644 --- a/framework/dts.py +++ b/framework/dts.py @@ -64,7 +64,6 @@ reload(sys) sys.setdefaultencoding('UTF8') -config = None requested_tests = None result = None excel_report = None @@ -72,7 +71,7 @@ stats_report = None log_handler = None -def dts_parse_param(section): +def dts_parse_param(config, section): """ Parse execution file parameters. """ @@ -112,7 +111,7 @@ def dts_parse_param(section): settings.save_global_setting(settings.FUNC_SETTING, 'no') -def dts_parse_config(section): +def dts_parse_config(config, section): """ Parse execution file configuration. """ @@ -369,8 +368,8 @@ def dts_run_suite(duts, tester, test_suites, target): """ Run each suite in test suite list. """ - try: - for suite_name in test_suites: + for suite_name in test_suites: + try: result.test_suite = suite_name suite_module = __import__('TestSuite_' + suite_name) for test_classname, test_class in get_subclasses(suite_module, TestCase): @@ -395,14 +394,19 @@ def dts_run_suite(duts, tester, test_suites, target): log_handler.info("\nTEST SUITE ENDED: " + test_classname) dts_log_execution(duts, tester, log_handler) - except VerifyFailure: - log_handler.error(" !!! DEBUG IT: " + traceback.format_exc()) - except KeyboardInterrupt: - log_handler.error(" !!! STOPPING DCTS") - except Exception as e: - log_handler.error(str(e)) - finally: - suite_obj.execute_tear_downall() + except VerifyFailure: + log_handler.error(" !!! DEBUG IT: " + traceback.format_exc()) + except KeyboardInterrupt: + # stop/save result/skip execution + log_handler.error(" !!! STOPPING DTS") + suite_obj.execute_tear_downall() + save_all_results() + break + except Exception as e: + log_handler.error(str(e)) + finally: + suite_obj.execute_tear_downall() + save_all_results() def run_all(config_file, pkgName, git, patch, skip_setup, @@ -413,7 +417,6 @@ def run_all(config_file, pkgName, git, patch, skip_setup, Main process of DTS, it will run all test suites in the config file. """ - global config global requested_tests global result global excel_report @@ -442,9 +445,9 @@ def run_all(config_file, pkgName, git, patch, skip_setup, # enable debug mode if debug is True: - setting.set_local_variable(settings.DEBUG_SETTING, 'yes') + settings.save_global_setting(settings.DEBUG_SETTING, 'yes') if debugcase is True: - setting.set_local_variable(settings.DEBUG_CASE_SETTING, 'yes') + settings.save_global_setting(settings.DEBUG_CASE_SETTING, 'yes') # init log_handler handler if verbose is True: @@ -482,10 +485,10 @@ def run_all(config_file, pkgName, git, patch, skip_setup, # for all Exectuion sections for section in config.sections(): - dts_parse_param(section) + dts_parse_param(config, section) # verify if the delimiter is good if the lists are vertical - dutIPs, targets, test_suites = dts_parse_config(section) + dutIPs, targets, test_suites = dts_parse_config(config, section) for dutIP in dutIPs: log_handler.info("\nDUT " + dutIP) -- 1.9.3