firmware_Cr50U2fPowerwash: Run test while logged in
This should fix the current test failures / flakiness,
and runs the test in the same way as the (recently updated)
firmware_IntegratedU2F.
BUG=b:134155812
TEST=test_that .. firmware_Cr50U2fPowerwash
Change-Id: I1b0bcc1e79492702aec9cd1e92c8b2acfe000a2e
Reviewed-on: https://chromium-review.googlesource.com/1731232
Tested-by: Louis Collard <louiscollard@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
diff --git a/client/common_lib/cros/g2f_utils.py b/client/common_lib/cros/g2f_utils.py
index 658a301..80f31ef 100644
--- a/client/common_lib/cros/g2f_utils.py
+++ b/client/common_lib/cros/g2f_utils.py
@@ -4,6 +4,14 @@
import time
+def ChromeOSLogin(client):
+ """Logs in to ChromeOS, so that u2fd can start up."""
+ client.run('/usr/local/autotest/bin/autologin.py')
+
+def ChromeOSLogout(client):
+ """Logs out of ChromeOS, to return the device to a known state."""
+ client.run('restart ui')
+
def StartU2fd(client):
"""Starts u2fd on the client.
diff --git a/server/site_tests/firmware_Cr50U2fPowerwash/firmware_Cr50U2fPowerwash.py b/server/site_tests/firmware_Cr50U2fPowerwash/firmware_Cr50U2fPowerwash.py
index e9a50f9..39076c1 100644
--- a/server/site_tests/firmware_Cr50U2fPowerwash/firmware_Cr50U2fPowerwash.py
+++ b/server/site_tests/firmware_Cr50U2fPowerwash/firmware_Cr50U2fPowerwash.py
@@ -6,7 +6,6 @@
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import g2f_utils
from autotest_lib.client.common_lib.cros import tpm_utils
-from autotest_lib.server import autotest
from autotest_lib.server import test
U2F_AUTH_ENFORCE=3
@@ -37,8 +36,8 @@
# Start by clearing TPM to make sure the device is in a known state.
tpm_utils.ClearTPMOwnerRequest(self.client, wait_for_ready=True)
- client_at = autotest.Autotest(self.client)
- client_at.run_test('login_LoginSuccess')
+ # u2fd reads files from the user's home dir, so we need to log in.
+ g2f_utils.ChromeOSLogin(self.client);
# U2fd does will not start normally if the device has not gone
# through OOBE. Force it to startup.
@@ -81,8 +80,8 @@
# key handle after this.
tpm_utils.ClearTPMOwnerRequest(self.client, wait_for_ready=True)
- client_at = autotest.Autotest(self.client)
- client_at.run_test('login_LoginSuccess')
+ # u2fd reads files from the user's home dir, so we need to log in.
+ g2f_utils.ChromeOSLogin(self.client)
# U2fd does will not start normally if the device has not gone
# through OOBE. Force it to startup.
@@ -100,3 +99,10 @@
if g2f_auth_clear.exit_status == 0:
raise error.TestError('Authenticate succeeded; should have failed')
+
+
+ def cleanup(self):
+ """Leave the device in a predictable state"""
+ g2f_utils.ChromeOSLogout(self.client)
+
+ super(firmware_Cr50U2fPowerwash, self).cleanup()