From e871307f6a9536ce9d7e95fe8157937ce4908c9a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 31 Jan 2026 15:23:19 +0300 Subject: [PATCH] chore: add more Make tasks for tests & benchmarks Signed-off-by: NotAShelf Change-Id: I5cabfcf1815588ffec6c8b865cd163176a6a6964 --- Makefile | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 0efc0bd..f26050d 100644 --- a/Makefile +++ b/Makefile @@ -131,11 +131,12 @@ clean: @echo "Cleaning build artifacts..." rm -rf $(OBJDIR) $(BINDIR) rm -f $(PROTOCOL_HEADERS) $(PROTOCOL_SOURCES) + rm -f "vcore.*" # Format source code (requires clang-format) format: @echo "Formatting source code..." - @find $(SRCDIR) $(INCDIR) -name "*.c" -o -name "*.h" | xargs clang-format -i + @find $(SRCDIR) -name "*.c" -o -name "*.h" | xargs clang-format -i # Static analysis (requires cppcheck) analyze: @@ -147,10 +148,33 @@ analyze: $(SRCDIR) # Run tests -# FIXME: add tests test: $(TARGET) - @echo "Running tests..." - @echo "Tests not implemented yet." + @echo "Running unit tests..." + @$(CC) -o bin/test tests/test.c lib/test_common.c \ + -I./include -I./tests -I./tests/util -lm -std=c11 -D_GNU_SOURCE $(CFLAGS) + @./bin/test + +# Run benchmarks +bench: + @echo "Running performance benchmarks..." + @$(CC) -o bin/bench benchmarks/bench.c lib/test_common.c \ + -I./include -I./tests -I./tests/util -lm -std=c11 -D_GNU_SOURCE $(CFLAGS) + @./bin/bench + +# Memory analysis tests +test-memory: + @echo "Building memory tests..." + @$(CC) -o bin/test tests/test.c lib/test_common.c \ + -I./include -I./tests -I./tests/util -lm -std=c11 -D_GNU_SOURCE $(CFLAGS) + @valgrind --leak-check=full --show-leak-kinds=all ./bin/test 2>&1 | tee tests/memory_report.txt + @echo "Analysis complete. See tests/memory_report.txt" + +# Generate memory profile CSVs +profile-memory: + @$(CC) -o bin/test tests/test.c lib/test_common.c \ + -I./include -I./tests -I./tests/util -lm -std=c11 -D_GNU_SOURCE $(CFLAGS) + @./bin/test --profile + @echo "CSV files generated in /tmp/" # Version management targets bump-patch: @@ -213,7 +237,7 @@ help: -include $(DEPENDS) # Phony targets -.PHONY: all debug static check-deps install uninstall systemd-service version-header sample-config clean distclean format analyze test help bump-patch bump-minor bump-major set-version +.PHONY: all debug static check-deps install uninstall systemd-service version-header clean distclean format analyze test test-memory memory-report help bump-patch bump-minor bump-major set-version # Print variables print-%: