From 5ba8ef79df1e09d27be8d829a1abf74cc33df656 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 13 Sep 2016 14:29:42 +0200 Subject: [PATCH] qemu: Add QMP socket unit tests We test that the QMP socket parameter is properly built. Signed-off-by: Samuel Ortiz --- qemu_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/qemu_test.go b/qemu_test.go index 7f01c4b612..d973a090d0 100644 --- a/qemu_test.go +++ b/qemu_test.go @@ -74,6 +74,13 @@ func testAppend(structure interface{}, expected string, t *testing.T) { } params = appendCPUs([]string{}, config) + + case QMPSocket: + config := Config{ + QMPSocket: s, + } + + params = appendQMPSocket([]string{}, config) } result := strings.Join(params, " ") @@ -205,3 +212,27 @@ func TestAppendCPUs(t *testing.T) { testAppend(smp, cpusString, t) } + +var qmpSocketServerString = "-qmp unix:cc-qmp,server,nowait" +var qmpSocketString = "-qmp unix:cc-qmp" + +func TestAppendQMPSocketServer(t *testing.T) { + qmp := QMPSocket{ + Type: "unix", + Name: "cc-qmp", + Server: true, + NoWait: true, + } + + testAppend(qmp, qmpSocketServerString, t) +} + +func TestAppendQMPSocket(t *testing.T) { + qmp := QMPSocket{ + Type: "unix", + Name: "cc-qmp", + Server: false, + } + + testAppend(qmp, qmpSocketString, t) +}