qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases
@ 2014-06-23 11:53 arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 1/4] tests: add OHCI qtest arei.gonglei
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: arei.gonglei @ 2014-06-23 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, luonengjun, peter.huangpeng, Gonglei, kraxel,
	stefanha, akong, afaerber

From: Gonglei <arei.gonglei@huawei.com>

This patch series base on my request usb host adapter hotplug/unplug
series:

[PATCH v3 00/10] usb: usb host adapter hotplug
http://lists.gnu.org/archive/html/qemu-devel/2014-06/msg00746.html

Changes since v3:
 - rebase on latest qemu master

Changes since v2:
  - add 'const' qualifier argument in usb_hcd_hotplug
    function for building errors reported by Gerd

Changes since v1:
 * By Andreas suggestion:
  - rework hci-{ohci,uhci,xhci} files for functional tests
  - add "cold-plug" test, "-device" in init funciton
  - use QMP for device_add/del because of parsing security
  - some other fixs

 * By Gerd suggestion:
  - add an usb-hcd-hotplug-test.c file and collect hotplug
    testing for all usb hcds

Thanks for your suggestion, please review again.

My "make check V=1" results:

 [...]
TEST: tests/usb-hcd-ohci-test... (pid=20031)
  /x86_64/ohci/pci/init:                                               OK
PASS: tests/usb-hcd-ohci-test
TEST: tests/usb-hcd-uhci-test... (pid=20034)
  /x86_64/uhci/pci/init:                                               OK
PASS: tests/usb-hcd-uhci-test
TEST: tests/usb-hcd-ehci-test... (pid=20037)
  /x86_64/ehci/pci/init:                                               OK
  /x86_64/ehci/pci/uhci-port-1:                                        OK
  /x86_64/ehci/pci/ehci-port-1:                                        OK
  /x86_64/ehci/pci/ehci-config:                                        OK
  /x86_64/ehci/pci/uhci-port-2:                                        OK
  /x86_64/ehci/pci/ehci-port-2:                                        OK
PASS: tests/usb-hcd-ehci-test
TEST: tests/usb-hcd-xhci-test... (pid=20040)
  /x86_64/xhci/pci/init:                                               OK
PASS: tests/usb-hcd-xhci-test
TEST: tests/usb-hcd-hotplug-test... (pid=20043)
  /x86_64/usb/hcd/pci/ohci-hotplug:                                    OK
  /x86_64/usb/hcd/pci/uhci-hotplug:                                    OK
  /x86_64/usb/hcd/pci/ehci-hotplug:                                    OK
  /x86_64/usb/hcd/pci/xhci-hotplug:                                    OK
PASS: tests/usb-hcd-hotplug-test
TEST: tests/qom-test... (pid=20068)
  /x86_64/qom/pc-i440fx-1.4:                                           OK
  /x86_64/qom/pc-1.3:                                                  OK
  /x86_64/qom/pc-0.11:                                                 OK
 [...]

Best regards,
-Gonglei

Gonglei (4):
  tests: add OHCI qtest
  tests: add UHCI qtest
  tests: add xHCI qtest
  tests: add usb hcds hotplugging qtest

 MAINTAINERS                  |  2 +-
 tests/Makefile               | 12 +++++-
 tests/usb-hcd-hotplug-test.c | 88 ++++++++++++++++++++++++++++++++++++++++++++
 tests/usb-hcd-ohci-test.c    | 35 ++++++++++++++++++
 tests/usb-hcd-uhci-test.c    | 35 ++++++++++++++++++
 tests/usb-hcd-xhci-test.c    | 35 ++++++++++++++++++
 6 files changed, 205 insertions(+), 2 deletions(-)
 create mode 100644 tests/usb-hcd-hotplug-test.c
 create mode 100644 tests/usb-hcd-ohci-test.c
 create mode 100644 tests/usb-hcd-uhci-test.c
 create mode 100644 tests/usb-hcd-xhci-test.c

-- 
1.7.12.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v4 1/4] tests: add OHCI qtest
  2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
