From 6a5414c02584913483710602969d8b58d8cd5cdd Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Fri, 26 Apr 2019 12:29:01 +0100 Subject: [PATCH] exekall: Allow customization of run exit code exekall run on LISA will return with exit code 20 if an exception was raised during execution of any expression, and 10 if any of the ResultBundle.result is Result.FAILED. --- lisa/exekall_customize.py | 26 ++++++++++++++++++++++++-- tools/exekall/exekall/customization.py | 13 ++++++++++++- tools/exekall/exekall/main.py | 2 +- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lisa/exekall_customize.py b/lisa/exekall_customize.py index 9e9b1d6c5..72b5e8e95 100644 --- a/lisa/exekall_customize.py +++ b/lisa/exekall_customize.py @@ -30,11 +30,11 @@ from lisa.trace import FtraceCollector, FtraceConf from lisa.platforms.platinfo import PlatformInfo from lisa.utils import HideExekallID, Loggable, ArtifactPath, get_subclasses, groupby, Serializable from lisa.conf import MultiSrcConf -from lisa.tests.base import TestBundle, ResultBundle +from lisa.tests.base import TestBundle, ResultBundle, Result from lisa.tests.scheduler.load_tracking import InvarianceItem from lisa.regression import compute_regressions -from exekall.utils import get_name, get_method_class, add_argument +from exekall.utils import get_name, get_method_class, add_argument, NoValue, flatten_seq from exekall.engine import ExprData, Consumer, PrebuiltOperator from exekall.customization import AdaptorBase @@ -367,3 +367,25 @@ comparison. Can be repeated.""") tags = {k: v for k, v in tags.items() if v is not None} return tags + + def get_run_exit_code(self, result_map): + expr_val_list = flatten_seq( + expr_val_list + for expr, expr_val_list in result_map.items() + ) + + for expr_val in expr_val_list: + # An exception happened + if expr_val.get_excep(): + return 20 + + val = expr_val.value + if isinstance(val, ResultBundle): + if val.result is Result.FAILED: + return 10 + return 0 + + + + + diff --git a/tools/exekall/exekall/customization.py b/tools/exekall/exekall/customization.py index 343a47f37..b0cf5291d 100644 --- a/tools/exekall/exekall/customization.py +++ b/tools/exekall/exekall/customization.py @@ -201,7 +201,7 @@ class AdaptorBase: :param result_map: Dictionary of expressions to the list of their values. :type result_map: dict(exekall.engine.ComputableExpression, - exekall.engine.ExprVal) + list(exekall.engine.ExprVal)) """ hidden_callable_set = { op.callable_ @@ -233,6 +233,17 @@ class AdaptorBase: )) return '\n'.join(summary) + def get_run_exit_code(self, result_map): + """ + Return an integer used as ``exekall run`` exit status. + + :param result_map: Dictionary of expressions to the list of their + values. + :type result_map: dict(exekall.engine.ComputableExpression, + exekall.engine.ExprVal) + """ + return 0 + @classmethod def get_adaptor_cls(cls, name=None): """ diff --git a/tools/exekall/exekall/main.py b/tools/exekall/exekall/main.py index 7ba064b0b..92d8af8dc 100755 --- a/tools/exekall/exekall/main.py +++ b/tools/exekall/exekall/main.py @@ -1142,7 +1142,7 @@ def exec_expr_list(iteration_expr_list, adaptor, artifact_dir, testsession_uuid, with script_path.open('wt', encoding='utf-8') as f: f.write(all_scripts + '\n') - return 0 + return adaptor.get_run_exit_code(result_map) SILENT_EXCEPTIONS = (KeyboardInterrupt, BrokenPipeError) GENERIC_ERROR_CODE = 1 -- GitLab