From d6e7a58ac9464a7a6936986142ebc83cdd8a350a Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 23 Jun 2020 15:17:51 +1000 Subject: [PATCH] qemu: Clarify test with bad machine type The last stanza of TestQemuAmd64Bridges is rather odd. It tries to create a qemu instance with a machine type of (QemuQ35 + QemuPC), or in other words "q35pc", which isn't a thing. What it's asserting about this is that the returned bridges list is empty despite asking for bridges, so it looks like what this is really trying to test is for sane behaviour when given a bad machine type. So, split this out into a separate test, and make it explicit for clarity. Signed-off-by: David Gibson --- src/runtime/virtcontainers/qemu_amd64_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/runtime/virtcontainers/qemu_amd64_test.go b/src/runtime/virtcontainers/qemu_amd64_test.go index 2032e1f01d..4c5e0d1bd7 100644 --- a/src/runtime/virtcontainers/qemu_amd64_test.go +++ b/src/runtime/virtcontainers/qemu_amd64_test.go @@ -27,6 +27,15 @@ func newTestQemu(machineType string) qemuArch { return newQemuArch(config) } +func TestQemuAmd64BadMachineType(t *testing.T) { + assert := assert.New(t) + + amd64 := newTestQemu("no-such-machine-type") + amd64.bridges(5) + bridges := amd64.getBridges() + assert.Nil(bridges) +} + func TestQemuAmd64Capabilities(t *testing.T) { assert := assert.New(t) @@ -66,11 +75,6 @@ func TestQemuAmd64Bridges(t *testing.T) { assert.Equal(id, b.ID) assert.NotNil(b.Devices) } - - amd64 = newTestQemu(QemuQ35 + QemuPC) - amd64.bridges(uint32(len)) - bridges = amd64.getBridges() - assert.Nil(bridges) } func TestQemuAmd64CPUModel(t *testing.T) {