Skip to content

Do not double-destroy botan's crypto object. #353

Do not double-destroy botan's crypto object.

Do not double-destroy botan's crypto object. #353

# Copyright (c) 2023 Ribose Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
name: windows-native
on:
push:
branches:
- main
- 'release/**'
paths-ignore:
- '/*.sh'
- '/.*'
- '/_*'
- 'Brewfile'
- 'docs/**'
- '**.adoc'
- '**.md'
- '**.nix'
- 'flake.lock'
- '.github/workflows/*.yml'
- '!.github/workflows/windows-native.yml'
pull_request:
paths-ignore:
- '/*.sh'
- '/.*'
- '/_*'
- 'Brewfile'
- 'docs/**'
- '**.adoc'
- '**.md'
- '**.nix'
- 'flake.lock'
concurrency:
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true
env:
VCPKG_DIR: C:/vcpkg
VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}\cache
RNP_TEST_DATA: ${{github.workspace}}\src\tests\data
jobs:
build_and_test:
name: Windows-2019 [arch ${{ matrix.arch.name }}, toolset ${{ matrix.toolset }}, backend ${{ matrix.backend }}, build shared libs ${{ matrix.shared_libs }}, use CMake prefix path ${{ matrix.use_cmake_prefix_path }}]
runs-on: windows-2019
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
fail-fast: false
matrix:
arch: [ { name: 'x64', triplet: 'x64-windows' } ]
toolset: [ 'v142', 'ClangCL' ]
backend: [ 'botan', 'openssl' ]
shared_libs: [ 'off']
use_cmake_prefix_path: [ 'on', 'off' ]
include:
- arch: { name: 'Win32', triplet: 'x86-windows' }
toolset: 'ClangCL'
backend: 'botan'
use_cmake_prefix_path: 'on'
shared_libs: 'off'
- arch: { name: 'Win32', triplet: 'x86-windows' }
toolset: 'v142'
backend: 'openssl'
use_cmake_prefix_path: 'off'
shared_libs: 'off'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
lfs: true
fetch-depth: 1
- name: vcpkg parameters
run: |
vcpkg version >> vcpkg.version
mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- name: vcpkg cache
uses: actions/cache@v3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: vcpkg-${{ hashFiles('vcpkg.version') }}-${{ matrix.arch.triplet }}-${{ matrix.toolset }}-${{ matrix.backend }}
- name: vcpkg packages
shell: bash
run: |
dir_u=$(cygpath -u ${{ env.VCPKG_DIR }})
echo "VCPKG_DIR_U=$dir_u" >> $GITHUB_ENV
vcpkg install --triplet ${{ matrix.arch.triplet }} bzip2 zlib json-c getopt dirent ${{ matrix.backend }}
- name: Set OPENSSL_ROOT_DIR
# Ensure consistent access to openssl installation for test_backend_version test
# There is another one instance of ssl at /mingw and /mingw/bin is always at the first position at PATH
# So we have to adjust PATH for each step below; changing $GITHUB_PATH does not work
if: matrix.backend == 'openssl'
shell: bash
run: |
echo OPENSSL_ROOT_DIR=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }} >> $GITHUB_ENV
echo OPENSSL_MODULES=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin >> $GITHUB_ENV
- name: Adjust settings for s2k_iteration_tuning test
# This step adjusts s2k_iteration_tuning threshold for
# s2k_iteration_tuning test (src/tests/cipher.cpp)
# It looks like cl on Win32 does not provide robust response
if: matrix.arch.name == 'Win32' && matrix.toolset == 'ClangCL'
shell: bash
run: echo CXXFLAGS="-DS2K_MINIMUM_TUNING_RATIO=4" >> $GITHUB_ENV
- name: Configure using vpkg toolchain file
if: matrix.use_cmake_prefix_path != 'on'
shell: bash
run: |
echo CORES="$(nproc --all)" >> $GITHUB_ENV
export PATH=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin:$PATH
cmake -B build -G "Visual Studio 16 2019" \
-A ${{ matrix.arch.name }} \
-T ${{ matrix.toolset }} \
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs}} \
-DCRYPTO_BACKEND=${{ matrix.backend }} \
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_DIR }}/scripts/buildsystems/vcpkg.cmake .
- name: Configure using CMake prefix path
if: matrix.use_cmake_prefix_path == 'on'
shell: bash
run: |
echo CORES="$(nproc --all)" >> $GITHUB_ENV
export PATH=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin:$PATH
cmake -B build -G "Visual Studio 16 2019" \
-A ${{ matrix.arch.name }} \
-T ${{ matrix.toolset }} \
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs}} \
-DCRYPTO_BACKEND=${{ matrix.backend }} \
-DCMAKE_PREFIX_PATH=${{ env.VCPKG_DIR }}/installed/${{ matrix.arch.triplet }} .
- name: Build
shell: bash
run: |
export PATH=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin:$PATH
cmake --build build --config "Release" --parallel ${{ env.CORES }}
- name: Test
shell: bash
# Sometimes running cli_tests in parallel causes instability [???]
# ctest --test-dir build -R cli_tests -C Debug --output-on-failure
# ctest --parallel ${{ env.CORES }} --test-dir build -R rnp_tests -C Debug --output-on-failure
# ctest --parallel ${{ env.CORES }} --test-dir build -C Release --output-on-failure
run: |
export PATH=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin:$PATH
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
ctest --parallel ${{ env.CORES }} --test-dir build -C Release --output-on-failure