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 { 2182cab70bSMarkus Armbruster usb_test_hotplug("xhci", "1", NULL); 22b3937683SIgor Mammedov } 2325e89ec5SGonglei 2449cec385SIgor Mammedov static void test_usb_uas_hotplug(void) 2549cec385SIgor Mammedov { 2682cab70bSMarkus Armbruster qtest_qmp_device_add("usb-uas", "uas", "{}"); 2782cab70bSMarkus Armbruster 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 34acd80015SThomas Huth qtest_qmp_device_del("scsihd"); 35acd80015SThomas Huth qtest_qmp_device_del("uas"); 3649cec385SIgor Mammedov } 3749cec385SIgor Mammedov 381a3ff20eSMarc-André Lureau static void test_usb_ccid_hotplug(void) 391a3ff20eSMarc-André Lureau { 4082cab70bSMarkus Armbruster qtest_qmp_device_add("usb-ccid", "ccid", "{}"); 411a3ff20eSMarc-André Lureau qtest_qmp_device_del("ccid"); 421a3ff20eSMarc-André Lureau /* check the device can be added again */ 4382cab70bSMarkus Armbruster qtest_qmp_device_add("usb-ccid", "ccid", "{}"); 441a3ff20eSMarc-André Lureau qtest_qmp_device_del("ccid"); 451a3ff20eSMarc-André Lureau } 461a3ff20eSMarc-André Lureau 4725e89ec5SGonglei int main(int argc, char **argv) 4825e89ec5SGonglei { 4925e89ec5SGonglei int ret; 5025e89ec5SGonglei 5125e89ec5SGonglei g_test_init(&argc, &argv, NULL); 5225e89ec5SGonglei 5325e89ec5SGonglei qtest_add_func("/xhci/pci/init", test_xhci_init); 54b3937683SIgor Mammedov qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug); 5549cec385SIgor Mammedov qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug); 561a3ff20eSMarc-André Lureau qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug); 5725e89ec5SGonglei 5849cec385SIgor Mammedov qtest_start("-device nec-usb-xhci,id=xhci" 59*ca1ef1e6SAndrey Shinkevich " -drive id=drive0,if=none,file=null-co://," 60*ca1ef1e6SAndrey Shinkevich "file.read-zeroes=on,format=raw"); 6125e89ec5SGonglei ret = g_test_run(); 62b3937683SIgor Mammedov qtest_end(); 6325e89ec5SGonglei 6425e89ec5SGonglei return ret; 6525e89ec5SGonglei } 66