autotest: Check and update servo firmware before run verifiers
BUG=b/158616208
TEST=run local
./server/autoserv -s --host-info-subdir host_info_store -m chromeos1-row4-rack1-host5 --lab True --local-only-host-info True -v -r /tr/
./server/autoserv -s --host-info-subdir host_info_store -m chromeos1-row4-rack1-host3 --lab True --local-only-host-info True -v -r /tr/
Change-Id: I4fdaaaa6ae7548b04c88ee9798e144ac8c7e59f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2274194
Commit-Queue: Otabek Kasimov <otabek@google.com>
Tested-by: Otabek Kasimov <otabek@google.com>
Auto-Submit: Otabek Kasimov <otabek@google.com>
Reviewed-by: Garry Wang <xianuowang@chromium.org>
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 56bb32e..b3e4868 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -30,6 +30,7 @@
from autotest_lib.server.hosts import servo_constants
from autotest_lib.server.cros.faft.utils import config
from autotest_lib.client.common_lib import global_config
+from autotest_lib.site_utils.admin_audit import servo_updater
try:
from chromite.lib import metrics
@@ -1392,6 +1393,8 @@
caller.
@param try_servo_repair If true, check a servo host with
`repair()` instead of `verify()`.
+ @param dut_host_info: A HostInfo object of the DUT that connected
+ to this servo.
@returns: A ServoHost object or None. See comments above.
@@ -1446,6 +1449,15 @@
if dut:
newhost.set_dut_hostname(dut.hostname)
+ if try_lab_servo or try_servo_repair:
+ try:
+ logging.info("Check and update servo firmware.")
+ servo_updater.update_servo_firmware(
+ newhost,
+ force_update=False)
+ except Exception as e:
+ logging.error("Servo device update error: %s", e)
+
try:
newhost.restart_servod(quick_startup=True)
except error.AutoservSSHTimeout: