nasa / fprime

F´ - A flight software and embedded systems framework

Home Page:https://nasa.github.io/fprime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration Test API: Better Timeout implementation

LeStarch opened this issue · comments

Presently timeouts are using the signal library and throw an exception to end the search. This timeout behavior can be modified very easily by changing the __search_test_history method. All searches use this method to accomplish scoping, logging and history substitution. Changing the timeout to something like below would be better.

# in IntegrationTestAPI's __search_test_history method on ~line 912 of api.py
if timeout:
    self.__log(name + " now awaiting for at most {} s.".format(timeout))
    end_time = time.time() + timeout
    while True:
        new_items = history.retrieve_new()
        for item in new_items:
            if searcher.incremental_search(item):
                return searcher.get_return_value()
        if time.time() >= end_time:
            msg = name + " timed out and ended unsuccessfully."
            self.__log(msg, TestLogger.YELLOW)
            break
        time.sleep(0.1)
else:
    self.__log(name + " ended unsuccessfully.", TestLogger.YELLOW)
return searcher.get_return_value()

NOTE: The above code hasn't been tested and may have issues if the system time changes: time.time().