Ejemplo n.º 1
0
    def test_CanUseImgdiff_ineligible(self):
        # Disabled by caller.
        block_image_diff = BlockImageDiff(EmptyImage(),
                                          EmptyImage(),
                                          disable_imgdiff=True)
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/app/app1.apk",
                                           RangeSet("10-15"), RangeSet("0-5")))

        # Unsupported file type.
        block_image_diff = BlockImageDiff(EmptyImage(), EmptyImage())
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/bin/gzip",
                                           RangeSet("10-15"), RangeSet("0-5")))

        # At least one of the ranges is in non-monotonic order.
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/app/app2.apk",
                                           RangeSet("10-15"),
                                           RangeSet("15-20 30 10-14")))

        # At least one of the ranges is incomplete.
        src_ranges = RangeSet("0-5")
        src_ranges.extra['incomplete'] = True
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/vendor/app/app4.apk",
                                           RangeSet("10-15"), src_ranges))

        # The stats are correctly logged.
        self.assertDictEqual(
            {
                ImgdiffStats.SKIPPED_NONMONOTONIC: {'/system/app/app2.apk'},
                ImgdiffStats.SKIPPED_INCOMPLETE: {'/vendor/app/app4.apk'},
            }, block_image_diff.imgdiff_stats.stats)
Ejemplo n.º 2
0
    def test_CanUseImgdiff_ineligible(self):
        # Disabled by caller.
        block_image_diff = BlockImageDiff(EmptyImage(),
                                          EmptyImage(),
                                          disable_imgdiff=True)
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/app/app1.apk",
                                           RangeSet("10-15"), RangeSet("0-5")))

        # Unsupported file type.
        block_image_diff = BlockImageDiff(EmptyImage(), EmptyImage())
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/bin/gzip",
                                           RangeSet("10-15"), RangeSet("0-5")))

        # At least one of the ranges is in non-monotonic order.
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/system/app/app2.apk",
                                           RangeSet("10-15"),
                                           RangeSet("15-20 30 10-14")))

        # At least one of the ranges has been modified.
        src_ranges = RangeSet("0-5")
        src_ranges.extra['trimmed'] = True
        self.assertFalse(
            block_image_diff.CanUseImgdiff("/vendor/app/app3.apk",
                                           RangeSet("10-15"), src_ranges))
Ejemplo n.º 3
0
    def test_CanUseImgdiff(self):
        block_image_diff = BlockImageDiff(EmptyImage(), EmptyImage())
        self.assertTrue(
            block_image_diff.CanUseImgdiff("/system/app/app1.apk",
                                           RangeSet("10-15"), RangeSet("0-5")))
        self.assertTrue(
            block_image_diff.CanUseImgdiff("/vendor/app/app2.apk",
                                           RangeSet("20 25"),
                                           RangeSet("30-31"), True))

        self.assertDictEqual(
            {
                ImgdiffStats.USED_IMGDIFF: {"/system/app/app1.apk"},
                ImgdiffStats.USED_IMGDIFF_LARGE_APK: {"/vendor/app/app2.apk"},
            }, block_image_diff.imgdiff_stats.stats)
Ejemplo n.º 4
0
 def test_CanUseImgdiff(self):
     block_image_diff = BlockImageDiff(EmptyImage(), EmptyImage())
     self.assertTrue(
         block_image_diff.CanUseImgdiff("/system/app/app1.apk",
                                        RangeSet("10-15"), RangeSet("0-5")))