def testUpdateSDKWithChrome(self): """Test UpdateSDK old workspace version.""" self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=[ '--cache-dir', '/cache', '--chrome_root', '/chrome' ]) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ './update_chroot', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'CHROME_ORIGIN': 'LOCAL_SOURCE', 'FEATURES': ' -separatedebug splitdebug', 'USE': '-cros-debug chrome_internal chromeless_tty', }, cwd=self.workspace, )
def testFactoryBuildPackages(self): """Test building factory for an old workspace version.""" self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=[ '--cache-dir', '/cache', '--chrome_root', '/chrome' ]) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ './build_packages', '--board=board', '--accept_licenses=@CHROMEOS', '--skip_chroot_upgrade', '--nousepkg', 'virtual/target-os', 'virtual/target-os-dev', 'virtual/target-os-test', 'virtual/target-os-factory', 'virtual/target-os-factory-shim', 'chromeos-base/autotest-all', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache', '--chrome_root', '/chrome'], extra_env={ 'USE': u'-cros-debug chrome_internal', 'CHROME_ORIGIN': 'LOCAL_SOURCE', }, cwd=self.workspace, )
def testFirmwareBuildPackagesModern(self): """Test building firmware for a modern workspace version.""" self.SetWorkspaceVersion(self.MODERN_VERSION) self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ './build_packages', '--board=board', '--accept_licenses=@CHROMEOS', '--skip_chroot_upgrade', '--withdebugsymbols', '--nousepkg', 'virtual/chromeos-firmware', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'USE': u'-cros-debug chrome_internal chromeless_tty', }, cwd=self.workspace, )
def testBasic(self): """Test invoking child syncs in standard case.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) self.RunStage() self.assertEqual(self.sync_stage_mock.call_args_list, [ mock.call(self._run, self.buildstore, patch_pool=mock.ANY, suffix=' [Infra]', external=True, branch='master', build_root=self.build_root), mock.call(self._run, self.buildstore, patch_pool=mock.ANY, suffix=' [test-branch]', external=False, branch='test-branch', version=None, build_root=self.workspace, copy_repo=self.build_root), ]) self.assertEqual( self.SyncCallToPathNumbers(self.sync_stage_mock.call_args_list[0]), []) self.assertEqual( self.SyncCallToPathNumbers(self.sync_stage_mock.call_args_list[1]), [])
def testFactoryModern(self): self.SetWorkspaceVersion(self.MODERN_VERSION) self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_count, 1) # Ensure has --builderpath self.rc.assertCommandCalled( [ './build_image', '--board', 'board', '--replace', '--version', 'R1-%s' % self.MODERN_VERSION, '--noeclean', '--builder_path', 'test-factorybranch/R1-%s' % self.MODERN_VERSION, 'test', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'USE': '-cros-debug chrome_internal', }, cwd=self.workspace, )
def testPatches(self): """Tests sync command used with patches.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) patchA = mock.Mock() patchA.url = 'urlA' patchA.gerrit_number_str = '1' patchB = mock.Mock() patchB.url = 'urlB' patchB.gerrit_number_str = '2' self.RunStage(build_root='/root', patch_pool=[patchA, patchB]) self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled([ os.path.join(constants.CHROMITE_DIR, 'scripts', 'repo_sync_manifest'), '--repo-root', '/root', '--manifest-versions-int', self.manifest_versions_int, '--manifest-versions-ext', self.manifest_versions, '--gerrit-patches', '1', '--gerrit-patches', '2', ])
def testAfterLimit(self): """Tests AfterLimit.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) stage = self.ConstructStage() # 1.2.3 self.SetWorkspaceVersion(self.OLD_VERSION) LIMITS_BEFORE_OLD = ('1.0.0', '1.0.5', '1.2.2') LIMITS_AFTER_OLD = ('1.2.3', '1.2.4', '2.0.0') # The workspace is after these limits. for l in LIMITS_BEFORE_OLD: self.assertTrue(stage.AfterLimit(l)) # The workspace is before these limits. for l in LIMITS_AFTER_OLD: self.assertFalse(stage.AfterLimit(l)) # 11000.0.0 self.SetWorkspaceVersion(self.MODERN_VERSION) # The workspace is after ALL of these limits. for l in LIMITS_BEFORE_OLD + LIMITS_AFTER_OLD: self.assertTrue(stage.AfterLimit(l))
def testFirmwareBuildPackagesOld(self): """Test building firmware for an old workspace version.""" self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ './build_packages', '--board=board', '--accept_licenses=@CHROMEOS', '--skip_chroot_upgrade', '--nousepkg', '--reuse_pkgs_from_local_boards', 'virtual/chromeos-firmware', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'USE': u'-cros-debug chrome_internal chromeless_tty', 'FEATURES': 'separatedebug', }, cwd=self.workspace, )
def testSetupBoardWithChromeModern(self): """Test setup_board modern workspace version.""" self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=[ '--cache-dir', '/cache', '--chrome_root', '/chrome' ]) self.SetWorkspaceVersion(self.MODERN_VERSION) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ self.setup_board, '--board=board', '--accept-licenses=@CHROMEOS', '--nousepkg', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache', '--chrome_root', '/chrome'], extra_env={ 'USE': '-cros-debug chrome_internal chromeless_tty', 'CHROME_ORIGIN': 'LOCAL_SOURCE', }, cwd=self.workspace, )
def testInitSDKWithChrome(self): """Test InitSDK old workspace version.""" self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=[ '--cache-dir', '/cache', '--chrome_root', '/chrome' ]) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ os.path.join(self.workspace, 'chromite', 'bin', 'cros_sdk'), '--create', '--cache-dir', '/cache', '--chrome_root', '/chrome', ], extra_env={ 'USE': '-cros-debug chrome_internal chromeless_tty', 'CHROME_ORIGIN': 'LOCAL_SOURCE', }, cwd=self.workspace, )
def testFactory(self): """Test with a generic factory build config.""" self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.rc.assertCommandCalled([ '/mnt/host/source/chromite/bin/cros_generate_breakpad_symbols', '--board=board', '--jobs', mock.ANY, '--exclude-dir=firmware', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'USE': '-cros-debug chrome_internal', 'FEATURES': 'separatedebug', }, cwd=self.workspace) self.assertEqual( self.tarball_mock.call_args_list, [ mock.call( buildroot=self.workspace, board='board', archive_path=os.path.join( self.build_root, 'buildbot_archive/test-factorybranch/R10-infra-tag'), gdb_symbols=True, archive_name='debug.tgz', chroot_compression=False), mock.call( buildroot=self.workspace, board='board', archive_path=os.path.join( self.build_root, 'buildbot_archive/test-factorybranch/R10-infra-tag'), gdb_symbols=False, archive_name='debug_breakpad.tar.xz', chroot_compression=False), ], ) self.assertEqual( self.archive_mock.call_args_list, [ mock.call('/debug.tgz', archive=False), mock.call('/breakpad.tgz', archive=False), ], )
def testFactoryOld(self): self.SetWorkspaceVersion(self.OLD_VERSION) self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_args_list, [])
def testVersionInfo(self): """Tests GetWorkspaceVersionInfo.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) stage = self.ConstructStage() stage.GetWorkspaceVersionInfo() self.assertEqual(self.from_repo_mock.call_args_list, [ mock.call(self.workspace), ])
def notestPatches(self): """Test invoking child syncs with patches to apply.""" self._Prepare( cmd_args=[ '-r', self.build_root, '--buildbot', '--noprebuilts', '--branch', self.TARGET_MANIFEST_BRANCH, '-g', '1', '-g', '2', 'buildspec', ], site_config=workspace_builders_unittest.CreateMockSiteConfig(), ) self.RunStage() self.assertEqual(self.sync_stage_mock.call_args_list, [ mock.call(self._run, self.buildstore, patch_pool=mock.ANY, suffix=' [Infra]', external=True, branch='master', build_root=self.build_root), mock.call(self._run, self.buildstore, patch_pool=mock.ANY, suffix=' [test-branch]', external=True, branch='test-branch', version=None, build_root=self.workspace, copy_repo=self.build_root), ]) self.assertEqual( self.SyncCallToPathNumbers(self.sync_stage_mock.call_args_list[0]), []) self.assertEqual( self.SyncCallToPathNumbers(self.sync_stage_mock.call_args_list[1]), [])
def testDefaults(self): """Tests sync command used by default.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) self.RunStage(build_root='/root') self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled([ os.path.join(constants.CHROMITE_DIR, 'scripts', 'repo_sync_manifest'), '--repo-root', '/root', '--manifest-versions-int', self.manifest_versions_int, '--manifest-versions-ext', self.manifest_versions, ])
def testBuildRoots(self): """Tests that various properties are correctly set.""" self._Prepare( 'buildspec', site_config=workspace_builders_unittest.CreateMockSiteConfig()) stage = self.ConstructStage() # Verify buildroot directories. self.assertEqual(self.build_root, stage._orig_root) self.assertEqual(self.workspace, stage._build_root) # Verify repo creation. repo = stage.GetWorkspaceRepo() self.assertEqual(repo.directory, self.workspace) # Verify manifest-versions directories. self.assertEqual(self.manifest_versions, stage.ext_manifest_versions_path) self.assertEqual(self.manifest_versions_int, stage.int_manifest_versions_path)
def testNormal(self): """Test SyncChrome with normal usage.""" self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--chrome_root', '/chrome']) self.RunStage() self.assertEqual( self.mock_best_visible.call_args_list, [mock.call('chromeos-base/chromeos-chrome', cwd=self.workspace)]) self.assertEqual(self.rc.call_args_list, [ mock.call([ os.path.join(self.build_root, 'chromite/bin/sync_chrome'), '--reset', '--tag', '0.0.1', '--git_cache_dir', mock.ANY, '--internal', '/chrome' ], cwd=self.workspace), ])
def testFactoryNew(self): self.SetWorkspaceVersion(self.MODERN_VERSION) self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_args_list, [ mock.call( [ '/mnt/host/source/chromite/bin/cros_run_unit_tests', '--board=board', '--jobs=10' ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={'USE': '-cros-debug chrome_internal'}, cwd=self.workspace, ), ])
def testSetupBoard(self): """Test setup_board old workspace version.""" self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--cache-dir', '/cache']) self.RunStage() self.assertEqual(self.rc.call_count, 1) self.rc.assertCommandCalled( [ './setup_board', '--board=board', '--accept_licenses=@CHROMEOS', '--nousepkg', ], enter_chroot=True, chroot_args=['--cache-dir', '/cache'], extra_env={ 'USE': '-cros-debug chrome_internal chromeless_tty', }, cwd=self.workspace, )
def testDebug(self): """Tests sync command used by default.""" self._Prepare( 'test-factorybranch', site_config=workspace_builders_unittest.CreateMockSiteConfig(), extra_cmd_args=['--debug']) self.RunStage() # Validate properties. self.assertEqual(self.stage.dummy_config, 'board-factory-tryjob') self.assertEqual(self.stage.dummy_version, 'R1-1.2.3-bNone') self.assertEqual( self.stage.dummy_archive_url, 'gs://chromeos-image-archive/board-factory-tryjob/' 'R1-1.2.3-bNone') self.assertEqual(self.build_image_mock.call_args_list, [ mock.call(self.workspace, 'board', extra_env={ 'FEATURES': 'separatedebug', 'USE': '-cros-debug chrome_internal', }), ]) self.assertEqual(self.net_boot_mock.call_args_list, [ mock.call(self.workspace, 'board', '/factory_image'), ]) self.assertEqual(self.factory_zip_mock.call_args_list, [ mock.call(self.workspace, 'board', '/tempdir', '/factory_image', 'R1-1.2.3-bNone'), ]) self.assertEqual(self.create_tar_mock.call_args_list, [ mock.call('/tempdir/chromiumos_test_image.tar.xz', inputs=['chromiumos_test_image.bin'], compression=1, cwd=os.path.join(self.workspace, 'src/build/images/board/latest')), ]) self.assertEqual(self.copy_mock.call_args_list, [ mock.call('/factory.zip', '/tempdir/board/factory.zip'), mock.call('/tempdir/chromiumos_test_image.tar.xz', '/tempdir/board/chromiumos_test_image.tar.xz'), mock.call('/tempdir/metadata.json', '/tempdir/board/metadata.json'), ]) self.assertEqual(self.upload_mock.call_args_list, [ mock.call('/tempdir/board/factory.zip', archive=True), mock.call('/tempdir/board/chromiumos_test_image.tar.xz', archive=True), mock.call('/tempdir/board/metadata.json', archive=True), ]) self.assertEqual( self.read_overlay_file_mock.call_args_list, 3 * [ mock.call('scripts/artifacts.json', buildroot=self.workspace, board='board'), ]) self.assertEqual(self.gs_copy_mock.call_args_list, [ mock.call( '/factory.zip', 'gs://chromeos-image-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), mock.call( '/factory.zip', 'gs://chromeos-extra-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), mock.call( '/tempdir/chromiumos_test_image.tar.xz', 'gs://chromeos-image-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), mock.call( '/tempdir/chromiumos_test_image.tar.xz', 'gs://chromeos-extra-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), mock.call( '/tempdir/metadata.json', 'gs://chromeos-image-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), mock.call( '/tempdir/metadata.json', 'gs://chromeos-extra-archive/board-factory-tryjob/R1-1.2.3-bNone', recursive=True, parallel=True), ]) self.assertEqual(self.push_mock.call_args_list, [ mock.call(profile=None, buildroot=self.workspace, sign_types=['factory'], dryrun=True, archive_url=('gs://chromeos-image-archive/' 'board-factory-tryjob/R1-1.2.3-bNone'), board='board'), ])
def testProd(self): """Tests sync command used by default.""" self.PatchObject(commands, 'BuildFirmwareArchive', return_value='/tempdir/firmware_from_source.tar.bz2') self._Prepare( 'test-firmwarebranch', site_config=workspace_builders_unittest.CreateMockSiteConfig()) self.RunStage() # Validate properties. self.assertEqual(self.stage.dummy_config, 'board-firmware') self.assertEqual(self.stage.dummy_version, 'R1-1.2.3') self.assertEqual( self.stage.dummy_archive_url, 'gs://chromeos-image-archive/board-firmware/R1-1.2.3') self.assertEqual(self.copy_mock.call_args_list, [ mock.call('/tempdir/firmware_from_source.tar.bz2', '/tempdir/board/firmware_from_source.tar.bz2'), mock.call('/tempdir/metadata.json', '/tempdir/board/metadata.json'), ]) self.assertEqual(self.upload_mock.call_args_list, [ mock.call('/tempdir/board/firmware_from_source.tar.bz2', prefix='board', archive=True), mock.call('/tempdir/board/metadata.json', archive=True), ]) self.assertEqual( self.read_overlay_file_mock.call_args_list, 2 * [ mock.call('scripts/artifacts.json', buildroot=self.workspace, board='board'), ]) self.assertEqual(self.gs_copy_mock.call_args_list, [ mock.call('/tempdir/firmware_from_source.tar.bz2', 'gs://chromeos-image-archive/board-firmware/R1-1.2.3', recursive=True, parallel=True), mock.call('/tempdir/firmware_from_source.tar.bz2', 'gs://chromeos-extra-archive/board-firmware/R1-1.2.3', recursive=True, parallel=True), mock.call('/tempdir/metadata.json', 'gs://chromeos-image-archive/board-firmware/R1-1.2.3', recursive=True, parallel=True), mock.call('/tempdir/metadata.json', 'gs://chromeos-extra-archive/board-firmware/R1-1.2.3', recursive=True, parallel=True), ]) self.assertEqual(self.push_mock.call_args_list, [ mock.call(profile=None, buildroot=self.workspace, sign_types=['firmware', 'accessory_rwsig'], dryrun=False, archive_url=('gs://chromeos-image-archive/' 'board-firmware/R1-1.2.3'), board='board'), ])