Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df055580 authored by Tianjie Xu's avatar Tianjie Xu
Browse files

Fix the imgdiff failure when running test_common unittest

imgdiff fails on plain strings after we put more checks the input
data. This leads to failure when running unittest
"test_recovery_from_boot". The CL fixes the issue by serving gzipped
dummy images as the test input.

Bug: 68988329
Test: InstallRecoveryScriptFormatTest passes
Change-Id: I1952b311681ac4f39c0e51aef1de1177aebeac43
parent dee5abd8
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -312,6 +312,17 @@ class InstallRecoveryScriptFormatTest(unittest.TestCase):
         "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"]
         "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"]
    self._info["fstab"] = common.LoadRecoveryFSTab(lambda x : "\n".join(x),
    self._info["fstab"] = common.LoadRecoveryFSTab(lambda x : "\n".join(x),
                                                   2, dummy_fstab)
                                                   2, dummy_fstab)
    # Construct the gzipped recovery.img and boot.img
    self.recovery_data = bytearray([
        0x1f, 0x8b, 0x08, 0x00, 0x81, 0x11, 0x02, 0x5a, 0x00, 0x03, 0x2b, 0x4a,
        0x4d, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0x04, 0x00, 0xc9, 0x93, 0x43, 0xf3,
        0x08, 0x00, 0x00, 0x00
    ])
    # echo -n "boot" | gzip -f | hd
    self.boot_data = bytearray([
        0x1f, 0x8b, 0x08, 0x00, 0x8c, 0x12, 0x02, 0x5a, 0x00, 0x03, 0x4b, 0xca,
        0xcf, 0x2f, 0x01, 0x00, 0xc4, 0xae, 0xed, 0x46, 0x04, 0x00, 0x00, 0x00
    ])


  def _out_tmp_sink(self, name, data, prefix="SYSTEM"):
  def _out_tmp_sink(self, name, data, prefix="SYSTEM"):
    loc = os.path.join(self._tempdir, prefix, name)
    loc = os.path.join(self._tempdir, prefix, name)
@@ -321,8 +332,8 @@ class InstallRecoveryScriptFormatTest(unittest.TestCase):
      f.write(data)
      f.write(data)


  def test_full_recovery(self):
  def test_full_recovery(self):
    recovery_image = common.File("recovery.img", "recovery");
    recovery_image = common.File("recovery.img", self.recovery_data);
    boot_image = common.File("boot.img", "boot");
    boot_image = common.File("boot.img", self.boot_data);
    self._info["full_recovery_image"] = "true"
    self._info["full_recovery_image"] = "true"


    common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
    common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
@@ -331,9 +342,9 @@ class InstallRecoveryScriptFormatTest(unittest.TestCase):
                                                        self._info)
                                                        self._info)


  def test_recovery_from_boot(self):
  def test_recovery_from_boot(self):
    recovery_image = common.File("recovery.img", "recovery");
    recovery_image = common.File("recovery.img", self.recovery_data);
    self._out_tmp_sink("recovery.img", recovery_image.data, "IMAGES")
    self._out_tmp_sink("recovery.img", recovery_image.data, "IMAGES")
    boot_image = common.File("boot.img", "boot");
    boot_image = common.File("boot.img", self.boot_data);
    self._out_tmp_sink("boot.img", boot_image.data, "IMAGES")
    self._out_tmp_sink("boot.img", boot_image.data, "IMAGES")


    common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
    common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,