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 A634837A8 for ; Thu, 29 Dec 2016 09:08:42 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 29 Dec 2016 00:08:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="1087740800" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by fmsmga001.fm.intel.com with ESMTP; 29 Dec 2016 00:08:40 -0800 From: Marvin Liu To: dts@dpdk.org Cc: Marvin Liu Date: Thu, 29 Dec 2016 16:09:46 +0800 Message-Id: <1482998987-21640-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH 1/2] framework settings: add support for global error status 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, 29 Dec 2016 08:08:43 -0000 Record error information in system environment variable. And changed system exit value according to what's kind of error met in execution process. Signed-off-by: Marvin Liu diff --git a/framework/settings.py b/framework/settings.py index e232364..df2a491 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -32,6 +32,7 @@ Folders for framework running enviornment. """ import os +import sys import re import socket @@ -194,7 +195,19 @@ HOST_NIC_SETTING = "DTS_HOST_NIC" DEBUG_SETTING = "DTS_DEBUG_ENABLE" DEBUG_CASE_SETTING = "DTS_DEBUGCASE_ENABLE" DPDK_RXMODE_SETTING = "DTS_DPDK_RXMODE" +DTS_ERROR_ENV = "DTS_RUNNING_ERROR" +""" +DTS global error table +""" +DTS_ERR_TBL = { + "GENERIC_ERR": 1, + "DPDK_BUILD_ERR" : 2, + "DUT_SETUP_ERR" : 3, + "TESTER_SETUP_ERR" : 4, + "SUITE_SETUP_ERR": 5, + "SUITE_EXECUTE_ERR": 6, +} def get_nic_name(type): """ @@ -271,6 +284,27 @@ def load_global_setting(key): return '' +def report_error(error): + """ + Report error when error occurred + """ + if error in DTS_ERR_TBL.keys(): + os.environ[DTS_ERROR_ENV] = error + else: + os.environ[DTS_ERROR_ENV] = "GENERIC_ERR" + + +def exit_error(): + """ + Set system exit value when error occurred + """ + if DTS_ERROR_ENV in os.environ.keys(): + ret_val = DTS_ERR_TBL[os.environ[DTS_ERROR_ENV]] + sys.exit(ret_val) + else: + sys.exit(0) + + def accepted_nic(pci_id): """ Return True if the pci_id is a known NIC card in the settings file and if -- 1.9.3