aboutsummaryrefslogtreecommitdiff
path: root/crosperf/download_images_unittest.py
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2016-11-02 10:03:17 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-11-07 13:31:02 -0800
commit4b133961b76c2cb8bc58f0ea2cded9e3438ffb6f (patch)
treeeb560da8a69b754f33a31e3e44ae7bffa7282753 /crosperf/download_images_unittest.py
parentc39917fe61858e884d06656122cf88a8c66fd825 (diff)
downloadtoolchain-utils-4b133961b76c2cb8bc58f0ea2cded9e3438ffb6f.tar.gz
Download autotest files with crosperf and add autotest path to test_that
when running non-telemetry tests BUG: chromium:647429 TEST:crosperf unit tests, sample experiment file that runs WebGl_Aquarium Change-Id: I067e350fee36596ce269b954773c39a3868632aa Reviewed-on: https://chrome-internal-review.googlesource.com/302296 Commit-Ready: Manoj Gupta <manojgupta@google.com> Tested-by: Manoj Gupta <manojgupta@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf/download_images_unittest.py')
-rwxr-xr-xcrosperf/download_images_unittest.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/crosperf/download_images_unittest.py b/crosperf/download_images_unittest.py
index 06ea5bb7..fbf2ec79 100755
--- a/crosperf/download_images_unittest.py
+++ b/crosperf/download_images_unittest.py
@@ -137,11 +137,14 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Set test arguments
test_chroot = '/usr/local/home/chromeos'
test_build_id = 'remote/lumpy/latest-dev'
+ test_empty_autotest_path = ''
+ test_autotest_path = '/tmp/autotest'
# Set values to test/check.
self.called_download_image = False
self.called_uncompress_image = False
self.called_get_build_id = False
+ self.called_download_autotest_files = False
# Define fake stub functions for Run to call
def FakeGetBuildID(unused_root, unused_xbuddy_label):
@@ -166,6 +169,12 @@ class ImageDownloaderTestcast(unittest.TestCase):
self.called_uncompress_image = True
return 0
+ def FakeDownloadAutotestFiles(root, build_id):
+ if root or build_id:
+ pass
+ self.called_download_autotest_files = True
+ return 'autotest'
+
# Initialize downloader
downloader = download_images.ImageDownloader(logger_to_use=MOCK_LOGGER)
@@ -173,26 +182,45 @@ class ImageDownloaderTestcast(unittest.TestCase):
downloader.GetBuildID = FakeGetBuildID
downloader.UncompressImage = FakeUncompressImage
downloader.DownloadImage = GoodDownloadImage
+ downloader.DownloadAutotestFiles = FakeDownloadAutotestFiles
# Call Run.
- downloader.Run(test_chroot, test_build_id)
+ image_path, autotest_path = downloader.Run(test_chroot, test_build_id,
+ test_empty_autotest_path)
# Make sure it called both _DownloadImage and _UncompressImage
self.assertTrue(self.called_download_image)
self.assertTrue(self.called_uncompress_image)
+ # Make sure it called DownloadAutotestFiles
+ self.assertTrue(self.called_download_autotest_files)
+ # Make sure it returned a autotest path returned from this call
+ self.assertTrue(autotest_path == 'autotest')
+
+ # Call Run with a non-empty autotest path
+ self.called_download_autotest_files = False
+
+ image_path, autotest_path = downloader.Run(test_chroot, test_build_id,
+ test_autotest_path)
+
+ # Verify that downloadAutotestFiles was not called
+ self.assertFalse(self.called_download_autotest_files)
+ # Make sure it returned the specified autotest path returned from this call
+ self.assertTrue(autotest_path == test_autotest_path)
# Reset values; Now use fake stub that simulates DownloadImage failing.
self.called_download_image = False
self.called_uncompress_image = False
+ self.called_download_autotest_files = False
downloader.DownloadImage = BadDownloadImage
# Call Run again.
self.assertRaises(download_images.MissingImage, downloader.Run, test_chroot,
- test_build_id)
+ test_autotest_path, test_build_id)
- # Verify that UncompressImage was not called, since _DownloadImage "failed"
+ # Verify that UncompressImage and downloadAutotestFiles was not called, since _DownloadImage "failed"
self.assertTrue(self.called_download_image)
self.assertFalse(self.called_uncompress_image)
+ self.assertFalse(self.called_download_autotest_files)
if __name__ == '__main__':