1 # we can run tests in parallel with GNU make
5 pid
:= $(shell echo
$$PPID)
9 zbatery_lib
:= $(shell cd ..
/lib
&& pwd
)
11 ifeq ($(RUBY_VERSION
),)
12 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
15 ifeq ($(RUBY_VERSION
),)
16 $(error unable to detect RUBY_VERSION
)
19 RUBY_ENGINE
:= $(shell $(RUBY
) -e
'puts((RUBY_ENGINE rescue "ruby"))')
20 export RUBY_VERSION RUBY_ENGINE
22 ifeq (Linux
,$(shell uname
-s
))
24 models
+= XEpollThreadSpawn
25 models
+= XEpollThreadPool
28 models
+= WriterThreadPool
29 models
+= WriterThreadSpawn
33 models
+= EventMachine
36 ifeq ($(RUBY_ENGINE
),ruby
)
38 ONENINE
:= $(shell case
$(RUBY_VERSION
) in
1.9.
*$(rp
) echo true
;;esac
)
39 ifeq ($(ONENINE
),true
)
42 models
+= CoolioFiberSpawn
44 models
+= CoolioThreadSpawn
45 models
+= CoolioThreadPool
49 ifeq ($(RUBY_ENGINE
),rbx
)
52 all_models
:= $(models
) Base
54 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
56 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
57 $(T
): MODELS
= $(models
)
59 # some tests can be run with all models
60 t0000-simple-http.sh
: MODELS
= $(all_models
)
61 t0001-unix-http.sh
: MODELS
= $(all_models
)
62 t0002-graceful.sh
: MODELS
= $(all_models
)
63 t0002-parser-error.sh
: MODELS
= $(all_models
)
64 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
66 # recursively run per-model tests
67 # haven't figured out a good way to make make non-recursive here, yet...
69 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
72 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
76 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
77 t_pfx
= trash
/$@
-$(RUBY_ENGINE
)-$(RUBY_VERSION
)
79 # TRACER = strace -f -o $(t_pfx).strace -s 100000
80 # TRACER = /usr/bin/time -o $(t_pfx).time
86 TEST_OPTS
+= --verbose
90 bindir := $(CURDIR
)/bin-
$(RUBY_ENGINE
)-$(RUBY_VERSION
)
91 bin_zbatery
:= $(bindir)/zbatery
92 $(bin_zbatery
): ruby_bin
= $(shell which
$(RUBY
))
93 $(bin_zbatery
): ..
/bin
/zbatery
95 install -m
755 $^
$@.
$(pid
)
96 $(MRI
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
100 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
105 dependencies
:= socat curl
106 deps
:= $(addprefix .dep
+,$(dependencies
))
107 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
109 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
110 @
test -s
$@.
$(pid
) || \
111 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
114 libs
:= tmp
/isolate
/$(RUBY_ENGINE
)-$(RUBY_VERSION
)/.libs
115 $(libs
): test_isolate.rb
119 t_deps
:= $(libs
) $(deps
) $(bin_zbatery
) trash
/.gitignore
122 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
123 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
124 $(MODEL_T
): export RUBY
:= $(RUBY
)
125 $(MODEL_T
): export PATH
:= $(bindir):$(PATH
)
126 $(MODEL_T
): $(t_deps
)
127 RUBYLIB
=$(zbatery_lib
):$$(cat
$(libs
)) \
128 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
135 $(RM
) -r trash
/*.log trash
/*.code
$(bindir)