usb-hcd-xhci-test.c 1.2 KB
Newer Older
G
Gonglei 已提交
1 2 3
/*
 * QTest testcase for USB xHCI controller
 *
4
 * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
G
Gonglei 已提交
5 6 7 8 9
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

P
Peter Maydell 已提交
10
#include "qemu/osdep.h"
G
Gonglei 已提交
11
#include "libqtest.h"
12
#include "libqos/usb.h"
G
Gonglei 已提交
13 14 15 16 17 18


static void test_xhci_init(void)
{
}

19 20 21 22
static void test_xhci_hotplug(void)
{
    usb_test_hotplug("xhci", 1, NULL);
}
G
Gonglei 已提交
23

I
Igor Mammedov 已提交
24 25
static void test_usb_uas_hotplug(void)
{
26 27
    qtest_qmp_device_add("usb-uas", "uas", NULL);
    qtest_qmp_device_add("scsi-hd", "scsihd", "'drive': 'drive0'");
I
Igor Mammedov 已提交
28 29 30 31 32 33

    /* TODO:
        UAS HBA driver in libqos, to check that
        added disk is visible after BUS rescan
    */

34 35
    qtest_qmp_device_del("scsihd");
    qtest_qmp_device_del("uas");
I
Igor Mammedov 已提交
36 37
}

G
Gonglei 已提交
38 39 40 41 42 43 44
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);

    qtest_add_func("/xhci/pci/init", test_xhci_init);
45
    qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
I
Igor Mammedov 已提交
46
    qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
G
Gonglei 已提交
47

I
Igor Mammedov 已提交
48
    qtest_start("-device nec-usb-xhci,id=xhci"
49
                " -drive id=drive0,if=none,file=null-co://,format=raw");
G
Gonglei 已提交
50
    ret = g_test_run();
51
    qtest_end();
G
Gonglei 已提交
52 53 54

    return ret;
}