ppc64le: Adding test for appendProtectionDevice
Fixes:
@@ -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)
+
+}
