mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
qmp_test: Add TestExecMemdevAdd and TestExecQomSet
Add TestExecMemdevAdd and TestExecQomSet to qmp_test.go. They can test ExecMemdevAdd and ExecQomSet. Signed-off-by: Hui Zhu <teawater@antfin.com>
This commit is contained in:
parent
201fd0ae82
commit
6667f4e90b
@ -1294,6 +1294,24 @@ func TestExecSetMigrateArguments(t *testing.T) {
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
||||
// Checks add memory device
|
||||
func TestExecMemdevAdd(t *testing.T) {
|
||||
connectedCh := make(chan *QMPVersion)
|
||||
disconnectedCh := make(chan struct{})
|
||||
buf := newQMPTestCommandBuffer(t)
|
||||
buf.AddCommand("object-add", nil, "return", nil)
|
||||
buf.AddCommand("device_add", nil, "return", nil)
|
||||
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||
checkVersion(t, connectedCh)
|
||||
err := q.ExecMemdevAdd(context.Background(), "memory-backend-ram", "mem0", "", 128, true, "virtio-mem-pci", "virtiomem0")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
||||
// Checks hotplug memory
|
||||
func TestExecHotplugMemory(t *testing.T) {
|
||||
connectedCh := make(chan *QMPVersion)
|
||||
@ -1692,3 +1710,20 @@ func TestQMPExecQueryQmpStatus(t *testing.T) {
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
||||
// Checks qom-set
|
||||
func TestExecQomSet(t *testing.T) {
|
||||
connectedCh := make(chan *QMPVersion)
|
||||
disconnectedCh := make(chan struct{})
|
||||
buf := newQMPTestCommandBuffer(t)
|
||||
buf.AddCommand("qom-set", nil, "return", nil)
|
||||
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||
checkVersion(t, connectedCh)
|
||||
err := q.ExecQomSet(context.Background(), "virtiomem0", "requested-size", 1024)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user