From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: Sebastian Weyer <sebastian.weyer@smile.fr>
Cc: Romain Naour <romain.naour@smile.fr>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v6 3/3] support/testing/tests/package/test_nu.py: New runtime test
Date: Wed, 30 Aug 2023 22:37:34 +0200 [thread overview]
Message-ID: <20230830223734.65df730e@windsurf> (raw)
In-Reply-To: <20230308131554.642965-3-sebastian.weyer@smile.fr>
On Wed, 8 Mar 2023 14:15:53 +0100
Sebastian Weyer <sebastian.weyer@smile.fr> wrote:
> +class TestNuBase(infra.basetest.BRTest):
> + # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it doesn't
> + # support a host rustc which is necessary for nushell
> + config = \
> + """
> + BR2_arm=y
> + BR2_cortex_a9=y
> + BR2_ARM_ENABLE_NEON=y
> + BR2_ARM_ENABLE_VFP=y
> + BR2_TOOLCHAIN_EXTERNAL=y
> + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
> + BR2_SYSTEM_DHCP="eth0"
> + BR2_PACKAGE_NUSHELL=y
> + BR2_TARGET_ROOTFS_CPIO=y
> + """
> +
> + def login(self):
> + img = os.path.join(self.builddir, "images", "rootfs.cpio")
> + self.emulator.boot(arch="armv7",
> + kernel="builtin",
> + options=["-initrd",img])
> + self.emulator.login()
> +
> +# load a script on the target and check if it is executed correctly by nu
> +class TestNu(TestNuBase):
> + config_sample_scripts = \
> + """
> + BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
> + BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
> + """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
> + "{sample_scripts}")
> +
> + #simple hello world script found in the nushell doc
> + sample_scripts = ["tests/package/sample_nu.nu"]
> +
> + def __init__(self, names):
> + """Add the scripts to the target in build time."""
> + super(TestNuBase, self).__init__(names)
> + scripts = [infra.filepath(s) for s in self.sample_scripts]
> + self.config += self.config_sample_scripts.format(sample_scripts=" ".join(scripts))
> +
> + def check_sample_scripts_exist(self):
> + """Check the scripts were really added to the image."""
> + scripts = [os.path.basename(s) for s in self.sample_scripts]
> + cmd = "md5sum " + " ".join(scripts)
> + _, exit_code = self.emulator.run(cmd)
> + self.assertEqual(exit_code, 0)
> +
> + def run_sample_scripts(self):
> + """Run each script previously added to the image."""
> + for script in self.sample_scripts:
> + cmd = "nu " + os.path.basename(script)
> + self.assertRunOk(cmd)
> +
> + def test_run(self):
> + self.login()
> + self.check_sample_scripts_exist()
> + self.run_sample_scripts()
This was way too complicated, because you based it on the Python
testing infrastructure that aims at being generic. Here we don't need
to be generic, so it can be as simple as:
import os
import infra.basetest
class TestNu(infra.basetest.BRTest):
# infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it doesn't
# support a host rustc which is necessary for nushell
config = \
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_SYSTEM_DHCP="eth0"
BR2_PACKAGE_NUSHELL=y
BR2_TARGET_ROOTFS_CPIO=y
BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
""".format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
infra.filepath("tests/package/sample_nu.nu"))
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv7",
kernel="builtin",
options=["-initrd", img])
self.emulator.login()
cmd = "nu sample_nu.nu"
self.assertRunOk(cmd)
So I adjusted your patch like this and applied to next. Thanks a lot!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2023-08-30 20:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 13:15 [Buildroot] [PATCH v6 1/3] package/nushell: new package Sebastian Weyer
2023-03-08 13:15 ` [Buildroot] [PATCH v6 2/3] package/nushell: Add default configs Sebastian Weyer
2023-08-30 20:36 ` Thomas Petazzoni via buildroot
2023-03-08 13:15 ` [Buildroot] [PATCH v6 3/3] support/testing/tests/package/test_nu.py: New runtime test Sebastian Weyer
2023-08-30 20:37 ` Thomas Petazzoni via buildroot [this message]
2023-08-30 20:35 ` [Buildroot] [PATCH v6 1/3] package/nushell: new package Thomas Petazzoni via buildroot
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=20230830223734.65df730e@windsurf \
--to=buildroot@buildroot.org \
--cc=romain.naour@smile.fr \
--cc=sebastian.weyer@smile.fr \
--cc=thomas.petazzoni@bootlin.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox