docs/pci_expander_bridge: fix typo
[qemu/ar7.git] / tests / usb-hcd-xhci-test.c
blob56ab367316dbe233996ebc52e30713afadcc686a
1 /*
2 * QTest testcase for USB xHCI controller
4 * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
10 #include <glib.h>
11 #include <string.h>
12 #include "libqtest.h"
13 #include "qemu/osdep.h"
14 #include "libqos/usb.h"
17 static void test_xhci_init(void)
21 static void test_xhci_hotplug(void)
23 usb_test_hotplug("xhci", 1, NULL);
26 static void test_usb_uas_hotplug(void)
28 QDict *response;
30 response = qmp("{'execute': 'device_add',"
31 " 'arguments': {"
32 " 'driver': 'usb-uas',"
33 " 'id': 'uas'"
34 "}}");
35 g_assert(response);
36 g_assert(!qdict_haskey(response, "error"));
37 QDECREF(response);
39 response = qmp("{'execute': 'device_add',"
40 " 'arguments': {"
41 " 'driver': 'scsi-hd',"
42 " 'drive': 'drive0',"
43 " 'id': 'scsi-hd'"
44 "}}");
45 g_assert(response);
46 g_assert(!qdict_haskey(response, "error"));
47 QDECREF(response);
49 /* TODO:
50 UAS HBA driver in libqos, to check that
51 added disk is visible after BUS rescan
54 response = qmp("{'execute': 'device_del',"
55 " 'arguments': {"
56 " 'id': 'scsi-hd'"
57 "}}");
58 g_assert(response);
59 g_assert(!qdict_haskey(response, "error"));
60 QDECREF(response);
62 response = qmp("");
63 g_assert(qdict_haskey(response, "event"));
64 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
65 QDECREF(response);
68 response = qmp("{'execute': 'device_del',"
69 " 'arguments': {"
70 " 'id': 'uas'"
71 "}}");
72 g_assert(response);
73 g_assert(!qdict_haskey(response, "error"));
74 QDECREF(response);
76 response = qmp("");
77 g_assert(response);
78 g_assert(qdict_haskey(response, "event"));
79 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
80 QDECREF(response);
83 int main(int argc, char **argv)
85 int ret;
87 g_test_init(&argc, &argv, NULL);
89 qtest_add_func("/xhci/pci/init", test_xhci_init);
90 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
91 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
93 qtest_start("-device nec-usb-xhci,id=xhci"
94 " -drive id=drive0,if=none,file=/dev/null,format=raw");
95 ret = g_test_run();
96 qtest_end();
98 return ret;