-
Notifications
You must be signed in to change notification settings - Fork 271
/
Makefile
99 lines (81 loc) · 3.23 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
CONTRIB_DIR = .
TEST_DIR = ./tests
LLQUEUE_DIR = $(CONTRIB_DIR)/CLinkedListQueue
VPATH = src
GCOV_OUTPUT = *.gcda *.gcno *.gcov
GCOV_CCFLAGS = -fprofile-arcs -ftest-coverage
SHELL = /bin/bash
CFLAGS += -Iinclude -Werror -Werror=return-type -Werror=uninitialized -Wcast-align \
-Wno-pointer-sign -fno-omit-frame-pointer -fno-common -fsigned-char \
-Wunused-variable \
$(GCOV_CCFLAGS) -I$(LLQUEUE_DIR) -Iinclude -g -O2 -fPIC
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
ASANFLAGS = -fsanitize=address
SHAREDFLAGS = -dynamiclib
SHAREDEXT = dylib
# We need to include the El Capitan specific /usr/includes, aargh
CFLAGS += -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/
CFLAGS += -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include
CFLAGS += $(ASANFLAGS)
CFLAGS += -Wno-nullability-completeness
else
SHAREDFLAGS = -shared
SHAREDEXT = so
endif
OBJECTS = src/raft_server.o src/raft_server_properties.o src/raft_node.o src/raft_log.o
all: static shared
clinkedlistqueue:
mkdir -p $(LLQUEUE_DIR)/.git
git --git-dir=$(LLQUEUE_DIR)/.git init
pushd $(LLQUEUE_DIR); git pull http://github.com/willemt/CLinkedListQueue; popd
download-contrib: clinkedlistqueue
$(TEST_DIR)/main_test.c: $(TEST_DIR)/test_*.c
if test -d $(LLQUEUE_DIR); \
then echo have contribs; \
else make download-contrib; \
fi
cd $(TEST_DIR) && sh make-tests.sh "test_*.c" > main_test.c && cd ..
.PHONY: shared
shared: $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) $(CFLAGS) -fPIC $(SHAREDFLAGS) -o libraft.$(SHAREDEXT)
.PHONY: static
static: $(OBJECTS)
ar -r libraft.a $(OBJECTS)
.PHONY: tests
tests: src/raft_server.c src/raft_server_properties.c src/raft_log.c src/raft_node.c $(TEST_DIR)/main_test.c $(TEST_DIR)/test_*.c $(TEST_DIR)/mock_send_functions.c $(TEST_DIR)/CuTest.c $(LLQUEUE_DIR)/linked_list_queue.c
$(CC) $(CFLAGS) -o tests_main $^
./tests_main
gcov raft_server.c
.PHONY: test_fuzzer
test_fuzzer:
python tests/log_fuzzer.py
.PHONY: tests_full
tests_full:
make clean
make tests
make test_fuzzer
make test_virtraft
.PHONY: test_virtraft
test_virtraft:
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 1 -m 3
python3 tests/virtraft2.py --servers 7 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 1 -m 3
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 2 -m 3
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 3 -m 3
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 4 -m 3
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 5 -m 3
python3 tests/virtraft2.py --servers 5 -i 20000 --compaction_rate 50 --drop_rate 5 -P 10 --seed 6 -m 3
.PHONY: amalgamation
amalgamation:
./scripts/amalgamate.sh > raft.h
.PHONY: infer
infer: do_infer
.PHONY: do_infer
do_infer:
make clean
infer -- make
clean:
@rm -f $(TEST_DIR)/main_test.c src/*.o $(GCOV_OUTPUT); \
if [ -f "libraft.$(SHAREDEXT)" ]; then rm libraft.$(SHAREDEXT); fi;\
if [ -f libraft.a ]; then rm libraft.a; fi;\
if [ -f tests_main ]; then rm tests_main; fi;