qemu: Add an Object unit test

We test that memory-backend-file and empty objects parameters are
properly built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2016-09-13 12:38:18 +02:00
parent 38e041dc9d
commit 8aeb3d45aa

View File

@ -39,11 +39,18 @@ func testAppend(structure interface{}, expected string, t *testing.T) {
} }
params = appendDevices([]string{}, config) params = appendDevices([]string{}, config)
case Object:
config := Config{
Objects: []Object{s},
}
params = appendObjects([]string{}, config)
} }
result := strings.Join(params, " ") result := strings.Join(params, " ")
if result != expected { if result != expected {
t.Fatalf("Failed to append Machine [%s] != [%s]", result, expected) t.Fatalf("Failed to append parameters [%s] != [%s]", result, expected)
} }
} }
@ -93,3 +100,22 @@ func TestAppendEmptyDevice(t *testing.T) {
testAppend(device, "", t) testAppend(device, "", t)
} }
var objectMemoryString = "-object memory-backend-file,id=mem0,mem-path=/root,size=65536"
func TestAppendObjectMemory(t *testing.T) {
object := Object{
Type: "memory-backend-file",
ID: "mem0",
MemPath: "/root",
Size: 1 << 16,
}
testAppend(object, objectMemoryString, t)
}
func TestAppendEmptyObject(t *testing.T) {
device := Device{}
testAppend(device, "", t)
}