diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eab40346f..b0e84b94b 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 ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-abrmd + - name: Run the container + run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/examples.sh \ No newline at end of file diff --git a/tss-esapi/tests/Dockerfile-ubuntu b/tss-esapi/tests/Dockerfile-ubuntu index c42119197..01645bca3 100644 --- a/tss-esapi/tests/Dockerfile-ubuntu +++ b/tss-esapi/tests/Dockerfile-ubuntu @@ -28,6 +28,15 @@ RUN cd tpm2-tools \ && ./configure \ && make install +FROM tpm2-tools AS tpm2-abrmd +# Download and install TPM2 ABRMD +RUN git clone https://github.com/tpm2-software/tpm2-abrmd.git --branch 3.0.0 +RUN cd tpm2-abrmd \ + && ./bootstrap \ + && ./configure \ + && make install \ + && ldconfig + FROM tpm2-tools AS tpm2-tss-install-dir # TPM2_TSS_PATH is the env variable build.rs looks for # an installation. diff --git a/tss-esapi/tests/examples.sh b/tss-esapi/tests/examples.sh new file mode 100755 index 000000000..8941bec1d --- /dev/null +++ b/tss-esapi/tests/examples.sh @@ -0,0 +1,45 @@ +#!/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 simulation server # +################################# +tpm_server & +sleep 5 + +#################### +# Start tpm2-abrmd # +#################### +sudo -u tss tpm2-abrmd \ + --logger=stdout \ + --tcti=mssim \ + --session \ + --flush-all & + +################# +# Clear the TPM # +################# +tpm2_startup -clear -T tabrmd + +#################### +# Run the examples # +#################### +TEST_TCTI=tabrmd: RUST_BACKTRACE=1 RUST_LOG=info cargo run --example certify \ No newline at end of file