[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH XTF 3/3] xtf-runner: regularise runner exit code



On 21/07/2016 16:44, Wei Liu wrote:
> Report the first "ERROR" and "FAILURE" if found, otherwise report "SKIP"
> if found. Eventually if everything is ok the exit code will be 0.
>
> See runner code for numeric exit code space.
>
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  xtf-runner | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/xtf-runner b/xtf-runner
> index 17ce933..ebe5c27 100755
> --- a/xtf-runner
> +++ b/xtf-runner
> @@ -249,17 +249,23 @@ def run_tests(args):
>      if not len(tests):
>          raise RunnerError("No tests to run")
>  
> -    rc = 0
> +    rc = exit_code('SUCCESS')

This logic would be easier to express if you use the indices of
all_results as a measure of severity.

e.g.

rc = all_results.index('SUCCESS')

>      results = []
>  
>      for test in tests:
>  
>          res = run_test(test)
> -        if res != "SUCCESS":
> -            rc = 1
> +        if res in ("ERROR", "FAILURE") and rc == exit_code('SUCCESS'):
> +            rc = exit_code(res)

res_idx = all_results.index(res)
if res_idx > rc:
    rc = res_idx

>  
>          results.append(res)
>  
> +    if rc == exit_code('SUCCESS'):
> +        for res in results:
> +            if res == 'SKIP':
> +                rc = exit_code('SKIP')
> +                break
> +
>      print "\nCombined test results:"
>  
>      for test, res in zip(tests, results):

And down at the end here:

return exit_code(all_results[rc])

Finally, please update the epilog text in main() to enumerate the exit
codes.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.