|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH XTF 2/3] xtf-runner: provide a set of exit codes for different states
On 21/07/2016 16:44, Wei Liu wrote:
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
> xtf-runner | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/xtf-runner b/xtf-runner
> index ad7dcf9..17ce933 100755
> --- a/xtf-runner
> +++ b/xtf-runner
> @@ -21,6 +21,14 @@ except ImportError:
> # Note that warning is not a state on its own.
> all_states = [ 'SUCCESS', 'SKIP', 'ERROR', 'FAILURE' ]
>
> +# Return the exit code for different states.
> +# Avoid using 1 and 2 because python interpreter uses them.
> +def exit_code(state):
> + if state == 'SUCCESS': return 0
> + if state == 'SKIP': return 3
> + if state == 'ERROR': return 4
> + if state == 'FAILURE': return 5
You can make a pseudo switch statement with a dictionary by doing:
def exit_code(state):
""" Convert a test result to an xtf-runner exit code. """
return { "SUCCESS": 0,
"SKIP": 3,
"ERROR": 4,
"FAILURE": 5,
}.get(state, 4)
This also causes the default return value in the case that state isn't
matched to be ERROR, rather than None which translates to 0 when the
process exists.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |