]> git.proxmox.com Git - mirror_qemu.git/blame - tests/usb-hcd-xhci-test.c
pseries: Enforce homogeneous threads-per-core
[mirror_qemu.git] / tests / usb-hcd-xhci-test.c
CommitLineData
25e89ec5
GA
1/*
2 * QTest testcase for USB xHCI controller
3 *
fe75270c 4 * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
25e89ec5
GA
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
e532b2e0 10#include "qemu/osdep.h"
25e89ec5 11#include "libqtest.h"
b3937683 12#include "libqos/usb.h"
25e89ec5
GA
13
14
15static void test_xhci_init(void)
16{
25e89ec5
GA
17}
18
b3937683
IM
19static void test_xhci_hotplug(void)
20{
21 usb_test_hotplug("xhci", 1, NULL);
22}
25e89ec5 23
49cec385
IM
24static void test_usb_uas_hotplug(void)
25{
26 QDict *response;
27
28 response = qmp("{'execute': 'device_add',"
29 " 'arguments': {"
30 " 'driver': 'usb-uas',"
31 " 'id': 'uas'"
32 "}}");
33 g_assert(response);
34 g_assert(!qdict_haskey(response, "error"));
35 QDECREF(response);
36
37 response = qmp("{'execute': 'device_add',"
38 " 'arguments': {"
39 " 'driver': 'scsi-hd',"
40 " 'drive': 'drive0',"
41 " 'id': 'scsi-hd'"
42 "}}");
43 g_assert(response);
44 g_assert(!qdict_haskey(response, "error"));
45 QDECREF(response);
46
47 /* TODO:
48 UAS HBA driver in libqos, to check that
49 added disk is visible after BUS rescan
50 */
51
52 response = qmp("{'execute': 'device_del',"
53 " 'arguments': {"
54 " 'id': 'scsi-hd'"
55 "}}");
56 g_assert(response);
57 g_assert(!qdict_haskey(response, "error"));
58 QDECREF(response);
59
60 response = qmp("");
61 g_assert(qdict_haskey(response, "event"));
62 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
63 QDECREF(response);
64
65
66 response = qmp("{'execute': 'device_del',"
67 " 'arguments': {"
68 " 'id': 'uas'"
69 "}}");
70 g_assert(response);
71 g_assert(!qdict_haskey(response, "error"));
72 QDECREF(response);
73
74 response = qmp("");
75 g_assert(response);
76 g_assert(qdict_haskey(response, "event"));
77 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
78 QDECREF(response);
79}
80
25e89ec5
GA
81int main(int argc, char **argv)
82{
83 int ret;
84
85 g_test_init(&argc, &argv, NULL);
86
87 qtest_add_func("/xhci/pci/init", test_xhci_init);
b3937683 88 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
49cec385 89 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
25e89ec5 90
49cec385 91 qtest_start("-device nec-usb-xhci,id=xhci"
b8e665e4 92 " -drive id=drive0,if=none,file=/dev/null,format=raw");
25e89ec5 93 ret = g_test_run();
b3937683 94 qtest_end();
25e89ec5
GA
95
96 return ret;
97}