Skip to content

Commit 1933fc9

Browse files
committed
Add support for testing with opensuse
This adds opensuse as an option for the docker integration tests. Additionally, it adds a .dockerignore file to improve build times and reduce image size. Signed-off-by: William Brown <william.brown@suse.com>
1 parent b75d2ad commit 1933fc9

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.github
3+
.gitignore
4+
.mypy_cache
5+
.vscode
6+
*.md
7+
**/__pycache__/**
8+
docs
9+
Makefile
10+
target
11+
test.db
12+
vendor

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
*.patch
77
*NVChip
88
.vscode
9+
.cargo/
10+
vendor/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# USAGE:
2+
# docker build -t tssdev -f ./tss-esapi/tests/Dockerfile-opensuse-tw .
3+
# docker run -v ./:/usr/src/rust-tss-esapi --rm -i -t tssdev
4+
#
5+
# It is a good idea to vendor to prevent repeat crate downloads.
6+
# mkdir .cargo
7+
# cargo vendor > .cargo/config.toml
8+
9+
FROM opensuse/tumbleweed:latest
10+
11+
RUN zypper install -y \
12+
tpm2-0-tss-devel tpm2.0-tools tpm2.0-abrmd \
13+
swtpm \
14+
cargo \
15+
clang \
16+
dbus-1-daemon
17+
18+
# Instead of bind mounting, we could do this instead.
19+
# COPY . /usr/src/rust-tss-esapi
20+
21+
WORKDIR /usr/src/rust-tss-esapi
22+
23+
CMD ["/usr/bin/bash", "tss-esapi/tests/all-opensuse.sh"]

tss-esapi/tests/all-opensuse.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2024 Contributors to the Parsec project.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# This script executes tests for the tss-esapi crate.
7+
# It can be run inside the container which Dockerfile is in the same folder.
8+
#
9+
# Usage: ./tests/all.sh
10+
11+
set -euf -o pipefail
12+
13+
############################
14+
# Run the TPM SWTPM server #
15+
############################
16+
mkdir /tmp/tpmdir
17+
swtpm_setup --tpm2 \
18+
--tpmstate /tmp/tpmdir \
19+
--createek --decryption --create-ek-cert \
20+
--create-platform-cert \
21+
--pcr-banks sha1,sha256 \
22+
--display
23+
swtpm socket --tpm2 \
24+
--tpmstate dir=/tmp/tpmdir \
25+
--flags startup-clear \
26+
--ctrl type=tcp,port=2322 \
27+
--server type=tcp,port=2321 \
28+
--daemon
29+
30+
###################
31+
# Build the crate #
32+
###################
33+
RUST_BACKTRACE=1 cargo build --features "generate-bindings integration-tests"
34+
35+
#################
36+
# Run the tests #
37+
#################
38+
TEST_TCTI="swtpm:host=localhost,port=2321" RUST_BACKTRACE=1 RUST_LOG=info cargo test --features "generate-bindings integration-tests" -- --test-threads=1 --nocapture
39+

0 commit comments

Comments
 (0)