Skip to content

Commit

Permalink
Azure-Pipeline: calculate code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cHuberCoffee authored and cspiel1 committed Mar 7, 2024
1 parent 7936844 commit 78de645
Showing 1 changed file with 64 additions and 7 deletions.
71 changes: 64 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Azure Pipelines file for building and testing re

# Improvements:
# Run Tests for different OpenSSL version in parallel
# Publish Test report

# Available OpenSSL builds
parameters:
- name: 'openssl_version'
Expand All @@ -8,6 +12,14 @@ parameters:
- 1.1.1
- 3.0.13
- 3.2.1
- name: 'min_coverage'
type: number
default: 62.5

# Define Variables
variables:
- name: CMAKE_GENERATOR
value: Ninja

# Use a machine from the Azure Pipelines pool. Use Linux 'ubuntu-latest' image
pool:
Expand All @@ -27,14 +39,15 @@ steps:
fetchTags : 'false'
continueOnError: 'false'

# Install/Prepare Valgrind for tests
# Install/Prepare Build Environment for tests
- task: Bash@3
displayName: Prepare Valgrind
displayName: Prepare Build Environment
inputs:
targetType: 'inline'
script: sudo apt install valgrind
script: |
sudo apt install valgrind ninja-build gcovr
# Run this part of the pipeline for each openssl_version
# BEGIN Run the following pipeline part for each OpenSSL version ---------------
- ${{ each version in parameters.openssl_version }}:
# Fetch Prebuild OpenSSL stored in Azure Artifects Universal Package
- task: UniversalPackages@0
Expand All @@ -51,7 +64,11 @@ steps:
- task: CMake@1
displayName: 'Generate CMake Build Environment'
inputs:
cmakeArgs: '-B build_${{version}} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(System.DefaultWorkingDirectory)/install -DOPENSSL_ROOT_DIR=$(System.DefaultWorkingDirectory)/openssl_${{version}}'
cmakeArgs: >-
-B build_${{version}}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=$(System.DefaultWorkingDirectory)/install
-DOPENSSL_ROOT_DIR=$(System.DefaultWorkingDirectory)/openssl_${{version}}
workingDirectory: '$(System.DefaultWorkingDirectory)'

# Build project
Expand All @@ -63,16 +80,56 @@ steps:

# Build tests
- task: CMake@1
displayName: "Build RE Tests"
displayName: 'Build RE Tests'
inputs:
cmakeArgs: '--build build_${{version}} -t retest -j'
workingDirectory: '$(System.DefaultWorkingDirectory)'

# Run Tests
- task: Bash@3
displayName: "Run Tests"
displayName: 'Run Tests'
inputs:
targetType: 'inline'
script: |
$(System.DefaultWorkingDirectory)/build_${{version}}/test/retest
valgrind $(System.DefaultWorkingDirectory)/build_${{version}}/test/retest -r -v
# END Run the following pipeline part for each OpenSSL version -----------------

# Generage Cmake Build Environment
- task: CMake@1
displayName: 'Generage CMake Build Environment'
inputs:
cmakeArgs: >-
-B build_coverage
-DCMAKE_BUILD_TYPE=Debug
-DOPENSSL_ROOT_DIR=$(System.DefaultWorkingDirectory)/openssl_3.2.1
-DCMAKE_C_FLAGS="--coverage"
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
-DUSE_TRACE=ON
workingDirectory: '$(System.DefaultWorkingDirectory)'

# Build Coverage Tests
- task: CMake@1
displayName: 'Build Code Coverage Test'
inputs:
cmakeArgs: '--build build_coverage -t retest -j'
workingDirectory: '$(System.DefaultWorkingDirectory)'

# Run Coverage Calculation
- task: Bash@3
displayName: 'Calculate Coverage'
inputs:
targetType: 'inline'
script: |
$(System.DefaultWorkingDirectory)/build_coverage/test/retest -a -v
$(System.DefaultWorkingDirectory)/build_coverage/test/retest -r -m select -v
gcov build_coverage/**/*.o
gcovr -r . -s --xml-pretty --xml code_coverage_report.xml --gcov-ignore-parse-errors
# Publish code coverage results (XML)
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: $(System.DefaultWorkingDirectory)/code_coverage_report.xml
failIfCoverageEmpty: 'true'


0 comments on commit 78de645

Please sign in to comment.