qom: Make all the object_property_add_FOO() return the property
[qemu.git] / tests / qtest / usb-hcd-xhci-test.c
blob10ef9d2a91ad8bfab48d26a68c6ab2ad5a4cbefc
1 /*
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.
8 */
10 #include "qemu/osdep.h"
11 #include "libqtest-single.h"
12 #include "libqos/usb.h"
15 static void test_xhci_init(void)
19 static void test_xhci_hotplug(void)
21 usb_test_hotplug(global_qtest, "xhci", "1", NULL);
24 static void test_usb_uas_hotplug(void)
26 QTestState *qts = global_qtest;
28 qtest_qmp_device_add(qts, "usb-uas", "uas", "{}");
29 qtest_qmp_device_add(qts, "scsi-hd", "scsihd", "{'drive': 'drive0'}");
31 /* TODO:
32 UAS HBA driver in libqos, to check that
33 added disk is visible after BUS rescan
36 qtest_qmp_device_del(qts, "scsihd");
37 qtest_qmp_device_del(qts, "uas");
40 static void test_usb_ccid_hotplug(void)
42 QTestState *qts = global_qtest;
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");
51 int main(int argc, char **argv)
53 int ret;
55 g_test_init(&argc, &argv, NULL);
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);
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();
68 return ret;