From patchwork Mon Jun 7 20:42:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1488982 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FzQMB6fF1z9sW6 for ; Tue, 8 Jun 2021 06:43:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id F2F59826C1; Mon, 7 Jun 2021 20:43:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Thsa208-bqjJ; Mon, 7 Jun 2021 20:43:48 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 45A4182F40; Mon, 7 Jun 2021 20:43:47 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 75F4B1BF973 for ; Mon, 7 Jun 2021 20:42:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 65C6A4029F for ; Mon, 7 Jun 2021 20:42:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V6Z6nvnWFnPA for ; Mon, 7 Jun 2021 20:42:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by smtp2.osuosl.org (Postfix) with ESMTPS id 369034029B for ; Mon, 7 Jun 2021 20:42:30 +0000 (UTC) Received: (Authenticated sender: thomas.petazzoni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id EDD27240003; Mon, 7 Jun 2021 20:42:27 +0000 (UTC) From: Thomas Petazzoni To: Buildroot List Date: Mon, 7 Jun 2021 22:42:19 +0200 Message-Id: <20210607204221.124908-5-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210607204221.124908-1-thomas.petazzoni@bootlin.com> References: <20210607204221.124908-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v5 4/5] support/testing/tests/package/test_bmap_tools: new test X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Nicolas Carrier This patch implements a simple test in which a dummy file system image is created, then `bmaptool create` and `bmaptool copy` are used to copy it to another file. Signed-off-by: Nicolas Carrier [Thomas: several reworks, add myself to DEVELOPERS] Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 4 ++ .../tests/package/sample_bmap_tools.sh | 15 +++++ .../testing/tests/package/test_bmap_tools.py | 59 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100755 support/testing/tests/package/sample_bmap_tools.sh create mode 100644 support/testing/tests/package/test_bmap_tools.py diff --git a/DEVELOPERS b/DEVELOPERS index 973aab8824..9c44568c65 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1978,6 +1978,8 @@ F: configs/galileo_defconfig N: Nicolas Carrier F: package/bmap-tools/ F: package/php-xdebug/ +F: support/testing/tests/package/sample_bmap_tools.sh +F: support/testing/tests/package/test_bmap_tools.py N: Nicolas Cavallari F: package/libgit2/ @@ -2678,6 +2680,8 @@ F: package/squashfs/ F: package/wayland/ F: package/weston/ F: support/testing/tests/boot/test_syslinux.py +F: support/testing/tests/package/sample_bmap_tools.sh +F: support/testing/tests/package/test_bmap_tools.py F: toolchain/ N: Timo Ketola diff --git a/support/testing/tests/package/sample_bmap_tools.sh b/support/testing/tests/package/sample_bmap_tools.sh new file mode 100755 index 0000000000..7c90368c17 --- /dev/null +++ b/support/testing/tests/package/sample_bmap_tools.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# simple test which creates a dummy file system image, then use bmaptool create +# and bmaptool copy to copy it to another file + +set -xeu + +# create the necessary test files +dd if=/dev/zero of=disk.img bs=2M count=1 +mkfs.ext4 disk.img +fallocate -d disk.img +dd if=/dev/zero of=copy.img bs=2M count=1 + +# do a test copy of the file system image +bmaptool create -o disk.img.bmap disk.img +bmaptool copy disk.img copy.img diff --git a/support/testing/tests/package/test_bmap_tools.py b/support/testing/tests/package/test_bmap_tools.py new file mode 100644 index 0000000000..6f3a8cc072 --- /dev/null +++ b/support/testing/tests/package/test_bmap_tools.py @@ -0,0 +1,59 @@ +import os +import infra + +from infra.basetest import BRTest + + +class TestBmapTools(BRTest): + __test__ = False + sample_script = "tests/package/sample_bmap_tools.sh" + copy_script = 'tests/package/copy-sample-script-to-target.sh' + config = \ + """ + BR2_arm=y + BR2_cortex_a8=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y + BR2_PACKAGE_BMAP_TOOLS=y + BR2_ROOTFS_POST_BUILD_SCRIPT="{}" + BR2_ROOTFS_POST_SCRIPT_ARGS="{}" + BR2_TARGET_ROOTFS_EXT2=y + BR2_TARGET_ROOTFS_EXT2_4=y + # BR2_TARGET_ROOTFS_TAR is not set + BR2_PACKAGE_UTIL_LINUX=y + BR2_PACKAGE_UTIL_LINUX_FALLOCATE=y + BR2_PACKAGE_E2FSPROGS=y + BR2_PACKAGE_UTIL_LINUX_LIBUUID=y + """.format(infra.filepath(copy_script), + infra.filepath(sample_script)) + + def login(self): + img = os.path.join(self.builddir, "images", "rootfs.ext4") + self.emulator.boot(arch="armv7", + kernel="builtin", + kernel_cmdline=["root=/dev/mmcblk0", + "rootfstype=ext4"], + options=["-drive", "file={},if=sd,format=raw".format(img)]) + self.emulator.login() + + def test_run(self): + self.login() + cmd = "/root/{}".format(os.path.basename(self.sample_script)) + _, exit_code = self.emulator.run(cmd, timeout=20) + self.assertEqual(exit_code, 0) + + +class TestPy2BmapTools(TestBmapTools): + __test__ = True + config = TestBmapTools.config + \ + """ + BR2_PACKAGE_PYTHON=y + """ + + +class TestPy3BmapTools(TestBmapTools): + __test__ = True + config = TestBmapTools.config + \ + """ + BR2_PACKAGE_PYTHON3=y + """