ppc64le: Adding test for appendProtectionDevice

Fixes: #2038

Signed-off-by: Amulya Meka <amulmek1@in.ibm.com>
This commit is contained in:
Amulya Meka 2021-06-15 10:23:38 +00:00
parent 5a71786986
commit ea9bb8e9ad

View File

@ -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)
}