doc: document Etc.nprocessors for worker_processes
[unicorn.git] / t / GNUmakefile
blob5f5d9bc398a2f22ee4322bbe7c2b1a61970155f9
1 # we can run tests in parallel with GNU make
2 all::
4 pid := $(shell echo $$PPID)
6 RUBY = ruby
7 RAKE = rake
8 -include ../local.mk
9 ifeq ($(RUBY_VERSION),)
10 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
11 endif
13 ifeq ($(RUBY_VERSION),)
14 $(error unable to detect RUBY_VERSION)
15 endif
17 RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
18 export RUBY_ENGINE
20 MYLIBS := $(RUBYLIB)
22 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
24 all:: $(T)
26 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
27 t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
28 TEST_OPTS =
29 # TRACER = strace -f -o $(t_pfx).strace -s 100000
30 # TRACER = /usr/bin/time -o $(t_pfx).time
32 ifdef V
33 ifeq ($(V),2)
34 TEST_OPTS += --trace
35 else
36 TEST_OPTS += --verbose
37 endif
38 endif
40 random_blob:
41 dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
42 mv $@.$(pid) $@
44 $(T): random_blob
46 dependencies := socat curl
47 deps := $(addprefix .dep+,$(dependencies))
48 $(deps): dep_bin = $(lastword $(subst +, ,$@))
49 $(deps):
50 @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
51 @test -s $@.$(pid) || \
52 { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
53 @mv $@.$(pid) $@
54 dep: $(deps)
56 test_prefix := $(CURDIR)/../test/$(RUBY_ENGINE)-$(RUBY_VERSION)
57 $(test_prefix)/.stamp:
58 $(MAKE) -C .. test-install
60 $(T): export RUBY := $(RUBY)
61 $(T): export RAKE := $(RAKE)
62 $(T): export PATH := $(test_prefix)/bin:$(PATH)
63 $(T): export RUBYLIB := $(test_prefix)/lib:$(MYLIBS)
64 $(T): dep $(test_prefix)/.stamp trash/.gitignore
65 $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS)
67 trash/.gitignore:
68 mkdir -p $(@D)
69 echo '*' > $@
71 clean:
72 $(RM) -r trash/*
74 .PHONY: $(T) clean