]> Git Repo - qemu.git/blame - tests/usb-hcd-xhci-test.c
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-next-2016-02-02...
[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 <glib.h>
25e89ec5 12#include "libqtest.h"
b3937683 13#include "libqos/usb.h"
25e89ec5
GA
14
15
16static void test_xhci_init(void)
17{
25e89ec5
GA
18}
19
b3937683
IM
20static void test_xhci_hotplug(void)
21{
22 usb_test_hotplug("xhci", 1, NULL);
23}
25e89ec5 24
49cec385
IM
25static void test_usb_uas_hotplug(void)
26{
27 QDict *response;
28
29 response = qmp("{'execute': 'device_add',"
30 " 'arguments': {"
31 " 'driver': 'usb-uas',"
32 " 'id': 'uas'"
33 "}}");
34 g_assert(response);
35 g_assert(!qdict_haskey(response, "error"));
36 QDECREF(response);
37
38 response = qmp("{'execute': 'device_add',"
39 " 'arguments': {"
40 " 'driver': 'scsi-hd',"
41 " 'drive': 'drive0',"
42 " 'id': 'scsi-hd'"
43 "}}");
44 g_assert(response);
45 g_assert(!qdict_haskey(response, "error"));
46 QDECREF(response);
47
48 /* TODO:
49 UAS HBA driver in libqos, to check that
50 added disk is visible after BUS rescan
51 */
52
53 response = qmp("{'execute': 'device_del',"
54 " 'arguments': {"
55 " 'id': 'scsi-hd'"
56 "}}");
57 g_assert(response);
58 g_assert(!qdict_haskey(response, "error"));
59 QDECREF(response);
60
61 response = qmp("");
62 g_assert(qdict_haskey(response, "event"));
63 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
64 QDECREF(response);
65
66
67 response = qmp("{'execute': 'device_del',"
68 " 'arguments': {"
69 " 'id': 'uas'"
70 "}}");
71 g_assert(response);
72 g_assert(!qdict_haskey(response, "error"));
73 QDECREF(response);
74
75 response = qmp("");
76 g_assert(response);
77 g_assert(qdict_haskey(response, "event"));
78 g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
79 QDECREF(response);
80}
81
25e89ec5
GA
82int main(int argc, char **argv)
83{
84 int ret;
85
86 g_test_init(&argc, &argv, NULL);
87
88 qtest_add_func("/xhci/pci/init", test_xhci_init);
b3937683 89 qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
49cec385 90 qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
25e89ec5 91
49cec385 92 qtest_start("-device nec-usb-xhci,id=xhci"
b8e665e4 93 " -drive id=drive0,if=none,file=/dev/null,format=raw");
25e89ec5 94 ret = g_test_run();
b3937683 95 qtest_end();
25e89ec5
GA
96
97 return ret;
98}
This page took 0.124064 seconds and 4 git commands to generate.