From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Julien Olivain <ju.o@free.fr>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] support/testing: add ed runtime test
Date: Mon, 1 Apr 2024 16:28:50 +0200 [thread overview]
Message-ID: <ZgrEokl8om5MklrA@landeda> (raw)
In-Reply-To: <20240331201423.174954-1-ju.o@free.fr>
Julien, All,
On 2024-03-31 22:14 +0200, Julien Olivain spake thusly:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
Applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> DEVELOPERS | 1 +
> support/testing/tests/package/test_ed.py | 98 ++++++++++++++++++++++++
> 2 files changed, 99 insertions(+)
> create mode 100644 support/testing/tests/package/test_ed.py
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 313fc16b9d7..288a3ce0e68 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1780,6 +1780,7 @@ F: support/testing/tests/package/test_cryptsetup/
> F: support/testing/tests/package/test_ddrescue.py
> F: support/testing/tests/package/test_ddrescue/
> F: support/testing/tests/package/test_dos2unix.py
> +F: support/testing/tests/package/test_ed.py
> F: support/testing/tests/package/test_file.py
> F: support/testing/tests/package/test_file/
> F: support/testing/tests/package/test_fluidsynth.py
> diff --git a/support/testing/tests/package/test_ed.py b/support/testing/tests/package/test_ed.py
> new file mode 100644
> index 00000000000..eee5f8c4fc6
> --- /dev/null
> +++ b/support/testing/tests/package/test_ed.py
> @@ -0,0 +1,98 @@
> +import os
> +
> +import infra.basetest
> +
> +
> +class TestEd(infra.basetest.BRTest):
> + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
> + """
> + BR2_PACKAGE_ED=y
> + BR2_TARGET_ROOTFS_CPIO=y
> + # BR2_TARGET_ROOTFS_TAR is not set
> + """
> +
> + def run_ed_cmds(self, ed_cmds):
> + cmd = "ed <<EOF\n"
> + cmd += "\n".join(ed_cmds)
> + cmd += "\nEOF"
> + self.assertRunOk(cmd)
> +
> + def test_run(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()
> +
> + # We check the program can run. This also check we have the
> + # actual GNU ed, rather than the Busybox ed, which does not
> + # recognize the --version option.
> + self.assertRunOk("ed --version")
> +
> + test_fname = "test.txt"
> + input_text_lines = [
> + "Hello World",
> + "Embedded Linux is Hard."
> + ]
> + output_expected_text = [
> + "Hello Buildroot",
> + "---------------",
> + "Making Embedded Linux Easy."
> + ]
> +
> + # We define few "ed" command sequences, creating and editing a
> + # text file. The final output of this sequence is expected to
> + # match the expected text previously defined.
> + create_file = ["a"]
> + create_file += input_text_lines
> + create_file += [
> + ".",
> + f"w {test_fname}",
> + "q"
> + ]
> +
> + edit_file = [
> + f"r {test_fname}",
> + "1",
> + "s/World/Buildroot/",
> + "2",
> + "s/is Hard/Easy/",
> + "s/^/Making /",
> + "w",
> + "q"
> + ]
> +
> + insert_txt = [
> + f"r {test_fname}",
> + "2",
> + "i",
> + "This is a new line",
> + ".",
> + "w",
> + "q"
> + ]
> +
> + change_txt = [
> + f"r {test_fname}",
> + "2",
> + "c",
> + "---------------",
> + ".",
> + "w"
> + "q"
> + ]
> +
> + # We execute all "ed" command batches.
> + ed_cmd_batches = [
> + create_file,
> + edit_file,
> + insert_txt,
> + change_txt
> + ]
> + for ed_cmd_batch in ed_cmd_batches:
> + self.run_ed_cmds(ed_cmd_batch)
> +
> + # The final test file should contain the expected text.
> + out, ret = self.emulator.run(f"cat {test_fname}")
> + self.assertEqual(ret, 0)
> + self.assertEqual(out, output_expected_text)
> --
> 2.44.0
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2024-04-01 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-31 20:14 [Buildroot] [PATCH 1/1] support/testing: add ed runtime test Julien Olivain
2024-04-01 14:28 ` Yann E. MORIN [this message]
2024-04-28 19:42 ` Peter Korsgaard
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=ZgrEokl8om5MklrA@landeda \
--to=yann.morin.1998@free.fr \
--cc=buildroot@buildroot.org \
--cc=ju.o@free.fr \
/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