support/testing/tests/package/test_bmap_tools: add test for host bmap-tools
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 21 Jun 2021 21:01:10 +0000 (23:01 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Fri, 25 Jun 2021 12:24:34 +0000 (14:24 +0200)
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: check the two files are identical]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
support/testing/tests/package/test_bmap_tools.py

index e8802fc0571b8de43f125267c1eed24e2f1fe1c7..5b4e5dcd3f60af000015c6fe84e294cdc3618649 100644 (file)
@@ -1,5 +1,6 @@
 import os
 import infra
+import subprocess
 
 from infra.basetest import BRTest
 
@@ -59,3 +60,34 @@ class TestPy3BmapTools(TestBmapTools):
         """
         BR2_PACKAGE_PYTHON3=y
         """
+
+
+class TestHostBmapTools(BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_HOST_BMAP_TOOLS=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        BR2_TARGET_ROOTFS_EXT2=y
+        """
+
+    def test_run(self):
+        bmap_x = os.path.join(self.b.builddir, "host", "bin", "bmaptool")
+        src_f = os.path.join(self.b.builddir, "images", "rootfs.ext2")
+        dst_f = os.path.join(self.b.builddir, "images", "rootfs.ext2.copy")
+        map_f = os.path.join(self.b.builddir, "images", "rootfs.ext2.bmap")
+
+        ret = subprocess.call([bmap_x, "create", "-o", map_f, src_f],
+                              stdout=self.b.logfile,
+                              stderr=self.b.logfile)
+        self.assertEqual(ret, 0)
+
+        ret = subprocess.call([bmap_x, "copy", src_f, dst_f],
+                              stdout=self.b.logfile,
+                              stderr=self.b.logfile)
+        self.assertEqual(ret, 0)
+
+        with open(src_f, 'rb') as f:
+            src = f.read()
+        with open(dst_f, 'rb') as f:
+            dst = f.read()
+        self.assertEqual(src, dst)