Skip to content

Commit 2fef564

Browse files
Merge pull request #20 from jacksonwalters/add_code_coverage_report
add code coverage report
2 parents a869308 + a900293 commit 2fef564

File tree

166 files changed

+16737
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+16737
-5
lines changed

Makefile

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Compiler
22
CC = gcc
33
CFLAGS = -Wall -Wextra -Iinclude -g
4+
LDFLAGS =
5+
6+
# Coverage flags
7+
CFLAGS_COVERAGE = -Wall -Wextra -Iinclude -g -O0 -fprofile-arcs -ftest-coverage
8+
LDFLAGS_COVERAGE = -fprofile-arcs -ftest-coverage
49

510
# Debug toggle
611
ifeq ($(DEBUG),1)
@@ -26,7 +31,11 @@ APPS = $(patsubst $(APP_DIR)/%.c, $(BIN_DIR)/%, $(APP_SRCS))
2631
TESTS = $(patsubst $(TEST_DIR)/%.c, $(BIN_DIR)/%, $(TEST_SRCS))
2732

2833
# Default target
29-
all: $(OBJ_DIR) $(BIN_DIR) $(APPS) $(TESTS)
34+
all: $(OBJ_DIR) $(BIN_DIR) apps tests
35+
36+
# Build apps and tests separately
37+
apps: $(APPS)
38+
tests: $(TESTS)
3039

3140
# Compile source files
3241
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@@ -47,8 +56,8 @@ $(OBJ_DIR):
4756
$(BIN_DIR):
4857
mkdir -p $(BIN_DIR)
4958

50-
# Run all tests dynamically and fail CI if any test fails
51-
test: $(TESTS)
59+
# Run all tests dynamically
60+
test: tests
5261
@echo "Running all tests..."
5362
@failed=0; \
5463
for t in $(TESTS); do \
@@ -68,8 +77,28 @@ test: $(TESTS)
6877
echo "All tests PASSED."; \
6978
fi
7079

80+
# Coverage targets
81+
coverage: clean_coverage
82+
@echo "Building tests with coverage flags..."
83+
$(MAKE) clean
84+
$(MAKE) CFLAGS="$(CFLAGS_COVERAGE)" LDFLAGS="$(LDFLAGS_COVERAGE)" all
85+
@echo "Running tests for coverage..."
86+
$(MAKE) test
87+
@echo "Capturing coverage..."
88+
lcov --capture --directory . --output-file coverage.info --ignore-errors unsupported,unused
89+
genhtml coverage.info --output-directory coverage-report
90+
@echo "Coverage report generated: coverage-report/index.html"
91+
92+
clean_coverage:
93+
rm -f *.gcda *.gcno coverage.info
94+
rm -rf coverage-report
95+
96+
# Optional: quick badge
97+
badge:
98+
@coverage=$(shell lcov --summary coverage.info 2>/dev/null | awk '/lines/ {val=$$3; gsub("%","",val); print int(val)}'); \
99+
if [ -z "$$coverage" ]; then coverage=0; fi; \
100+
echo "![Coverage](https://img.shields.io/badge/coverage-$$coverage%25-brightgreen)"
101+
71102
# Clean
72103
clean:
73104
rm -rf $(OBJ_DIR)/*.o $(BIN_DIR)/*
74-
75-
.PHONY: all clean test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
44
![basic tests](https://github.com/jacksonwalters/aes-block-cipher-standards/actions/workflows/build.yml/badge.svg)
5+
![Coverage](https://img.shields.io/badge/coverage-0%25-brightgreen)
56

67
This repository implements several cryptographic standards in C.
78

bin/main_128

0 Bytes
Binary file not shown.

bin/main_256

0 Bytes
Binary file not shown.

bin/main_sbox_timing_256

0 Bytes
Binary file not shown.

bin/main_timing_256

0 Bytes
Binary file not shown.

bin/test_aes_128

0 Bytes
Binary file not shown.

bin/test_aes_192

0 Bytes
Binary file not shown.

bin/test_aes_256

0 Bytes
Binary file not shown.

bin/test_cbc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)