-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
94 lines (71 loc) · 3.02 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
CC = gcc
CFLAGS = -g -Isrc/include
BUILD_DIR = build
SRC_DIR = src
UNIT_TEST_DIR = test/unit
BUILD_UNIT_DIR = build/test/unit
EXAMPLE_FILES = examples/*.c
BUILD_EXAMPLES_DIR = build/examples
E2E_TEST_DIR = test/e2e
BUILD_E2E_DIR = build/test/e2e
E2E_SCRIPT = test/e2e/test.py
SRC_FILES = $(SRC_DIR)/*.c
UNIT_TEST_FILES = $(UNIT_TEST_DIR)/*.c
E2E_TEST_FILES = $(E2E_TEST_DIR)/*.c
TEST_PROGRAM = tests_program
ANALYZE_PROGRAM = analyze_program
all: build_examples build_test
build_examples: env
mkdir -p $(BUILD_EXAMPLES_DIR)
for file in $(EXAMPLE_FILES); do \
# basename --suffix $$file - removes the .c extension and path from the file name \
$(CC) $(CFLAGS) -o $(BUILD_EXAMPLES_DIR)/$$(basename --suffix=.c $$file).o $$file $(SRC_FILES) -lz -lcunit; \
done
build_test: env
mkdir -p $(BUILD_UNIT_DIR) $(BUILD_E2E_DIR)
$(CC) $(CFLAGS) -o $(BUILD_UNIT_DIR)/$(TEST_PROGRAM) $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
$(CC) $(CFLAGS) -o $(BUILD_E2E_DIR)/correct_scenario $(E2E_TEST_DIR)/normal_scenario.c $(SRC_FILES) -lz -lcunit
$(CC) $(CFLAGS) -o $(BUILD_E2E_DIR)/seq_fault_test $(E2E_TEST_DIR)/seq_fault_test.c $(SRC_FILES) -lz -lcunit
test: build_test
$(BUILD_UNIT_DIR)/$(TEST_PROGRAM)
python3 $(E2E_SCRIPT)
examples: build_examples
for file in $(BUILD_EXAMPLES_DIR)/*.o; do \
echo "-----------------------------------"; \
echo "Running example: $$file"; \
$$file; \
echo "Example $$file finished"; \
done
regression: test analyze clean
analyze: build_test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --trace-children=yes --error-exitcode=1 $(BUILD_UNIT_DIR)/$(TEST_PROGRAM)
clang-tidy --quiet -checks=bugprone-*,-bugprone-easily-swappable-parameters,clang-analyzer-*,cert-*,concurrency-*,misc-*,modernize-*,performance-*,readability-* --warnings-as-errors=* ./src/allocator.c --extra-arg=-I./src/include/
scan-build --status-bugs --keep-cc --show-description $(BUILD_UNIT_DIR)/$(TEST_PROGRAM)
clang --analyze -Xanalyzer -analyzer-output=text ./$(BUILD_UNIT_DIR)/$(TEST_PROGRAM)
clang -fsanitize=address $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
./program
rm -f ./program
# doesn't work because of clang bug
# clang -fsanitize=thread $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
# ./program
# rm -f ./program
clang -fsanitize=memory $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
./program
rm -f ./program
clang -fsanitize=undefined $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
./program
rm -f ./program
clang -flto -fsanitize=cfi -fvisibility=default $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
./program
rm -f ./program
clang -flto -fsanitize=safe-stack $(CFLAGS) -o program $(UNIT_TEST_FILES) $(SRC_FILES) -lz -lcunit
./program
rm -f ./program
env:
sudo chmod a+x ./scripts/install_env/env-preparation.sh
./scripts/install_env/env-preparation.sh
install: env
sudo chmod a+x ./scripts/install_lib/install_lib.sh
./scripts/install_lib/install_lib.sh $(DESTINATION)
clean:
rm -fr build