forked from scy-phy/minicps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (103 loc) · 2.88 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
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
# MiniCPS Makefile
# VARIABLES {{{1
LATEST_VERSION = 1.1.3
MININET = sudo mn
PYTHON = sudo -E $(shell which python)
PYTHON_OPTS =
# regex testMatch: (?:^|[b_.-])[Tt]est)
# --exe: include also executable files
# -s: don't capture std output
# nosetests -s tests/devices_tests.py:fun_name
# TODO: add testing conditionals for verbosity, doctest plugin and coverage plugin
# http://web.mit.edu/gnu/doc/html/make_7.html
# NOTE: sudo because of mininet
TESTER = sudo nosetests
TESTER_TRAVIS = nosetests
TESTER_OPTS = -s -v --exe --rednose
TESTER_OPTS_COV_HTML = $(TESTER_OPTS) --with-coverage --cover-html
UPLOADER=twine
# }}}
.PHONY: tests tests-travis clean
# TOY {{{1
toy:
cd examples/toy; $(PYTHON) $(PYTHON_OPTS) run.py; cd ../..
toy-init:
cd examples/toy; $(PYTHON) $(PYTHON_OPTS) init.py; cd ../..
test-toy:
cd examples/toy; $(TESTER) $(TESTER_OPTS) tests.py; cd ../..
# TODO
test-toy-cover:
cd examples/toy; $(TESTER) $(TESTER_OPTS_COV_HTML) tests.py; cd ../..
# }}}
# SWAT-S1 {{{1
swat-s1-init:
cd examples/swat-s1; $(PYTHON) $(PYTHON_OPTS) init.py; cd ../..
swat-s1:
cd examples/swat-s1; $(PYTHON) $(PYTHON_OPTS) run.py; cd ../..
test-swat-s1:
cd examples/swat-s1; $(TESTER) $(TESTER_OPTS) tests.py; cd ../..
# }}}
# TESTS {{{1
# ALL {{{2
tests:
$(TESTER) $(TESTER_OPTS) tests
# }}}
# MANUAL {{{2
test-mcps:
$(TESTER) $(TESTER_OPTS) tests/mcps_tests.py
test-networks:
$(TESTER) $(TESTER_OPTS) tests/networks_tests.py
test-sdns:
$(TESTER) $(TESTER_OPTS) tests/sdns_tests.py
test-protocols:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py
test-enip:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py:TestEnipProtocol
test-modbus:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py:TestModbusProtocol
test-utils:
$(TESTER) $(TESTER_OPTS) tests/utils_tests.py
test-states:
$(TESTER) $(TESTER_OPTS) tests/states_tests.py
test-devices:
$(TESTER) $(TESTER_OPTS) tests/devices_tests.py
test-device:
$(TESTER) $(TESTER_OPTS) tests/devices_tests.py:TestDevice
# }}}
# TRAVIS {{{2
tests-travis:
$(TESTER_TRAVIS) $(TESTER_OPTS) tests/protocols_tests.py
$(TESTER_TRAVIS) $(TESTER_OPTS) tests/devices_tests.py
$(TESTER_TRAVIS) $(TESTER_OPTS) tests/states_tests.py
# https://pypi.python.org/pypi/nose-cov/1.6
# FIXME: test cov
# report: term, term-missing, html, xml, annotate
# --cov set the covered FS
# test-cov:
# sudo $(TESTER) $(TESTER_OPTS_COV) minicps_tests.py
# }}}
# }}}
# CLEAN {{{1
clean: clean-cover clean-pyc clean-logs
clean-simulation:
sudo pkill -f -u root "python -m cpppo.server.enip"
sudo mn -c
clean-cover:
rm -f minicps/*,cover
rm -f tests/*,cover
clean-pyc:
rm -f minicps/*.pyc
rm -f tests/*.pyc
clean-logs:
rm -f logs/*.log
clean-cpppo:
sudo pkill -f -u root "python -m cpppo.server.enip"
clean-mininet:
sudo mn -c
# }}}
# PYPI {{{1
pypi-wheel:
./setup.py sdist bdist_wheel
pypi-upload:
$(UPLOADER) upload dist/minicps-$(LATEST_VERSION)*
# }}}