Skip to content

Commit ae389be

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
Skip QEMU SPDM tests when QEMU lacks spdm_port support
Stock QEMU builds don't include NVMe SPDM support (the spdm_port property). Probe QEMU via '-device nvme,help' and skip the test when the property is absent, instead of failing with "Property 'nvme.spdm_port' not found".
1 parent 79a9b22 commit ae389be

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

tests/qemu/go_go_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
func TestQEMU_GoRequester_GoResponder(t *testing.T) {
1818
skipIfNoQEMU(t)
1919
skipIfNoKernel(t)
20+
skipIfNoSPDMSupport(t)
2021

2122
guestBin := buildGuestBinary(t)
2223
initramfs := buildInitramfs(t, guestBin)

tests/qemu/go_ref_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
func TestQEMU_GoRequester_RefResponder(t *testing.T) {
2323
skipIfNoQEMU(t)
2424
skipIfNoKernel(t)
25+
skipIfNoSPDMSupport(t)
2526

2627
emuBin := os.Getenv("SPDM_EMU_BIN")
2728
if emuBin == "" {

tests/qemu/harness_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,24 @@ func skipIfNoKernel(t *testing.T) {
174174
t.Skipf("kernel not available: %v", err)
175175
}
176176
}
177+
178+
// skipIfNoSPDMSupport skips the test if QEMU lacks NVMe SPDM support
179+
// (the spdm_port property). Stock QEMU builds don't include this;
180+
// it requires an SPDM-patched QEMU.
181+
func skipIfNoSPDMSupport(t *testing.T) {
182+
t.Helper()
183+
184+
qemuBin, err := findQEMU()
185+
if err != nil {
186+
t.Skipf("QEMU not available: %v", err)
187+
}
188+
189+
out, err := exec.Command(qemuBin, "-device", "nvme,help").CombinedOutput()
190+
if err != nil {
191+
t.Skipf("failed to probe QEMU NVMe properties: %v", err)
192+
}
193+
194+
if !strings.Contains(string(out), "spdm_port") {
195+
t.Skip("QEMU NVMe device does not support spdm_port (SPDM-patched QEMU required)")
196+
}
197+
}

0 commit comments

Comments
 (0)