diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eab40346f..8c77bd553 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,3 +121,14 @@ jobs: run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.74.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh - name: Check Clippy lints latest run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh + + # Check that examples builds can be executed. + tests-examples: + name: Check examples + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Build the container + run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora + - name: Run the container + run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env USE_FROZEN_LOCKFILE=1 fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/examples.sh \ No newline at end of file diff --git a/tss-esapi/tests/examples.sh b/tss-esapi/tests/examples.sh new file mode 100755 index 000000000..79322c232 --- /dev/null +++ b/tss-esapi/tests/examples.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright 2019 Contributors to the Parsec project. +# SPDX-License-Identifier: Apache-2.0 + +# This script builds and tests the examples. +# It can be run inside the container which Dockerfile +# is in the same folder. + +set -euf -o pipefail + +################################################# +# Change rust toolchain version +################################################# +if [[ ! -z ${RUST_TOOLCHAIN_VERSION:+x} ]]; then + rustup override set ${RUST_TOOLCHAIN_VERSION} + # Use the frozen Cargo lock to prevent any drift from MSRV being upgraded + # underneath our feet. + cp tests/Cargo.lock.frozen ../Cargo.lock +fi + +############################ +# Run the TPM SWTPM server # +############################ +mkdir /tmp/tpmdir +swtpm_setup --tpm2 \ + --tpmstate /tmp/tpmdir \ + --createek --decryption --create-ek-cert \ + --create-platform-cert \ + --pcr-banks sha1,sha256 \ + --display +swtpm socket --tpm2 \ + --tpmstate dir=/tmp/tpmdir \ + --flags startup-clear \ + --ctrl type=tcp,port=2322 \ + --server type=tcp,port=2321 \ + --daemon + +#################### +# Start tpm2-abrmd # +#################### +tpm2-abrmd \ + --logger=stdout \ + --tcti=swtpm: \ + --allow-root \ + --session \ + --flush-all & + +################# +# Clear the TPM # +################# +tpm2_startup -c -T tabrmd:bus_type=session + +#################### +# Run the examples # +#################### +TEST_TCTI=tabrmd:bus_type=session RUST_BACKTRACE=1 RUST_LOG=info cargo run --example rsa_oaep \ No newline at end of file