From 180b83412469a66ec7790dbe6387ff9713f968cd Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Fri, 3 Nov 2023 13:47:05 -0400 Subject: [PATCH] Revert "Address review comments from @glhewett" This reverts commit 1770db53d90a7f26d42531c8a09dceefae345cc4. --- .github/actions/build/action.yml | 8 +------- .github/workflows/main_ci.yml | 23 +++++++++-------------- CMakeLists.txt | 2 +- lib/bytes/test/bytes.cpp | 5 ++++- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 30dd29f1..153f0b9d 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,12 +1,6 @@ name: Install build prerequisites inputs: - os: - description: The operating system on which the test is being run - required: true - crypto-dir: - description: The manifest directory for crypto dependencies - required: true cache-dir: description: Where to put vcpkg cache required: true @@ -23,7 +17,7 @@ runs: uses: actions/cache@v3 with: path: ${{ inputs.cache-dir }} - key: v01-vcpkg-${{ inputs.os }}-${{ hashFiles('vcpkg_commit.txt', "${{ inputs.crypto-dir }}/vcpkg.json") }} + key: v01-vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg_commit.txt', 'alternatives/*/vcpkg.json') }} restore-keys: | v01-vcpkg-${{ runner.os }} diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml index 30863bba..afbf93a4 100644 --- a/.github/workflows/main_ci.yml +++ b/.github/workflows/main_ci.yml @@ -36,6 +36,13 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-latest] crypto: [openssl_1.1, openssl_3, boringssl] + include: + - os: windows-latest + ctest-target: RUN_TESTS + - os: ubuntu-latest + ctest-target: test + - os: macos-latest + ctest-target: test env: BUILD_DIR: "${RUNNER_TEMP}/build_${{ matrix.crypto }}" @@ -49,8 +56,6 @@ jobs: - uses: ./.github/actions/build with: - os: ${{ matrix.os }} - crypto-dir: ${{ env.CRYPTO_DIR }} cache-dir: ${{ github.workspace }}/vcpkg_cache - name: Build @@ -60,15 +65,9 @@ jobs: cmake -B "${{ env.BUILD_DIR }}" -DVCPKG_MANIFEST_DIR="${{ env.CRYPTO_DIR }}" -DTESTING=ON -DSANITIZERS=ON cmake --build "${{ env.BUILD_DIR }}" - - name: Unit Test (non-Windows) - if: matrix.os != "windows-latest" + - name: Unit Test run: | - cmake --build "${{ env.BUILD_DIR }}" --target test - - - name: Unit Test (Windows) - if: matrix.os == "windows-latest" - run: | - cmake --build "${{ env.BUILD_DIR }}" --target RUN_TESTS + cmake --build "${{ env.BUILD_DIR }}" --target "${{ matrix.ctest-target}}" interop-test: if: github.event.pull_request.draft == false @@ -88,8 +87,6 @@ jobs: - uses: ./.github/actions/build with: - os: ubuntu-latest - crypto-dir: ${{ env.CRYPTO_DIR }} cache-dir: ${{ github.workspace }}/vcpkg_cache - name: Build @@ -137,8 +134,6 @@ jobs: - uses: ./.github/actions/build with: - os: ubuntu-latest - crypto-dir: ${{ env.CRYPTO_DIR }} cache-dir: ${{ github.workspace }}/vcpkg_cache - name: Build with clang-tidy diff --git a/CMakeLists.txt b/CMakeLists.txt index 8875b9fb..436f8e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ elseif(MSVC) endif() if (SANITIZERS) - message(STATUS "Enabling sanitizers") + message("Enabling sanitizers") add_definitions(-DSANITIZERS) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/lib/bytes/test/bytes.cpp b/lib/bytes/test/bytes.cpp index 3c84c9c3..39b1a909 100644 --- a/lib/bytes/test/bytes.cpp +++ b/lib/bytes/test/bytes.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -23,13 +24,15 @@ TEST_CASE("Zeroization") const auto* end = begin + size; vec.reset(); + const auto snapshot = std::vector(begin, end); + std::cout << "snapshot = " << to_hex(snapshot) << std::endl; + // In principle, the memory previously owned by the vector should be all zero // at this point. However, since this is now unallocated memory, the // allocator can do with it what it wants, and may have written something to // it when deallocating. macOS and Linux mostly leave the buffer alone, // writing a couple of pointers to the beginning. So we look for the buffer // to be basically all zero. - const auto snapshot = std::vector(begin, end); const auto threshold = size - 4 * sizeof(void*); REQUIRE(std::count(snapshot.begin(), snapshot.end(), 0) >= threshold); }