Merge pull request #2039 from Amulyam24/pef-tests

ppc64le: Adding test for appendProtectionDevice
This commit is contained in:
Chelsea Mafrica 2021-06-15 16:19:05 -07:00 committed by GitHub
commit 6abe7caecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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