From ea9bb8e9ad2513f922aa525c70b7f9118fd51539 Mon Sep 17 00:00:00 2001 From: Amulya Meka Date: Tue, 15 Jun 2021 10:23:38 +0000 Subject: [PATCH] ppc64le: Adding test for appendProtectionDevice Fixes: #2038 Signed-off-by: Amulya Meka --- .../virtcontainers/qemu_ppc64le_test.go | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/runtime/virtcontainers/qemu_ppc64le_test.go b/src/runtime/virtcontainers/qemu_ppc64le_test.go index c5e1038de5..ffe790d8e2 100644 --- a/src/runtime/virtcontainers/qemu_ppc64le_test.go +++ b/src/runtime/virtcontainers/qemu_ppc64le_test.go @@ -50,3 +50,53 @@ func TestQemuPPC64leMemoryTopology(t *testing.T) { assert.Equal(expectedMemory, m) } + +func TestQemuPPC64leAppendProtectionDevice(t *testing.T) { + assert := assert.New(t) + ppc64le := newTestQemu(assert, QemuPseries) + + var devices []govmmQemu.Device + var bios, firmware string + var err error + devices, bios, err = ppc64le.appendProtectionDevice(devices, firmware) + assert.NoError(err) + + //no protection + assert.Empty(bios) + + //Secure Execution protection + ppc64le.(*qemuPPC64le).protection = seProtection + devices, bios, err = ppc64le.appendProtectionDevice(devices, firmware) + assert.Error(err) + assert.Empty(bios) + + //SEV protection + ppc64le.(*qemuPPC64le).protection = sevProtection + devices, bios, err = ppc64le.appendProtectionDevice(devices, firmware) + assert.Error(err) + assert.Empty(bios) + + //TDX protection + ppc64le.(*qemuPPC64le).protection = tdxProtection + devices, bios, err = ppc64le.appendProtectionDevice(devices, firmware) + assert.Error(err) + assert.Empty(bios) + + //PEF protection + ppc64le.(*qemuPPC64le).protection = pefProtection + devices, bios, err = ppc64le.appendProtectionDevice(devices, firmware) + assert.NoError(err) + assert.Empty(bios) + + expectedOut := []govmmQemu.Device{ + govmmQemu.Object{ + Driver: govmmQemu.SpaprTPMProxy, + Type: govmmQemu.PEFGuest, + ID: pefID, + DeviceID: tpmID, + File: tpmHostPath, + }, + } + assert.Equal(expectedOut, devices) + +}