mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] kbuild: add make check target
@ 2025-10-27  8:08 Ahmad Fatoum
  2025-10-28  9:03 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-10-27  8:08 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The barebox test suite is invoked by running pytest, but for many
projects running make check is what is usually expected.

Add a make check target that calls pytest to accommodate that.
In future, we may add extra checks to test that pytest is correctly
installed to make it easier to use.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 Makefile | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/Makefile b/Makefile
index 9af028cbc6a0..018a206ee8ca 100644
--- a/Makefile
+++ b/Makefile
@@ -463,6 +463,7 @@ KLZOP		= lzop
 LZMA		= lzma
 LZ4		= lz4
 XZ		= xz
+PYTEST		= $(if $(shell command -v labgrid-pytest 2>/dev/null),labgrid-pytest,pytest)
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
 CFLAGS_KERNEL	=
@@ -1054,7 +1055,32 @@ endif
 
 PHONY += install
 
+# Testing barebox
+# ---------------------------------------------------------------------------
+# This target has pytest select the YAML env matching CONFIG_NAME if available.
+# Use pytest --lg-env $labgrid_env_yaml directly if you need more than that.
+
+labgrid-env := $(srctree)/test/$(SRCARCH)/$(CONFIG_NAME).yaml
+
+check:
+ifeq ($(CONFIG_NAME),"")
+	@echo "error: can't autoload labgrid env with CONFIG_NAME unset!" >&2
+	@exit 1
+endif
+	@if [ ! -r "$(labgrid-env)" ]; then \
+		echo "error: No Labgrid environment at $(labgrid-env)!" >&2; \
+		echo "Choose a different config (or change CONFIG_NAME)" >&2; \
+		echo "that can be automatically tested" >&2; \
+		exit 1; \
+	fi
+	@echo
+	@# This is intentionally not @suppressed, to make it easier to reproduce
+	(cd $(srctree); $(PYTEST))
+
+PHONY += check
+
 # barebox image
+# ---------------------------------------------------------------------------
 barebox: $(BAREBOX_LDS) $(BAREBOX_OBJS) $(kallsyms.o) FORCE
 	$(call if_changed_rule,barebox__)
 	$(Q)rm -f .old_version
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kbuild: add make check target
  2025-10-27  8:08 [PATCH] kbuild: add make check target Ahmad Fatoum
@ 2025-10-28  9:03 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-10-28  9:03 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 27 Oct 2025 09:08:23 +0100, Ahmad Fatoum wrote:
> The barebox test suite is invoked by running pytest, but for many
> projects running make check is what is usually expected.
> 
> Add a make check target that calls pytest to accommodate that.
> In future, we may add extra checks to test that pytest is correctly
> installed to make it easier to use.
> 
> [...]

Applied, thanks!

[1/1] kbuild: add make check target
      https://git.pengutronix.de/cgit/barebox/commit/?id=91243c375738 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-28  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-27  8:08 [PATCH] kbuild: add make check target Ahmad Fatoum
2025-10-28  9:03 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox