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.
13 #include "qemu/osdep.h"
14 #include "libqos/usb.h"
17 static void test_xhci_init(void)
21 static void test_xhci_hotplug(void)
23 usb_test_hotplug("xhci", 1, NULL
);
26 static void test_usb_uas_hotplug(void)
30 response
= qmp("{'execute': 'device_add',"
32 " 'driver': 'usb-uas',"
36 g_assert(!qdict_haskey(response
, "error"));
39 response
= qmp("{'execute': 'device_add',"
41 " 'driver': 'scsi-hd',"
46 g_assert(!qdict_haskey(response
, "error"));
50 UAS HBA driver in libqos, to check that
51 added disk is visible after BUS rescan
54 response
= qmp("{'execute': 'device_del',"
59 g_assert(!qdict_haskey(response
, "error"));
63 g_assert(qdict_haskey(response
, "event"));
64 g_assert(!strcmp(qdict_get_str(response
, "event"), "DEVICE_DELETED"));
68 response
= qmp("{'execute': 'device_del',"
73 g_assert(!qdict_haskey(response
, "error"));
78 g_assert(qdict_haskey(response
, "event"));
79 g_assert(!strcmp(qdict_get_str(response
, "event"), "DEVICE_DELETED"));
83 int main(int argc
, char **argv
)
87 g_test_init(&argc
, &argv
, NULL
);
89 qtest_add_func("/xhci/pci/init", test_xhci_init
);
90 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug
);
91 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug
);
93 qtest_start("-device nec-usb-xhci,id=xhci"
94 " -drive id=drive0,if=none,file=/dev/null");