33# TEST-INITRD.SH - Isolated initrd validation for AMDSEV
44# ==============================================================================
55#
6- # Runs focused checks for initrd behavior without requiring the full SEV-SNP
7- # launch path:
8- # 1) Static archive/content checks (no VM boot)
9- # 2) Plain-QEMU boot smoke test with RPC health check (no OVMF/SEV)
6+ # Runs a focused initrd boot smoke test without requiring the full SEV-SNP
7+ # launch path. Uses plain QEMU (no OVMF/SEV) and validates Katana RPC readiness.
108#
119# Usage:
1210# ./test-initrd.sh [OPTIONS]
1311#
1412# Options:
1513# --output-dir DIR Boot artifacts directory (default: ./output/qemu)
16- # --static-only Run only static initrd checks
17- # --boot-only Run only boot smoke test
1814# --host-rpc-port PORT Host port for forwarded Katana RPC (default: 15052)
1915# --vm-rpc-port PORT Guest Katana RPC port (default: 5050)
2016# --timeout SEC Boot wait timeout in seconds (default: 90)
@@ -31,15 +27,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3127OUTPUT_DIR=" ${SCRIPT_DIR} /output/qemu"
3228INITRD_FILE=" "
3329KERNEL_FILE=" "
34- RUN_STATIC=1
35- RUN_BOOT=1
3630HOST_RPC_PORT=15052
3731VM_RPC_PORT=5050
3832BOOT_TIMEOUT=90
3933TEST_DISK_SIZE=" ${TEST_DISK_SIZE:- 1G} "
4034
4135TEMP_DIR=" $( mktemp -d /tmp/katana-amdsev-initrd-test.XXXXXX) "
42- EXTRACT_DIR=" ${TEMP_DIR} /extract"
4336SERIAL_LOG=" ${TEMP_DIR} /serial.log"
4437DISK_IMG=" ${TEMP_DIR} /test-disk.img"
4538QEMU_PID=" "
@@ -50,8 +43,6 @@ Usage: $0 [OPTIONS]
5043
5144Options:
5245 --output-dir DIR Boot artifacts directory (default: ./output/qemu)
53- --static-only Run only static initrd checks
54- --boot-only Run only boot smoke test
5546 --host-rpc-port PORT Host port for forwarded Katana RPC (default: 15052)
5647 --vm-rpc-port PORT Guest Katana RPC port (default: 5050)
5748 --timeout SEC Boot wait timeout in seconds (default: 90)
@@ -110,16 +101,6 @@ while [[ $# -gt 0 ]]; do
110101 OUTPUT_DIR=" ${2:? Missing value for --output-dir} "
111102 shift 2
112103 ;;
113- --static-only)
114- RUN_STATIC=1
115- RUN_BOOT=0
116- shift
117- ;;
118- --boot-only)
119- RUN_STATIC=0
120- RUN_BOOT=1
121- shift
122- ;;
123104 --host-rpc-port)
124105 HOST_RPC_PORT=" ${2:? Missing value for --host-rpc-port} "
125106 shift 2
@@ -145,77 +126,6 @@ done
145126INITRD_FILE=" ${OUTPUT_DIR} /initrd.img"
146127KERNEL_FILE=" ${OUTPUT_DIR} /vmlinuz"
147128
148- assert_extract_path () {
149- local rel_path=" $1 "
150- if [ ! -e " ${EXTRACT_DIR} /${rel_path} " ]; then
151- die " Expected initrd path missing: ${rel_path} "
152- fi
153- }
154-
155- assert_init_contains () {
156- local pattern=" $1 "
157- if ! grep -Fq -- " $pattern " " ${EXTRACT_DIR} /init" ; then
158- die " Expected pattern missing in init script: ${pattern} "
159- fi
160- }
161-
162- run_static_checks () {
163- log " Running static initrd checks"
164-
165- require_tool gzip
166- require_tool cpio
167- require_tool grep
168-
169- [ -f " $INITRD_FILE " ] || die " Initrd not found: $INITRD_FILE "
170-
171- if ! gzip -t " $INITRD_FILE " 2> /dev/null; then
172- die " Initrd is not valid gzip: $INITRD_FILE "
173- fi
174-
175- mkdir -p " $EXTRACT_DIR "
176- (
177- cd " $EXTRACT_DIR "
178- gzip -dc " $INITRD_FILE " | cpio -id --quiet
179- )
180-
181- REQUIRED_PATHS=(
182- init
183- bin/busybox
184- bin/katana
185- etc/passwd
186- etc/group
187- bin/sh
188- bin/mount
189- bin/umount
190- bin/ip
191- bin/insmod
192- bin/poweroff
193- bin/sync
194- )
195-
196- for path in " ${REQUIRED_PATHS[@]} " ; do
197- assert_extract_path " $path "
198- done
199-
200- [ -x " ${EXTRACT_DIR} /init" ] || die " Init script is not executable"
201- [ -x " ${EXTRACT_DIR} /bin/katana" ] || die " Katana binary in initrd is not executable"
202-
203- assert_init_contains " trap shutdown_handler TERM INT"
204- assert_init_contains " poweroff -f"
205- assert_init_contains " exec 0</dev/console"
206- assert_init_contains " if [ -d /sys/class/net/eth0 ]; then"
207- assert_init_contains " katana.args="
208-
209- if [ ! -e " ${EXTRACT_DIR} /lib/modules/tsm.ko" ]; then
210- warn " tsm.ko not present in initrd"
211- fi
212- if [ ! -e " ${EXTRACT_DIR} /lib/modules/sev-guest.ko" ]; then
213- warn " sev-guest.ko not present in initrd"
214- fi
215-
216- log " Static initrd checks passed"
217- }
218-
219129resolve_qemu_bin () {
220130 if [ -n " ${QEMU_BIN:- } " ]; then
221131 echo " $QEMU_BIN "
@@ -322,14 +232,6 @@ run_boot_smoke_test() {
322232}
323233
324234log " Output directory: $OUTPUT_DIR "
325- log " Modes: static=$RUN_STATIC boot=$RUN_BOOT "
326-
327- if [ " $RUN_STATIC " -eq 1 ]; then
328- run_static_checks
329- fi
330-
331- if [ " $RUN_BOOT " -eq 1 ]; then
332- run_boot_smoke_test
333- fi
235+ run_boot_smoke_test
334236
335237log " All requested initrd checks passed"
0 commit comments