diff options
| author | jvoisin | 2023-05-30 21:19:56 +0200 |
|---|---|---|
| committer | jvoisin | 2023-05-30 21:42:35 +0200 |
| commit | c4247e4389b765179aa1fd0b010f50e8d6bddf4d (patch) | |
| tree | 41c83ed2eddc0617fb81e61b6f9007130162b0f0 | |
| parent | 37d8733dc522c44f9cdb9247f4a59e23bf0a9659 (diff) | |
Add code coverage
And make it available at https://jvoisin.github.io/fortify-headers/include/index.html
| -rw-r--r-- | .github/workflows/coverage.yaml | 45 | ||||
| -rw-r--r-- | tests/Makefile | 8 |
2 files changed, 53 insertions, 0 deletions
diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..94887f9 --- /dev/null +++ b/.github/workflows/coverage.yaml | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | name: Deploy static content to Pages | ||
| 2 | |||
| 3 | on: | ||
| 4 | push: | ||
| 5 | branches: ["master"] | ||
| 6 | |||
| 7 | workflow_dispatch: | ||
| 8 | |||
| 9 | permissions: | ||
| 10 | contents: read | ||
| 11 | pages: write | ||
| 12 | id-token: write | ||
| 13 | |||
| 14 | concurrency: | ||
| 15 | group: "pages" | ||
| 16 | cancel-in-progress: true | ||
| 17 | |||
| 18 | jobs: | ||
| 19 | deploy: | ||
| 20 | environment: | ||
| 21 | name: github-pages | ||
| 22 | url: ${{ steps.deployment.outputs.page_url }} | ||
| 23 | runs-on: ubuntu-latest | ||
| 24 | steps: | ||
| 25 | - name: Checking out the code | ||
| 26 | uses: actions/checkout@v3 | ||
| 27 | - name: Downloading musl-based toolchain | ||
| 28 | run: wget https://musl.cc/x86_64-linux-musl-native.tgz | ||
| 29 | - name: Extracting musl-based toolchain | ||
| 30 | run: tar xzf ./x86_64-linux-musl-native.tgz | ||
| 31 | - name: Installing lcov | ||
| 32 | run: sudo apt install lcov | ||
| 33 | - name: Running the testsuite | ||
| 34 | run: make -C tests clean coverage | ||
| 35 | - name: Setup Pages | ||
| 36 | uses: actions/configure-pages@v3 | ||
| 37 | - name: Upload artifact | ||
| 38 | uses: actions/upload-pages-artifact@v1 | ||
| 39 | with: | ||
| 40 | # Upload entire repository | ||
| 41 | path: './tests/coverage/' | ||
| 42 | - name: Deploy to GitHub Pages | ||
| 43 | id: deployment | ||
| 44 | uses: actions/deploy-pages@v2 | ||
| 45 | |||
diff --git a/tests/Makefile b/tests/Makefile index 8eded26..2c4e067 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | CC=../x86_64-linux-musl-native/bin/gcc | 1 | CC=../x86_64-linux-musl-native/bin/gcc |
| 2 | GCOV=../x86_64-linux-musl-native/bin/gcov | ||
| 2 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 | 3 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 |
| 3 | 4 | ||
| 4 | TARGETS=test_memcpy_static_write \ | 5 | TARGETS=test_memcpy_static_write \ |
| @@ -21,6 +22,12 @@ TARGETS=test_memcpy_static_write \ | |||
| 21 | 22 | ||
| 22 | all: $(TARGETS) run | 23 | all: $(TARGETS) run |
| 23 | 24 | ||
| 25 | coverage: CFLAGS += -fprofile-arcs -ftest-coverage | ||
| 26 | coverage: all | ||
| 27 | $(GCOV) *.c | ||
| 28 | lcov --capture --directory . --output-file coverage.info | ||
| 29 | genhtml coverage.info --output-directory coverage | ||
| 30 | |||
| 24 | $(TARGETS): %: %.c | 31 | $(TARGETS): %: %.c |
| 25 | $(CC) $(CFLAGS) -o $@ $< | 32 | $(CC) $(CFLAGS) -o $@ $< |
| 26 | 33 | ||
| @@ -33,4 +40,5 @@ clean: | |||
| 33 | $(foreach EXE, $(TARGETS), \ | 40 | $(foreach EXE, $(TARGETS), \ |
| 34 | rm -f ./$(EXE) \ | 41 | rm -f ./$(EXE) \ |
| 35 | ) | 42 | ) |
| 43 | rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage | ||
| 36 | 44 | ||
