* [Buildroot] [PATCH 1/1] support/testing: add make runtime test
@ 2024-02-20 22:07 Julien Olivain
2024-08-03 10:35 ` Thomas Petazzoni via buildroot
2024-09-03 18:20 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-02-20 22:07 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
DEVELOPERS | 2 +
support/testing/tests/package/test_make.py | 82 +++++++++++++++++++
.../test_make/rootfs-overlay/root/Makefile | 23 ++++++
3 files changed, 107 insertions(+)
create mode 100644 support/testing/tests/package/test_make.py
create mode 100644 support/testing/tests/package/test_make/rootfs-overlay/root/Makefile
diff --git a/DEVELOPERS b/DEVELOPERS
index f0e16af1623..6c8d07d4761 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1815,6 +1815,8 @@ F: support/testing/tests/package/test_lzip.py
F: support/testing/tests/package/test_lsof.py
F: support/testing/tests/package/test_lz4.py
F: support/testing/tests/package/test_lzop.py
+F: support/testing/tests/package/test_make.py
+F: support/testing/tests/package/test_make/
F: support/testing/tests/package/test_mdadm.py
F: support/testing/tests/package/test_mdadm/
F: support/testing/tests/package/test_micropython.py
diff --git a/support/testing/tests/package/test_make.py b/support/testing/tests/package/test_make.py
new file mode 100644
index 00000000000..d549cca37d8
--- /dev/null
+++ b/support/testing/tests/package/test_make.py
@@ -0,0 +1,82 @@
+import os
+
+import infra.basetest
+
+
+class TestMake(infra.basetest.BRTest):
+ rootfs_overlay = \
+ infra.filepath("tests/package/test_make/rootfs-overlay")
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ f"""
+ BR2_PACKAGE_MAKE=y
+ BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def gen_expected_str(self, count):
+ """Return the expected string generated by the test Makefile"""
+ return "".join(map(lambda x: str(x), range(1,count+1)))
+
+ 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.
+ self.assertRunOk("make --version")
+
+ # We touch the Makefile to set its modification time to the
+ # current system time. This is to avoid warnings from Make
+ # about having files with timestamps in the future. This is
+ # because the minimal system running in the emulator might not
+ # set the clock to the real time, and the Makefile has a
+ # correct timestamp from the build host (which is likely at
+ # the correct time).
+ self.assertRunOk("touch Makefile")
+
+ # We test the "message" target and check we get the expected
+ # string.
+ out, ret = self.emulator.run("make message")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0], "Hello Buildroot!")
+
+ # We redo the same test, this time by passing a new message
+ # with a variable.
+ msg = "This is Another Message..."
+ out, ret = self.emulator.run(f"make message MESSAGE='{msg}'")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0], msg)
+
+ # We run a simple "make" invocation, using the defaults.
+ self.assertRunOk("make")
+
+ # We check the generated output contains the expected string.
+ expected_str = self.gen_expected_str(10)
+ out, ret = self.emulator.run("cat output.txt")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0], expected_str)
+
+ # Clean the previous invocation.
+ self.assertRunOk("make clean")
+
+ # We check a output generated file is no longer present.
+ self.assertRunOk("test ! -e output.txt")
+
+ # We run an invocation with a larger COUNT value. GNU Make
+ # version 4.4 introduced the --shuffle option, which shuffle
+ # rules. We use it with a constant seed, in order to have a
+ # stable reshuffling in all test runs. We also include in this
+ # execution a request for parallel jobs.
+ count = 50
+ seed = 123456
+ self.assertRunOk(f"make -j10 --shuffle={seed} COUNT={count}")
+
+ # Despite the pseudo-randomization in the previous invocation,
+ # the expected output should be correctly ordered.
+ expected_str = self.gen_expected_str(count)
+ out, ret = self.emulator.run("cat output.txt")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0], expected_str)
diff --git a/support/testing/tests/package/test_make/rootfs-overlay/root/Makefile b/support/testing/tests/package/test_make/rootfs-overlay/root/Makefile
new file mode 100644
index 00000000000..7ac86945a5e
--- /dev/null
+++ b/support/testing/tests/package/test_make/rootfs-overlay/root/Makefile
@@ -0,0 +1,23 @@
+MESSAGE ?= "Hello Buildroot!"
+COUNT ?= 10
+
+LIST = $(shell seq $(COUNT))
+INPUTS = $(addsuffix .in.txt,$(LIST))
+OUTPUT = output.txt
+
+.PHONY: all
+all: $(OUTPUT)
+
+.PHONY: clean
+clean:
+ $(RM) $(OUTPUT) *.in.txt
+
+.PHONY: message
+message:
+ @echo $(MESSAGE)
+
+%.in.txt:
+ echo $(subst .in.txt,,$@) > $@
+
+$(OUTPUT): $(INPUTS)
+ (cat $? | tr -d '\n' ; echo) > $@
--
2.43.2
_______________________________________________
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 make runtime test
2024-02-20 22:07 [Buildroot] [PATCH 1/1] support/testing: add make runtime test Julien Olivain
@ 2024-08-03 10:35 ` Thomas Petazzoni via buildroot
2024-09-03 18:20 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-03 10:35 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
On Tue, 20 Feb 2024 23:07:20 +0100
Julien Olivain <ju.o@free.fr> wrote:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> DEVELOPERS | 2 +
> support/testing/tests/package/test_make.py | 82 +++++++++++++++++++
> .../test_make/rootfs-overlay/root/Makefile | 23 ++++++
> 3 files changed, 107 insertions(+)
> create mode 100644 support/testing/tests/package/test_make.py
> create mode 100644 support/testing/tests/package/test_make/rootfs-overlay/root/Makefile
There was a very minor flake8 warning:
support/testing/tests/package/test_make.py:19:53: E231 missing whitespace after ','
I fixed it up, and applied. Thanks for this work!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
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 make runtime test
2024-02-20 22:07 [Buildroot] [PATCH 1/1] support/testing: add make runtime test Julien Olivain
2024-08-03 10:35 ` Thomas Petazzoni via buildroot
@ 2024-09-03 18:20 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-09-03 18:20 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 and 2024.05.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-09-03 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 22:07 [Buildroot] [PATCH 1/1] support/testing: add make runtime test Julien Olivain
2024-08-03 10:35 ` Thomas Petazzoni via buildroot
2024-09-03 18:20 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox