From 7a8b1f4bf29d9f681e56eef57a92d61ab1606d13 Mon Sep 17 00:00:00 2001 From: Leonard Chan Date: Mon, 11 Dec 2023 22:45:44 +0000 Subject: [PATCH] Add asan+ubsan sanitized builder --- .github/workflows/build-sanitized.yml | 31 +++++++++++++++++++++++++++ README.md | 7 ++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/build-sanitized.yml diff --git a/.github/workflows/build-sanitized.yml b/.github/workflows/build-sanitized.yml new file mode 100644 index 0000000..80e178f --- /dev/null +++ b/.github/workflows/build-sanitized.yml @@ -0,0 +1,31 @@ +name: Build + Test (Sanitized) + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + merge_group: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get googletest + run: | + wget https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip + unzip release-1.12.1.zip + cd googletest-release-1.12.1 + mkdir build + cd build + cmake .. + make + - name: Build main executable + run: make EXTRA_CPPFLAGS="-fsanitize=address -fsanitize=undefined" + - name: Build test executable + run: make test GTEST_HDR=googletest-release-1.12.1/googletest/include GTEST_LIB=googletest-release-1.12.1/build/lib EXTRA_CPPFLAGS="-fsanitize=address -fsanitize=undefined" + - name: Run test executable + run: ./test diff --git a/README.md b/README.md index 64d675d..dee9309 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ $ make ./main ``` +Define `EXTRA_CPPFLAGS` to pass flags to the build. For example, to build with +sanitizers: + +``` +$ make EXTRA_CPPFLAGS="-fsanitize=address -fsanitize=undefined" +``` + ## Testing ```sh