1
2
3
4
5
6
7
8
9
10#include "qemu/osdep.h"
11#include "libqtest.h"
12#include "libqos/usb.h"
13
14
15static void test_xhci_init(void)
16{
17}
18
19static void test_xhci_hotplug(void)
20{
21 usb_test_hotplug("xhci", 1, NULL);
22}
23
24static void test_usb_uas_hotplug(void)
25{
26 qtest_qmp_device_add("usb-uas", "uas", NULL);
27 qtest_qmp_device_add("scsi-hd", "scsihd", "'drive': 'drive0'");
28
29
30
31
32
33
34 qtest_qmp_device_del("scsihd");
35 qtest_qmp_device_del("uas");
36}
37
38static void test_usb_ccid_hotplug(void)
39{
40 qtest_qmp_device_add("usb-ccid", "ccid", NULL);
41 qtest_qmp_device_del("ccid");
42
43 qtest_qmp_device_add("usb-ccid", "ccid", NULL);
44 qtest_qmp_device_del("ccid");
45}
46
47int 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);
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);
57
58 qtest_start("-device nec-usb-xhci,id=xhci"
59 " -drive id=drive0,if=none,file=null-co://,format=raw");
60 ret = g_test_run();
61 qtest_end();
62
63 return ret;
64}
65