* [dts] [PATCH 1/2] framework settings: add support for global error status
@ 2016-12-29 8:09 Marvin Liu
2016-12-29 8:09 ` [dts] [PATCH 2/2] framework dts: report error in execution process Marvin Liu
2017-01-04 3:31 ` [dts] [PATCH 1/2] framework settings: add support for global error status Liu, Yong
0 siblings, 2 replies; 3+ messages in thread
From: Marvin Liu @ 2016-12-29 8:09 UTC (permalink / raw)
To: dts; +Cc: Marvin Liu
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 <yong.liu@intel.com>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [dts] [PATCH 2/2] framework dts: report error in execution process
2016-12-29 8:09 [dts] [PATCH 1/2] framework settings: add support for global error status Marvin Liu
@ 2016-12-29 8:09 ` Marvin Liu
2017-01-04 3:31 ` [dts] [PATCH 1/2] framework settings: add support for global error status Liu, Yong
1 sibling, 0 replies; 3+ messages in thread
From: Marvin Liu @ 2016-12-29 8:09 UTC (permalink / raw)
To: dts; +Cc: Marvin Liu
Add error report in execution process, now framework report
build/setup/execution/generic errors. When those types of error
happened, system exit value will be changed as pre-defined value in
settings module.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/dts.py b/framework/dts.py
index e9879e5..369599d 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -51,7 +51,6 @@ from test_case import TestCase
from test_result import Result
from stats_reporter import StatsReporter
from excel_reporter import ExcelReporter
-import utils
from exception import TimeoutException, ConfigParseException, VerifyFailure
from logger import getLogger
import logger
@@ -316,6 +315,14 @@ def dts_run_prerequisties(duts, tester, pkgName, patch, dts_commands, serializer
dts_run_commands(tester, dts_commands)
tester.prerequisites()
dts_run_commands(tester, dts_commands)
+ except Exception as ex:
+ log_handler.error(" PREREQ EXCEPTION " + traceback.format_exc())
+ log_handler.info('CACHE: Discarding cache.')
+ serializer.discard_cache()
+ settings.report_error("TESTER_SETUP_ERR")
+ return False
+
+ try:
for dutobj in duts:
dutobj.set_package(pkgName, patch)
dutobj.prerequisites()
@@ -327,6 +334,7 @@ def dts_run_prerequisties(duts, tester, pkgName, patch, dts_commands, serializer
result.add_failed_dut(duts[0], str(ex))
log_handler.info('CACHE: Discarding cache.')
serializer.discard_cache()
+ settings.report_error("DUT_SETUP_ERR")
return False
@@ -348,9 +356,11 @@ def dts_run_target(duts, tester, targets, test_suites):
dutobj.set_target(target)
except AssertionError as ex:
log_handler.error(" TARGET ERROR: " + str(ex))
+ settings.report_error("DPDK_BUILD_ERR")
result.add_failed_target(result.dut, target, str(ex))
continue
except Exception as ex:
+ settings.report_error("GENERIC_ERR")
log_handler.error(" !!! DEBUG IT: " + traceback.format_exc())
result.add_failed_target(result.dut, target, str(ex))
continue
@@ -395,6 +405,7 @@ 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:
+ settings.report_error("SUITE_EXECUTE_ERR")
log_handler.error(" !!! DEBUG IT: " + traceback.format_exc())
except KeyboardInterrupt:
# stop/save result/skip execution
@@ -403,6 +414,7 @@ def dts_run_suite(duts, tester, test_suites, target):
save_all_results()
break
except Exception as e:
+ settings.report_error("GENERIC_ERR")
log_handler.error(str(e))
finally:
suite_obj.execute_tear_downall()
@@ -510,7 +522,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
duts, tester = dts_crbs_init(crbInsts, skip_setup, read_cache, project, base_dir, serializer, virttype)
# register exit action
- atexit.register(close_all_sessions, duts, tester)
+ atexit.register(quit_execution, duts, tester)
check_case_inst = check_case_skip(duts[0])
support_case_inst = check_case_support(duts[0])
@@ -547,9 +559,10 @@ def save_all_results():
stats_report.save(result)
-def close_all_sessions(duts, tester):
+def quit_execution(duts, tester):
"""
- Close session to DUT and tester.
+ Close session to DUT and tester before quit.
+ Return exit status when failure occurred.
"""
# close all nics
for dutobj in duts:
@@ -562,3 +575,6 @@ def close_all_sessions(duts, tester):
if tester is not None:
tester.close()
log_handler.info("DTS ended")
+
+ # return value
+ settings.exit_error()
--
1.9.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dts] [PATCH 1/2] framework settings: add support for global error status
2016-12-29 8:09 [dts] [PATCH 1/2] framework settings: add support for global error status Marvin Liu
2016-12-29 8:09 ` [dts] [PATCH 2/2] framework dts: report error in execution process Marvin Liu
@ 2017-01-04 3:31 ` Liu, Yong
1 sibling, 0 replies; 3+ messages in thread
From: Liu, Yong @ 2017-01-04 3:31 UTC (permalink / raw)
To: dts
Applied into master branch.
-----Original Message-----
From: Liu, Yong
Sent: Thursday, December 29, 2016 4:10 PM
To: dts@dpdk.org
Cc: Liu, Yong <yong.liu@intel.com>
Subject: [dts][PATCH 1/2] framework settings: add support for global error status
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 <yong.liu@intel.com>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-04 3:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-29 8:09 [dts] [PATCH 1/2] framework settings: add support for global error status Marvin Liu
2016-12-29 8:09 ` [dts] [PATCH 2/2] framework dts: report error in execution process Marvin Liu
2017-01-04 3:31 ` [dts] [PATCH 1/2] framework settings: add support for global error status Liu, Yong
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).