xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH XTF 2/3] xtf-runner: provide a set of exit codes for different states
Date: Thu, 21 Jul 2016 19:56:54 +0100	[thread overview]
Message-ID: <b54bea89-f688-08d6-74c9-f8efd5027e9d@citrix.com> (raw)
In-Reply-To: <1469115891-2269-3-git-send-email-wei.liu2@citrix.com>

On 21/07/2016 16:44, Wei Liu wrote:
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  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@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-21 18:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-21 15:44 [PATCH XTF 0/3] Runner exit code clean up Wei Liu
2016-07-21 15:44 ` [PATCH XTF 1/3] xtf-runner: sync all test states Wei Liu
2016-07-21 18:49   ` Andrew Cooper
2016-07-21 15:44 ` [PATCH XTF 2/3] xtf-runner: provide a set of exit codes for different states Wei Liu
2016-07-21 16:27   ` Ian Jackson
2016-07-21 16:29     ` Wei Liu
2016-07-21 16:37       ` Wei Liu
2016-07-21 18:56   ` Andrew Cooper [this message]
2016-07-21 15:44 ` [PATCH XTF 3/3] xtf-runner: regularise runner exit code Wei Liu
2016-07-21 19:04   ` Andrew Cooper
2016-07-22  9:29     ` Wei Liu
2016-07-22  9:35       ` Andrew Cooper
2016-07-25 11:25         ` Ian Jackson
2016-07-25 12:09           ` Andrew Cooper
2016-07-25 17:05             ` Ian Jackson
2016-07-26  8:57               ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b54bea89-f688-08d6-74c9-f8efd5027e9d@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).