[LLVMdev] [PATCH] Parallelized make check

Julien Lerouge jlerouge at apple.com
Tue Feb 24 18:24:17 PST 2009


Hello,

The attached patch adds the jcheck target equivalent to make check, but
that can run with a -j flag ($ make jcheck -jX).

It does not interfere with the regular check, but rather builds on top
of the check-one target: it first generates a list of tests to run using
RunLLVMTests, and then run those tests according to the supplied -j
flag, invoking the check-one target for each one of them.

One minor change is that the check-one target can take an absolute path
name for the test, and that the site.exp is not regenerated for the
check-one target.

The created log is called jrun.log, and the target will fail if there is
any XPASS or FAIL.

I haven't tested with objdir != srcdir.

Hope this helps,
Julien

-- 
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
-------------- next part --------------
Index: lib/llvm.exp
===================================================================
--- lib/llvm.exp	(revision 65423)
+++ lib/llvm.exp	(working copy)
@@ -116,8 +116,18 @@
 # This procedure runs the set of tests for the test_source_files array.
 proc RunLLVMTests { test_source_files } {
   global srcroot objroot srcdir objdir subdir target_triplet llvmgcc_version
+  global listtests
   set timeout 60
 
+  if { [ string length "$listtests" ] } {
+    set chan [open $listtests a]
+    foreach test $test_source_files {
+      puts $chan "$test"
+      flush $chan
+    }
+    return
+  }
+
   set path [file join $objdir $subdir]
   
   #Make Output Directory if it does not exist already
Index: Makefile
===================================================================
--- Makefile	(revision 65423)
+++ Makefile	(working copy)
@@ -26,6 +26,9 @@
 RUNTESTFLAGS := $(VERBOSE)
 endif
 
+SITE_EXP := site.exp
+FORCETGT := FORCE
+
 ifdef TESTSUITE
 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
@@ -49,22 +52,23 @@
 endif
 
 ifneq ($(RUNTEST),)
-check-local:: site.exp
+check-local:: $(SITE_EXP)
 	( ulimit -t 600 ; ulimit -d 512000 ; \
 	  PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
 	  $(RUNTEST) $(RUNTESTFLAGS) )
 else
-check-local:: site.exp
+check-local:: $(SITE_EXP)
 	@echo "*** dejagnu not found.  Make sure 'runtest' is in your PATH, then reconfigure LLVM."
 endif
 
 ifdef TESTONE
-CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE))
+CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE:$(CURDIR)/%=%))
 CLEANED_TESTONE := $(patsubst test/%,%,$(CLEANED_TESTONE))
 SUBDIR := $(shell dirname $(CLEANED_TESTONE))
 TESTPATH := $(LLVM_SRC_ROOT)/test/$(CLEANED_TESTONE)
-check-one: site.exp $(TCLSH)
-	$(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/site.exp" ; \
+FORCETGT :=
+check-one: $(SITE_EXP) $(TCLSH)
+	$(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/$(SITE_EXP)" ; \
 	  echo "set subdir $(SUBDIR)" ; \
 	  echo "proc pass  { msg } { puts \"PASS: \$$msg\" } "; \
 	  echo "proc fail  { msg } { puts \"FAIL: \$$msg\" }" ; \
@@ -80,6 +84,7 @@
 
 clean::
 	$(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
+	$(RM) -f Makefile.jcheck $(JTESTLIST) $(JLOG)
 
 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
 ifeq ($(OS),Darwin)
@@ -90,7 +95,7 @@
 
 FORCE:
 
-site.exp: FORCE
+site.exp: $(FORCETGT)
 	@echo 'Making a new site.exp file...'
 	@echo '## these variables are automatically generated by make ##' >site.tmp
 	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
@@ -120,9 +125,55 @@
 	@echo 'set grep "$(GREP)"' >>site.tmp
 	@echo 'set gas "$(GAS)"' >>site.tmp
 	@echo 'set llvmdsymutil "$(DSYMUTIL)"' >>site.tmp
+	@echo 'set listtests "$(LISTTESTS)"' >> site.tmp
 	@echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
 	@test ! -f site.exp || \
 	sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
 	@-rm -f site.bak
 	@test ! -f site.exp || mv site.exp site.bak
 	@mv site.tmp site.exp
+
+#===------------------------------------------------------------------------===#
+# Parallelized check support
+#===------------------------------------------------------------------------===#
+
+JCHECKS   :=
+JLOG      := jrun.log
+JTESTLIST := testlist.jcheck
+
+Makefile.jcheck:
+	@$(ECHO) "Creating list of tests to run... "
+	@$(RM) -f $(SITE_EXP) $(JTESTLIST)
+	@$(MAKE) check LISTTESTS=$(JTESTLIST) &>/dev/null
+	@$(RM) -f $(SITE_EXP)
+	@$(ECHO) "JCHECKS := \\" > $@
+	@$(SED) 's/$$/.jcheck \\/' < $(JTESTLIST) >> $@
+	@$(ECHO) >> $@
+	@$(ECHO) "Running test... "
+
+ifeq ($(MAKECMDGOALS), jcheck-local)
+    -include Makefile.jcheck
+endif
+
+$(JCHECKS): $(SITE_EXP)
+	@$(MAKE) check-one TESTONE=$(@:%.jcheck=%) &>$(@:%.jcheck=%.log)
+	@cat $(@:%.jcheck=%.log)
+
+jcheck-local: $(JCHECKS)
+	@$(RM) -f $(JLOG)
+	@$(SED) 's/$$/.log/' < $(JTESTLIST) | xargs cat >> $(JLOG)
+	@$(ECHO) "\n\n\n\n== Results ==" >> $(JLOG)
+	@for R in PASS FAIL XFAIL XPASS; do \
+            M=`$(GREP) "^$$R" $(JLOG) | wc -l | $(SED) 's/[[:space:]]//g'`; \
+            if [ $$M != 0 ]; then \
+                $(ECHO) "$$R: $$M" >> $(JLOG); \
+            fi; \
+         done
+	@tail -n 5 $(JLOG)
+	@$(SED) 's/$$/.log/' < $(JTESTLIST) | xargs $(RM) -f
+
+jcheck:
+	@$(RM) -f Makefile.jcheck
+	@$(MAKE) jcheck-local
+	@if [ -n "`$(GREP) "^XPASS" $(JLOG)`" ]; then false; fi
+	@if [ -n "`$(GREP) "^FAIL" $(JLOG)`" ]; then false; fi


More information about the llvm-dev mailing list