Add a helpful "is_failure" function to log.py for checking if a test status should be considered a failure. Also added some comments and whitespace to make the related code a little clearer.
Signed-off-by: John Admanski <[email protected]> --- autotest/client/common_lib/log.py 2008-10-23 15:18:29.000000000 -0700 +++ autotest/client/common_lib/log.py 2010-08-18 09:15:07.000000000 -0700 @@ -1,17 +1,29 @@ import sys, re, traceback - +# these statuses are ordered such that a status earlier in the list will +# override a status later in a list (e.g. ERROR during a test will override +# prior GOOD results, but WARN will not override a FAIL) job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT", "RUNNING", "NOSTATUS"] def is_valid_status(status): - if not re.match(r'(START|INFO|(END )?('+'|'.join(job_statuses)+'))$', + if not re.match(r'(START|INFO|(END )?(' + '|'.join(job_statuses) + '))$', status): return False else: return True +def is_failure(status): + if not is_valid_status(status): + return False + if status in ('START', 'INFO'): + return False + if status.startswith('END '): + status = status[len('END '):] + return job_statuses.index(status) <= job_statuses.index("FAIL") + + def record(fn): """ Generic method decorator for logging calls under the _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
