diff options
author | Eric Auger <eric.auger@redhat.com> | 2020-06-29 21:34:23 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-07-10 18:02:16 -0400 |
commit | 9fc719b869264824db0be615122754909facc929 (patch) | |
tree | 5cf606d9543baae85eb0c3dd28de297ffeeb6d1a /tests/qtest | |
parent | db57fef1e285a1f56a2d99b83456abf2f0b86e96 (diff) | |
download | qemu-9fc719b869264824db0be615122754909facc929.zip |
tests/qmp-cmd-test: Add qmp/object-add-duplicate-id
This new test checks that attempting to create an object
with an existing ID gracefully fails.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200629193424.30280-3-eric.auger@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/qtest')
-rw-r--r-- | tests/qtest/qmp-cmd-test.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 9f5228cd99..fc65fa3726 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -213,6 +213,23 @@ static void test_object_add_without_props(void) qtest_quit(qts); } +static void test_object_add_with_duplicate_id(void) +{ + QTestState *qts; + QDict *resp; + + qts = qtest_init(common_args); + resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" + " {'qom-type': 'memory-backend-ram', 'id': 'ram1', 'props': {'size': 1048576 } } }"); + g_assert_nonnull(resp); + g_assert(qdict_haskey(resp, "return")); + resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" + " {'qom-type': 'memory-backend-ram', 'id': 'ram1', 'props': {'size': 1048576 } } }"); + g_assert_nonnull(resp); + qmp_assert_error_class(resp, "GenericError"); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { QmpSchema schema; @@ -225,6 +242,8 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/object-add-without-props", test_object_add_without_props); + qtest_add_func("qmp/object-add-duplicate-id", + test_object_add_with_duplicate_id); /* TODO: add coverage of generic object-add failure modes */ ret = g_test_run(); |