@ 2014-06-23 11:53 ` arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 2/4] tests: add UHCI qtest arei.gonglei
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: arei.gonglei @ 2014-06-23 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, luonengjun, peter.huangpeng, Gonglei, kraxel,
	stefanha, akong, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 MAINTAINERS               |  2 +-
 tests/Makefile            |  3 +++
 tests/usb-hcd-ohci-test.c | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 tests/usb-hcd-ohci-test.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9b93edd..04fb69f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -613,7 +613,7 @@ USB
 M: Gerd Hoffmann <kraxel@redhat.com>
 S: Maintained
 F: hw/usb/*
-F: tests/usb-hcd-ehci-test.c
+F: tests/usb-*-test.c
 
 VFIO
 M: Alex Williamson <alex.williamson@redhat.com>
diff --git a/tests/Makefile b/tests/Makefile
index 4caf7de..7644e61 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -151,6 +151,8 @@ check-qtest-i386-y += tests/i82801b11-test$(EXESUF)
 gcov-files-i386-y += hw/pci-bridge/i82801b11.c
 check-qtest-i386-y += tests/ioh3420-test$(EXESUF)
 gcov-files-i386-y += hw/pci-bridge/ioh3420.c
+check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF)
+gcov-files-i386-y += hw/usb/hcd-ohci.c
 check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/hcd-uhci.c
@@ -322,6 +324,7 @@ tests/ac97-test$(EXESUF): tests/ac97-test.o
 tests/es1370-test$(EXESUF): tests/es1370-test.o
 tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o
 tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o
+tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c
new file mode 100644
index 0000000..fbc3ffe
--- /dev/null
+++ b/tests/usb-hcd-ohci-test.c
@@ -0,0 +1,35 @@
+/*
+ * QTest testcase for USB OHCI controller
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include "libqtest.h"
+#include "qemu/osdep.h"
+
+
+static void test_ohci_init(void)
+{
+    qtest_start("-device pci-ohci,id=ohci");
+
+    qtest_end();
+}
+
+
+int main(int argc, char **argv)
+{
+    int ret;
+
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("/ohci/pci/init", test_ohci_init);
+
+    ret = g_test_run();
+
+    return ret;
+}
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v4 2/4] tests: add UHCI qtest
  2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 1/4] tests: add OHCI qtest arei.gonglei
@ 2014-06-23 11:53 ` arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 3/4] tests: add xHCI qtest arei.gonglei
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: arei.gonglei @ 2014-06-23 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, luonengjun, peter.huangpeng, Gonglei, kraxel,
	stefanha, akong, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 tests/Makefile            |  4 +++-
 tests/usb-hcd-uhci-test.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 tests/usb-hcd-uhci-test.c

diff --git a/tests/Makefile b/tests/Makefile
index 7644e61..ac16ae5 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -153,9 +153,10 @@ check-qtest-i386-y += tests/ioh3420-test$(EXESUF)
 gcov-files-i386-y += hw/pci-bridge/ioh3420.c
 check-qtest-i386-y += tests/usb-hcd-ohci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ohci.c
+check-qtest-i386-y += tests/usb-hcd-uhci-test$(EXESUF)
+gcov-files-i386-y += hw/usb/hcd-uhci.c
 check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
-gcov-files-i386-y += hw/usb/hcd-uhci.c
 gcov-files-i386-y += hw/usb/dev-hid.c
 gcov-files-i386-y += hw/usb/dev-storage.c
 #check-qtest-i386-y += tests/vhost-user-test$(EXESUF)
@@ -325,6 +326,7 @@ tests/es1370-test$(EXESUF): tests/es1370-test.o
 tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o
 tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o
 tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o
+tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
new file mode 100644
index 0000000..94e858f
--- /dev/null
+++ b/tests/usb-hcd-uhci-test.c
@@ -0,0 +1,35 @@
+/*
+ * QTest testcase for USB UHCI controller
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include "libqtest.h"
+#include "qemu/osdep.h"
+
+
+static void test_uhci_init(void)
+{
+    qtest_start("-device piix3-usb-uhci,id=uhci");
+
+    qtest_end();
+}
+
+
+int main(int argc, char **argv)
+{
+    int ret;
+
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("/uhci/pci/init", test_uhci_init);
+
+    ret = g_test_run();
+
+    return ret;
+}
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v4 3/4] tests: add xHCI qtest
  2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 1/4] tests: add OHCI qtest arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 2/4] tests: add UHCI qtest arei.gonglei
@ 2014-06-23 11:53 ` arei.gonglei
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest arei.gonglei
  2014-06-25 15:29 ` [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases Amos Kong
  4 siblings, 0 replies; 8+ messages in thread
From: arei.gonglei @ 2014-06-23 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, luonengjun, peter.huangpeng, Gonglei, kraxel,
	stefanha, akong, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 tests/Makefile            |  3 +++
 tests/usb-hcd-xhci-test.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 tests/usb-hcd-xhci-test.c

diff --git a/tests/Makefile b/tests/Makefile
index ac16ae5..6a78ade 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -159,6 +159,8 @@ check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/dev-hid.c
 gcov-files-i386-y += hw/usb/dev-storage.c
+check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
+gcov-files-i386-y += hw/usb/hcd-xhci.c
 #check-qtest-i386-y += tests/vhost-user-test$(EXESUF)
 check-qtest-x86_64-y = $(check-qtest-i386-y)
 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
@@ -328,6 +330,7 @@ tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o
 tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o
 tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
+tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
 tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
new file mode 100644
index 0000000..743e979
--- /dev/null
+++ b/tests/usb-hcd-xhci-test.c
@@ -0,0 +1,35 @@
+/*
+ * QTest testcase for USB xHCI controller
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include "libqtest.h"
+#include "qemu/osdep.h"
+
+
+static void test_xhci_init(void)
+{
+    qtest_start("-device nec-usb-xhci,id=xhci");
+
+    qtest_end();
+}
+
+
+int main(int argc, char **argv)
+{
+    int ret;
+
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("/xhci/pci/init", test_xhci_init);
+
+    ret = g_test_run();
+
+    return ret;
+}
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest
  2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
                   ` (2 preceding siblings ...)
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 3/4] tests: add xHCI qtest arei.gonglei
@ 2014-06-23 11:53 ` arei.gonglei
  2014-06-25 14:42   ` Amos Kong
  2014-06-25 15:29 ` [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases Amos Kong
  4 siblings, 1 reply; 8+ messages in thread
From: arei.gonglei @ 2014-06-23 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, luonengjun, peter.huangpeng, Gonglei, kraxel,
	stefanha, akong, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Because of we now support usb hcds hotplugging, and
collect all hcds hotplugging tests into one file
for code sharing.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 tests/Makefile               |  2 +
 tests/usb-hcd-hotplug-test.c | 88 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 tests/usb-hcd-hotplug-test.c

diff --git a/tests/Makefile b/tests/Makefile
index 6a78ade..f0362f7 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -161,6 +161,7 @@ gcov-files-i386-y += hw/usb/dev-hid.c
 gcov-files-i386-y += hw/usb/dev-storage.c
 check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-xhci.c
+check-qtest-i386-y += tests/usb-hcd-hotplug-test$(EXESUF)
 #check-qtest-i386-y += tests/vhost-user-test$(EXESUF)
 check-qtest-x86_64-y = $(check-qtest-i386-y)
 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
@@ -331,6 +332,7 @@ tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o
 tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
 tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o
+tests/usb-hcd-hotplug-test$(EXESUF): tests/usb-hcd-hotplug-test.o
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
 tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
diff --git a/tests/usb-hcd-hotplug-test.c b/tests/usb-hcd-hotplug-test.c
new file mode 100644
index 0000000..04bea97
--- /dev/null
+++ b/tests/usb-hcd-hotplug-test.c
@@ -0,0 +1,88 @@
+/*
+ * QTest testcase for usb host adapters hotplug/unplug
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include "libqtest.h"
+#include "qemu/osdep.h"
+
+
+static void usb_hcd_hotplug(const char *hcd, const char *id)
+{
+    QDict *response;
+
+    qtest_start("");
+
+    /* hotplug an usb host adapter */
+    response = qmp("{\"execute\": \"device_add\","
+                   " \"arguments\": {"
+                   "   \"driver\": \"%s\","
+                   "   \"id\": \"%s\""
+                   "}}", hcd, id);
+    g_assert(response);
+    g_assert(!qdict_haskey(response, "error"));
+    QDECREF(response);
+
+    /* hotplug an usb-tablet to the usb host adapter, bus=$id.0 */
+    response = qmp("{\"execute\": \"device_add\","
+                       " \"arguments\": {"
+                       "   \"driver\": \"usb-tablet\","
+                       "   \"bus\": \"%s.0\""
+                       "}}", id);
+    g_assert(response);
+    g_assert(!qdict_haskey(response, "error"));
+    QDECREF(response);
+
+    /* delete the usb host adapter */
+    response = qmp("{\"execute\": \"device_del\","
+                   " \"arguments\": {"
+                   "   \"id\": \"%s\""
+                   "}}", id);
+    g_assert(response);
+    g_assert(!qdict_haskey(response, "error"));
+    QDECREF(response);
+
+    qtest_end();
+}
+
+static void test_ohci_hotplug(void)
+{
+    usb_hcd_hotplug("pci-ohci", "ohci");
+}
+
+static void test_uhci_hotplug(void)
+{
+    usb_hcd_hotplug("piix3-usb-uhci", "uhci");
+}
+
+static void test_ehci_hotplug(void)
+{
+    usb_hcd_hotplug("usb-ehci", "ehci");
+}
+
+static void test_xhci_hotplug(void)
+{
+    usb_hcd_hotplug("nec-usb-xhci", "xhci");
+}
+
+int main(int argc, char **argv)
+{
+    int ret;
+
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("/usb/hcd/pci/ohci-hotplug", test_ohci_hotplug);
+    qtest_add_func("/usb/hcd/pci/uhci-hotplug", test_uhci_hotplug);
+    qtest_add_func("/usb/hcd/pci/ehci-hotplug", test_ehci_hotplug);
+    qtest_add_func("/usb/hcd/pci/xhci-hotplug", test_xhci_hotplug);
+
+    ret = g_test_run();
+
+    return ret;
+}
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest arei.gonglei
@ 2014-06-25 14:42   ` Amos Kong
  2014-06-25 15:13     ` Gonglei (Arei)
  0 siblings, 1 reply; 8+ messages in thread
