autotest: servo.py: retry checking of recently set GPIOs
During debug of a FAFT flakiness we discovered that occasionally the setting of
warm_reset quietly failed its assertion. Turns out its due to the slow edge rate
of the pull-up and a fast read by servod to check the result.
This CL adds a retry loop for the read allowing for a maximum of a 1 second
settling time. It re-checks the value every 100ms in order to not overly delay
faster GPIOs.
For the the particular GPIO, warm_reset, I see only one retry when necessary and
its seen only 1 out of 4 times that I transistion warm_reset to off.
BUG=chromium-os:26808
TEST=run FAFT suite successfully via,
./run_remote_tests.sh suites/control.faft -a \
'servo_serial=498432-00031 xml_config=servo_stumpy_overlay.xml' \
--remote=<remote>
Change-Id: I57d363ebd6ef429e20b01d9f5d783576cc93ee42
Reviewed-on: https://gerrit.chromium.org/gerrit/16742
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Ready: Todd Broch <tbroch@chromium.org>
diff --git a/server/cros/servo.py b/server/cros/servo.py
index 707e974..35fd059 100644
--- a/server/cros/servo.py
+++ b/server/cros/servo.py
@@ -29,6 +29,7 @@
NORMAL_TRANSITION_DELAY = 1.2
# Maximum number of times to re-read power button on release.
RELEASE_RETRY_MAX = 5
+ GET_RETRY_MAX = 10
# Delays to deal with computer transitions.
SLEEP_DELAY = 6
@@ -275,8 +276,15 @@
def set(self, gpio_name, gpio_value):
"""Set and check the value of a gpio using Servod."""
self.set_nocheck(gpio_name, gpio_value)
- assert gpio_value == self.get(gpio_name), \
- 'Servo failed to set %s to %s' % (gpio_name, gpio_value)
+ retry_count = Servo.GET_RETRY_MAX
+ while gpio_value != self.get(gpio_name) and retry_count:
+ logging.warn("%s != %s, retry %d", gpio_name, gpio_value,
+ retry_count)
+ retry_count -= 1
+ time.sleep(Servo.SHORT_DELAY)
+ if not retry_count:
+ assert gpio_value == self.get(gpio_name), \
+ 'Servo failed to set %s to %s' % (gpio_name, gpio_value)
def set_nocheck(self, gpio_name, gpio_value):