]>
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 | { | |
82cab70b | 21 | usb_test_hotplug("xhci", "1", NULL); |
b3937683 | 22 | } |
25e89ec5 | 23 | |
49cec385 IM |
24 | static void test_usb_uas_hotplug(void) |
25 | { | |
82cab70b MA |
26 | qtest_qmp_device_add("usb-uas", "uas", "{}"); |
27 | qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drive0'}"); | |
49cec385 IM |
28 | |
29 | /* TODO: | |
30 | UAS HBA driver in libqos, to check that | |
31 | added disk is visible after BUS rescan | |
32 | */ | |
33 | ||
acd80015 TH |
34 | qtest_qmp_device_del("scsihd"); |
35 | qtest_qmp_device_del("uas"); | |
49cec385 IM |
36 | } |
37 | ||
1a3ff20e MAL |
38 | static void test_usb_ccid_hotplug(void) |
39 | { | |
82cab70b | 40 | qtest_qmp_device_add("usb-ccid", "ccid", "{}"); |
1a3ff20e MAL |
41 | qtest_qmp_device_del("ccid"); |
42 | /* check the device can be added again */ | |
82cab70b | 43 | qtest_qmp_device_add("usb-ccid", "ccid", "{}"); |
1a3ff20e MAL |
44 | qtest_qmp_device_del("ccid"); |
45 | } | |
46 | ||
25e89ec5 GA |
47 | int main(int argc, char **argv) |
48 | { | |
49 | int ret; | |
50 | ||
51 | g_test_init(&argc, &argv, NULL); | |
52 | ||
53 | qtest_add_func("/xhci/pci/init", test_xhci_init); | |
b3937683 | 54 | qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug); |
49cec385 | 55 | qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug); |
1a3ff20e | 56 | qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug); |
25e89ec5 | 57 | |
49cec385 | 58 | qtest_start("-device nec-usb-xhci,id=xhci" |
2420d369 | 59 | " -drive id=drive0,if=none,file=null-co://,format=raw"); |
25e89ec5 | 60 | ret = g_test_run(); |
b3937683 | 61 | qtest_end(); |
25e89ec5 GA |
62 | |
63 | return ret; | |
64 | } |