[PATCH 2/4] gdb/testsuite: Factor out dg-extract-results.sh calls

Pedro Alves <[email protected]> Thu, 23 Jul 2026 18:51:29 +0100
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
The parallel-testing targets in the testsuite Makefile each combine
the per-test gdb.sum / gdb.log files produced by a run into a single
combined pair, using contrib/dg-extract-results.sh.  The same pair of
invocations (once for gdb.sum, once with -L for gdb.log) is copied in
check-parallel, check-parallel-racy, and check-all-boards, each only
differing in the input and output directories.

Factor those invocations into a DG_EXTRACT_RESULTS canned recipe
parameterized by the input and output directories, and use it from all
three targets.

Change-Id: Ia3417c9410b87a415cb9b104efa60d4bfb9ffbc5
---
 gdb/testsuite/Makefile.in | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index f103d7ddd65..fb312583b0e 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -254,16 +254,23 @@ check-single-racy:
 	  `ls racy_outputs/*/gdb.sum` > racy.sum; \
 	sed -n '/=== gdb Summary ===/,$$ p' racy.sum
 
+# Combine the individual gdb.sum / gdb.log files found anywhere under
+# directory $(1) into a single gdb.sum / gdb.log pair in directory
+# $(2), using contrib/dg-extract-results.sh.
+define DG_EXTRACT_RESULTS
+	$(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
+	  `find $(1) -name gdb.sum -print` > $(2)/gdb.sum; \
+	$(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
+	  `find $(1) -name gdb.log -print` > $(2)/gdb.log
+endef
+
 check-parallel:
 	-rm -f *core*
 	-rm -rf cache outputs temp
 	$(MAKE) -k do-check-parallel; \
 	result=$$?; \
 	if test -d outputs; then \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
-	    `find outputs -name gdb.sum -print` > gdb.sum; \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
-	    `find outputs -name gdb.log -print` > gdb.log; \
+	  $(call DG_EXTRACT_RESULTS,outputs,.); \
 	  $(SHELL) $(srcdir)/lib/dg-add-core-file-count.sh; \
 	  sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
 	fi; \
@@ -282,12 +289,7 @@ check-parallel-racy:
 	for n in `seq $$racyiter` ; do \
 	  $(MAKE) -k do-check-parallel-racy \
 	    RACY_OUTPUT_N=$$n; \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
-	    `find racy_outputs/$$n -name gdb.sum -print` > \
-	    racy_outputs/$$n/gdb.sum; \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
-	    `find racy_outputs/$$n -name gdb.log -print` > \
-	    racy_outputs/$$n/gdb.log; \
+	  $(call DG_EXTRACT_RESULTS,racy_outputs/$$n,racy_outputs/$$n); \
 	  sed -n '/=== gdb Summary ===/,$$ p' racy_outputs/$$n/gdb.sum; \
 	done; \
 	$(srcdir)/analyze-racy-logs.py \
@@ -389,10 +391,7 @@ check-all-boards: all $(abs_builddir)/site.exp
 		"$(TESTS)" \
 	result=$$?; \
 	if test -d check-all; then \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
-	    `find check-all -name gdb.sum -print` > check-all/gdb.sum; \
-	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
-	    `find check-all -name gdb.log -print` > check-all/gdb.log; \
+	  $(call DG_EXTRACT_RESULTS,check-all,check-all); \
 	  sed -n '/=== gdb Summary ===/,$$ p' check-all/gdb.sum; \
 	fi; \
 	exit $$result
-- 
2.54.0