1
2
3
4
5
6
7
8
9
10#include "qemu/osdep.h"
11#include "libqtest-single.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(global_qtest, "xhci", "1", NULL);
22}
23
24static void test_usb_uas_hotplug(void)
25{
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'}");
30
31
32
33
34
35
36 qtest_qmp_device_del(qts, "scsihd");
37 qtest_qmp_device_del(qts, "uas");
38}
39
40static void test_usb_ccid_hotplug(void)
41{
42 QTestState *qts = global_qtest;
43
44 qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}");
45 qtest_qmp_device_del(qts, "ccid");
46
47 qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}");
48 qtest_qmp_device_del(qts, "ccid");
49}
50
51int 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);
58 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
59 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
60 qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug);
61
62 qtest_start("-device nec-usb-xhci,id=xhci"
63 " -drive id=drive0,if=none,file=null-co://,"
64 "file.read-zeroes=on,format=raw");
65 ret = g_test_run();
66 qtest_end();
67
68 return ret;
69}
70