Re: [libvirt] [PATCH v2 64/73] tests: Add tests for QEMU migration parameters

2018-04-16 Thread Ján Tomko

On Wed, Apr 11, 2018 at 04:41:54PM +0200, Jiri Denemark wrote:

This is an enhanced replacement for the original test from
qemumonitorjsontest which was dropped earlier in this series. More data
files with some real data will be added in the following patches.

Signed-off-by: Jiri Denemark 
---
tests/Makefile.am |  12 ++
tests/qemumigparamsdata/unsupported.json  |   3 +
tests/qemumigparamsdata/unsupported.reply |   7 +
tests/qemumigparamsdata/unsupported.xml   |   4 +
tests/qemumigparamstest.c | 237 ++
5 files changed, 263 insertions(+)
create mode 100644 tests/qemumigparamsdata/unsupported.json
create mode 100644 tests/qemumigparamsdata/unsupported.reply
create mode 100644 tests/qemumigparamsdata/unsupported.xml
create mode 100644 tests/qemumigparamstest.c



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 64/73] tests: Add tests for QEMU migration parameters

2018-04-11 Thread Jiri Denemark
This is an enhanced replacement for the original test from
qemumonitorjsontest which was dropped earlier in this series. More data
files with some real data will be added in the following patches.

Signed-off-by: Jiri Denemark 
---
 tests/Makefile.am |  12 ++
 tests/qemumigparamsdata/unsupported.json  |   3 +
 tests/qemumigparamsdata/unsupported.reply |   7 +
 tests/qemumigparamsdata/unsupported.xml   |   4 +
 tests/qemumigparamstest.c | 237 ++
 5 files changed, 263 insertions(+)
 create mode 100644 tests/qemumigparamsdata/unsupported.json
 create mode 100644 tests/qemumigparamsdata/unsupported.reply
 create mode 100644 tests/qemumigparamsdata/unsupported.xml
 create mode 100644 tests/qemumigparamstest.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index a4f231d2a7..2c0d1311c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -124,6 +124,7 @@ EXTRA_DIST = \
qemuhotplugtestcpus \
qemuhotplugtestdevices \
qemuhotplugtestdomains \
+   qemumigparamsdata \
qemumonitorjsondata \
qemuxml2argvdata \
qemuxml2startupxmloutdata \
@@ -284,6 +285,7 @@ test_programs += qemuxml2argvtest qemuxml2xmltest \
qemumemlocktest \
qemucommandutiltest \
qemublocktest \
+   qemumigparamstest \
$(NULL)
 test_helpers += qemucapsprobe
 test_libraries += libqemumonitortestutils.la \
@@ -670,6 +672,15 @@ qemumemlocktest_SOURCES = \
testutilsqemu.c testutilsqemu.h \
testutils.c testutils.h
 qemumemlocktest_LDADD = $(qemu_LDADDS) $(LDADDS)
+
+qemumigparamstest_SOURCES = \
+   qemumigparamstest.c \
+   testutils.c testutils.h \
+   testutilsqemu.c testutilsqemu.h \
+   $(NULL)
+qemumigparamstest_LDADD = libqemumonitortestutils.la \
+   $(qemu_LDADDS) $(LDADDS)
+
 else ! WITH_QEMU
 EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \
domainsnapshotxml2xmltest.c \
@@ -680,6 +691,7 @@ EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c 
qemuargv2xmltest.c \
qemucaps2xmltest.c qemucommandutiltest.c \
qemumemlocktest.c qemucpumock.c testutilshostcpus.h \
qemublocktest.c \
+   qemumigparamstest.c \
$(QEMUMONITORTESTUTILS_SOURCES)
 endif ! WITH_QEMU
 
diff --git a/tests/qemumigparamsdata/unsupported.json 
b/tests/qemumigparamsdata/unsupported.json
new file mode 100644
index 00..0db3279e44
--- /dev/null
+++ b/tests/qemumigparamsdata/unsupported.json
@@ -0,0 +1,3 @@
+{
+
+}
diff --git a/tests/qemumigparamsdata/unsupported.reply 
b/tests/qemumigparamsdata/unsupported.reply
new file mode 100644
index 00..2b88ba10c3
--- /dev/null
+++ b/tests/qemumigparamsdata/unsupported.reply
@@ -0,0 +1,7 @@
+{
+  "id": "libvirt-1",
+  "error": {
+"class": "CommandNotFound",
+"desc": "The command query-migrate-parameters has not been found"
+  }
+}
diff --git a/tests/qemumigparamsdata/unsupported.xml 
b/tests/qemumigparamsdata/unsupported.xml
new file mode 100644
index 00..8aa3abefc0
--- /dev/null
+++ b/tests/qemumigparamsdata/unsupported.xml
@@ -0,0 +1,4 @@
+
+  
+  
+
diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c
new file mode 100644
index 00..4cc27bcf52
--- /dev/null
+++ b/tests/qemumigparamstest.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2011-2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * .
+ *
+ */
+
+#include 
+
+#include "virjson.h"
+#include "virbuffer.h"
+#include "virxml.h"
+#include "testutils.h"
+#include "testutilsqemu.h"
+#include "qemumonitortestutils.h"
+#include "qemu/qemu_migration_params.h"
+#include "qemu/qemu_migration_paramspriv.h"
+#include "qemu/qemu_monitor.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+typedef struct _qemuMigParamsData qemuMigParamsData;
+struct _qemuMigParamsData {
+virDomainXMLOptionPtr xmlopt;
+const char *name;
+};
+
+
+static void
+qemuMigParamsTestFormatXML(virBufferPtr buf,
+   qemuMigrationParamsPtr migParams)
+{
+virBufferAddLit(buf, "\n");
+virBufferAdjustIndent(buf, 2);
+
+if (migParams)
+qemuMigrationParamsFormat(buf, migParams);
+
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, "\n");
+}
+
+
+static int
+qemuMigParamsTestXML2XML(const void *opaque)
+{
+const