def testMakeAclDict(self):
   """Test generation of acls dictionary."""
   acls = cros_mark_android_as_stable.MakeAclDict(self.mock_android_dir)
   self.assertEquals(acls['ARM'], os.path.join(self.mock_android_dir,
                                               'googlestorage_acl_arm.txt'))
   self.assertEquals(acls['X86'], os.path.join(self.mock_android_dir,
                                               'googlestorage_acl_x86.txt'))
   self.assertEquals(acls['X86_INTERNAL'],
                     os.path.join(self.mock_android_dir,
                                  'googlestorage_acl_internal.txt'))
   self.assertEquals(acls['X86_NDK_TRANSLATION'],
                     os.path.join(self.mock_android_dir,
                                  'googlestorage_acl_internal.txt'))
   self.assertEquals(acls['X86_NDK_TRANSLATION_USERDEBUG'],
                     os.path.join(self.mock_android_dir,
                                  'googlestorage_acl_internal.txt'))
   # Test that all MST targets have their ACLs set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_MST_BUILD_BRANCH).keys():
     self.assertTrue(t in acls)
   # Test that all NYC targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_NYC_BUILD_BRANCH).keys():
     self.assertTrue(t in acls)
   # Test that all PI targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_PI_BUILD_BRANCH).keys():
     self.assertTrue(t in acls)
Beispiel #2
0
 def GetLatestAndroidVersion(self):
   """Returns the version of Android to uprev."""
   return cros_mark_android_as_stable.GetLatestBuild(
       constants.ANDROID_BUCKET_URL, self._run.config.android_import_branch,
       cros_mark_android_as_stable.MakeBuildTargetDict(
           self._run.config.android_package,
           self._run.config.android_import_branch))[0]
  def testMakeBuildTargetDictPI(self):
    """Test generation of PI build target dictionary.

    If the number of targets is correct and PI-specific targets are
    present, then the dictionary is correct.
    """
    targets = cros_mark_android_as_stable.MakeBuildTargetDict(
        constants.ANDROID_PI_BUILD_BRANCH)
    # Test the number of targets.
    self.assertEquals(len(targets),
                      len(constants.ANDROID_PI_BUILD_TARGETS))
    # Test that all PI-specific targets are in the dictionary.
    for target in constants.ANDROID_PI_BUILD_TARGETS:
      self.assertEquals(targets[target],
                        constants.ANDROID_PI_BUILD_TARGETS[target])
Beispiel #4
0
  def testMakeBuildTargetDictVMMst(self):
    """Test generation of VMMst build target dictionary.

    If the number of targets is correct and VMMst-specific targets are
    present, then the dictionary is correct.
    """
    targets = cros_mark_android_as_stable.MakeBuildTargetDict(
        'android-vm-master',
        constants.ANDROID_VMMST_BUILD_BRANCH)
    # Test the number of targets.
    self.assertEqual(len(targets),
                     len(constants.ANDROID_VMMST_BUILD_TARGETS))
    # Test that all VMMst-specific targets are in the dictionary.
    for target in constants.ANDROID_VMMST_BUILD_TARGETS:
      self.assertEqual(targets[target],
                       constants.ANDROID_VMMST_BUILD_TARGETS[target])
Beispiel #5
0
  def testMakeBuildTargetDictNYC(self):
    """Test generation of NYC build target dictionary.

    If the number of targets is correct and NYC-specific targets are present,
    then the dictionary is correct.
    """
    targets = cros_mark_android_as_stable.MakeBuildTargetDict(
        'android-container-nyc',
        constants.ANDROID_NYC_BUILD_BRANCH)
    # Test the number of targets.
    self.assertEqual(len(targets),
                     len(constants.ANDROID_NYC_BUILD_TARGETS))
    # Test that all NYC-specific targets are in the dictionary.
    for target in constants.ANDROID_NYC_BUILD_TARGETS:
      self.assertEqual(targets[target],
                       constants.ANDROID_NYC_BUILD_TARGETS[target])
