Skip to content

Allow a host test to reset the device under test #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mbed_host_tests/host_tests/base_host_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def reset_dut(self, value):
if self.__event_queue:
self.__event_queue.put(('__reset_dut', value, time()))

def reset(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I wrote this code pretty hastily, but let's get the keys matching the function names if at all possible.

Can we make this function soft_reset_dut?

This would mean you'd need to update your custom host test as well.

"""
Reset the device under test and continue running the host test
:return:
"""
if self.__event_queue:
self.__event_queue.put(("__reset", "0", time()))

def notify_conn_lost(self, text):
"""! Notify main even loop that there was a DUT-host test connection error
@param consume If True htrun will process (consume) all remaining events
Expand Down
6 changes: 5 additions & 1 deletion mbed_host_tests/host_tests_conn_proxy/conn_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def flush(self):
"""! Flush read/write channels of DUT """
raise NotImplementedError

def reset(self):
"""! Reset the dut
"""
raise NotImplementedError

def connected(self):
"""! Check if there is a connection to DUT
@return True if there is conenction to DUT (read/write/flush API works)
Expand All @@ -83,4 +88,3 @@ def finish(self):
"""! Handle DUT dtor like (close resource) operations here
"""
raise NotImplementedError

Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,8 @@ def finish(self):
except self.remote_module.resources.ResourceError as e:
self.logger.prn_err("RemoteConnectorPrimitive.finish() failed, reason: " + str(e))

def reset(self):
self.__remote_reset()

def __del__(self):
self.finish()
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,8 @@ def finish(self):
if self.serial:
self.serial.close()

def reset(self):
self.reset_dev_via_serial(self.forced_reset_timeout)

def __del__(self):
self.finish()
9 changes: 7 additions & 2 deletions mbed_host_tests/host_tests_conn_proxy/conn_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,15 @@ def __send_sync(timeout=None):
else:
# Return if state machine in host_test_default has finished to end process
if key == '__host_test_finished' and value == True:
logger.prn_inf("received special even '%s' value='%s', finishing"% (key, value))
logger.prn_inf("received special event '%s' value='%s', finishing"% (key, value))
connector.finish()
return 0
if not connector.write_kv(key, value):
elif key == '__reset':
logger.prn_inf("received special event '%s', resetting dut" % (key))
connector.reset()
event_queue.put(("reset_complete", 0, time()))
elif not connector.write_kv(key, value):
connector.write_kv(key, value)
__notify_conn_lost()
break

Expand Down
3 changes: 3 additions & 0 deletions mbed_host_tests/host_tests_runner/host_test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ def process_code_coverage(key, value, timestamp):
self.logger.prn_inf("%s(%s)" % (key, str(value)))
result = value
event_queue.put(('__exit_event_queue', 0, time()))
elif key == '__reset':
# This event only resets the dut, not the host test
dut_event_queue.put(('__reset', True, time()))
elif key == '__reset_dut':
# Disconnect to avoid connection lost event
dut_event_queue.put(('__host_test_finished', True, time()))
Expand Down