Files
systemd/test/units/TEST-94-COCO.tdx-direct.sh
T
Paul Meyer 671206e266 test: split coco test per-platform
Grow TEST-94-COCO from a single inline check into the reusable structure
that can be used by multiple future subtests:

- lib.sh: code shared between subtests on the host side.
- guest-test.sh: the testcase_coco_* checks.
- guest-test-runner.sh: runs each testcase_coco_* check, ships guest
  side testcase results over vsock.

Helpers live under test/units/TEST-94-COCO/. The vsock records are
best-effort detail, the aggregate exit status stays the authoritative
pass/fail.

Split the test into subtests per platform/boot flow.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-09-25 08:15:24 +02:00

33 lines
886 B
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# TDX, direct kernel boot: launch a confidential guest with --linux=/--initrd=.
set -eux
set -o pipefail
# shellcheck source=test/units/TEST-94-COCO/lib.sh
. "$(dirname "$0")"/TEST-94-COCO/lib.sh
if [[ "${COCO_TYPE:?}" != "tdx" ]]; then
echo "host coco type is '$COCO_TYPE', not tdx, skipping"
exit 77
fi
MACHINE="coco-tdx-direct-$$"
WORKDIR="$(mktemp -d)"
at_exit() {
set +e
jobs -p | xargs -r kill 2>/dev/null
machinectl terminate "$MACHINE" 2>/dev/null || :
rm -rf "$WORKDIR"
}
trap at_exit EXIT
vmspawn_boot_coco "$MACHINE" "$COCO_TYPE" "$WORKDIR" "" \
--image="$IMAGE_DIR/image.raw" \
--linux="$IMAGE_DIR/image.vmlinuz" \
--initrd="$IMAGE_DIR/image.initrd" \
selinux=0 systemd.firstboot=no rw
echo "TDX direct-boot guest correctly reported confidential virtualization"