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"
13 #include "libqos/usb.h"
16 static void test_xhci_init(void)
20 static void test_xhci_hotplug(void)
22 usb_test_hotplug("xhci", 1, NULL
);
25 static void test_usb_uas_hotplug(void)
29 response
= qmp("{'execute': 'device_add',"
31 " 'driver': 'usb-uas',"
35 g_assert(!qdict_haskey(response
, "error"));
38 response
= qmp("{'execute': 'device_add',"
40 " 'driver': 'scsi-hd',"
45 g_assert(!qdict_haskey(response
, "error"));
49 UAS HBA driver in libqos, to check that
50 added disk is visible after BUS rescan
53 response
= qmp("{'execute': 'device_del',"
58 g_assert(!qdict_haskey(response
, "error"));
62 g_assert(qdict_haskey(response
, "event"));
63 g_assert(!strcmp(qdict_get_str(response
, "event"), "DEVICE_DELETED"));
67 response
= qmp("{'execute': 'device_del',"
72 g_assert(!qdict_haskey(response
, "error"));
77 g_assert(qdict_haskey(response
, "event"));
78 g_assert(!strcmp(qdict_get_str(response
, "event"), "DEVICE_DELETED"));
82 int main(int argc
, char **argv
)
86 g_test_init(&argc
, &argv
, NULL
);
88 qtest_add_func("/xhci/pci/init", test_xhci_init
);
89 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug
);
90 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug
);
92 qtest_start("-device nec-usb-xhci,id=xhci"
93 " -drive id=drive0,if=none,file=/dev/null,format=raw");