Skip to content

Commit b66e122

Browse files
bridadanc1728p9
authored andcommitted
Allow a host test to reset the device under test
Add a host test reset function to allow the current DUT to be reset. This allow unexpected power loss to be tested.
1 parent c1aa092 commit b66e122

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

mbed_host_tests/host_tests/base_host_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ def reset_dut(self, value):
6464
if self.__event_queue:
6565
self.__event_queue.put(('__reset_dut', value, time()))
6666

67+
def reset(self):
68+
"""
69+
Reset device under test
70+
:return:
71+
"""
72+
if self.__event_queue:
73+
self.__event_queue.put(("__reset", "0", time()))
74+
6775
def notify_conn_lost(self, text):
6876
"""! Notify main even loop that there was a DUT-host test connection error
6977
@param consume If True htrun will process (consume) all remaining events

mbed_host_tests/host_tests_conn_proxy/conn_primitive.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def flush(self):
6767
"""! Flush read/write channels of DUT """
6868
raise NotImplementedError
6969

70+
def reset(self):
71+
"""! Reset the dut
72+
"""
73+
raise NotImplementedError
74+
7075
def connected(self):
7176
"""! Check if there is a connection to DUT
7277
@return True if there is conenction to DUT (read/write/flush API works)
@@ -83,4 +88,3 @@ def finish(self):
8388
"""! Handle DUT dtor like (close resource) operations here
8489
"""
8590
raise NotImplementedError
86-

mbed_host_tests/host_tests_conn_proxy/conn_primitive_remote.py

+3
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,8 @@ def finish(self):
160160
except self.remote_module.resources.ResourceError as e:
161161
self.logger.prn_err("RemoteConnectorPrimitive.finish() failed, reason: " + str(e))
162162

163+
def reset(self):
164+
self.__remote_reset()
165+
163166
def __del__(self):
164167
self.finish()

mbed_host_tests/host_tests_conn_proxy/conn_primitive_serial.py

+3
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,8 @@ def finish(self):
137137
if self.serial:
138138
self.serial.close()
139139

140+
def reset(self):
141+
self.reset_dev_via_serial(self.forced_reset_timeout)
142+
140143
def __del__(self):
141144
self.finish()

mbed_host_tests/host_tests_conn_proxy/conn_proxy.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,15 @@ def __send_sync(timeout=None):
231231
else:
232232
# Return if state machine in host_test_default has finished to end process
233233
if key == '__host_test_finished' and value == True:
234-
logger.prn_inf("received special even '%s' value='%s', finishing"% (key, value))
234+
logger.prn_inf("received special event '%s' value='%s', finishing"% (key, value))
235235
connector.finish()
236236
return 0
237-
if not connector.write_kv(key, value):
237+
elif key == '__reset':
238+
logger.prn_inf("received special event '%s', resetting dut" % (key))
239+
connector.reset()
240+
event_queue.put(("reset_complete", 0, time()))
241+
elif not connector.write_kv(key, value):
242+
connector.write_kv(key, value)
238243
__notify_conn_lost()
239244
break
240245

mbed_host_tests/host_tests_runner/host_test_default.py

+3
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ def process_code_coverage(key, value, timestamp):
366366
self.logger.prn_inf("%s(%s)" % (key, str(value)))
367367
result = value
368368
event_queue.put(('__exit_event_queue', 0, time()))
369+
elif key == '__reset':
370+
# This event only resets the dut, not the host test
371+
dut_event_queue.put(('__reset', True, time()))
369372
elif key == '__reset_dut':
370373
# Disconnect to avoid connection lost event
371374
dut_event_queue.put(('__host_test_finished', True, time()))

0 commit comments

Comments
 (0)