diff --git a/qemu_test.go b/qemu_test.go index d2321a311d..e19f659306 100644 --- a/qemu_test.go +++ b/qemu_test.go @@ -32,6 +32,13 @@ func testAppend(structure interface{}, expected string, t *testing.T) { } params = appendMachine([]string{}, config) + + case Device: + config := Config{ + Devices: []Device{s}, + } + + params = appendDevices([]string{}, config) } result := strings.Join(params, " ") @@ -56,3 +63,33 @@ func TestAppendEmptyMachine(t *testing.T) { testAppend(machine, "", t) } + +var deviceNVDIMMString = "-device nvdimm,id=nv0,memdev=mem0" + +func TestAppendDeviceNVDIMM(t *testing.T) { + device := Device{ + Type: "nvdimm", + ID: "nv0", + MemDev: "mem0", + } + + testAppend(device, deviceNVDIMMString, t) +} + +var deviceFSString = "-device virtio-9p-pci,fsdev=workload9p,mount_tag=rootfs" + +func TestAppendDeviceFS(t *testing.T) { + device := Device{ + Type: "virtio-9p-pci", + FSDev: "workload9p", + MountTag: "rootfs", + } + + testAppend(device, deviceFSString, t) +} + +func TestAppendEmptyDevice(t *testing.T) { + device := Device{} + + testAppend(device, "", t) +}