Skip to content

Commit

Permalink
Revert "Address review comments from @glhewett"
Browse files Browse the repository at this point in the history
This reverts commit 1770db5.
  • Loading branch information
bifurcation committed Nov 3, 2023
1 parent 181cdd4 commit 180b834
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
8 changes: 1 addition & 7 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }}
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion lib/bytes/test/bytes.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <bytes/bytes.h>
#include <doctest/doctest.h>
#include <iostream>
#include <memory>
#include <sstream>

Expand All @@ -23,13 +24,15 @@ TEST_CASE("Zeroization")
const auto* end = begin + size;
vec.reset();

const auto snapshot = std::vector<uint8_t>(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<uint8_t>(begin, end);
const auto threshold = size - 4 * sizeof(void*);
REQUIRE(std::count(snapshot.begin(), snapshot.end(), 0) >= threshold);
}
Expand Down

0 comments on commit 180b834

Please sign in to comment.