]>
Commit | Line | Data |
---|---|---|
25e89ec5 GA |
1 | /* |
2 | * QTest testcase for USB xHCI controller | |
3 | * | |
fe75270c | 4 | * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD. |
25e89ec5 GA |
5 | * |
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 | */ | |
9 | ||
e532b2e0 | 10 | #include "qemu/osdep.h" |
25e89ec5 | 11 | #include "libqtest.h" |
b3937683 | 12 | #include "libqos/usb.h" |
25e89ec5 GA |
13 | |
14 | ||
15 | static void test_xhci_init(void) | |
16 | { | |
25e89ec5 GA |
17 | } |
18 | ||
b3937683 IM |
19 | static void test_xhci_hotplug(void) |
20 | { | |
e5758de4 | 21 | usb_test_hotplug(global_qtest, "xhci", "1", NULL); |
b3937683 | 22 | } |
25e89ec5 | 23 | |
49cec385 IM |
24 | static void test_usb_uas_hotplug(void) |
25 | { | |
e5758de4 TH |
26 | QTestState *qts = global_qtest; |
27 | ||
28 | qtest_qmp_device_add(qts, "usb-uas", "uas", "{}"); | |
29 | qtest_qmp_device_add(qts, "scsi-hd", "scsihd", "{'drive': 'drive0'}"); | |
49cec385 IM |
30 | |
31 | /* TODO: | |
32 | UAS HBA driver in libqos, to check that | |
33 | added disk is visible after BUS rescan | |
34 | */ | |
35 | ||
e5758de4 TH |
36 | qtest_qmp_device_del(qts, "scsihd"); |
37 | qtest_qmp_device_del(qts, "uas"); | |
49cec385 IM |
38 | } |
39 | ||
1a3ff20e MAL |
40 | static void test_usb_ccid_hotplug(void) |
41 | { | |
e5758de4 TH |
42 | QTestState *qts = global_qtest; |
43 | ||
44 | qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}"); | |
45 | qtest_qmp_device_del(qts, "ccid"); | |
1a3ff20e | 46 | /* check the device can be added again */ |
e5758de4 TH |
47 | qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}"); |
48 | qtest_qmp_device_del(qts, "ccid"); | |
1a3ff20e MAL |
49 | } |
50 | ||
25e89ec5 GA |
51 | int main(int argc, char **argv) |
52 | { | |
53 | int ret; | |
54 | ||
55 | g_test_init(&argc, &argv, NULL); | |
56 | ||
57 | qtest_add_func("/xhci/pci/init", test_xhci_init); | |
b3937683 | 58 | qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug); |
49cec385 | 59 | qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug); |
1a3ff20e | 60 | qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug); |
25e89ec5 | 61 | |
49cec385 | 62 | qtest_start("-device nec-usb-xhci,id=xhci" |
ca1ef1e6 AS |
63 | " -drive id=drive0,if=none,file=null-co://," |
64 | "file.read-zeroes=on,format=raw"); | |
25e89ec5 | 65 | ret = g_test_run(); |
b3937683 | 66 | qtest_end(); |
25e89ec5 GA |
67 | |
68 | return ret; | |
69 | } |