xref: /qemu/tests/qtest/usb-hcd-xhci-test.c (revision acd80015fbe28f4f513e036ad1db2a76738d1f53)
125e89ec5SGonglei /*
225e89ec5SGonglei  * QTest testcase for USB xHCI controller
325e89ec5SGonglei  *
425e89ec5SGonglei  * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
525e89ec5SGonglei  *
625e89ec5SGonglei  * This work is licensed under the terms of the GNU GPL, version 2 or later.
725e89ec5SGonglei  * See the COPYING file in the top-level directory.
825e89ec5SGonglei  */
925e89ec5SGonglei 
1025e89ec5SGonglei #include "qemu/osdep.h"
11e532b2e0SPeter Maydell #include "libqtest.h"
12b3937683SIgor Mammedov #include "libqos/usb.h"
1325e89ec5SGonglei 
1425e89ec5SGonglei 
1525e89ec5SGonglei static void test_xhci_init(void)
1625e89ec5SGonglei {
1725e89ec5SGonglei }
1825e89ec5SGonglei 
19b3937683SIgor Mammedov static void test_xhci_hotplug(void)
20b3937683SIgor Mammedov {
21b3937683SIgor Mammedov     usb_test_hotplug("xhci", 1, NULL);
22b3937683SIgor Mammedov }
2325e89ec5SGonglei 
2449cec385SIgor Mammedov static void test_usb_uas_hotplug(void)
2549cec385SIgor Mammedov {
26*acd80015SThomas Huth     qtest_qmp_device_add("usb-uas", "uas", NULL);
27*acd80015SThomas Huth     qtest_qmp_device_add("scsi-hd", "scsihd", "'drive': 'drive0'");
2849cec385SIgor Mammedov 
2949cec385SIgor Mammedov     /* TODO:
3049cec385SIgor Mammedov         UAS HBA driver in libqos, to check that
3149cec385SIgor Mammedov         added disk is visible after BUS rescan
3249cec385SIgor Mammedov     */
3349cec385SIgor Mammedov 
34*acd80015SThomas Huth     qtest_qmp_device_del("scsihd");
35*acd80015SThomas Huth     qtest_qmp_device_del("uas");
3649cec385SIgor Mammedov }
3749cec385SIgor Mammedov 
3825e89ec5SGonglei int main(int argc, char **argv)
3925e89ec5SGonglei {
4025e89ec5SGonglei     int ret;
4125e89ec5SGonglei 
4225e89ec5SGonglei     g_test_init(&argc, &argv, NULL);
4325e89ec5SGonglei 
4425e89ec5SGonglei     qtest_add_func("/xhci/pci/init", test_xhci_init);
45b3937683SIgor Mammedov     qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
4649cec385SIgor Mammedov     qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
4725e89ec5SGonglei 
4849cec385SIgor Mammedov     qtest_start("-device nec-usb-xhci,id=xhci"
492420d369SFam Zheng                 " -drive id=drive0,if=none,file=null-co://,format=raw");
5025e89ec5SGonglei     ret = g_test_run();
51b3937683SIgor Mammedov     qtest_end();
5225e89ec5SGonglei 
5325e89ec5SGonglei     return ret;
5425e89ec5SGonglei }
55