[PATCH spice-server] tests: Test bug registering 2 vdagent devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This reproduces https://bugzilla.redhat.com/show_bug.cgi?id=1411194

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/tests/Makefile.am              |  1 +
 server/tests/test-interface-vdagent.c | 75 +++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100644 server/tests/test-interface-vdagent.c

diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index f696f9f..8762f5e 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -45,6 +45,7 @@ check_PROGRAMS =				\
 	test-loop				\
 	test-qxl-parsing			\
 	test-stat-file				\
+	test-interface-vdagent			\
 	$(NULL)
 
 noinst_PROGRAMS =				\
diff --git a/server/tests/test-interface-vdagent.c b/server/tests/test-interface-vdagent.c
new file mode 100644
index 0000000..0bb2910
--- /dev/null
+++ b/server/tests/test-interface-vdagent.c
@@ -0,0 +1,75 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2017 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+/* This test check double registration of vdagent interface
+ */
+#include <config.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "test-display-base.h"
+
+static int vmc_write(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+                     SPICE_GNUC_UNUSED const uint8_t *buf,
+                     int len)
+{
+    return len;
+}
+
+static int vmc_read(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+                    uint8_t *buf,
+                    int len)
+{
+    return 0;
+}
+
+static void vmc_state(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+                      SPICE_GNUC_UNUSED int connected)
+{
+}
+
+static SpiceCharDeviceInterface vmc_interface = {
+    .base.type          = SPICE_INTERFACE_CHAR_DEVICE,
+    .base.description   = "test spice virtual channel char device",
+    .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
+    .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
+    .state              = vmc_state,
+    .write              = vmc_write,
+    .read               = vmc_read,
+};
+
+SpiceCharDeviceInstance vmc_instances[2] = {
+    { .subtype = "vdagent", },
+    { .subtype = "vdagent", },
+};
+
+int main(void)
+{
+    SpiceCoreInterface *core = basic_event_loop_init();
+    Test *test = test_new(core);
+
+    vmc_instances[0].base.sif = &vmc_interface.base;
+    spice_server_add_interface(test->server, &vmc_instances[0].base);
+    vmc_instances[1].base.sif = &vmc_interface.base;
+    spice_server_add_interface(test->server, &vmc_instances[1].base);
+
+    spice_server_remove_interface(&vmc_instances[1].base);
+    spice_server_remove_interface(&vmc_instances[0].base);
+
+    return 0;
+}
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]