faft: Refactoring soft reset test
Moved the states_list to be part of the plankton PD device class
similar to the changes for the hard_reset() method. In addition
added try/except clauses to method calls in the soft_reset test
script.
BRANCH=none
BUG=chrome-os-partner:50178
TEST=Manual
Tested with Samus to Plankton. Verfied that soft resets are initiated
and the state transition history can be used to verify expected operation.
Change-Id: I131f6b2784c77cfdb69210250d3dd5c11fd739c9
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340248
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
diff --git a/server/cros/servo/pd_device.py b/server/cros/servo/pd_device.py
index 7f9d5c9..0d0d51a 100644
--- a/server/cros/servo/pd_device.py
+++ b/server/cros/servo/pd_device.py
@@ -91,10 +91,9 @@
raise NotImplementedError(
'vbus_request should be implemented in derived class')
- def soft_reset(self, states_list=None):
+ def soft_reset(self):
"""Initates a PD soft reset sequence
- @param states_list: list of expected PD state transitions
"""
raise NotImplementedError(
'soft_reset should be implemented in derived class')
@@ -277,7 +276,7 @@
val = 'off'
return bool(val == m[0][1])
- def soft_reset(self, states_list=None):
+ def soft_reset(self):
"""Initates a PD soft reset sequence
To verify that a soft reset sequence was initiated, the
@@ -285,8 +284,6 @@
was acknowledged by its port pair. The connect state should
be same as it was prior to issuing the reset command.
- @param states_list: list of expected PD state transitions
-
@returns True if the port pair acknowledges the the reset message
and if following the command, the device returns to the same
connected state. False otherwise.
@@ -480,13 +477,36 @@
m = self.utils.send_pd_command_get_output(cmd, reply_exp)
return self._verify_state_sequence(states_list, m[0][0])
- def soft_reset(self, states_list):
+ def soft_reset(self):
"""Initates a PD soft reset sequence
- @param states_list: list of expected PD state transitions
-
@returns True if state transitions match, False otherwise
"""
+ snk_reset_states = [
+ 'SOFT_RESET',
+ 'SNK_DISCOVERY',
+ 'SNK_REQUESTED',
+ 'SNK_TRANSITION',
+ 'SNK_READY'
+ ]
+
+ src_reset_states = [
+ 'SOFT_RESET',
+ 'SRC_DISCOVERY',
+ 'SRC_NEGOCIATE',
+ 'SRC_ACCEPTED',
+ 'SRC_POWERED',
+ 'SRC_TRANSITION',
+ 'SRC_READY'
+ ]
+
+ if self.is_src():
+ states_list = src_reset_states
+ elif self.is_snk():
+ states_list = snk_reset_states
+ else:
+ raise error.TestFail('Port Pair not in a connected state')
+
cmd = 'pd %d soft' % self.port
return self._reset(cmd, states_list)