[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/12] qapi: More tests of alternate output
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 08/12] qapi: More tests of alternate output |
Date: |
Mon, 9 Nov 2015 18:46:40 +0100 |
From: Eric Blake <address@hidden>
The testsuite was only covering that we could output the 'int'
branch of an alternate (no additional allocation/cleanup required).
Add a test of the 'str' branch, to make sure that things still
work even when a branch involves allocation.
Update to modern style of g_new0() over g_malloc0() while
touching it.
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
tests/test-qmp-output-visitor.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index 0164984..0d0c859 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -425,8 +425,9 @@ static void
test_visitor_out_alternate(TestOutputVisitorData *data,
const void *unused)
{
QObject *arg;
+ UserDefAlternate *tmp;
- UserDefAlternate *tmp = g_malloc0(sizeof(UserDefAlternate));
+ tmp = g_new0(UserDefAlternate, 1);
tmp->type = USER_DEF_ALTERNATE_KIND_I;
tmp->u.i = 42;
@@ -438,6 +439,19 @@ static void
test_visitor_out_alternate(TestOutputVisitorData *data,
qapi_free_UserDefAlternate(tmp);
qobject_decref(arg);
+
+ tmp = g_new0(UserDefAlternate, 1);
+ tmp->type = USER_DEF_ALTERNATE_KIND_S;
+ tmp->u.s = g_strdup("hello");
+
+ visit_type_UserDefAlternate(data->ov, &tmp, NULL, &error_abort);
+ arg = qmp_output_get_qobject(data->qov);
+
+ g_assert(qobject_type(arg) == QTYPE_QSTRING);
+ g_assert_cmpstr(qstring_get_str(qobject_to_qstring(arg)), ==, "hello");
+
+ qapi_free_UserDefAlternate(tmp);
+ qobject_decref(arg);
}
static void test_visitor_out_empty(TestOutputVisitorData *data,
--
2.4.3
- [Qemu-devel] [PULL 00/12] QAPI patches, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 02/12] qapi: Strengthen test of TestStructList, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 09/12] qapi: Test failure in middle of array parse, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 04/12] qapi: Share test_init code in test-qmp-input*, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 01/12] qapi: Use generated TestStruct machinery in tests, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 11/12] qapi: Provide nicer array names in introspection, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 03/12] qobject: Protect against use-after-free in qobject_decref(), Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 10/12] qapi: More tests of input arrays, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 05/12] qapi: Plug leaks in test-qmp-*, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 08/12] qapi: More tests of alternate output,
Markus Armbruster <=
- [Qemu-devel] [PULL 12/12] qapi-introspect: Document lack of sorting, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 07/12] qapi: Simplify error cleanup in test-qmp-*, Markus Armbruster, 2015/11/09
- [Qemu-devel] [PULL 06/12] qapi: Simplify non-error testing in test-qmp-*, Markus Armbruster, 2015/11/09