Tools: autotest: Added a generic run_test.

This function is called from every vehicle to run a test. If any of the tests throws an exception, it will be caught here, and the name of the test and the exception that got raised will be added to the fail_list
This commit is contained in:
Karthik Desai 2018-05-08 14:12:13 +02:00 committed by Peter Barker
parent b485867db3
commit 7a20dd8b73

View File

@ -668,6 +668,19 @@ class AutoTest(ABC):
self.progress("Failed to get EKF.flags=%u" % required_value)
raise AutoTestTimeoutException()
def run_test(self, desc, function):
self.progress("#")
self.progress("########## %s ##########" % (desc))
self.progress("#")
try:
function()
except Exception as e:
self.progress('FAILED: "%s": %s' % (desc, type(e).__name__))
self.fail_list.append( (desc, e) )
return
self.progress('PASSED: "%s"' % desc)
@abc.abstractmethod
def init(self):
"""Initilialize autotest feature."""