From 5cb3908e4fb9d8f6529eacb951ca03139607d65e Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Mon, 19 May 2025 09:07:14 +0100 Subject: [PATCH] test: Run undefined sanitizer without ignoring errors (#2134) --- .github/workflows/test_impl.yml | 17 ++++++++++------- tests/unit/rpc/ErrorTests.cpp | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_impl.yml b/.github/workflows/test_impl.yml index 72a75f43..4fe50c20 100644 --- a/.github/workflows/test_impl.yml +++ b/.github/workflows/test_impl.yml @@ -46,6 +46,10 @@ jobs: if: inputs.run_unit_tests + env: + # TODO: remove when we have fixed all currently existing issues from sanitizers + SANITIZER_IGNORE_ERRORS: ${{ inputs.sanitizer != 'false' && inputs.sanitizer != 'ubsan' }} + steps: - name: Clean workdir if: ${{ runner.os == 'macOS' }} @@ -64,15 +68,15 @@ jobs: run: chmod +x ./clio_tests - name: Run clio_tests (regular) - if: inputs.sanitizer == 'false' + if: env.SANITIZER_IGNORE_ERRORS == 'false' run: ./clio_tests - - name: Run clio_tests (sanitizer) - if: inputs.sanitizer != 'false' + - name: Run clio_tests (sanitizer errors ignored) + if: env.SANITIZER_IGNORE_ERRORS == 'true' run: ./.github/scripts/execute-tests-under-sanitizer ./clio_tests - name: Check for sanitizer report - if: inputs.sanitizer != 'false' + if: env.SANITIZER_IGNORE_ERRORS == 'true' shell: bash id: check_report run: | @@ -83,16 +87,15 @@ jobs: fi - name: Upload sanitizer report - if: inputs.sanitizer != 'false' && steps.check_report.outputs.found_report == 'true' + if: env.SANITIZER_IGNORE_ERRORS == 'true' && steps.check_report.outputs.found_report == 'true' uses: actions/upload-artifact@v4 with: name: ${{ inputs.conan_profile }}_report path: .sanitizer-report/* include-hidden-files: true - # TODO: enable when we have fixed all currently existing issues from sanitizers - name: Create an issue - if: false && inputs.sanitizer != 'false' && steps.check_report.outputs.found_report == 'true' + if: false && env.SANITIZER_IGNORE_ERRORS == 'true' && steps.check_report.outputs.found_report == 'true' uses: ./.github/actions/create_issue env: GH_TOKEN: ${{ github.token }} diff --git a/tests/unit/rpc/ErrorTests.cpp b/tests/unit/rpc/ErrorTests.cpp index 12659b0d..f970c6d8 100644 --- a/tests/unit/rpc/ErrorTests.cpp +++ b/tests/unit/rpc/ErrorTests.cpp @@ -184,5 +184,8 @@ TEST_P(WarningCodeTest, WarningToJSON) TEST(RPCErrorsTest, InvalidWarningToJSON) { - EXPECT_ANY_THROW((void)makeWarning(static_cast(999999))); + auto notSanitizedMakeWarning = []() __attribute__((no_sanitize("undefined"))) { + return makeWarning(static_cast(999999)); + }; + EXPECT_ANY_THROW((void)notSanitizedMakeWarning()); }