xref: /qemu/tests/qtest/virtio-serial-test.c (revision 1e8a1fae)
1*1e8a1faeSThomas Huth /*
2*1e8a1faeSThomas Huth  * QTest testcase for VirtIO Serial
3*1e8a1faeSThomas Huth  *
4*1e8a1faeSThomas Huth  * Copyright (c) 2014 SUSE LINUX Products GmbH
5*1e8a1faeSThomas Huth  *
6*1e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7*1e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
8*1e8a1faeSThomas Huth  */
9*1e8a1faeSThomas Huth 
10*1e8a1faeSThomas Huth #include "qemu/osdep.h"
11*1e8a1faeSThomas Huth #include "libqtest-single.h"
12*1e8a1faeSThomas Huth #include "qemu/module.h"
13*1e8a1faeSThomas Huth #include "libqos/virtio-serial.h"
14*1e8a1faeSThomas Huth 
15*1e8a1faeSThomas Huth /* Tests only initialization so far. TODO: Replace with functional tests */
virtio_serial_nop(void * obj,void * data,QGuestAllocator * alloc)16*1e8a1faeSThomas Huth static void virtio_serial_nop(void *obj, void *data, QGuestAllocator *alloc)
17*1e8a1faeSThomas Huth {
18*1e8a1faeSThomas Huth     /* no operation */
19*1e8a1faeSThomas Huth }
20*1e8a1faeSThomas Huth 
serial_hotplug(void * obj,void * data,QGuestAllocator * alloc)21*1e8a1faeSThomas Huth static void serial_hotplug(void *obj, void *data, QGuestAllocator *alloc)
22*1e8a1faeSThomas Huth {
23*1e8a1faeSThomas Huth     qtest_qmp_device_add(global_qtest, "virtserialport", "hp-port", "{}");
24*1e8a1faeSThomas Huth     qtest_qmp_device_del(global_qtest, "hp-port");
25*1e8a1faeSThomas Huth }
26*1e8a1faeSThomas Huth 
register_virtio_serial_test(void)27*1e8a1faeSThomas Huth static void register_virtio_serial_test(void)
28*1e8a1faeSThomas Huth {
29*1e8a1faeSThomas Huth     QOSGraphTestOptions opts = { };
30*1e8a1faeSThomas Huth 
31*1e8a1faeSThomas Huth     opts.edge.before_cmd_line = "-device virtconsole,bus=vser0.0";
32*1e8a1faeSThomas Huth     qos_add_test("console-nop", "virtio-serial", virtio_serial_nop, &opts);
33*1e8a1faeSThomas Huth 
34*1e8a1faeSThomas Huth     opts.edge.before_cmd_line = "-device virtserialport,bus=vser0.0";
35*1e8a1faeSThomas Huth     qos_add_test("serialport-nop", "virtio-serial", virtio_serial_nop, &opts);
36*1e8a1faeSThomas Huth 
37*1e8a1faeSThomas Huth     qos_add_test("hotplug", "virtio-serial", serial_hotplug, NULL);
38*1e8a1faeSThomas Huth }
39*1e8a1faeSThomas Huth libqos_init(register_virtio_serial_test);
40