qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

usb-hcd-xhci-test.c (1741B)


      1 /*
      2  * QTest testcase for USB xHCI controller
      3  *
      4  * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
      5  *
      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.
      8  */
      9 
     10 #include "qemu/osdep.h"
     11 #include "libqtest-single.h"
     12 #include "libqos/usb.h"
     13 
     14 
     15 static void test_xhci_init(void)
     16 {
     17 }
     18 
     19 static void test_xhci_hotplug(void)
     20 {
     21     usb_test_hotplug(global_qtest, "xhci", "1", NULL);
     22 }
     23 
     24 static 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     /* TODO:
     32         UAS HBA driver in libqos, to check that
     33         added disk is visible after BUS rescan
     34     */
     35 
     36     qtest_qmp_device_del(qts, "scsihd");
     37     qtest_qmp_device_del(qts, "uas");
     38 }
     39 
     40 static 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     /* check the device can be added again */
     47     qtest_qmp_device_add(qts, "usb-ccid", "ccid", "{}");
     48     qtest_qmp_device_del(qts, "ccid");
     49 }
     50 
     51 int 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 }