Skip to content

eBPF-based security platform

testing: group TPM tests

John Fastabend184db2f2badf
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index 09d00eff..6e529f5e 100644
--- a/Documentation/requirements.rst
+++ b/Documentation/requirements.rst
@@ -352,8 +352,8 @@ binary, as described in `operations <operations.rst>`__.
docutils' ``rst2html`` (``python3-docutils``).
* The host-side suite, ``make -C testing test-op``, runs its Python
helpers on the standard library alone. With the ``cryptography``
- module installed, ``t0033-tpm-wire.sh`` also cross-checks the TPM
- credential blob it builds against an independent implementation;
+ module installed, ``testing/tpm/t0033-tpm-wire.sh`` also cross-checks
+ the TPM credential blob it builds against an independent implementation;
without it that one check is skipped.
* ``make -C testing fuzz`` builds the parsers' libFuzzer targets with
``clang`` and needs its fuzzer and sanitizer runtime
diff --git a/Documentation/tpm.rst b/Documentation/tpm.rst
index b414dbc8..55f1e82e 100644
--- a/Documentation/tpm.rst
+++ b/Documentation/tpm.rst
@@ -573,10 +573,10 @@ context and the deferred mitigations the plan.
8) Testing
----------
-``testing/t0033-tpm-wire.sh`` checks the policy digests, names, wire
+``testing/tpm/t0033-tpm-wire.sh`` checks the policy digests, names, wire
parsers, the key derivations, the endorsement policy and the
credential blob against known vectors and an independent
-implementation, without a TPM. ``testing/t0034-register.sh`` drives the
+implementation, without a TPM. ``testing/tpm/t0034-register.sh`` drives the
whole register and attestation path, the initrd phases simulated as
PCR 11 extensions, the credential challenge with an ECC and an RSA
endorsement key included, against libtpms:
diff --git a/testing/run-target-tests.sh b/testing/run-target-tests.sh
index b8fe9128..e388a018 100755
--- a/testing/run-target-tests.sh
+++ b/testing/run-target-tests.sh
@@ -18,11 +18,11 @@ for t in \
bpm/t1118-bpm-tree.sh \
bpm/t1119-bpm-tree-sequential.sh \
bpm/t1120-bpm-tree-delete.sh \
- t1102-eventlog-full.sh \
+ tpm/t1102-eventlog-full.sh \
t1103-version-gate.sh \
t1104-payload-mismatch.sh \
t1107-load-unload.sh \
- t1108-tpm-chain.sh \
+ tpm/t1108-tpm-chain.sh \
t1111-upatch-get.sh \
t1114-uprobe-multi.sh \
otel/t1115-map-export-all.sh \
diff --git a/testing/run-tests.sh b/testing/run-tests.sh
index 1d9cc9c7..75fe7968 100755
--- a/testing/run-tests.sh
+++ b/testing/run-tests.sh
@@ -54,6 +54,19 @@ for t in bpm/t0[0-9][0-9][0-9]-*.sh; do
fi
done
+for t in tpm/t0[0-9][0-9][0-9]-*.sh; do
+ [ -e "$t" ] || continue
+ found=1
+ if sh "$t"; then
+ :
+ else
+ fail=$((fail + 1))
+ if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then
+ printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE" 2>/dev/null || :
+ fi
+ fi
+done
+
for t in upatch/kernel-obs/dns/t0[0-9][0-9][0-9]-*.sh; do
[ -e "$t" ] || continue
found=1
diff --git a/testing/t0015-test-vm-cli.sh b/testing/t0015-test-vm-cli.sh
index 72866133..e6ca022b 100755
--- a/testing/t0015-test-vm-cli.sh
+++ b/testing/t0015-test-vm-cli.sh
@@ -902,17 +902,18 @@ test_expect_success 'operator and target runners have disjoint explicit scopes'
grep -q "for t in t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&
grep -q "for t in otel/t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&
grep -q "bpm/t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&
+ grep -q "tpm/t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&
! grep -q "t1101" ../testing/run-tests.sh &&
for test_name in \
t1200-target-fixtures.sh \
bpm/t1118-bpm-tree.sh \
bpm/t1119-bpm-tree-sequential.sh \
bpm/t1120-bpm-tree-delete.sh \
- t1102-eventlog-full.sh \
+ tpm/t1102-eventlog-full.sh \
t1103-version-gate.sh \
t1104-payload-mismatch.sh \
t1107-load-unload.sh \
- t1108-tpm-chain.sh \
+ tpm/t1108-tpm-chain.sh \
t1111-upatch-get.sh \
t1114-uprobe-multi.sh \
otel/t1115-map-export-all.sh \
diff --git a/testing/t0003-chain.sh b/testing/tpm/t0003-chain.sh
similarity index 97%
rename from testing/t0003-chain.sh
rename to testing/tpm/t0003-chain.sh
index 62fed3b2..ccfc8bce 100644
--- a/testing/t0003-chain.sh
+++ b/testing/tpm/t0003-chain.sh
@@ -6,7 +6,7 @@
# and constant-time compare. These underpin the measurement register;
# a drift here silently breaks attestation.
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./test-lib.sh
H=helper/test-chain
diff --git a/testing/t0033-tpm-wire.sh b/testing/tpm/t0033-tpm-wire.sh
similarity index 99%
rename from testing/t0033-tpm-wire.sh
rename to testing/tpm/t0033-tpm-wire.sh
index 5bc9f426..1536f408 100644
--- a/testing/t0033-tpm-wire.sh
+++ b/testing/tpm/t0033-tpm-wire.sh
@@ -6,7 +6,7 @@
# under, NV and object names, and the attestation structures the
# verifier parses, each against values computed independently here.
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./test-lib.sh
H=helper/test-tpm-wire
diff --git a/testing/t0034-register.sh b/testing/tpm/t0034-register.sh
similarity index 99%
rename from testing/t0034-register.sh
rename to testing/tpm/t0034-register.sh
index 36051043..ffb191b7 100644
--- a/testing/t0034-register.sh
+++ b/testing/tpm/t0034-register.sh
@@ -8,7 +8,7 @@
# a verifier accepts or refuses. Needs the libtpms-backed
# helper/tpmsim-cmd; skipped where libtpms is not installed.
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./test-lib.sh
R=helper/test-register
diff --git a/testing/t0035-eventlog-pending.sh b/testing/tpm/t0035-eventlog-pending.sh
similarity index 98%
rename from testing/t0035-eventlog-pending.sh
rename to testing/tpm/t0035-eventlog-pending.sh
index 88e7435d..db05134e 100755
--- a/testing/t0035-eventlog-pending.sh
+++ b/testing/tpm/t0035-eventlog-pending.sh
@@ -7,7 +7,7 @@
# system's init adopts it, and adoption appends it to the eventlog
# exactly once.
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./test-lib.sh
H=helper/test-eventlog
W=$(mktemp -d)
diff --git a/testing/t1102-eventlog-full.sh b/testing/tpm/t1102-eventlog-full.sh
similarity index 97%
rename from testing/t1102-eventlog-full.sh
rename to testing/tpm/t1102-eventlog-full.sh
index 12c5da04..e56ad336 100644
--- a/testing/t1102-eventlog-full.sh
+++ b/testing/tpm/t1102-eventlog-full.sh
@@ -6,7 +6,7 @@
# shirudo.conf, a valid load refuses with category eventlog_full at
# pre-flight. No BPF_PROG_LOAD, no chain extend, no append. Non-destructive.
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./integration-lib.sh
target_guard
diff --git a/testing/t1108-tpm-chain.sh b/testing/tpm/t1108-tpm-chain.sh
similarity index 97%
rename from testing/t1108-tpm-chain.sh
rename to testing/tpm/t1108-tpm-chain.sh
index b1746da3..6ff38df7 100644
--- a/testing/t1108-tpm-chain.sh
+++ b/testing/tpm/t1108-tpm-chain.sh
@@ -8,7 +8,7 @@
# usable TPM; init refuses to run without one, so a host with no chain
# has no shirudo state and the test skips (it runs on the CI vTPM runner).
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./integration-lib.sh
target_guard