Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Compiler
CC = gcc
CFLAGS = -Wall -Wextra -Iinclude -g
LDFLAGS =

# Coverage flags
CFLAGS_COVERAGE = -Wall -Wextra -Iinclude -g -O0 -fprofile-arcs -ftest-coverage
LDFLAGS_COVERAGE = -fprofile-arcs -ftest-coverage

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

# Default target
all: $(OBJ_DIR) $(BIN_DIR) $(APPS) $(TESTS)
all: $(OBJ_DIR) $(BIN_DIR) apps tests

# Build apps and tests separately
apps: $(APPS)
tests: $(TESTS)

# Compile source files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
Expand All @@ -47,8 +56,8 @@ $(OBJ_DIR):
$(BIN_DIR):
mkdir -p $(BIN_DIR)

# Run all tests dynamically and fail CI if any test fails
test: $(TESTS)
# Run all tests dynamically
test: tests
@echo "Running all tests..."
@failed=0; \
for t in $(TESTS); do \
Expand All @@ -68,8 +77,28 @@ test: $(TESTS)
echo "All tests PASSED."; \
fi

# Coverage targets
coverage: clean_coverage
@echo "Building tests with coverage flags..."
$(MAKE) clean
$(MAKE) CFLAGS="$(CFLAGS_COVERAGE)" LDFLAGS="$(LDFLAGS_COVERAGE)" all
@echo "Running tests for coverage..."
$(MAKE) test
@echo "Capturing coverage..."
lcov --capture --directory . --output-file coverage.info --ignore-errors unsupported,unused
genhtml coverage.info --output-directory coverage-report
@echo "Coverage report generated: coverage-report/index.html"

clean_coverage:
rm -f *.gcda *.gcno coverage.info
rm -rf coverage-report

# Optional: quick badge
badge:
@coverage=$(shell lcov --summary coverage.info 2>/dev/null | awk '/lines/ {val=$$3; gsub("%","",val); print int(val)}'); \
if [ -z "$$coverage" ]; then coverage=0; fi; \
echo "![Coverage](https://img.shields.io/badge/coverage-$$coverage%25-brightgreen)"

# Clean
clean:
rm -rf $(OBJ_DIR)/*.o $(BIN_DIR)/*

.PHONY: all clean test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

This repository implements several cryptographic standards in C.

Expand Down
Binary file modified bin/main_128
Binary file not shown.
Binary file modified bin/main_256
Binary file not shown.
Binary file modified bin/main_sbox_timing_256
Binary file not shown.
Binary file modified bin/main_timing_256
Binary file not shown.
Binary file modified bin/test_aes_128
Binary file not shown.
Binary file modified bin/test_aes_192
Binary file not shown.
Binary file modified bin/test_aes_256
Binary file not shown.
Binary file modified bin/test_cbc
Binary file not shown.
Binary file modified bin/test_ccm
Binary file not shown.
Binary file modified bin/test_cfb
Binary file not shown.
Binary file modified bin/test_cmac
Binary file not shown.
Binary file modified bin/test_ctr
Binary file not shown.
Binary file modified bin/test_ecb
Binary file not shown.
Binary file modified bin/test_gcm
Binary file not shown.
Binary file modified bin/test_gmac
Binary file not shown.
Binary file modified bin/test_ofb
Binary file not shown.
Binary file modified bin/test_xts
Binary file not shown.
Binary file added coverage-report/amber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions coverage-report/cmd_line
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
genhtml coverage.info --output-directory coverage-report
Binary file added coverage-report/emerald.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading