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.
10 #include "qemu/osdep.h"
12 #include "libqos/usb.h"
15 static void test_xhci_init(void)
19 static void test_xhci_hotplug(void)
21 usb_test_hotplug("xhci", "1", NULL
);
24 static void test_usb_uas_hotplug(void)
26 qtest_qmp_device_add("usb-uas", "uas", "{}");
27 qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drive0'}");
30 UAS HBA driver in libqos, to check that
31 added disk is visible after BUS rescan
34 qtest_qmp_device_del("scsihd");
35 qtest_qmp_device_del("uas");
38 static void test_usb_ccid_hotplug(void)
40 qtest_qmp_device_add("usb-ccid", "ccid", "{}");
41 qtest_qmp_device_del("ccid");
42 /* check the device can be added again */
43 qtest_qmp_device_add("usb-ccid", "ccid", "{}");
44 qtest_qmp_device_del("ccid");
47 int main(int argc
, char **argv
)
51 g_test_init(&argc
, &argv
, NULL
);
53 qtest_add_func("/xhci/pci/init", test_xhci_init
);
54 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug
);
55 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug
);
56 qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug
);
58 qtest_start("-device nec-usb-xhci,id=xhci"
59 " -drive id=drive0,if=none,file=null-co://,format=raw");