1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 2010-2011. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%
ifneq ($(ERL_TOP),)
include $(ERL_TOP)/make/target.mk
include $(ERL_TOP)/make/$(TARGET)/otp.mk
else
include $(DIAMETER_TOP)/make/target.mk
include $(DIAMETER_TOP)/make/$(TARGET)/rules.mk
endif
# ----------------------------------------------------
# Application version
# ----------------------------------------------------
include ../vsn.mk
VSN=$(DIAMETER_VSN)
# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------
RELSYSDIR = $(RELEASE_PATH)/diameter_test
ifeq ($(findstring win32,$(TARGET)),win32)
MAKEFILE_SRC = Makefile.win32.src
else
MAKEFILE_SRC = Makefile.src
endif
ifeq ($(TT_DIR),)
TT_DIR = /tmp
endif
# ----------------------------------------------------
# Target Specs
# ----------------------------------------------------
include modules.mk
EBIN = .
HRL_FILES = diameter_test_lib.hrl
ERL_FILES = $(MODULES:%=%.erl)
SOURCE = $(HRL_FILES) $(ERL_FILES)
TARGET_FILES = $(MODULES:%=%.$(EMULATOR))
APP_CASES = app
TRANSPORT_CASES = tcp
ALL_CASES = \
$(APP_CASES) \
compiler conf sync stats reg peer \
$(TRANSPORT_CASES)
EMAKEFILE = Emakefile
ifneq ($(ERL_TOP),)
MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile)
else
MAKE_EMAKE = $(wildcard $(DIAMETER_TOP)/make/make_emakefile)
endif
ifeq ($(MAKE_EMAKE),)
BUILDTARGET = $(TARGET_FILES)
RELTEST_FILES = $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE)
else
BUILDTARGET = emakebuild
RELTEST_FILES = $(EMAKEFILE) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE)
endif
# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
include ../src/app/diameter.mk
ifeq ($(USE_DIAMETER_TEST_CODE),true)
ERL_COMPILE_FLAGS += -DDIAMETER_TEST_CODE=mona_lisa_spelar_doom
endif
ifeq ($(USE_DIAMETER_HIPE),true)
ERL_COMPILE_FLAGS += +native -DDIAMETER_hipe_special=true
endif
ifneq ($(ERL_TOP),)
ERL_COMPILE_FLAGS += \
$(DIAMETER_ERL_COMPILE_FLAGS) \
-pa $(ERL_TOP)/lib/test_server/ebin \
-I$(ERL_TOP)/lib/test_server/include
else
ERL_COMPILE_FLAGS += \
$(DIAMETER_ERL_COMPILE_FLAGS) \
-pa $(TEST_SERVER_DIR)/ebin \
-I$(TEST_SERVER_DIR)/include
endif
ERL_PATH = \
-pa ../../$(APPLICATION)/ebin \
-pa ../../et/ebin
ifndef SUITE
SUITE = diameter_SUITE
endif
ESTOP = -s init stop
ifeq ($(DONT_STOP),true)
MAYBE_ESTOP =
else
MAYBE_ESTOP = $(ESTOP)
endif
ETVIEW = -s et_viewer
ifeq ($(USE_ET_VIEWER),true)
MAYBE_ETVIEW =
else
MAYBE_ETVIEW = $(ETVIEW)
endif
ifeq ($(MERL),)
MERL = $(ERL)
endif
ARGS += -noshell
ifeq ($(DISABLE_TC_TIMEOUT),true)
ARGS += -diameter_test_timeout
endif
DIAMETER_TEST_SERVER = diameter_test_server
# ----------------------------------------------------
# Targets
# ----------------------------------------------------
tests debug opt: $(BUILDTARGET)
targets: $(TARGET_FILES)
.PHONY: emakebuild
emakebuild: $(EMAKEFILE)
$(EMAKEFILE):
$(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' | grep -v Warning > $(EMAKEFILE)
$(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) | grep -v Warning >> $(EMAKEFILE)
clean:
rm -f $(EMAKEFILE)
rm -f $(TARGET_FILES)
rm -f errs core *~
docs:
info:
@echo "MAKE_EMAKE = $(MAKE_EMAKE)"
@echo "EMAKEFILE = $(EMAKEFILE)"
@echo "BUILDTARGET = $(BUILDTARGET)"
@echo ""
@echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)"
@echo "ERL = $(ERL)"
@echo "ERLC = $(ERLC)"
@echo "MERL = $(MERL)"
@echo ""
@echo "ARGS = $(ARGS)"
@echo ""
@echo "HRL_FILES = $(HRL_FILES)"
@echo "ERL_FILES = $(ERL_FILES)"
@echo "TARGET_FILES = $(TARGET_FILES)"
@echo ""
help:
@echo ""
@echo "This Makefile controls the test of the $(APPLICATION) application. "
@echo ""
@echo "There are two separate ways to perform the test of $(APPLICATION)."
@echo ""
@echo " a) Run the official OTP test-server (which we do not describe here)"
@echo ""
@echo " b) Run the test-server provided with this application. "
@echo " There are a number of targets to run the entire or parts"
@echo " of this applications ($(APPLICATION)) test-suite"
@echo ""
@echo "Targets:"
@echo ""
@echo " help"
@echo " Print this info"
@echo ""
@echo " info"
@echo " Prints various environment variables. "
@echo " May be useful when debugging the Makefile. "
@echo ""
@echo " tests | debug | opt "
@echo " Compile all test-code. "
@echo ""
@echo " clean "
@echo " Remove all targets. "
@echo ""
@echo " test"
@echo " Run the entire $(APPLICATION) test-suite. "
@echo ""
@echo " app"
@echo " Run the $(APPLICATION) application sub-test-suite. "
@echo ""
@echo " compiler"
@echo " Run the $(APPLICATION) compiler sub-test-suite(s). "
@echo ""
@echo " conf"
@echo " Run the $(APPLICATION) config sub-test-suite. "
@echo " Checks various aspects of the $(APPLICATION) configuration. "
@echo ""
@echo " sync"
@echo " Run the $(APPLICATION) sync sub-test-suite. "
@echo ""
@echo " stats"
@echo " Run the $(APPLICATION) stats sub-test-suite. "
@echo ""
@echo " reg"
@echo " Run the $(APPLICATION) reg sub-test-suite. "
@echo ""
@echo " peer"
@echo " Run the $(APPLICATION) peer sub-test-suite"
@echo ""
@echo " ptab"
@echo " Run the $(APPLICATION) persistent-table sub-test-suite"
@echo ""
@echo " tcp"
@echo " Run the $(APPLICATION) tcp sub-test-suite"
@echo ""
@echo ""
# ----------------------------------------------------
# Special Targets
# ----------------------------------------------------
all: make
@echo "make sure epmd is new"
@epmd -kill > /dev/null
@echo "Running all sub-suites separatelly"
@for i in $(ALL_CASES); do \
echo "SUITE: $$i"; \
clearmake -V $$i > $$i.log; \
done
aall: make
@echo "make sure epmd is new"
@epmd -kill > /dev/null
@echo "Running all app sub-suites separatelly"
@for i in $(APP_CASES); do \
echo "SUITE: $$i"; \
clearmake -V $$i > $$i.log; \
done
echo "done"
tall: make
@echo "make sure epmd is new"
@epmd -kill > /dev/null
@echo "Running all transport sub-suites separatelly"
@for i in $(TRANSPORT_CASES); do \
echo "SUITE: $$i"; \
clearmake -V $$i > $$i.log; \
done
make: targets
test: make
$(MERL) $(ARGS) -sname diameter_test $(ERL_PATH) \
-s $(DIAMETER_TEST_SERVER) t $(SUITE) \
$(MAYBE_ESTOP)
log:
mkdir $@
##########################
# This assumes GNU sed to exit 1 if the output looks to indicate failure.
# diameter_ct:run/1 itself can't tell (it seems).
app codec dict reg stats sync: log make
$(MERL) $(ARGS) \
-sname diameter_test_$@ \
-s diameter_ct run $@ \
-s init stop \
| sed '/ FAILED /h; p; $$!d; x; /./!d; Q 1'
compiler conf peer tcp: make
$(MERL) $(ARGS) -sname diameter_$@ $(ERL_PATH) \
-s $(DIAMETER_TEST_SERVER) t diameter_$@_test \
$(ESTOP)
node:
$(MERL) -sname diameter $(ERL_PATH)
# ----------------------------------------------------
# Release Targets
# ----------------------------------------------------
ifneq ($(ERL_TOP),)
include $(ERL_TOP)/make/otp_release_targets.mk
else
include $(DIAMETER_TOP)/make/release_targets.mk
endif
release_spec:
release_docs_spec:
release_tests_spec: tests
$(INSTALL_DIR) $(RELSYSDIR)
$(INSTALL_DATA) $(RELTEST_FILES) $(RELSYSDIR)
# $(INSTALL_DATA) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) \
# $(HRL_FILES) $(ERL_FILES) \
# $(RELSYSDIR)
#
chmod -R u+w $(RELSYSDIR)
|