diff mbox series

[v2,9/9] ltp: add makefile target to show test results

Message ID 20250312214232.955450-10-smayhew@redhat.com (mailing list archive)
State New
Headers show
Series tweak results organization and reporting | expand

Commit Message

Scott Mayhew March 12, 2025, 9:42 p.m. UTC
Under the hood, it more or less just does 'find ... | xargs cat'.

By default, the "*.log" files will be shown for the most recent kernel
run.  You can show the results for a different kernel by overriding the
LAST_KERNEL variable, e.g.

$ LAST_KERNEL=6.11.9-100.fc39.x86_64 make ltp-show-results

You can change the files being shown by overriding the PATTERN variable.
For example, to just see the failures:

$ PATTERN="-name \"*.failed\"" make ltp-show-results

Note that since the ltp log files have a date and timestamp in the
filename, it's possible to accumulate logs from multiple test runs.  If
you're showing the results from the most recent kernel, then we'll only
show the logs from the most recent run (i.e. logs that are in the
last-run directory). But if you're showing the results from an older
kernel, then we'll show all the logs in that directory (but you can
override that too if you get creative with the PATTERN variable).

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 workflows/ltp/Makefile | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/workflows/ltp/Makefile b/workflows/ltp/Makefile
index 4e439da..e946be7 100644
--- a/workflows/ltp/Makefile
+++ b/workflows/ltp/Makefile
@@ -96,6 +96,24 @@  LTP_KERNEL_CI_LOOP      := scripts/workflows/ltp/run_kernel_ci.sh
 LTP_KERNEL_CI_LOOP_KOTD := scripts/workflows/ltp/run_kernel_ci_kotd.sh
 endif # CONFIG_KERNEL_CI
 
+ifndef LAST_KERNEL
+LAST_KERNEL := $(shell cat workflows/ltp/results/last-kernel.txt 2>/dev/null)
+endif
+
+ifeq ($(LAST_KERNEL), $(shell cat workflows/ltp/results/last-kernel.txt 2>/dev/null))
+FIND_PATH := workflows/ltp/results/last-run
+else
+FIND_PATH := workflows/ltp/results/$(LAST_KERNEL)
+endif
+
+ifndef PATTERN
+PATTERN := -name "*.log"
+endif
+
+ifndef XARGS_ARGS
+XARGS_ARGS := -I {} bash -c 'echo "{}:"; cat {}; echo;'
+endif
+
 ltp:
 	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -l baseline,dev \
 		-f 30 -i hosts playbooks/ltp.yml --skip-tags run_tests,copy_results
@@ -128,6 +146,11 @@  ltp-dev-reset:
 		-f 30 -i hosts -l dev playbooks/ltp.yml \
 		--tags vars,reset --extra-vars=@./extra_vars.yaml
 
+ltp-show-results:
+	@find $(FIND_PATH) -type f $(PATTERN) \
+		| xargs $(XARGS_ARGS) \
+		| sed '$${/^$$/d;}'
+
 ltp-help-menu:
 	@echo "ltp options:"
 	@echo "ltp                              - Git clone ltp, build and install it"