From: Amos Kong @ 2014-06-25 14:42 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, luonengjun, qemu-devel, peter.huangpeng, kraxel,
	stefanha, afaerber

On Mon, Jun 23, 2014 at 07:53:54PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Because of we now support usb hcds hotplugging, and
> collect all hcds hotplugging tests into one file
> for code sharing.
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  tests/Makefile               |  2 +
>  tests/usb-hcd-hotplug-test.c | 88 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
>  create mode 100644 tests/usb-hcd-hotplug-test.c
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index 6a78ade..f0362f7 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -161,6 +161,7 @@ gcov-files-i386-y += hw/usb/dev-hid.c
>  gcov-files-i386-y += hw/usb/dev-storage.c
>  check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
>  gcov-files-i386-y += hw/usb/hcd-xhci.c
> +check-qtest-i386-y += tests/usb-hcd-hotplug-test$(EXESUF)
>  #check-qtest-i386-y += tests/vhost-user-test$(EXESUF)
>  check-qtest-x86_64-y = $(check-qtest-i386-y)
>  gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
> @@ -331,6 +332,7 @@ tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o
>  tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o
>  tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
>  tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o
> +tests/usb-hcd-hotplug-test$(EXESUF): tests/usb-hcd-hotplug-test.o
>  tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a
>  tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
>  tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
> diff --git a/tests/usb-hcd-hotplug-test.c b/tests/usb-hcd-hotplug-test.c
> new file mode 100644
> index 0000000..04bea97
> --- /dev/null
> +++ b/tests/usb-hcd-hotplug-test.c
> @@ -0,0 +1,88 @@
> +/*
> + * QTest testcase for usb host adapters hotplug/unplug
> + *
> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#include <glib.h>
> +#include <string.h>
> +#include "libqtest.h"
> +#include "qemu/osdep.h"
> +
> +
> +static void usb_hcd_hotplug(const char *hcd, const char *id)
> +{
> +    QDict *response;
> +
> +    qtest_start("");
> +
> +    /* hotplug an usb host adapter */
> +    response = qmp("{\"execute\": \"device_add\","
> +                   " \"arguments\": {"
> +                   "   \"driver\": \"%s\","
> +                   "   \"id\": \"%s\""
> +                   "}}", hcd, id);
> +    g_assert(response);
> +    g_assert(!qdict_haskey(response, "error"));
> +    QDECREF(response);
> +
> +    /* hotplug an usb-tablet to the usb host adapter, bus=$id.0 */
> +    response = qmp("{\"execute\": \"device_add\","
> +                       " \"arguments\": {"
> +                       "   \"driver\": \"usb-tablet\","
> +                       "   \"bus\": \"%s.0\""
> +                       "}}", id);
> +    g_assert(response);
> +    g_assert(!qdict_haskey(response, "error"));
> +    QDECREF(response);

