test_object_add_without_props() tests a bug in qmp_object_add() we fixed in commit e64c75a975. Sadly, we don't have systematic object-add tests. This lone test can go into qmp-cmd-test for want of a better home.
test_qom_set_without_value() is about a bug in infrastructure used by the QMP core, fixed in commit c489780203. We covered the bug in infrastructure unit tests (commit bce3035a44). I wrote that test earlier, to cover QMP level as well, the test could go into qmp-test. Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- tests/qmp-cmd-test.c | 31 +++++++++++++++++++++++++++++++ tests/qmp-test.c | 18 ++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/qmp-cmd-test.c b/tests/qmp-cmd-test.c index c5b70df974..3ba8f68476 100644 --- a/tests/qmp-cmd-test.c +++ b/tests/qmp-cmd-test.c @@ -19,6 +19,15 @@ const char common_args[] = "-nodefaults -machine none"; +static const char *get_error_class(QDict *resp) +{ + QDict *error = qdict_get_qdict(resp, "error"); + const char *desc = qdict_get_try_str(error, "desc"); + + g_assert(desc); + return error ? qdict_get_try_str(error, "class") : NULL; +} + /* Query smoke tests */ static int query_error_class(const char *cmd) @@ -197,6 +206,24 @@ static void add_query_tests(QmpSchema *schema) } } +static void test_object_add_without_props(void) +{ + QTestState *qts; + QDict *ret; + + qts = qtest_init(common_args); + + ret = qtest_qmp(qts, + "{'execute': 'object-add', 'arguments':" + " {'qom-type': 'memory-backend-ram', 'id': 'ram1' } }"); + g_assert_nonnull(ret); + + g_assert_cmpstr(get_error_class(ret), ==, "GenericError"); + + qobject_unref(ret); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { QmpSchema schema; @@ -206,6 +233,10 @@ int main(int argc, char *argv[]) qmp_schema_init(&schema); add_query_tests(&schema); + + qtest_add_func("qmp/object-add-without-props", + test_object_add_without_props); + ret = g_test_run(); qmp_schema_cleanup(&schema); diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 4ae2245484..fdfe73b6d2 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -348,6 +348,23 @@ static void test_qmp_preconfig(void) qtest_quit(qs); } +static void test_qom_set_without_value(void) +{ + QTestState *qts; + QDict *ret; + + qts = qtest_init(common_args); + + ret = qtest_qmp(qts, "{'execute': 'qom-set', 'arguments':" + " { 'path': '/machine', 'property': 'rtc-time' } }"); + g_assert_nonnull(ret); + + g_assert_cmpstr(get_error_class(ret), ==, "GenericError"); + + qobject_unref(ret); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -355,6 +372,7 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/protocol", test_qmp_protocol); qtest_add_func("qmp/oob", test_qmp_oob); qtest_add_func("qmp/preconfig", test_qmp_preconfig); + qtest_add_func("qmp/qom-set-without-value", test_qom_set_without_value); return g_test_run(); } -- 2.18.0.547.g1d89318c48