3030 BUILD_TYPE = release
3131endif
3232
33+ # Sanitizer Support (for Linux CI)
34+ ifdef SANITIZER
35+ ifeq ($(SANITIZER),address)
36+ CFLAGS += -fsanitize=address -fno-omit-frame-pointer
37+ LIBS += -fsanitize=address
38+ else ifeq ($(SANITIZER),undefined)
39+ CFLAGS += -fsanitize=undefined -fno-omit-frame-pointer
40+ LIBS += -fsanitize=undefined
41+ else ifeq ($(SANITIZER),thread)
42+ CFLAGS += -fsanitize=thread -fno-omit-frame-pointer
43+ LIBS += -fsanitize=thread
44+ endif
45+ endif
46+
3347# Source Files
3448SOURCES = $(wildcard $(SRC_DIR ) /* .c)
3549HEADERS = $(wildcard $(INCLUDE_DIR ) /* .h)
@@ -93,9 +107,15 @@ test-unit: $(BUILD_DIR)/test_allocator
93107 @echo " Running unit tests..."
94108 @./$(BUILD_DIR ) /test_allocator
95109
110+ .PHONY : integration-test
111+ integration-test : test-unit
112+ @echo " Running integration tests..."
113+ @echo " Integration tests are currently the same as unit tests"
114+ @./$(BUILD_DIR ) /test_allocator
115+
96116# Memory analysis (skip valgrind on macOS as it's not well supported)
97117.PHONY : valgrind
98- valgrind :
118+ valgrind : $( BUILD_DIR ) /test_allocator
99119ifeq ($(PLATFORM ) ,macos)
100120 @echo "Valgrind not well supported on macOS, skipping..."
101121else
@@ -105,16 +125,59 @@ else
105125 ./$(BUILD_DIR)/test_allocator
106126endif
107127
128+ # Code coverage (Linux only, requires gcc and lcov)
129+ .PHONY : coverage
130+ coverage :
131+ ifeq ($(PLATFORM ) ,macos)
132+ @echo "Coverage analysis not configured for macOS, skipping..."
133+ else
134+ @echo "Building with coverage instrumentation..."
135+ @$(MAKE) clean
136+ @$(MAKE) build DEBUG=1 CFLAGS="$(CFLAGS) --coverage -fprofile-arcs -ftest-coverage"
137+ @echo "Running tests with coverage..."
138+ @./$(BUILD_DIR)/test_allocator || true
139+ @echo "Generating coverage report..."
140+ @mkdir -p coverage
141+ @lcov --capture --directory $(BUILD_DIR) --output-file coverage/coverage.info --no-external
142+ @genhtml coverage/coverage.info --output-directory coverage/html
143+ @echo "Coverage report generated in coverage/html/index.html"
144+ endif
145+
108146# Code quality
109147.PHONY : format
110148format :
111149 @echo " Formatting code with clang-format..."
112150 @clang-format -i $(SOURCES ) $(HEADERS ) $(TEST_SOURCES )
113151
152+ .PHONY : format-check
153+ format-check :
154+ @echo " Checking code formatting..."
155+ @if command -v clang-format > /dev/null 2>&1 ; then \
156+ for file in $( SOURCES) $( HEADERS) $( TEST_SOURCES) ; do \
157+ if [ -f " $$ file" ]; then \
158+ if ! clang-format " $$ file" | diff -q " $$ file" - > /dev/null 2>&1 ; then \
159+ echo " [ERROR] $$ file is not properly formatted" ; \
160+ echo " Run 'make format' to fix formatting issues" ; \
161+ exit 1; \
162+ fi ; \
163+ fi ; \
164+ done ; \
165+ echo " [OK] All files are properly formatted" ; \
166+ else \
167+ echo " [WARN] clang-format not found, skipping format check" ; \
168+ fi
169+
114170.PHONY : lint
115171lint :
116172 @echo " Running static analysis..."
117- @cppcheck --enable=warning --std=c11 $(INCLUDES ) $(SRC_DIR ) || true
173+ @if command -v clang-tidy > /dev/null 2>&1 ; then \
174+ echo " Running clang-tidy..." ; \
175+ clang-tidy $(SOURCES ) -- $(CFLAGS ) $(INCLUDES ) -std=c11 || true ; \
176+ fi
177+ @if command -v cppcheck > /dev/null 2>&1 ; then \
178+ echo " Running cppcheck..." ; \
179+ cppcheck --enable=warning --std=c11 $(INCLUDES ) $(SRC_DIR ) || true ; \
180+ fi
118181
119182# Installation
120183.PHONY : install
0 commit comments