mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 22:17:19 +00:00
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:
parent
38e041dc9d
commit
8aeb3d45aa
28
qemu_test.go
28
qemu_test.go
@ -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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user