-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Makefile
220 lines (205 loc) · 5.5 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
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
ifeq ($(origin CC), default)
CC = gcc
endif
C_SOURCES := \
tests/files/c_source/oer.c \
tests/files/c_source/uper.c
FUZZER_CC ?= clang
FUZZER_OER_EXE = main_oer_fuzzer
FUZZER_UPER_EXE = main_uper_fuzzer
FUZZER_OER_C_SOURCES = \
tests/main_oer_fuzzer.c \
tests/files/c_source/oer.c
FUZZER_UPER_C_SOURCES = \
tests/main_uper_fuzzer.c \
tests/files/c_source/uper.c
FUZZER_CFLAGS = \
-fprofile-instr-generate \
-fcoverage-mapping \
-Itests/files/c_source \
-g -fsanitize=address,fuzzer \
-fsanitize=signed-integer-overflow \
-fno-sanitize-recover=all
FUZZER_EXECUTION_TIME ?= 30
CFLAGS := \
-Wall \
-Wextra \
-Wdouble-promotion \
-Wfloat-equal \
-Wformat=2 \
-Wshadow \
-Werror
CFLAGS_EXTRA := \
-Wduplicated-branches \
-Wduplicated-cond \
-Wjump-misses-init \
-Wlogical-op \
-Wnull-dereference \
-Wrestrict \
-Wconversion \
-Wpedantic
CFLAGS_EXTRA_CLANG := \
-fsanitize=address \
-fsanitize=undefined,nullability \
-Warray-bounds-pointer-arithmetic \
-Wassign-enum \
-Wcast-align \
-Wcast-qual \
-Wchar-subscripts \
-Wcomma \
-Wcomment \
-Wconditional-uninitialized \
-Wdate-time \
-Wdocumentation \
-Wduplicate-decl-specifier \
-Wduplicate-enum \
-Wduplicate-method-arg \
-Wduplicate-method-match \
-Wembedded-directive \
-Wempty-translation-unit \
-Wexpansion-to-defined \
-Wflexible-array-extensions \
-Wfloat-conversion \
-Wfloat-equal \
-Wfloat-overflow-conversion \
-Wfloat-zero-conversion \
-Wformat-non-iso \
-Wformat-nonliteral \
-Wformat-pedantic \
-Wfour-char-constants \
-Wgnu-anonymous-struct \
-Wgnu-array-member-paren-init \
-Wgnu-auto-type \
-Wgnu-binary-literal \
-Wgnu-case-range \
-Wgnu-complex-integer \
-Wgnu-compound-literal-initializer \
-Wgnu-conditional-omitted-operand \
-Wgnu-designator \
-Wgnu-empty-initializer \
-Wgnu-empty-struct \
-Wgnu-flexible-array-initializer \
-Wgnu-flexible-array-union-member \
-Wgnu-folding-constant \
-Wgnu-imaginary-constant \
-Wgnu-include-next \
-Wgnu-label-as-value \
-Wgnu-redeclared-enum \
-Wgnu-statement-expression \
-Wgnu-union-cast \
-Wgnu-zero-line-directive \
-Wgnu-zero-variadic-macro-arguments \
-Wheader-hygiene \
-Widiomatic-parentheses \
-Wimplicit \
-Wimplicit-fallthrough \
-Wloop-analysis \
-Wmethod-signatures \
-Wmissing-braces \
-Wmissing-field-initializers \
-Wnested-anon-types \
-Wnewline-eof \
-Wnull-pointer-arithmetic \
-Woverlength-strings \
-Wpointer-arith \
-Wsign-compare \
-Wtautological-compare \
-Wundef \
-Wuninitialized \
-Wunreachable-code \
-Wunreachable-code-aggressive \
-Wunused-comparison \
-Wunused-const-variable \
-Wunused-parameter \
-Wunused-variable \
-Wvariadic-macros \
-Wzero-as-null-pointer-constant \
-Wzero-length-array
.PHONY: test
test:
python3 setup.py test
$(MAKE) test-sdist
env PYTHONPATH=. python3 examples/benchmarks/packages/ber.py
env PYTHONPATH=. python3 examples/benchmarks/packages/uper.py
env PYTHONPATH=. python3 examples/benchmarks/codecs.py
env PYTHONPATH=. python3 examples/benchmarks/compile_methods.py
env PYTHONPATH=. python3 examples/benchmarks/question/question.py
env PYTHONPATH=. python3 examples/hello_world.py
env PYTHONPATH=. python3 examples/x509_pem.py
env PYTHONPATH=. python3 examples/compact_extensions_uper/main.py
env PYTHONPATH=. python3 examples/programming_types/main.py
$(MAKE) test-c
env FUZZER_EXECUTION_TIME=1 $(MAKE) test-c-fuzzer
$(MAKE) -C examples/benchmarks/c_source
python3 -m pycodestyle $$(git ls-files "asn1tools/*.py")
.PHONY: codespell
codespell:
codespell -d $$(git ls-files | grep -v ietf \
| grep -v 3gpp \
| grep -v generated \
| grep -v "\\.rs" \
| grep -v asn1tools/source/rust \
| grep -v "\.asn")
.PHONY: test-c
test-c:
for f in $(C_SOURCES) ; do \
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -std=c99 -O3 -c $$f ; \
clang $(CFLAGS) $(CFLAGS_EXTRA_CLANG) -std=c99 -O3 -c $$f ; \
done
$(MAKE) -C tests
.PHONY: test-c-oer-fuzzer-run
test-c-oer-fuzzer-run:
$(FUZZER_CC) $(FUZZER_CFLAGS) $(FUZZER_OER_C_SOURCES) -o $(FUZZER_OER_EXE)
rm -f $(FUZZER_OER_EXE).profraw
LLVM_PROFILE_FILE="$(FUZZER_OER_EXE).profraw" \
./$(FUZZER_OER_EXE) \
-max_total_time=$(FUZZER_EXECUTION_TIME) \
-print_final_stats
llvm-profdata merge \
-sparse $(FUZZER_OER_EXE).profraw \
-o $(FUZZER_OER_EXE).profdata
llvm-cov show ./$(FUZZER_OER_EXE) \
-instr-profile=$(FUZZER_OER_EXE).profdata
.PHONY: test-c-uper-fuzzer-run
test-c-uper-fuzzer-run:
$(FUZZER_CC) $(FUZZER_CFLAGS) $(FUZZER_UPER_C_SOURCES) -o $(FUZZER_UPER_EXE)
rm -f $(FUZZER_UPER_EXE).profraw
LLVM_PROFILE_FILE="$(FUZZER_UPER_EXE).profraw" \
./$(FUZZER_UPER_EXE) \
-max_total_time=$(FUZZER_EXECUTION_TIME) \
-print_final_stats
llvm-profdata merge \
-sparse $(FUZZER_UPER_EXE).profraw \
-o $(FUZZER_UPER_EXE).profdata
llvm-cov show ./$(FUZZER_UPER_EXE) \
-instr-profile=$(FUZZER_UPER_EXE).profdata
.PHONY: test-c-fuzzer
test-c-fuzzer:
$(MAKE) test-c-oer-fuzzer-run
$(MAKE) test-c-uper-fuzzer-run
echo
echo "REPORT:"
echo
llvm-cov report ./$(FUZZER_OER_EXE) \
-instr-profile=$(FUZZER_OER_EXE).profdata
echo
llvm-cov report ./$(FUZZER_UPER_EXE) \
-instr-profile=$(FUZZER_UPER_EXE).profdata
.PHONY: test-rust
test-rust:
cd tests/rust_source && cargo run
.PHONY: test-sdist
test-sdist:
rm -rf dist
python3 setup.py sdist
cd dist && \
mkdir test && \
cd test && \
tar xf ../*.tar.gz && \
cd asn1tools-* && \
python3 setup.py test
.PHONY: release-to-pypi
release-to-pypi:
python3 setup.py sdist
python3 setup.py bdist_wheel --universal
twine upload dist/*