Fix a couple bugs found when turning on archiving for nplus1 updates from cbuildbot.
1) Change join marker from -- to _ as it's much more human readable.
-- meaning payloads look like chromeos_R16-1024.0.0-a1_x86-zgb_full_dev.bin
2) Reading from last local build wasn't working correctly as I wasn't passing
any information about the folder (no name was embedded so no version). Fixed
to archive into latest_download/<version>/chromiumos_test_image.bin. This
also had the side-benefit of not having to have me repro this each time I test
a change.
3) New 3-version logic had broken my regexp unnoticed.
BUG=chromium-os:19958
TEST=Ran ctest with local copy of what's stored on one of the builders.
Change-Id: Idcfbb8d01ed805200af7df107da4e55286fc2dc5
Reviewed-on: http://gerrit.chromium.org/gerrit/10149
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
diff --git a/ctest/ctest.py b/ctest/ctest.py
index a0fd710..984a4ac 100755
--- a/ctest/ctest.py
+++ b/ctest/ctest.py
@@ -33,7 +33,7 @@
def GetLatestImage(self):
"""Gets the latest archive image for the board."""
- my_re = re.compile(r'(\d+)\.(\d+)\.(\d+).*')
+ my_re = re.compile(r'R\d+-(\d+)\.(\d+)\.(\d+).*')
def VersionCompare(version):
return map(int, my_re.match(version).groups())
@@ -48,18 +48,28 @@
def UnzipImage(self, image_dir):
"""Unzips the image.zip from the image_dir and returns the image."""
- local_path = 'latest_image'
- if os.path.isdir(local_path):
- logging.info('Removing cached image from %s', local_path)
- shutil.rmtree(local_path)
+ archive_dir = 'latest_image'
+ # We include the dirname of the image here so that we don't have to
+ # re-unzip the same one each time.
+ local_path = os.path.join(archive_dir, os.path.basename(image_dir))
+ image_to_return = os.path.abspath(os.path.join(local_path,
+ self.IMAGE_TO_EXTRACT))
+ # We only unzip it if we don't have it.
+ if not os.path.exists(image_to_return):
+ # We don't want to keep test archives around.
+ if os.path.exists(archive_dir):
+ logging.info('Removing old archive from %s', archive_dir)
+ shutil.rmtree(archive_dir)
- os.makedirs(local_path)
- zip_path = os.path.join(image_dir, 'image.zip')
- logging.info('Unzipping image from %s', zip_path)
- chromite_build_lib.RunCommand(['unzip', '-d', local_path, zip_path],
- print_cmd=False)
+ logging.info('Creating directory %s to store image for testing.',
+ local_path)
+ os.makedirs(local_path)
+ zip_path = os.path.join(image_dir, 'image.zip')
+ logging.info('Unzipping image from %s', zip_path)
+ chromite_build_lib.RunCommand(['unzip', '-d', local_path, zip_path],
+ print_cmd=False)
- return os.path.abspath(os.path.join(local_path, self.IMAGE_TO_EXTRACT))
+ return image_to_return
class TestException(Exception):
diff --git a/generate_test_payloads/cros_generate_test_payloads.py b/generate_test_payloads/cros_generate_test_payloads.py
index 11da86d..efaa386 100755
--- a/generate_test_payloads/cros_generate_test_payloads.py
+++ b/generate_test_payloads/cros_generate_test_payloads.py
@@ -54,7 +54,7 @@
archive_stateful: If set and archive is set, archive the stateful tarball
for the target image.
"""
- NAME_SPLITTER = '--'
+ NAME_SPLITTER = '_'
def __init__(self, target, base, key=None, archive=False,
archive_stateful=False):