From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 20/20] support/testing: add runtime testing for init systems
Date: Sat, 22 Jul 2017 16:45:52 +0200 [thread overview]
Message-ID: <20170722144552.GE9929@scaer> (raw)
In-Reply-To: <e1b95878-e58f-c884-4265-8a1dcae14583@mind.be>
Arnout, All,
On 2017-07-22 16:32 +0200, Arnout Vandecappelle spake thusly:
> I think this patch should go in right away, even before the skeleton/systemd
> fixes. Yes, that may make some tests fail, but that's fine.
I am not so sure. We don;t know how long it will take this series to get
in in its entirety.
OTOH, ahving the tests in right now would be quite an incentive to get
the rest in. ;-]
> On 18-07-17 19:25, Yann E. MORIN wrote:
> > 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.
> >
> > We test the 11 following combinations:
> >
> > - busybox, read-only, without network
> > - busybox, read-only, with network
> > - busybox, read-write, without network
> > - busybox, read-write, with network
> >
> > - basic systemd, read-only, network w/ ifupdown
> > - basic systemd, read-only, network w/ networkd
> > - basic systemd, read-write, network w/ ifupdown
> > - basic systemd, read-write, network w/ networkd
> >
> > - full systemd, read-only, network w/ networkd
> > - full systemd, read-write, network w/ networkd
> >
> > - no init system, read-only, without network
>
> Given that we're testing init here, it would be nice to also add tests with the
> cpio filesystem, which runs a shell script before starting /sbin/init.
As I said, we can add more tests in the future. I already have a few
ideas of what we could/should add, but I'll refrain to do so for now,
to concentrate on doing the requested cleanups on this series. ;-)
> It's probably sufficient to just do the maximal test with this scenario.
> Oh, and a test with sysvinit would also be nice...
>
> > The tests just verify what the /sbin/init binary is, and that we were
> > able to grab an IP address. More tests can be added later, for example
> > to check each systemd features (journal, tmpfiles...)
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>
> I have a bunch of comments, but nothing critical so
>
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
>
> [snip]
> > + def startEmulator(self, fs_type, kernel=None, dtb=None, init=None):
>
> PEP8 says snake-case for functions. I'm not sure if the rest of the testing
> infra satisfies this, but let's try to not make things worse.
We already have BRTest.setUp() and BRTest.tearDown(), so I mimicked
that. And I also applied Thomas suggestion to go camel-case with
functions (reviewed on IRC).
> > + img = os.path.join(self.builddir, "images", "rootfs.{}".format(fs_type))
> > + subprocess.call(["truncate", "-s", "%1M", img])
>
> It's a bit weird to do that here, but I see no better way either.
>
> > +
> > + 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)
>
> This condition should probably be refactored into emulator.boot itself -
> although admittedly that doesn't have a reference to builddir at the moment.
I was planning on reworking the test infra as you suggested, because I
also found it did make sense, but again, that is out-of-scope for this
series.
> > + options.extend(["-dtb", os.path.join(self.builddir, "images",
> > + "{}.dtb".format(dtb))])
>
> This should only be done if dtb is not None.
Right.
> > +
> > + kernel_cmdline = ["root=/dev/mmcblk0",
> > + "rootfstype={}".format(fs_type),
> > + "rootwait",
> > + "ro",
> > + "console=ttyAMA0"]
> > +
> > + if not init is None:
> > + kernel_cmdline.extend(["init={}".format(init)])
>
> Just a single element, so append() instead of extend().
Right.
> > +
> > + self.emulator.boot(arch="armv7",
> > + kernel=kernel,
> > + kernel_cmdline=kernel_cmdline,
> > + options=options)
> > +
> > + if init is None:
> > + self.emulator.login()
>
> This looks weird so warrants a comment:
>
> # The init argument is passed when there is no /sbin/init and we instead
> # directly run an executable. So when init is None, we have to log in.
Ack.
> > +
> > + def checkInit(self, path):
> > + cmd = "cmp /proc/1/exe {}".format(path)
> > + _, exit_code = self.emulator.run(cmd)
> > + self.assertEqual(exit_code, 0)
> > +
> > + def checkNetwork(self, interface, exitCode=0):
> > + cmd = "ip addr show {} |grep inet".format(interface)
> > + _, exit_code = self.emulator.run(cmd)
> > + self.assertEqual(exit_code, exitCode)
>
> These you could also run automatically, and request the arguments from the
> instance:
>
> def test_run(self):
> self.startEmulator(self.fs_type())
> self.checkInit(self.init_path())
> if self.have_network():
> self.checkNetwork("eth0")
> else:
> self.checkNetwork("eth0", 1)
>
> Ideally you'd then make this an ABC class and declare those callbacks as
> @abstractmethod, but perhaps that's going too far for you :-)
Is it really necessary that we go this route? It is much more complex,
for a dubious gain, if at all.
I'd prefer we keep with simple, plain code, so that everyone can
contribute more easily...
> [snip]
> > +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")
>
> Why do you need to raise an exception here? Why not
>
> if index != 0:
> self.fail(==> System does not boot")
> return
I did exactly as is currently done in Emulator.login():
index = self.qemu.expect(["buildroot login:", pexpect.TIMEOUT],
timeout=60)
if index != 0:
self.logfile.write("==> System does not boot")
raise SystemError("System does not boot")
Regards,
Yann E. MORIN.
>
> Regards,
> Arnout
>
> [snip]
> --
> Arnout Vandecappelle arnout at mind be
> Senior Embedded Software Architect +32-16-286500
> Essensium/Mind http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
next prev parent reply other threads:[~2017-07-22 14:45 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 17:25 [Buildroot] [PATCH 00/20] system: properly handle systemd as init system Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 01/20] support/tests: allow properly indented config fragment Yann E. MORIN
2017-07-18 20:45 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 02/20] core/pkg-generic: add variable to skip skeleton dependency Yann E. MORIN
2017-07-22 12:27 ` Arnout Vandecappelle
2017-07-23 9:12 ` Peter Korsgaard
2017-07-23 9:21 ` Yann E. MORIN
2017-07-23 13:01 ` Peter Korsgaard
2017-07-22 13:41 ` Thomas Petazzoni
2017-07-18 17:25 ` [Buildroot] [PATCH 03/20] package/skeleton: add macro to rsync skeleton directory Yann E. MORIN
2017-07-22 12:34 ` Arnout Vandecappelle
2017-07-22 13:02 ` Arnout Vandecappelle
2017-07-22 14:33 ` Yann E. MORIN
2017-07-22 13:42 ` Thomas Petazzoni
2017-07-18 17:25 ` [Buildroot] [PATCH 04/20] package/skeleton: make SKELETON_LIB_SYMLINK a macro Yann E. MORIN
2017-07-22 12:56 ` Arnout Vandecappelle
2017-07-22 19:47 ` Thomas Petazzoni
2017-07-22 21:02 ` [Buildroot] Is MIPS_NABI32 a 64-bit architecture? [was: [PATCH 04/20] package/skeleton: make SKELETON_LIB_SYMLINK a macro] Arnout Vandecappelle
2017-07-22 13:50 ` [Buildroot] [PATCH 04/20] package/skeleton: make SKELETON_LIB_SYMLINK a macro Thomas Petazzoni
2017-07-22 14:23 ` Yann E. MORIN
2017-07-22 19:45 ` Thomas Petazzoni
2017-07-18 17:25 ` [Buildroot] [PATCH 05/20] system: provide package-wide system variables and macros Yann E. MORIN
2017-07-22 13:00 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 06/20] system: move setting getty to the corresponding init systems Yann E. MORIN
2017-07-22 13:11 ` Arnout Vandecappelle
2017-07-22 19:57 ` Thomas Petazzoni
2017-07-22 21:13 ` Arnout Vandecappelle
2017-07-22 20:34 ` Thomas Petazzoni
2017-07-18 17:25 ` [Buildroot] [PATCH 07/20] system: move remounting / " Yann E. MORIN
2017-07-22 13:16 ` Arnout Vandecappelle
2017-07-22 20:36 ` Thomas Petazzoni
2017-07-18 17:25 ` [Buildroot] [PATCH 08/20] system: with no init system, only allow custom skeleton Yann E. MORIN
2017-07-22 13:28 ` Arnout Vandecappelle
2017-07-22 13:53 ` Yann E. MORIN
2017-07-22 21:18 ` Arnout Vandecappelle
2017-07-22 22:12 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 09/20] package/skeleton: drop dependency on host-mkpasswd Yann E. MORIN
2017-07-22 21:24 ` Arnout Vandecappelle
2017-07-22 22:32 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 10/20] package/skeleton: select it rather than default to y Yann E. MORIN
2017-07-22 21:47 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 11/20] package/skeleton: split out into skeleton-custom Yann E. MORIN
2017-07-22 22:31 ` Arnout Vandecappelle
2017-07-22 22:38 ` Arnout Vandecappelle
2017-07-23 9:45 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 12/20] package/skeleton: split out into skeleton-common Yann E. MORIN
2017-07-22 23:06 ` Arnout Vandecappelle
2017-07-23 9:48 ` Yann E. MORIN
2017-07-23 20:32 ` Arnout Vandecappelle
2017-07-24 7:19 ` Thomas Petazzoni
2017-07-24 15:19 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 13/20] package/skeleton: make it a virtual package Yann E. MORIN
2017-07-22 23:36 ` Arnout Vandecappelle
2017-07-23 10:13 ` Yann E. MORIN
2017-07-23 20:48 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 14/20] package/skeleton-common: simplify staging install Yann E. MORIN
2017-07-22 23:38 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 15/20] package/skeleton: introduce sysv- and systemd-specific skeletons Yann E. MORIN
2017-07-22 23:49 ` Arnout Vandecappelle
2017-07-23 10:15 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 16/20] system: separate sysv and systemd parts of the skeleton Yann E. MORIN
2017-07-23 0:08 ` Arnout Vandecappelle
2017-07-23 0:13 ` Arnout Vandecappelle
2017-07-23 10:31 ` Yann E. MORIN
2017-07-23 10:24 ` Yann E. MORIN
2017-07-23 13:32 ` Arnout Vandecappelle
2017-07-23 13:39 ` Arnout Vandecappelle
2017-07-23 13:41 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 17/20] sytem: no-init systems may use our default, common skeleton Yann E. MORIN
2017-07-23 0:18 ` Arnout Vandecappelle
2017-07-23 10:37 ` Yann E. MORIN
2017-07-18 17:25 ` [Buildroot] [PATCH 18/20] fs: add pre- and post-command hooks Yann E. MORIN
2017-07-23 13:42 ` Arnout Vandecappelle
2017-07-23 14:17 ` Yann E. MORIN
2017-07-23 21:51 ` Arnout Vandecappelle
2017-07-24 16:01 ` Yann E. MORIN
2017-07-24 22:23 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 19/20] system: make systemd work on a read-only rootfs Yann E. MORIN
2017-07-23 22:18 ` Arnout Vandecappelle
2017-07-24 15:45 ` Yann E. MORIN
2017-07-24 22:44 ` Arnout Vandecappelle
2017-07-25 16:07 ` Yann E. MORIN
2017-07-25 22:24 ` Arnout Vandecappelle
2017-07-18 17:25 ` [Buildroot] [PATCH 20/20] support/testing: add runtime testing for init systems Yann E. MORIN
2017-07-22 14:32 ` Arnout Vandecappelle
2017-07-22 14:45 ` Yann E. MORIN [this message]
2017-07-22 19:30 ` Thomas Petazzoni
2017-07-22 19:53 ` Arnout Vandecappelle
2017-07-22 20:10 ` Thomas Petazzoni
2017-07-22 22:50 ` Yann E. MORIN
2017-07-23 7:58 ` Thomas Petazzoni
2017-07-23 9:26 ` Yann E. MORIN
2017-07-23 18:13 ` [Buildroot] TestIso9660GrubExternal and TestIso9660GrubInternal failing Ricardo Martincoski
2017-07-23 20:02 ` Yann E. MORIN
2017-07-23 20:28 ` Yann E. MORIN
2017-07-23 20:39 ` Yann E. MORIN
2017-07-24 7:13 ` Thomas Petazzoni
2017-07-24 11:07 ` Ricardo Martincoski
2017-07-24 15:18 ` Yann E. MORIN
2017-07-24 15:20 ` [Buildroot] [PATCH 20/20] support/testing: add runtime testing for init systems Andrey Smirnov
2017-07-24 15:50 ` Yann E. MORIN
2017-07-19 20:14 ` [Buildroot] [PATCH 00/20] system: properly handle systemd as init system Andrey Yurovsky
2017-07-19 20:53 ` Thomas Petazzoni
2017-07-19 22:17 ` Andrey Yurovsky
2017-07-20 7:32 ` Thomas Petazzoni
2017-07-21 22:15 ` Marcus Hoffmann
2017-07-28 20:41 ` Marcus Hoffmann
2017-07-28 20:54 ` 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=20170722144552.GE9929@scaer \
--to=yann.morin.1998@free.fr \
--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