Do you need to unhot-plug usb-tablet first, before unhot-plug usb host
adapter?

> +    /* delete the usb host adapter */
> +    response = qmp("{\"execute\": \"device_del\","
> +                   " \"arguments\": {"
> +                   "   \"id\": \"%s\""
> +                   "}}", id);
> +    g_assert(response);
> +    g_assert(!qdict_haskey(response, "error"));
> +    QDECREF(response);
> +
> +    qtest_end();
> +}
> +
> +static void test_ohci_hotplug(void)
> +{
> +    usb_hcd_hotplug("pci-ohci", "ohci");
> +}
> +
> +static void test_uhci_hotplug(void)
> +{
> +    usb_hcd_hotplug("piix3-usb-uhci", "uhci");
> +}
> +
> +static void test_ehci_hotplug(void)
> +{
> +    usb_hcd_hotplug("usb-ehci", "ehci");
> +}
> +
> +static void test_xhci_hotplug(void)
> +{
> +    usb_hcd_hotplug("nec-usb-xhci", "xhci");
> +}
> +
> +int main(int argc, char **argv)
> +{
> +    int ret;
> +
> +    g_test_init(&argc, &argv, NULL);
> +
> +    qtest_add_func("/usb/hcd/pci/ohci-hotplug", test_ohci_hotplug);
> +    qtest_add_func("/usb/hcd/pci/uhci-hotplug", test_uhci_hotplug);
> +    qtest_add_func("/usb/hcd/pci/ehci-hotplug", test_ehci_hotplug);
> +    qtest_add_func("/usb/hcd/pci/xhci-hotplug", test_xhci_hotplug);
> +
> +    ret = g_test_run();
> +
> +    return ret;
> +}
> -- 
> 1.7.12.4
> 

-- 
			Amos.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest
  2014-06-25 14:42   ` Amos Kong
@ 2014-06-25 15:13     ` Gonglei (Arei)
  0 siblings, 0 replies; 8+ messages in thread
From: Gonglei (Arei) @ 2014-06-25 15:13 UTC (permalink / raw)
  To: Amos Kong
  Cc: Huangweidong (C), Luonengjun, qemu-devel@nongnu.org,
	Huangpeng (Peter), kraxel@redhat.com, stefanha@redhat.com,
	afaerber@suse.de

