summaryrefslogtreecommitdiff
path: root/lib/remote_access_unittest.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2015-05-12 00:30:53 -0400
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-13 08:36:08 +0000
commitc99cacbd0c7177fa0fc1df4957e47a1bd0270236 (patch)
treecaad6d3704380ae73609288d7e3d45a0e5e49a13 /lib/remote_access_unittest.py
parent231348146015739254fd2978dd172975555e9bdc (diff)
downloadchromite-c99cacbd0c7177fa0fc1df4957e47a1bd0270236.tar.gz
remote_access: delay creation of remote temp paths
For some scenarios, we never actually need or use the remote tempdir. That means the time we spend creating it (two connections) is purely overhead. Lets turn these two paths into properties which will auto create them on the device on demand. BUG=brillo:985 TEST=`cros_debug` delays creation of paths until they're used TEST=`cros_debug` (w/other speedups) does not run `mkdir` or `mktemp` at all Change-Id: I6a91c070e29e9b2b86554f8322e5b90db4eb5f43 Reviewed-on: https://chromium-review.googlesource.com/270400 Trybot-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Yiming Chen <yimingc@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'lib/remote_access_unittest.py')
-rw-r--r--lib/remote_access_unittest.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/remote_access_unittest.py b/lib/remote_access_unittest.py
index 7f575ce2c..d02a52174 100644
--- a/lib/remote_access_unittest.py
+++ b/lib/remote_access_unittest.py
@@ -21,7 +21,7 @@ from chromite.lib import partial_mock
from chromite.lib import remote_access
-# pylint: disable=W0212
+# pylint: disable=protected-access
class TestNormalizePort(cros_test_lib.TestCase):
@@ -270,6 +270,21 @@ class RemoteDeviceTest(cros_test_lib.MockTestCase):
self.assertEqual(expected_output,
device.BaseRunCommand(['echo', 'foo']).output)
+ def testDelayedRemoteDirs(self):
+ """Tests the delayed creation of base_dir/work_dir."""
+ with remote_access.RemoteDeviceHandler('1.1.1.1', base_dir='/f') as device:
+ # Make sure we didn't talk to the remote yet.
+ self.assertEqual(self.rsh_mock.call_count, 0)
+
+ # The work dir will get automatically created when we use it.
+ self.rsh_mock.AddCmdResult(partial_mock.In('mkdir'))
+ self.rsh_mock.AddCmdResult(partial_mock.In('mktemp'))
+ _ = device.work_dir
+ self.assertEqual(self.rsh_mock.call_count, 2)
+
+ # Add a mock for the clean up logic.
+ self.rsh_mock.AddCmdResult(partial_mock.In('rm'))
+
class USBDeviceTestCase(mdns_unittest.mDnsTestCase):
"""Base class for USB device related tests."""