Skip to content

spdmlib-test: introduce tests for SpdmContext::import and SpdmContext… #10

spdmlib-test: introduce tests for SpdmContext::import and SpdmContext…

spdmlib-test: introduce tests for SpdmContext::import and SpdmContext… #10

Workflow file for this run

name: Coverage
env:
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal
on:
push:
branches: [coverage]
tags:
- "**"
pull_request:
branches: [coverage]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
generate_coverage:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b # v1.5.2
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@a7a1a882e2d06ebe05d5bb97c3e1f8c984ae96fc # v2.0.7
with:
version: "14.0"
directory: ${{ runner.temp }}/llvm
- name: Install toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: rust-src, rustfmt, clippy, llvm-tools-preview
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none
- name: Run cargo install grcov
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
with:
command: install
args: grcov
- name: Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Check code
run: |
./sh_script/build.sh -c
- name: Install AFL (Linux)
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
with:
command: install
args: --force --version 0.12.12 afl
if: runner.os == 'Linux'
- name: Install Cargo-Fuzz (Linux)
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
with:
command: install
args: cargo-fuzz
if: runner.os == 'Linux'
- name: set core_pattern for core
run: |
sudo su - root <<EOF
echo core >/proc/sys/kernel/core_pattern
pushd /sys/devices/system/cpu
echo performance | tee cpu*/cpufreq/scaling_governor
popd
exit
EOF
if: runner.os == 'Linux'
- name: cargo build
env:
LLVM_PROFILE_FILE: build-%p-%m.profraw
RUSTFLAGS: "-C instrument-coverage"
CC_x86_64_unknown_none: clang
AR_x86_64_unknown_none: llvm-ar
RUN_REQUESTER_FEATURES: "spdm-ring"
RUN_RESPONDER_FEATURES: "spdm-ring"
run: |
./sh_script/build.sh -r
- name: cargo build hashed-transcript-data
env:
LLVM_PROFILE_FILE: build-hashed-transcript-data-%p-%m.profraw
RUSTFLAGS: "-C instrument-coverage"
CC_x86_64_unknown_none: clang
AR_x86_64_unknown_none: llvm-ar
RUN_REQUESTER_FEATURES: "spdm-ring,hashed-transcript-data,async-executor"
RUN_RESPONDER_FEATURES: "spdm-ring,hashed-transcript-data,async-executor"
run: |
./sh_script/build.sh -r
- name: cargo build spdm-mbedtls
env:
LLVM_PROFILE_FILE: build-hashed-transcript-data-%p-%m.profraw
RUSTFLAGS: "-C instrument-coverage"
CC_x86_64_unknown_none: clang
AR_x86_64_unknown_none: llvm-ar
RUN_REQUESTER_FEATURES: "spdm-mbedtls,async-executor"
RUN_RESPONDER_FEATURES: "spdm-mbedtls,async-executor"
run: |
./sh_script/build.sh -r
- name: cargo build mbedtls hashed-transcript-data
env:
LLVM_PROFILE_FILE: build-hashed-transcript-data-%p-%m.profraw
RUSTFLAGS: "-C instrument-coverage"
CC_x86_64_unknown_none: clang
AR_x86_64_unknown_none: llvm-ar
RUN_REQUESTER_FEATURES: "spdm-mbedtls,hashed-transcript-data,async-executor"
RUN_RESPONDER_FEATURES: "spdm-mbedtls,hashed-transcript-data,async-executor"
run: |
./sh_script/build.sh -r
- name: Run fuzz hash-transcript-data
env:
FUZZ_HASH_TRANSCRIPT_DATA_FEATURE: true
run: |
./sh_script/fuzz_run.sh -c Scoverage
- name: Run fuzz
env:
FUZZ_HASH_TRANSCRIPT_DATA_FEATURE: false
run: |
./sh_script/fuzz_run.sh -c Scoverage
- name: Run tests and collect coverage
run: |
grcov $(find . -name "*.profraw") \
--branch \
--binary-path ./target/debug/ \
-s . \
-t html \
--ignore-not-existing \
-o coverage
grcov $(find . -name "*.profraw") \
--branch \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--ignore-not-existing \
-o coverage/lcov.info
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: coverage_data-${{ github.sha }}
path: coverage/
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
files: coverage/lcov.info
fail_ci_if_error: false
verbose: true