diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 00:26:52 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 02:13:34 +0100 |
commit | c037100747a1a224160cb12defb600ddfe1ba927 (patch) | |
tree | 8332a7d288116b802866e1ed98d1b950425206f7 /testing/hstox/Makefile | |
parent | 1977d56caaff40ea9bbf6754b69bec9539a5a969 (diff) |
Import the hstox SUT interface from hstox.
We'll maintain it in the c-toxcore repo, where it belongs.
Diffstat (limited to 'testing/hstox/Makefile')
-rw-r--r-- | testing/hstox/Makefile | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/testing/hstox/Makefile b/testing/hstox/Makefile new file mode 100644 index 00000000..ec02719c --- /dev/null +++ b/testing/hstox/Makefile | |||
@@ -0,0 +1,97 @@ | |||
1 | # Don't bind to a CPU core. afl-fuzz doesn't release them again. | ||
2 | export AFL_NO_AFFINITY := 1 | ||
3 | |||
4 | CFLAGS := \ | ||
5 | -std=gnu99 \ | ||
6 | -Wall \ | ||
7 | -g3 \ | ||
8 | -DCONFIGURED=1 \ | ||
9 | -Imsgpack-c/include \ | ||
10 | -I../../toxcore \ | ||
11 | |||
12 | LDFLAGS := -pthread -lsodium | ||
13 | ifeq ($(shell echo 'int main(){}' | $(CC) -lrt -xc -o /dev/null - && echo true),true) | ||
14 | LDFLAGS += -lrt | ||
15 | endif | ||
16 | |||
17 | SOURCES := $(filter-out %_main.c,$(wildcard *.c msgpack-c/src/*.c ../../toxcore/*.c)) | ||
18 | HEADERS := $(shell find . -name "*.h") | ||
19 | |||
20 | ifeq ($(wildcard test-findings/master/fuzzer_stats),) | ||
21 | TEST_INPUTS := test-inputs | ||
22 | else | ||
23 | TEST_INPUTS := - | ||
24 | endif | ||
25 | |||
26 | # All the possible test flavours. | ||
27 | PROGRAMS := \ | ||
28 | test_main-cov \ | ||
29 | test_main-cov-asan \ | ||
30 | test_main-vanilla \ | ||
31 | test_main-vanilla-asan | ||
32 | |||
33 | ifneq ($(shell which afl-clang),) | ||
34 | AFL_CLANG := afl-clang | ||
35 | endif | ||
36 | |||
37 | ifneq ($(shell which afl-clang-fast),) | ||
38 | AFL_CLANG := afl-clang-fast | ||
39 | endif | ||
40 | |||
41 | ifneq ($(AFL_CLANG),) | ||
42 | PROGRAMS += \ | ||
43 | fuzz_main-afl \ | ||
44 | fuzz_main-afl-asan | ||
45 | endif | ||
46 | |||
47 | all: $(PROGRAMS) | ||
48 | |||
49 | check: test_main-sut | ||
50 | ./$< ./$< | ||
51 | |||
52 | master: fuzz_main-afl test-findings | ||
53 | afl-fuzz -i$(TEST_INPUTS) -o test-findings -M master ./$< | ||
54 | |||
55 | slave%: fuzz_main-afl test-findings | ||
56 | afl-fuzz -i test-inputs -o test-findings -S slave$* ./$< | ||
57 | |||
58 | %-afl: %.c $(SOURCES) $(HEADERS) | ||
59 | $(AFL_CLANG) $(CFLAGS) -O3 $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
60 | |||
61 | %-afl-asan: %.c $(SOURCES) $(HEADERS) | ||
62 | $(AFL_CLANG) $(CFLAGS) -O3 -fsanitize=address $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
63 | |||
64 | %-cov: %.c $(SOURCES) $(HEADERS) | ||
65 | $(CC) $(CFLAGS) -fprofile-arcs -ftest-coverage $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
66 | |||
67 | %-cov-asan: %.c $(SOURCES) $(HEADERS) | ||
68 | $(CC) $(CFLAGS) -fprofile-arcs -ftest-coverage -fsanitize=address $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
69 | |||
70 | %-vanilla: %.c $(SOURCES) $(HEADERS) | ||
71 | $(CC) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
72 | |||
73 | %-vanilla-asan: %.c $(SOURCES) $(HEADERS) | ||
74 | $(CC) $(CFLAGS) -fsanitize=address $(filter %.c,$^) $(LDFLAGS) -o $@ | ||
75 | |||
76 | %-sut: toxcore-sut.hs %.c $(SOURCES) $(HEADERS) | ||
77 | ghc -package hstox $< \ | ||
78 | $(filter %.c,$^) \ | ||
79 | $(foreach f,$(CFLAGS),-optc $f) \ | ||
80 | $(foreach f,$(LDFLAGS),-optl $f) \ | ||
81 | -o $@ | ||
82 | |||
83 | ifneq ($(wildcard /Volumes),) | ||
84 | test-findings: /Volumes/RAM\ Disk | ||
85 | mkdir -p "$</$@" | ||
86 | ln -sf "$</$@" $@ | ||
87 | |||
88 | /Volumes/RAM\ Disk: | ||
89 | diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://204800` | ||
90 | else | ||
91 | test-findings: /dev/shm | ||
92 | mkdir -p "$</$@" | ||
93 | test -d $@ || ln -sf "$</$@" $@ | ||
94 | endif | ||
95 | |||
96 | clean: | ||
97 | rm -rf $(wildcard *_main-* *.dSYM *.gcno *.gcda *.o *.hi test-findings/*) | ||