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