From 81d1c6cf288f6ad76235557d5a6220f4cbaa79c4 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Mon, 21 Jun 2021 23:01:10 +0200 Subject: [PATCH] support/testing/tests/package/test_bmap_tools: add test for host bmap-tools Signed-off-by: Thomas Petazzoni [yann.morin.1998@free.fr: check the two files are identical] Signed-off-by: Yann E. MORIN --- .../testing/tests/package/test_bmap_tools.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/support/testing/tests/package/test_bmap_tools.py b/support/testing/tests/package/test_bmap_tools.py index e8802fc057..5b4e5dcd3f 100644 --- a/support/testing/tests/package/test_bmap_tools.py +++ b/support/testing/tests/package/test_bmap_tools.py @@ -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) -- 2.30.2