]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
xtf-runner: provide a set of exit codes for different results
authorWei Liu <wei.liu2@citrix.com>
Thu, 21 Jul 2016 15:06:19 +0000 (16:06 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Jul 2016 10:07:00 +0000 (11:07 +0100)
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xtf-runner

index c938f287be449eb44d65ba76f70dce9fbe3abf39..1c967508c79035f101a026864c2c764c0f7c7dbe 100755 (executable)
@@ -21,6 +21,16 @@ except ImportError:
 # Note that warning is not a result on its own.
 all_results = ('SUCCESS', 'SKIP', 'ERROR', 'FAILURE')
 
+# Return the exit code for different states.  Avoid using 1 and 2 because
+# python interpreter uses them -- see document for sys.exit.
+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)
+
 # All test categories and configurations
 all_categories   = ("special", "functional", "xsa", "utility")
 pv_environments  = ("pv64", "pv32pae")