Beispiel #6
0
 def testMakeAclDict(self):
   """Test generation of acls dictionary."""
   acls = cros_mark_android_as_stable.MakeAclDict(self.mock_android_dir)
   self.assertEqual(acls['ARM'], os.path.join(self.mock_android_dir,
                                              'googlestorage_acl_arm.txt'))
   self.assertEqual(acls['ARM64'], os.path.join(self.mock_android_dir,
                                                'googlestorage_acl_arm.txt'))
   self.assertEqual(acls['ARM64_USERDEBUG'],
                    os.path.join(self.mock_android_dir,
                                 'googlestorage_acl_arm.txt'))
   self.assertEqual(acls['X86'], os.path.join(self.mock_android_dir,
                                              'googlestorage_acl_x86.txt'))
   self.assertEqual(acls['X86_INTERNAL'],
                    os.path.join(self.mock_android_dir,
                                 'googlestorage_acl_internal.txt'))
   # Test that all MST targets have their ACLs set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_CONTAINER_PACKAGE_KEYWORD,
       constants.ANDROID_MST_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
   # Test that all NYC targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_CONTAINER_PACKAGE_KEYWORD,
       constants.ANDROID_NYC_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
   # Test that all PI targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_CONTAINER_PACKAGE_KEYWORD,
       constants.ANDROID_PI_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
   # Test that all QT targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_CONTAINER_PACKAGE_KEYWORD,
       constants.ANDROID_QT_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
   # Test that all VMPI targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_VM_PACKAGE_KEYWORD,
       constants.ANDROID_VMPI_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
   # Test that all VMMST targets have their ACLS set.
   for t in cros_mark_android_as_stable.MakeBuildTargetDict(
       constants.ANDROID_VM_PACKAGE_KEYWORD,
       constants.ANDROID_VMMST_BUILD_BRANCH).keys():
     self.assertIn(t, acls)
  def setUp(self):
    """Setup vars and create mock dir."""
    self.android_package = 'test_package'

    self.tmp_overlay = os.path.join(self.tempdir, 'chromiumos-overlay')
    self.mock_android_dir = os.path.join(
        self.tmp_overlay,
        portage_util.GetFullAndroidPortagePackageName(self.android_package))

    ebuild = os.path.join(self.mock_android_dir,
                          self.android_package + '-%s.ebuild')
    self.unstable = ebuild % '9999'
    self.old_version = '25'
    self.old = ebuild % self.old_version
    self.old2_version = '50'
    self.old2 = ebuild % self.old2_version
    self.new_version = '100'
    self.new = ebuild % ('%s-r1' % self.new_version)
    self.partial_new_version = '150'
    self.not_new_version = '200'

    osutils.WriteFile(self.unstable, self.unstable_data, makedirs=True)
    osutils.WriteFile(self.old, self.stable_data, makedirs=True)
    osutils.WriteFile(self.old2, self.stable_data, makedirs=True)

    self.internal_acl_data = '-g google.com:READ'
    self.arm_acl_data = '-g google.com:READ'
    self.x86_acl_data = '-g google.com:WRITE'
    self.cts_acl_data = '-g google.com:WRITE'
    self.arm_acl = os.path.join(self.mock_android_dir,
                                'googlestorage_arm_acl.txt')
    self.x86_acl = os.path.join(self.mock_android_dir,
                                'googlestorage_x86_acl.txt')
    self.internal_acl = os.path.join(self.mock_android_dir,
                                     'googlestorage_internal_acl.txt')
    self.cts_acl = os.path.join(self.mock_android_dir,
                                'googlestorage_cts_acl.txt')
    self.acls = {
        'ARM': self.arm_acl,
        'X86': self.x86_acl,
        'X86_NDK_TRANSLATION': self.internal_acl,
        'X86_INTERNAL': self.internal_acl,
        'X86_64': self.x86_acl,
        'X86_USERDEBUG': self.x86_acl,
        'X86_NDK_TRANSLATION_USERDEBUG': self.internal_acl,
        'X86_64_USERDEBUG': self.x86_acl,
        'AOSP_X86_USERDEBUG': self.x86_acl,
        'SDK_GOOGLE_X86_USERDEBUG': self.x86_acl,
        'SDK_GOOGLE_X86_64_USERDEBUG': self.x86_acl,
        'SDK_TOOLS': self.cts_acl,
    }

    osutils.WriteFile(self.arm_acl, self.arm_acl_data, makedirs=True)
    osutils.WriteFile(self.x86_acl, self.x86_acl_data, makedirs=True)
    osutils.WriteFile(self.cts_acl, self.cts_acl_data, makedirs=True)
    osutils.WriteFile(self.internal_acl, self.internal_acl_data, makedirs=True)

    self.bucket_url = 'gs://u'
    self.build_branch = constants.ANDROID_NYC_BUILD_BRANCH
    self.gs_mock = self.StartPatcher(gs_unittest.GSContextMock())
    self.arc_bucket_url = 'gs://a'
    self.targets = cros_mark_android_as_stable.MakeBuildTargetDict(
        self.build_branch).copy()
    # Internal targets share path with main targets.
    # Redefine them for decoupled testing.
    self.targets['X86_INTERNAL'] = (
        self.targets['X86_INTERNAL'][0] + '-internal',
        self.targets['X86_INTERNAL'][1])
    # We only test NYC targets, thus add ndk-translation targets from PI, so
    # that they are covered too.
    self.targets['X86_NDK_TRANSLATION'] = \
        constants.ANDROID_PI_BUILD_TARGETS['X86_NDK_TRANSLATION']
    self.targets['X86_NDK_TRANSLATION_USERDEBUG'] = \
        constants.ANDROID_PI_BUILD_TARGETS['X86_NDK_TRANSLATION_USERDEBUG']

    builds = {
        'ARM': [
            self.old_version, self.old2_version, self.new_version,
            self.partial_new_version
        ],
        'X86': [self.old_version, self.old2_version, self.new_version],
        'X86_NDK_TRANSLATION': [
            self.old_version, self.old2_version, self.new_version
        ],
        'X86_INTERNAL': [self.old_version, self.old2_version, self.new_version],
        'X86_64': [self.old_version, self.old2_version, self.new_version],
        'X86_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'X86_NDK_TRANSLATION_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'X86_64_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'AOSP_X86_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'SDK_GOOGLE_X86_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'SDK_GOOGLE_X86_64_USERDEBUG': [
            self.old_version, self.old2_version, self.new_version
        ],
        'SDK_TOOLS': [
            self.old_version, self.old2_version, self.new_version,
            self.partial_new_version
        ],
    }
    for build_type, builds in builds.iteritems():
      url = self.makeSrcTargetUrl(self.targets[build_type][0])
      builds = '\n'.join(os.path.join(url, version) for version in builds)
      self.gs_mock.AddCmdResult(['ls', '--', url], output=builds)

    for version in [self.old_version, self.old2_version, self.new_version]:
      for key in self.targets.iterkeys():
        self.setupMockBuild(key, version)
    self.new_subpaths = {
        'ARM': 'linux-cheets_arm-user100',
        'X86': 'linux-cheets_x86-user100',
        'X86_NDK_TRANSLATION': 'linux-cheets_x86_ndk_translation-user100',
        'X86_INTERNAL': 'linux-cheets_x86-user-internal100',
        'X86_64': 'linux-cheets_x86_64-user100',
        'X86_USERDEBUG': 'linux-cheets_x86-userdebug100',
        'X86_NDK_TRANSLATION_USERDEBUG':
        'linux-cheets_x86_ndk_translation-userdebug100',
        'X86_64_USERDEBUG': 'linux-cheets_x86_64-userdebug100',
        'AOSP_X86_USERDEBUG': 'linux-aosp_cheets_x86-userdebug100',
        'SDK_GOOGLE_X86_USERDEBUG': 'linux-sdk_google_cheets_x86-userdebug100',
        'SDK_GOOGLE_X86_64_USERDEBUG':
        'linux-sdk_google_cheets_x86_64-userdebug100',
        'SDK_TOOLS': 'linux-static_sdk_tools100',
    }

    self.setupMockBuild('ARM', self.partial_new_version)
    self.setupMockBuild('X86', self.partial_new_version, valid=False)
    self.setupMockBuild('X86_NDK_TRANSLATION', self.partial_new_version,
                        valid=False)
    self.setupMockBuild('X86_INTERNAL', self.partial_new_version, valid=False)
    self.setupMockBuild('X86_64', self.partial_new_version, valid=False)
    self.setupMockBuild('X86_USERDEBUG', self.partial_new_version, valid=False)
    self.setupMockBuild('X86_NDK_TRANSLATION_USERDEBUG',
                        self.partial_new_version, valid=False)
    self.setupMockBuild('X86_64_USERDEBUG', self.partial_new_version,
                        valid=False)
    self.setupMockBuild('AOSP_X86_USERDEBUG', self.partial_new_version,
                        valid=False)
    self.setupMockBuild('SDK_GOOGLE_X86_USERDEBUG', self.partial_new_version,
                        valid=False)
    self.setupMockBuild('SDK_GOOGLE_X86_64_USERDEBUG', self.partial_new_version,
                        valid=False)
    self.setupMockBuild('SDK_TOOLS', self.partial_new_version)

    for key in self.targets.iterkeys():
      self.setupMockBuild(key, self.not_new_version, False)