mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-30 14:01:57 -09:00
support/testing: new patch runtime test
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 41bceec4e8)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
8e62aeb3fe
commit
b4151f28d0
@@ -1839,6 +1839,8 @@ F: support/testing/tests/package/test_octave.py
|
|||||||
F: support/testing/tests/package/test_ola.py
|
F: support/testing/tests/package/test_ola.py
|
||||||
F: support/testing/tests/package/test_ola/
|
F: support/testing/tests/package/test_ola/
|
||||||
F: support/testing/tests/package/test_openblas.py
|
F: support/testing/tests/package/test_openblas.py
|
||||||
|
F: support/testing/tests/package/test_patch.py
|
||||||
|
F: support/testing/tests/package/test_patch/
|
||||||
F: support/testing/tests/package/test_pciutils.py
|
F: support/testing/tests/package/test_pciutils.py
|
||||||
F: support/testing/tests/package/test_perftest.py
|
F: support/testing/tests/package/test_perftest.py
|
||||||
F: support/testing/tests/package/test_pigz.py
|
F: support/testing/tests/package/test_pigz.py
|
||||||
|
|||||||
44
support/testing/tests/package/test_patch.py
Normal file
44
support/testing/tests/package/test_patch.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import infra.basetest
|
||||||
|
|
||||||
|
|
||||||
|
class TestPatch(infra.basetest.BRTest):
|
||||||
|
rootfs_overlay = \
|
||||||
|
infra.filepath("tests/package/test_patch/rootfs-overlay")
|
||||||
|
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||||
|
f"""
|
||||||
|
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||||
|
BR2_PACKAGE_PATCH=y
|
||||||
|
BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
|
||||||
|
BR2_TARGET_ROOTFS_CPIO=y
|
||||||
|
# BR2_TARGET_ROOTFS_TAR is not set
|
||||||
|
"""
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Check the program can execute. This also checks that we are
|
||||||
|
# not using the patch applet from BusyBox (as it does not
|
||||||
|
# recognize the --version option).
|
||||||
|
self.assertRunOk("patch --version")
|
||||||
|
|
||||||
|
# We check the test file contains our expected string before
|
||||||
|
# the patch.
|
||||||
|
sed_cmd = "sed -n '2p' file.txt"
|
||||||
|
out, ret = self.emulator.run(sed_cmd)
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
self.assertEqual(out[0], "Hello World!")
|
||||||
|
|
||||||
|
# We apply our test patch...
|
||||||
|
self.assertRunOk("patch -p1 < file.diff")
|
||||||
|
|
||||||
|
# We check the test file contains our expected string after
|
||||||
|
# applying the patch.
|
||||||
|
out, ret = self.emulator.run(sed_cmd)
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
self.assertEqual(out[0], "Hello Buildroot!")
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
diff -Naur a/file.txt b/file.txt
|
||||||
|
--- a/file.txt 2024-12-18 23:11:50.863359248 +0100
|
||||||
|
+++ b/file.txt 2024-12-18 23:12:26.464561146 +0100
|
||||||
|
@@ -1,3 +1,3 @@
|
||||||
|
This is some context...
|
||||||
|
-Hello World!
|
||||||
|
+Hello Buildroot!
|
||||||
|
...and this is some more context.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
This is some context...
|
||||||
|
Hello World!
|
||||||
|
...and this is some more context.
|
||||||
Reference in New Issue
Block a user