commit c4247e4389b765179aa1fd0b010f50e8d6bddf4d
parent 37d8733dc522c44f9cdb9247f4a59e23bf0a9659
Author: jvoisin <julien.voisin@dustri.org>
Date: Tue, 30 May 2023 21:19:56 +0200
Add code coverage
And make it available at https://jvoisin.github.io/fortify-headers/include/index.html
Diffstat:
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml
@@ -0,0 +1,45 @@
+name: Deploy static content to Pages
+
+on:
+ push:
+ branches: ["master"]
+
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+concurrency:
+ group: "pages"
+ cancel-in-progress: true
+
+jobs:
+ deploy:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checking out the code
+ uses: actions/checkout@v3
+ - name: Downloading musl-based toolchain
+ run: wget https://musl.cc/x86_64-linux-musl-native.tgz
+ - name: Extracting musl-based toolchain
+ run: tar xzf ./x86_64-linux-musl-native.tgz
+ - name: Installing lcov
+ run: sudo apt install lcov
+ - name: Running the testsuite
+ run: make -C tests clean coverage
+ - name: Setup Pages
+ uses: actions/configure-pages@v3
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v1
+ with:
+ # Upload entire repository
+ path: './tests/coverage/'
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v2
+
diff --git a/tests/Makefile b/tests/Makefile
@@ -1,4 +1,5 @@
CC=../x86_64-linux-musl-native/bin/gcc
+GCOV=../x86_64-linux-musl-native/bin/gcov
CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2
TARGETS=test_memcpy_static_write \
@@ -21,6 +22,12 @@ TARGETS=test_memcpy_static_write \
all: $(TARGETS) run
+coverage: CFLAGS += -fprofile-arcs -ftest-coverage
+coverage: all
+ $(GCOV) *.c
+ lcov --capture --directory . --output-file coverage.info
+ genhtml coverage.info --output-directory coverage
+
$(TARGETS): %: %.c
$(CC) $(CFLAGS) -o $@ $<
@@ -33,4 +40,5 @@ clean:
$(foreach EXE, $(TARGETS), \
rm -f ./$(EXE) \
)
+ rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage