示例#1
0
    def testObtainBisectBoundaryScoreImplCrosVersionFlashError(self):
        """Tests ObtainBisectBoundaryScoreImpl() with CrOS version."""
        self.SetUpBisectorWithCrosVersion()
        # Inject good_commit and bad_commit as if
        # bisector.ResolveChromeBisectRangeFromCrosVersion() being run.
        self.bisector.good_commit = self.GOOD_COMMIT_SHA1
        self.bisector.bad_commit = self.BAD_COMMIT_SHA1

        git_mock = self.StartPatcher(
            git_bisector_unittest.GitMock(self.repo_dir))
        git_mock.AddRunGitResult(['checkout', self.GOOD_COMMIT_SHA1])
        git_mock.AddRunGitResult(['checkout', self.BAD_COMMIT_SHA1])

        self.PatchObject(chrome_on_cros_bisector.ChromeOnCrosBisector,
                         'UpdateCurrentCommit')
        evaluate_mock = self.PatchObject(DummyEvaluator, 'Evaluate')

        # Mock FlashCrosImage() to verify that customize_build_deploy is assigned
        # as expected.
        flash_cros_image_mock = self.PatchObject(
            chrome_on_cros_bisector.ChromeOnCrosBisector, 'FlashCrosImage')
        flash_cros_image_mock.side_effect = flash.FlashError('Flash failed.')

        with self.assertRaises(flash.FlashError):
            self.bisector.ObtainBisectBoundaryScoreImpl(True)

        flash_cros_image_mock.assert_called_with(
            self.bisector.GetCrosXbuddyPath(self.GOOD_CROS_VERSION))
        evaluate_mock.assert_not_called()

        with self.assertRaises(flash.FlashError):
            self.bisector.ObtainBisectBoundaryScoreImpl(False)
        flash_cros_image_mock.assert_called_with(
            self.bisector.GetCrosXbuddyPath(self.BAD_CROS_VERSION))
        evaluate_mock.assert_not_called()
示例#2
0
 def testFlashImageRetryFailed(self):
     """Tests FlashImage() with retry failed."""
     flash_mock = self.PatchObject(flash, 'Flash')
     flash_mock.side_effect = flash.FlashError('Flash failed.')
     xbuddy_path = self.bisector.GetCrosXbuddyPath(self.GOOD_CROS_VERSION)
     with self.assertRaises(flash.FlashError):
         self.bisector.FlashCrosImage(xbuddy_path)
     flash_mock.assert_called_with(self.DUT,
                                   xbuddy_path,
                                   board=self.BOARD,
                                   clobber_stateful=True,
                                   disable_rootfs_verification=True)
示例#3
0
    def _GetDefaultVersion(self):
        """Get default full SDK version.

    For non-chrome, use 'latest'. For chrome, look up the
    full version in the misc cache.
    """
        if path_util.DetermineCheckout(
        ).type != path_util.CHECKOUT_TYPE_GCLIENT:
            return 'latest'

        board = self.options.board or flash.GetDefaultBoard()
        if not board:
            raise flash.FlashError('Must specify board.')

        full_version = cros_chrome_sdk.SDKFetcher.GetCachedFullVersion(
            self.options.cache_dir or path_util.GetCacheDir(),
            board) or 'latest'
        logging.notice('CrOS SDK version: %s', full_version)
        return full_version
示例#4
0
    def testExchangeChromeSanityCheckFlashError(self):
        """Tests the flow of exchanging Chrome between good and bad CrOS."""
        self.SetUpBisectorWithCrosVersion()

        # Inject good_commit and bad_commit as if
        # bisector.ResolveChromeBisectRangeFromCrosVersion() has been run.
        self.bisector.good_commit = self.GOOD_COMMIT_SHA1
        self.bisector.bad_commit = self.BAD_COMMIT_SHA1

        # Inject commit_info and threshold as if
        # bisector.ObtainBisectBoundaryScore() and bisector.GetThresholdFromUser()
        # has been run.
        self.SetDefaultCommitInfo()
        self.bisector.threshold = self.THRESHOLD

        # Try bad Chrome first.
        git_mock = self.StartPatcher(
            git_bisector_unittest.GitMock(self.repo_dir))
        git_mock.AddRunGitResult(['checkout', self.BAD_COMMIT_SHA1])
        git_mock.AddRunGitResult(['checkout', self.GOOD_COMMIT_SHA1])

        self.PatchObject(chrome_on_cros_bisector.ChromeOnCrosBisector,
                         'UpdateCurrentCommit')

        evaluate_mock = self.PatchObject(DummyEvaluator, 'Evaluate')

        # Mock FlashCrosImage() to verify that customize_build_deploy is assigned
        # as expected.
        flash_cros_image_mock = self.PatchObject(
            chrome_on_cros_bisector.ChromeOnCrosBisector,
            'FlashCrosImage',
            side_effect=flash.FlashError('Flash failed.'))

        build_deploy_mock = self.PatchObject(
            chrome_on_cros_bisector.ChromeOnCrosBisector, 'BuildDeploy')

        with self.assertRaises(flash.FlashError):
            self.bisector.ExchangeChromeSanityCheck()

        evaluate_mock.assert_not_called()
        flash_cros_image_mock.assert_called()
        build_deploy_mock.assert_not_called()
示例#5
0
 def flash_mock_return(*unused_args, **unused_kwargs):
     nth_call = next(flash_mock_call_counter)
     if nth_call < 3:
         raise flash.FlashError('Flash failed.')