> -----Original Message-----
> From: Amos Kong [mailto:akong@redhat.com]
> Sent: Wednesday, June 25, 2014 10:42 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; kraxel@redhat.com; afaerber@suse.de;
> stefanha@redhat.com; Huangweidong (C); Luonengjun; Huangpeng (Peter)
> Subject: Re: [PATCH v4 4/4] tests: add usb hcds hotplugging qtest
> 
> On Mon, Jun 23, 2014 at 07:53:54PM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > Because of we now support usb hcds hotplugging, and
> > collect all hcds hotplugging tests into one file
> > for code sharing.
> >
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> >  tests/Makefile               |  2 +
> >  tests/usb-hcd-hotplug-test.c | 88
> ++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 90 insertions(+)
> >  create mode 100644 tests/usb-hcd-hotplug-test.c
> >
> > diff --git a/tests/Makefile b/tests/Makefile
> > index 6a78ade..f0362f7 100644
> > --- a/tests/Makefile
> > +++ b/tests/Makefile
> > @@ -161,6 +161,7 @@ gcov-files-i386-y += hw/usb/dev-hid.c
> >  gcov-files-i386-y += hw/usb/dev-storage.c
> >  check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
> >  gcov-files-i386-y += hw/usb/hcd-xhci.c
> > +check-qtest-i386-y += tests/usb-hcd-hotplug-test$(EXESUF)
> >  #check-qtest-i386-y += tests/vhost-user-test$(EXESUF)
> >  check-qtest-x86_64-y = $(check-qtest-i386-y)
> >  gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
> > @@ -331,6 +332,7 @@ tests/usb-hcd-ohci-test$(EXESUF):
> tests/usb-hcd-ohci-test.o
> >  tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o
> >  tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o
> $(libqos-pc-obj-y)
> >  tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o
> > +tests/usb-hcd-hotplug-test$(EXESUF): tests/usb-hcd-hotplug-test.o
> >  tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o
> qemu-timer.o libqemuutil.a libqemustub.a
> >  tests/qemu-iotests/socket_scm_helper$(EXESUF):
> tests/qemu-iotests/socket_scm_helper.o
> >  tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a
> libqemustub.a
> > diff --git a/tests/usb-hcd-hotplug-test.c b/tests/usb-hcd-hotplug-test.c
> > new file mode 100644
> > index 0000000..04bea97
> > --- /dev/null
> > +++ b/tests/usb-hcd-hotplug-test.c
> > @@ -0,0 +1,88 @@
> > +/*
> > + * QTest testcase for usb host adapters hotplug/unplug
> > + *
> > + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +
> > +#include <glib.h>
> > +#include <string.h>
> > +#include "libqtest.h"
> > +#include "qemu/osdep.h"
> > +
> > +
> > +static void usb_hcd_hotplug(const char *hcd, const char *id)
> > +{
> > +    QDict *response;
> > +
> > +    qtest_start("");
> > +
> > +    /* hotplug an usb host adapter */
> > +    response = qmp("{\"execute\": \"device_add\","
> > +                   " \"arguments\": {"
> > +                   "   \"driver\": \"%s\","
> > +                   "   \"id\": \"%s\""
> > +                   "}}", hcd, id);
> > +    g_assert(response);
> > +    g_assert(!qdict_haskey(response, "error"));
> > +    QDECREF(response);
> > +
> > +    /* hotplug an usb-tablet to the usb host adapter, bus=$id.0 */
> > +    response = qmp("{\"execute\": \"device_add\","
> > +                       " \"arguments\": {"
> > +                       "   \"driver\": \"usb-tablet\","
> > +                       "   \"bus\": \"%s.0\""
> > +                       "}}", id);
> > +    g_assert(response);
> > +    g_assert(!qdict_haskey(response, "error"));
> > +    QDECREF(response);
> 
> Do you need to unhot-plug usb-tablet first, before unhot-plug usb host
> adapter?

No, not need. If hot-unplug the usb hcd, the corresponding usb bus
will be deleted, and the devices attached will be deleted too.

> --
> 			Amos.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases
  2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
                   ` (3 preceding siblings ...)
  2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest arei.gonglei
@ 2014-06-25 15:29 ` Amos Kong
  4 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2014-06-25 15:29 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, luonengjun, qemu-devel, peter.huangpeng, kraxel,
	stefanha, afaerber

On Mon, Jun 23, 2014 at 07:53:50PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> This patch series base on my request usb host adapter hotplug/unplug
> series:
> 
> [PATCH v3 00/10] usb: usb host adapter hotplug
> http://lists.gnu.org/archive/html/qemu-devel/2014-06/msg00746.html

Looks good to me.

Reviewed-by: Amos Kong <akong@redhat.com>
 
> Changes since v3:
>  - rebase on latest qemu master
> 
> Changes since v2:
>   - add 'const' qualifier argument in usb_hcd_hotplug
>     function for building errors reported by Gerd
> 
> Changes since v1:
>  * By Andreas suggestion:
>   - rework hci-{ohci,uhci,xhci} files for functional tests
>   - add "cold-plug" test, "-device" in init funciton
>   - use QMP for device_add/del because of parsing security
>   - some other fixs
> 
>  * By Gerd suggestion:
>   - add an usb-hcd-hotplug-test.c file and collect hotplug
>     testing for all usb hcds
> 
> Thanks for your suggestion, please review again.
> 
> My "make check V=1" results:
> 
>  [...]
> TEST: tests/usb-hcd-ohci-test... (pid=20031)
>   /x86_64/ohci/pci/init:                                               OK
> PASS: tests/usb-hcd-ohci-test
> TEST: tests/usb-hcd-uhci-test... (pid=20034)
>   /x86_64/uhci/pci/init:                                               OK
> PASS: tests/usb-hcd-uhci-test
> TEST: tests/usb-hcd-ehci-test... (pid=20037)
>   /x86_64/ehci/pci/init:                                               OK
>   /x86_64/ehci/pci/uhci-port-1:                                        OK
>   /x86_64/ehci/pci/ehci-port-1:                                        OK
>   /x86_64/ehci/pci/ehci-config:                                        OK
>   /x86_64/ehci/pci/uhci-port-2:                                        OK
>   /x86_64/ehci/pci/ehci-port-2:                                        OK
> PASS: tests/usb-hcd-ehci-test
> TEST: tests/usb-hcd-xhci-test... (pid=20040)
>   /x86_64/xhci/pci/init:                                               OK
> PASS: tests/usb-hcd-xhci-test
> TEST: tests/usb-hcd-hotplug-test... (pid=20043)
>   /x86_64/usb/hcd/pci/ohci-hotplug:                                    OK
>   /x86_64/usb/hcd/pci/uhci-hotplug:                                    OK
>   /x86_64/usb/hcd/pci/ehci-hotplug:                                    OK
>   /x86_64/usb/hcd/pci/xhci-hotplug:                                    OK
> PASS: tests/usb-hcd-hotplug-test
> TEST: tests/qom-test... (pid=20068)
>   /x86_64/qom/pc-i440fx-1.4:                                           OK
>   /x86_64/qom/pc-1.3:                                                  OK
>   /x86_64/qom/pc-0.11:                                                 OK
>  [...]
> 
> Best regards,
> -Gonglei
> 
> Gonglei (4):
>   tests: add OHCI qtest
>   tests: add UHCI qtest
>   tests: add xHCI qtest
>   tests: add usb hcds hotplugging qtest
> 
>  MAINTAINERS                  |  2 +-
>  tests/Makefile               | 12 +++++-
>  tests/usb-hcd-hotplug-test.c | 88 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/usb-hcd-ohci-test.c    | 35 ++++++++++++++++++
>  tests/usb-hcd-uhci-test.c    | 35 ++++++++++++++++++
>  tests/usb-hcd-xhci-test.c    | 35 ++++++++++++++++++
>  6 files changed, 205 insertions(+), 2 deletions(-)
>  create mode 100644 tests/usb-hcd-hotplug-test.c
>  create mode 100644 tests/usb-hcd-ohci-test.c
>  create mode 100644 tests/usb-hcd-uhci-test.c
>  create mode 100644 tests/usb-hcd-xhci-test.c
> 
> -- 
> 1.7.12.4
> 

-- 
			Amos.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-25 15:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23 11:53 [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases arei.gonglei
2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 1/4] tests: add OHCI qtest arei.gonglei
2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 2/4] tests: add UHCI qtest arei.gonglei
2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 3/4] tests: add xHCI qtest arei.gonglei
2014-06-23 11:53 ` [Qemu-devel] [PATCH v4 4/4] tests: add usb hcds hotplugging qtest arei.gonglei
2014-06-25 14:42   ` Amos Kong
2014-06-25 15:13     ` Gonglei (Arei)
2014-06-25 15:29 ` [Qemu-devel] [PATCH v4 0/4] tests: add usb host adapter qtest cases Amos Kong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).