From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v5 01/14] support/testing: add runtime testing for init systems
Date: Wed, 2 Aug 2017 17:48:09 +0200 [thread overview]
Message-ID: <20170802174809.1a7bba4f@windsurf.home> (raw)
In-Reply-To: <20170801225224.16899-2-arnout@mind.be>
Hello,
On Wed, 2 Aug 2017 00:52:11 +0200, Arnout Vandecappelle
(Essensium/Mind) wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> The "builtin" kernel does not boot a systemd-based system, so
> we resort to building the same one as currently used by our
> qemu_arm_vexpress_defconfig.
[...]
Thanks, I've applied. I like the test case definitions themselves, they
are small and very readable. However, there are a few other things that
I think could be better, see below.
> +class InitSystemBase(infra.basetest.BRTest):
> +
> + def startEmulator(self, fs_type, kernel=None, dtb=None, init=None):
> + img = os.path.join(self.builddir, "images", "rootfs.{}".format(fs_type))
> + subprocess.call(["truncate", "-s", "%1M", img])
> +
> + options = ["-drive",
> + "file={},if=sd,format=raw".format(img),
> + "-M", "vexpress-a9"]
> +
> + if kernel is None:
> + kernel = "builtin"
> + else:
> + kernel = os.path.join(self.builddir, "images", kernel)
> + options.extend(["-dtb", os.path.join(self.builddir, "images",
> + "{}.dtb".format(dtb))])
> +
> + kernel_cmdline = ["root=/dev/mmcblk0",
> + "rootfstype={}".format(fs_type),
> + "rootwait",
> + "ro",
> + "console=ttyAMA0"]
The beginning of this function partly duplicates some of the logic in
the Emulator() class, like passing -M vexpress-a9, etc. The fact that
you needed this additional helper function on top indicates IMO that
the self.emulator.boot() method should be improved.
> + if not init is None:
if init is not None ?
> + kernel_cmdline.extend(["init={}".format(init)])
> +
> + self.emulator.boot(arch="armv7",
> + kernel=kernel,
> + kernel_cmdline=kernel_cmdline,
> + options=options)
> +
> + if init is None:
> + self.emulator.login()
Reading this condition is really weird. Indeed when you have an init
such as systemd or busybox, the init variable is None, and that's why
you login. And when you have *no* init, then the init variable has a
value, and you can't login.
But the naming of the variable can cause confusion here: "if init is
None" can be understood as "if there's no init program". But it's
actually exactly the opposite.
It would be nice to find a way to clarify that.
> +class TestInitSystemNone(InitSystemBase):
> + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
> + """
> + BR2_INIT_NONE=y
> + # BR2_TARGET_ROOTFS_TAR is not set
> + BR2_TARGET_ROOTFS_SQUASHFS=y
> + """
> +
> + def test_run(self):
> + self.startEmulator(fs_type="squashfs", init="/bin/sh")
> + index = self.emulator.qemu.expect(["/bin/sh: can't access tty; job control turned off", pexpect.TIMEOUT], timeout=60)
> + if index != 0:
> + self.emulator.logfile.write("==> System does not boot")
> + raise SystemError("System does not boot")
> + index = self.emulator.qemu.expect(["#", pexpect.TIMEOUT], timeout=60)
> + if index != 0:
> + self.emulator.logfile.write("==> System does not boot")
> + raise SystemError("System does not boot")
The self.emulator class should provide a method to wait for a string so
that you don't have to use the internals of self.emulator.qemu.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2017-08-02 15:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 22:52 [Buildroot] [PATCH v5 00/14] system: properly handle systemd as init system Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 01/14] support/testing: add runtime testing for init systems Arnout Vandecappelle
2017-08-02 15:48 ` Thomas Petazzoni [this message]
2017-08-01 22:52 ` [Buildroot] [PATCH v5 02/14] package/skeleton: split out into skeleton-custom Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 03/14] package/skeleton-custom: rework the merged_usr and building conditions Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 04/14] package/skeleton-custom: also check for missing directories Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 05/14] package/skeleton-custom: simplify target/staging install Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 06/14] package/skeleton: split out into skeleton-common Arnout Vandecappelle
2017-08-02 17:24 ` Thomas Petazzoni
2017-08-01 22:52 ` [Buildroot] [PATCH v5 07/14] skeleton-common: rename SKELETON_ROOT_PASSWORD to SKELETON_CUSTOM_ROOT_PASSWORD Arnout Vandecappelle
2017-08-02 17:29 ` Thomas Petazzoni
2017-08-02 19:22 ` Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 08/14] package/skeleton: make it a virtual package Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 09/14] package/skeleton-common: simplify staging install Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 10/14] package/skeleton: introduce sysv- and systemd-specific skeletons Arnout Vandecappelle
2017-08-02 17:59 ` Thomas Petazzoni
2017-08-01 22:52 ` [Buildroot] [PATCH v5 11/14] system: separate sysv and systemd parts of the skeleton Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 12/14] fs: add pre- and post-command hooks Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 13/14] system: make systemd work on a read-only rootfs Arnout Vandecappelle
2017-08-01 22:52 ` [Buildroot] [PATCH v5 14/14] support/testing: add runtime testing for read-only systemd Arnout Vandecappelle
2017-08-02 17:51 ` [Buildroot] [PATCH v5 00/14] system: properly handle systemd as init system Yann E. MORIN
2017-08-02 19:19 ` Thomas Petazzoni
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=20170802174809.1a7bba4f@windsurf.home \
--to=thomas.petazzoni@free-electrons.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox