-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
105 lines (98 loc) · 2.84 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
CFLAGS := \
-Wall \
-Wextra \
-Wdouble-promotion \
-Wfloat-equal \
-Wformat=2 \
-Wshadow \
-Werror \
-Wpedantic \
-std=c99 \
-g \
--coverage \
-Ic/heatshrink
FUZZER_CFLAGS = \
-fprofile-instr-generate \
-fcoverage-mapping \
-Itests/files/c_source \
-Ic/heatshrink \
-g \
-fsanitize=address,fuzzer \
-fsanitize=signed-integer-overflow \
-fno-sanitize-recover=all
FUZZER_EXECUTION_TIME ?= 30
test:
env CFLAGS=--coverage python3 setup.py test
$(MAKE) test-sdist
$(MAKE) test-c
find . -name "*.gcno" -exec gcov {} +
$(MAKE) test-c-fuzzer FUZZER_EXECUTION_TIME=1
$(MAKE) -C c/tst fuzz-corpus-patch FUZZER_EXECUTION_TIME=1
test-sdist:
rm -rf dist
python3 setup.py sdist
cd dist && \
mkdir test && \
cd test && \
tar xf ../*.tar.gz && \
cd detools-* && \
python3 setup.py test
test-c:
$(MAKE) -C c/tst SANITIZE=yes
$(CC) $(CFLAGS) -DDETOOLS_CONFIG_FILE_IO=0 -Ic/heatshrink \
-c c/detools.c -o detools.no-file-io.o
$(CC) $(CFLAGS) -DDETOOLS_CONFIG_COMPRESSION_NONE=0 -Ic/heatshrink \
-c c/detools.c -o detools.no-none.o
$(CC) $(CFLAGS) -DDETOOLS_CONFIG_COMPRESSION_LZMA=0 -Ic/heatshrink \
-c c/detools.c -o detools.no-lzma.o
$(CC) $(CFLAGS) -DDETOOLS_CONFIG_COMPRESSION_CRLE=0 -Ic/heatshrink \
-c c/detools.c -o detools.no-crle.o
$(CC) $(CFLAGS) -DDETOOLS_CONFIG_COMPRESSION_HEATSHRINK=0 -Ic/heatshrink \
-c c/detools.c -o detools.no-crle.o
$(CC) $(CFLAGS) \
-DDETOOLS_CONFIG_COMPRESSION_NONE=0 \
-DDETOOLS_CONFIG_COMPRESSION_CRLE=0 \
-Ic/heatshrink -c c/detools.c -o detools.no-crle.o
$(CC) $(CFLAGS) \
-DDETOOLS_CONFIG_COMPRESSION_NONE=0 \
-DDETOOLS_CONFIG_COMPRESSION_LZMA=0 \
-DDETOOLS_CONFIG_COMPRESSION_CRLE=0 \
-Ic/heatshrink -c c/detools.c -o detools.no-crle.o
$(CC) $(CFLAGS) \
-DDETOOLS_CONFIG_COMPRESSION_NONE=0 \
-DDETOOLS_CONFIG_COMPRESSION_CRLE=0 \
-DDETOOLS_CONFIG_COMPRESSION_HEATSHRINK=0 \
-Ic/heatshrink -c c/detools.c -o detools.no-crle.o
$(MAKE) -C c library
$(MAKE) -C c/examples/in_place all
$(MAKE) -C c/examples/in_place heatshrink
$(MAKE) -C c/examples/in_place crle
$(MAKE) -C c/examples/dump_restore
$(MAKE) -C c clean
$(MAKE) -C c test
$(MAKE) -C c clean
$(MAKE) -C c CFLAGS_EXTRA="-DHEATSHRINK_DYNAMIC_ALLOC=1" test
test-c-fuzzer:
clang $(FUZZER_CFLAGS) \
c/detools.c \
c/heatshrink/heatshrink_decoder.c \
tests/fuzzer.c \
-l lzma -o fuzzer
rm -f fuzzer.profraw
LLVM_PROFILE_FILE="fuzzer.profraw" \
./fuzzer \
-max_total_time=$(FUZZER_EXECUTION_TIME) \
-print_final_stats
llvm-profdata merge \
-sparse fuzzer.profraw \
-o fuzzer.profdata
llvm-cov show ./fuzzer \
-instr-profile=fuzzer.profdata
release-to-pypi:
python3 setup.py sdist
twine upload dist/*
benchmark:
$(MAKE) -C c
python3 setup.py test -s \
tests.test_detools.DetoolsTest.test_create_and_apply_patch_foo
tests/benchmark.sh