* [Buildroot] [PATCH 1/1] support/testing: add ed runtime test
@ 2024-03-31 20:14 Julien Olivain
2024-04-01 14:28 ` Yann E. MORIN
2024-04-28 19:42 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-03-31 20:14 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add ed runtime test
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
2024-04-28 19:42 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2024-04-01 14:28 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add ed runtime test
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
@ 2024-04-28 19:42 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-04-28 19:42 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
Committed to 2024.02.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-28 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-04-28 19:42 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox