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>
This commit is contained in:
Thomas Huth 2019-07-22 17:10:55 +02:00
parent 17de474129
commit e5758de4e8
16 changed files with 66 additions and 52 deletions

View file

@ -37,20 +37,20 @@ void uhci_port_test(struct qhc *hc, int port, uint16_t expect)
g_assert((value & mask) == (expect & mask));
}
void usb_test_hotplug(const char *hcd_id, const char *port,
void usb_test_hotplug(QTestState *qts, const char *hcd_id, const char *port,
void (*port_check)(void))
{
char *id = g_strdup_printf("usbdev%s", port);
char *bus = g_strdup_printf("%s.0", hcd_id);
qtest_qmp_device_add("usb-tablet", id, "{'port': %s, 'bus': %s}",
qtest_qmp_device_add(qts, "usb-tablet", id, "{'port': %s, 'bus': %s}",
port, bus);
if (port_check) {
port_check();
}
qtest_qmp_device_del(id);
qtest_qmp_device_del(qts, id);
g_free(bus);
g_free(id);