All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] support/testing/tests/package/: runtime test
Date: Sat, 26 Oct 2019 19:41:48 +0200	[thread overview]
Message-ID: <20191026194148.2007d479@windsurf.home> (raw)
In-Reply-To: <20191026144101.30599-2-nicolas.carrier@orolia.com>

Hello Nicolas,

On Sat, 26 Oct 2019 14:41:21 +0000
Nicolas Carrier <nicolas.carrier@orolia.com> wrote:

> 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 <nicolas.carrier@orolia.com>

The title should be: support/testing/tests/package/test_bmap_tools: new test

Also, please add an entry in the DEVELOPERS file for those two new
files you are doing. This will make sure you get notified when there is
a failure of your test in our CI.

> 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..02bd4634d4
> --- /dev/null
> +++ b/support/testing/tests/package/test_bmap_tools.py
> @@ -0,0 +1,54 @@
> +import os
> +import sys
> +import infra
> +
> +from infra.basetest import BRTest
> +from abc import ABC, abstractproperty

I don't think we really need this, it's not used anywhere else.

> +
> +class AbstractBmapToolsTest(BRTest, ABC):

Name this just:

class TestBmapTools(infra.basetest.BRTest)

> +    __test__ = False
> +    sample_script = "tests/package/sample_bmap_tools.sh"
> +

Maybe this empty line is not really needed.

BTW, did you run flake8 on your Python code to make sure it is
compliant with Buildroot's Python coding style ?

> +    copy_script = 'tests/package/copy-sample-script-to-target.sh'
> +    config = f'''
> +        {infra.basetest.BASIC_TOOLCHAIN_CONFIG}

I didn't know about this syntax. I don't think we're using it
elsewhere, but that's OK for me, this syntax is quite nice.

> +        BR2_TARGET_ROOTFS_CPIO=y
> +        BR2_PACKAGE_BMAP_TOOLS=y
> +        BR2_ROOTFS_POST_BUILD_SCRIPT="{infra.filepath(copy_script)}"
> +        BR2_ROOTFS_POST_SCRIPT_ARGS="{infra.filepath(sample_script)}"
> +        # 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
> +        '''
> +
> +    def __init__(self, names):
> +        super(AbstractBmapToolsTest, self).__init__(names)
> +        self.config += f"BR2_PACKAGE_PYTHON{self.python_version}=y"

I don't think you need this.

> +    @abstractproperty
> +    def python_version(self):
> +        pass

or this.

> +
> +    def login(self):
> +        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
> +        self.emulator.boot(arch="armv5",
> +                           kernel="builtin",
> +                           options=["-initrd", cpio_file])
> +        self.emulator.login()
> +
> +    def test_run(self):
> +        print(self.config, file=sys.stderr)
> +        self.login()
> +        cmd = f"/root/{os.path.basename(self.sample_script)}"
> +        _, exit_code = self.emulator.run(cmd, timeout=10)
> +        self.assertEqual(exit_code, 0)
> +
> +class TestPy2BmapTools(AbstractBmapToolsTest):
> +    __test__ = True
> +    python_version = ""

Just do this:

class TestBmapToolsPython2(TestBmapTools):
	__test__ = True
	config = TestBmapTools.config + \
	"""
	BR2_PACKAGE_PYTHON=y
	"""

and ditto for Python 3.x of course. See test_python_treq.py for an
example of how we are doing it.

I understand what you're proposing is a different way of doing the same
thing, we really value consistency across the code base. So we want a
given thing to always be done the same way.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2019-10-26 17:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 14:41 [Buildroot] [PATCH 1/2] package/bmap-tools: new package Nicolas Carrier
2019-10-26 14:41 ` [Buildroot] [PATCH 2/2] support/testing/tests/package/: runtime test Nicolas Carrier
2019-10-26 17:41   ` Thomas Petazzoni [this message]
2019-10-27  9:07     ` Arnout Vandecappelle
2019-10-26 17:30 ` [Buildroot] [PATCH 1/2] package/bmap-tools: new package Thomas Petazzoni
2019-10-26 19:15   ` Nicolas Carrier
2019-10-26 17:32 ` Thomas Petazzoni
2019-10-26 19:16   ` Nicolas Carrier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191026194148.2007d479@windsurf.home \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.