deploy_chrome: Don't try to disable rootfs verification if target is writable
If the target dir is writable we don't need to disable rootfs verification and reboot.
BUG=chromium:436971
TEST=Steps in bug.
Change-Id: I0ab53242d0b737442b2279b925cd28d33df6f30c
Reviewed-on: https://chromium-review.googlesource.com/232004
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Robert Flack <flackr@chromium.org>
Reviewed-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Robert Flack <flackr@chromium.org>
diff --git a/scripts/deploy_chrome_unittest.py b/scripts/deploy_chrome_unittest.py
index 605fc4e..f9976ed 100755
--- a/scripts/deploy_chrome_unittest.py
+++ b/scripts/deploy_chrome_unittest.py
@@ -20,6 +20,7 @@
from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import partial_mock
+from chromite.lib import remote_access
from chromite.lib import remote_access_unittest
from chromite.lib import stats
from chromite.lib import stats_unittest
@@ -119,6 +120,7 @@
def __init__(self):
partial_mock.PartialMock.__init__(self)
+ self.remote_device_mock = remote_access_unittest.RemoteDeviceMock()
# Target starts off as having rootfs verification enabled.
self.rsh_mock = remote_access_unittest.RemoteShMock()
self.rsh_mock.SetDefaultCmdResult(0)
@@ -135,10 +137,12 @@
self.backup['_DisableRootfsVerification'](inst)
def PreStart(self):
+ self.remote_device_mock.start()
self.rsh_mock.start()
def PreStop(self):
self.rsh_mock.stop()
+ self.remote_device_mock.stop()
def _KillProcsIfNeeded(self, _inst):
# Fully stub out for now.
@@ -187,13 +191,13 @@
"""Test the working case, disabling rootfs verification."""
self.deploy_mock.MockMountCmd(0)
self.deploy._DisableRootfsVerification()
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
def testDisableRootfsVerificationFailure(self):
"""Test failure to disable rootfs verification."""
self.assertRaises(cros_build_lib.RunCommandError,
self.deploy._DisableRootfsVerification)
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
class TestMount(DeployTest):
@@ -201,22 +205,32 @@
def testSuccess(self):
"""Test case where we are able to mount as writable."""
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
self.deploy_mock.MockMountCmd(0)
self.deploy._MountRootfsAsWritable()
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
def testMountError(self):
"""Test that mount failure doesn't raise an exception by default."""
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
+ self.PatchObject(remote_access.RemoteDevice, 'IsPathWritable',
+ return_value=False, autospec=True)
self.deploy._MountRootfsAsWritable()
- self.assertTrue(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertTrue(self.deploy._target_dir_is_still_readonly.is_set())
def testMountRwFailure(self):
"""Test that mount failure raises an exception if error_code_ok=False."""
self.assertRaises(cros_build_lib.RunCommandError,
self.deploy._MountRootfsAsWritable, error_code_ok=False)
- self.assertFalse(self.deploy._rootfs_is_still_readonly.is_set())
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
+
+ def testMountTempDir(self):
+ """Test that mount succeeds if target dir is writable."""
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
+ self.PatchObject(remote_access.RemoteDevice, 'IsPathWritable',
+ return_value=True, autospec=True)
+ self.deploy._MountRootfsAsWritable()
+ self.assertFalse(self.deploy._target_dir_is_still_readonly.is_set())
class TestUiJobStarted(DeployTest):