-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (76 loc) · 2.6 KB
/
Makefile
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
SCENARIOS:=$(shell find -maxdepth 1 -type d -name 'scenarios*'|sed 's_\./__g')
TESTS=$(addprefix test_,$(SCENARIOS))
BASH_SCRIPTS = bench.sh get_results.sh run_tests.sh t/testrunner bin/*.sh
PERL_SCRIPTS = bin/*.pl
SHELL_SCRIPTS = tests/do_test_yaml_format.sh
RESULTS ?= reports
CACHE_DIR ?= $(RESULTS)/.pytest_cache
# do nothing as default
all:
$(MAKE) syntaxcheck
.ONESHELL:
clean:
@echo "Clean files"
for SCENARIO in $(SCENARIOS); do
find "$${SCENARIO}" -type f \( \
-name 'callforward.yml' -o \
-name 'trusted.yml' -o \
-name 'lnp.yml' -o \
-name 'prefs.json' -o \
-name '*_test.yml' -o \
-name '*.csv' \
\) -exec rm {} \;
done
syntaxcheck: bashismcheck perlcheck pythoncheck shellcheck
bashismcheck:
@echo -n "Checking for bashisms: "; \
for SCRIPT in $(SHELL_SCRIPTS); do \
checkbashisms -x $${SCRIPT} || exit 1 ; \
done; \
echo "done."; \
perlcheck:
@echo "Checking for perl syntax errors: "; \
mkdir -p perl-dummy/Sipwise ; \
for f in Sipwise/API.pm ; do \
echo '1;' > perl-dummy/$$f ; \
done; \
for SCRIPT in $(PERL_SCRIPTS); do \
perl -Iperl-dummy/ -cw $${SCRIPT} || exit 1 ; \
done; \
rm -r perl-dummy ; \
echo "-> perl check done."; \
pythoncheck:
@echo -n "Checking for python syntax errors: "; \
python3 -m compileall ./ || exit 1 ; \
py3clean ./ # get rid of pyc files and __pycache__ dirs ; \
echo "done."; \
shellcheck:
@echo -n "Checking for shell syntax errors: "; \
for SCRIPT in $(BASH_SCRIPTS) $(SHELL_SCRIPTS); do \
bash -n $${SCRIPT} || exit ; \
done; \
echo "done."; \
# python-junitxml 0.6 has this bug
# https://bugs.launchpad.net/pyjunitxml/+bug/892293
$(TESTS):
@mkdir -p $(RESULTS)
$(eval SCEN_DIR := $(@:test_%=%))
./tests/do_test_yaml_format.sh $(SCEN_DIR)
test_check: tests/test_check.py
mkdir -p $(RESULTS)
./tests/test_check.py > $(RESULTS)/$(@).xml
test_detect_network: tests/test_detect_network.py
mkdir -p $(RESULTS)
pytest-3 -o cache_dir=$(CACHE_DIR) --junitxml=${RESULTS}/$(@).xml $(<)
test_generate_test_tt2: tests/test_generate_test_tt2.py
mkdir -p $(RESULTS)
pytest-3 -o cache_dir=$(CACHE_DIR) --junitxml=${RESULTS}/$(@).xml $(<)
test_generate_test_tt2_sipp: tests/test_generate_test_tt2_sipp.py
mkdir -p $(RESULTS)
pytest-3 -o cache_dir=$(CACHE_DIR) --junitxml=${RESULTS}/$(@).xml $(<)
test_generate_test_tt2_cfgt: tests/test_generate_test_tt2_cfgt.py
mkdir -p $(RESULTS)
pytest-3 -o cache_dir=$(CACHE_DIR) --junitxml=${RESULTS}/$(@).xml $(<)
# run this in parallel!! -j is your friend
test: $(TESTS) test_check test_detect_network test_generate_test_tt2 test_generate_test_tt2_sipp test_generate_test_tt2_cfgt
.PHONY: all $(TESTS)