chiark / gitweb /
test: Add a missing dependency on the sites file
[secnet.git] / test / Makefile.in
index 0f92038c38d5520f49f43d5fc149a6b302858905..61f6df6be7069b81f5681c09ec766b5068b3d9ed 100644 (file)
@@ -1,7 +1,10 @@
 
 CC:=@CC@
 
-TARGETS=udp-preload.so
+TARGETS=udp-preload.so check
+
+TESTSCRIPTS ?= $(shell echo t-*[0-9a-z])
+TESTNAMES := $(patsubst t-%,%,$(notdir $(TESTSCRIPTS)))
 
 all: $(TARGETS)
 
@@ -10,6 +13,32 @@ CFLAGS += -D_REENTRANT -fPIC
 udp-preload.so: udp-preload.o
        $(CC) -shared -Wl,-soname,$@.1 $^ -o $@ -ldl
 
+# These test scripts use little cpu but contain sleeps etc.  So when
+# there are several, we are going to want to run *loads* in parallel.
+#
+# Ideally we would do something like "every one of these counts for a
+# tenth of a job" but make can't do that.  So bodge it: we treat all the
+# tests as a single job, and disconnect the parent's jobserver.
+#
+# make.info says $(MAKE) causes special handling of the rule but only
+# if it's written literally like that in the rule, hence this
+# indirection.  We need no squash MAKEFLAGS and MFLAGS too.
+# MAKELEVEL seems like it will be fine to pass on.
+
+MAKE_NOTSPECIAL:=$(MAKE)
+
+check:
+       env -u MAKEFLAGS -u MFLAGS \
+       $(MAKE_NOTSPECIAL) -j$(shell nproc || 1)0 check-real
+
+check-real: $(foreach t,$(TESTNAMES),d-$t/ok)
+
+d-%/ok: t-% udp-preload.so common.tcl ../secnet ../test-example/sites.conf
+       @rm -rf d-$*; mkdir d-$*
+       @cd .. && test/$< >test/d-$*/log 2>&1
+       @printf "$* "
+       @touch $@
+
 clean:
        $(RM) -f *.o *.so
        $(RM) -rf tmp