From 0380aef323154205a7d838fb9953423621290d41 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Fri, 11 Apr 2014 18:07:12 -0400 Subject: qom-test: Test qom-list on link<> properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit But don't test their properties, otherwise we will recurse forever. Their properties are already tested when we encounter them as child<> properties elsewhere in the hierarchy, like /machine/unattached/... This would have caught the crash fixed by 92b3eead. Signed-off-by: Cole Robinson Signed-off-by: Andreas Färber --- tests/qom-test.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/qom-test.c b/tests/qom-test.c index 6d9a00b..d8d1d8d 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -44,7 +44,7 @@ static bool is_blacklisted(const char *arch, const char *mach) return false; } -static void test_properties(const char *path) +static void test_properties(const char *path, bool recurse) { char *child_path; QDict *response, *tuple; @@ -56,14 +56,21 @@ static void test_properties(const char *path) " 'arguments': { 'path': '%s' } }", path); g_assert(response); + if (!recurse) { + return; + } + g_assert(qdict_haskey(response, "return")); list = qobject_to_qlist(qdict_get(response, "return")); QLIST_FOREACH_ENTRY(list, entry) { tuple = qobject_to_qdict(qlist_entry_obj(entry)); - if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) { + bool is_child = strstart(qdict_get_str(tuple, "type"), "child<", NULL); + bool is_link = strstart(qdict_get_str(tuple, "type"), "link<", NULL); + + if (is_child || is_link) { child_path = g_strdup_printf("%s/%s", path, qdict_get_str(tuple, "name")); - test_properties(child_path); + test_properties(child_path, is_child); g_free(child_path); } else { const char *prop = qdict_get_str(tuple, "name"); @@ -87,7 +94,7 @@ static void test_machine(gconstpointer data) args = g_strdup_printf("-machine %s", machine); qtest_start(args); - test_properties("/machine"); + test_properties("/machine", true); response = qmp("{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); -- cgit v1.1 From a199b2b6a5b9dd50cfe96349778458d1b39899b5 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 26 May 2014 15:40:56 +0300 Subject: tests: Check empty QMP output visitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checks the output visitor behaviour for NULL values. Signed-off-by: Marcel Apfelbaum Acked-by: Michael S. Tsirkin Acked-by: Michael Roth Signed-off-by: Andreas Färber --- tests/test-qmp-output-visitor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 9c15458..74020de 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -507,6 +507,15 @@ static void test_visitor_out_union_anon(TestOutputVisitorData *data, qapi_free_UserDefAnonUnion(tmp); } +static void test_visitor_out_empty(TestOutputVisitorData *data, + const void *unused) +{ + QObject *arg; + + arg = qmp_output_get_qobject(data->qov); + g_assert(!arg); +} + static void init_native_list(UserDefNativeListUnion *cvalue) { int i; @@ -859,6 +868,8 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_union_flat); output_visitor_test_add("/visitor/output/union-anon", &out_visitor_data, test_visitor_out_union_anon); + output_visitor_test_add("/visitor/output/empty", + &out_visitor_data, test_visitor_out_empty); output_visitor_test_add("/visitor/output/native_list/int", &out_visitor_data, test_visitor_out_native_list_int); output_visitor_test_add("/visitor/output/native_list/int8", -- cgit v1.1