chiark / gitweb /
stest: Use common.make and therefore our standard CFLAGS
[secnet.git] / stest / Makefile.in
1
2 VPATH:=@srcdir@
3 srcdir:=@srcdir@
4 topdir:=@top_srcdir@
5 topbuilddir:=$(shell cd .. && pwd)
6
7 include ../common.make
8
9 TARGETS=udp-preload.so check
10
11 TESTSCRIPTS ?= $(shell echo $(srcdir)/t-*[0-9a-z])
12 TESTNAMES := $(patsubst t-%,%,$(notdir $(TESTSCRIPTS)))
13
14 all: $(TARGETS)
15
16 CFLAGS += -D_REENTRANT -fPIC
17
18 udp-preload.so: udp-preload.o
19         $(CC) -shared -Wl,-soname,$@.1 $^ -o $@ -ldl
20
21 # These test scripts use little cpu but contain sleeps etc.  So when
22 # there are several, we are going to want to run *loads* in parallel.
23 #
24 # Ideally we would do something like "every one of these counts for a
25 # tenth of a job" but make can't do that.  So bodge it: we treat all the
26 # tests as a single job, and disconnect the parent's jobserver.
27 #
28 # make.info says $(MAKE) causes special handling of the rule but only
29 # if it's written literally like that in the rule, hence this
30 # indirection.  We need no squash MAKEFLAGS and MFLAGS too.
31 # MAKELEVEL seems like it will be fine to pass on.
32
33 MAKE_NOTSPECIAL:=$(MAKE)
34
35 check:
36         env -u MAKEFLAGS -u MFLAGS \
37         $(MAKE_NOTSPECIAL) -j$(shell nproc || 1)0 check-real
38
39 check-real: $(foreach t,$(TESTNAMES),d-$t/ok)
40
41 d-%/ok: $(srcdir)/t-% udp-preload.so $(srcdir)/common.tcl \
42                 ../secnet ../test-example/sites.conf
43         @rm -rf d-$*; mkdir d-$*
44         export STEST_BUILDDIR=$(topbuilddir); \
45         cd $(topdir) && stest/t-$* >$(topbuilddir)/stest/d-$*/log 2>&1
46         @printf "$* "
47         @touch $@
48
49 clean:
50         $(RM) -f *.o *.so
51         $(RM) -rf tmp