diff options
author | Thomas Huth <thuth@redhat.com> | 2019-07-22 17:10:55 +0200 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2019-08-15 19:24:10 +0200 |
commit | e5758de4e836c3b2edc2befd904651fc6967d74f (patch) | |
tree | 324827884570aa10cb22024f8735e43178e3a947 /tests/libqtest.c | |
parent | 17de4741296af8ed3361b14feda130a7d7102987 (diff) |
tests/libqtest: Make qtest_qmp_device_add/del independent from global_qtest
Generic library functions like qtest_qmp_device_add() and _del()
should not depend on the global_qtest variable. Pass the test
state via parameter instead.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20190813093047.27948-6-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/libqtest.c')
-rw-r--r-- | tests/libqtest.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c index d1aead30ed..19c1fc2e97 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1246,7 +1246,7 @@ QDict *qtest_qmp_receive_success(QTestState *s, /* * Generic hot-plugging test via the device_add QMP command. */ -void qtest_qmp_device_add(const char *driver, const char *id, +void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, const char *fmt, ...) { QDict *args, *response; @@ -1260,7 +1260,8 @@ void qtest_qmp_device_add(const char *driver, const char *id, qdict_put_str(args, "driver", driver); qdict_put_str(args, "id", id); - response = qmp("{'execute': 'device_add', 'arguments': %p}", args); + response = qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}", + args); g_assert(response); g_assert(!qdict_haskey(response, "event")); /* We don't expect any events */ g_assert(!qdict_haskey(response, "error")); @@ -1293,19 +1294,17 @@ static void device_deleted_cb(void *opaque, const char *name, QDict *data) * * But the order of arrival may vary - so we've got to detect both. */ -void qtest_qmp_device_del(const char *id) +void qtest_qmp_device_del(QTestState *qts, const char *id) { bool got_event = false; QDict *rsp; - qtest_qmp_send(global_qtest, - "{'execute': 'device_del', 'arguments': {'id': %s}}", + qtest_qmp_send(qts, "{'execute': 'device_del', 'arguments': {'id': %s}}", id); - rsp = qtest_qmp_receive_success(global_qtest, device_deleted_cb, - &got_event); + rsp = qtest_qmp_receive_success(qts, device_deleted_cb, &got_event); qobject_unref(rsp); if (!got_event) { - rsp = qtest_qmp_receive(global_qtest); + rsp = qtest_qmp_receive(qts); g_assert_cmpstr(qdict_get_try_str(rsp, "event"), ==, "DEVICE_DELETED"); qobject_unref(rsp); |