[Spice-commits] 6 commits - tests/cd-emu.c tests/meson.build
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Sep 27 10:09:10 UTC 2019
tests/cd-emu.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 12 +-
2 files changed, 331 insertions(+), 1 deletion(-)
New commits:
commit ca6b5f384db812dbc45fe27e8358c7931afad74d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:33 2019 +0200
test-cd-emu: Test no libusb context support
Although currently not supported by the code (libusb_context in
SpiceUsbBackend is never NULL), try to support it in order to be able to
have only emulated devices if the libusb layer is failing.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/cd-emu.c b/tests/cd-emu.c
index 690423b..c96c0ba 100644
--- a/tests/cd-emu.c
+++ b/tests/cd-emu.c
@@ -193,7 +193,8 @@ device_iteration(const int loop, const bool attach_on_connect)
static void attach(const void *param)
{
- const bool attach_on_connect = !!GPOINTER_TO_UINT(param);
+ const bool attach_on_connect = !!(GPOINTER_TO_UINT(param) & 1);
+ const bool libusb_enabled = !!(GPOINTER_TO_UINT(param) & 2);
hellos_sent = 0;
messages_sent = 0;
@@ -236,7 +237,12 @@ static void attach(const void *param)
g_assert_nonnull(device);
g_assert_false(device->edev_configured);
+ void *libusb_context_saved = be->libusb_context;
+ if (!libusb_enabled) {
+ be->libusb_context = NULL;
+ }
usb_ch = spice_usb_backend_channel_new(be, SPICE_USBREDIR_CHANNEL(ch));
+ be->libusb_context = libusb_context_saved;
g_assert_nonnull(usb_ch);
for (int loop = 0; loop < 2; loop++) {
@@ -300,8 +306,12 @@ int main(int argc, char* argv[])
g_test_add_data_func("/cd-emu/simple", GUINT_TO_POINTER(1), multiple);
g_test_add_data_func("/cd-emu/multiple", GUINT_TO_POINTER(128), multiple);
- g_test_add_data_func("/cd-emu/attach_no_auto", GUINT_TO_POINTER(0), attach);
- g_test_add_data_func("/cd-emu/attach_auto", GUINT_TO_POINTER(1), attach);
+#define ATTACH_PARAM(auto_attach, libusb) \
+ GUINT_TO_POINTER(!!(auto_attach) + 2 * !!(libusb))
+ g_test_add_data_func("/cd-emu/attach_no_auto", ATTACH_PARAM(0, 1), attach);
+ g_test_add_data_func("/cd-emu/attach_auto", ATTACH_PARAM(1, 1), attach);
+ g_test_add_data_func("/cd-emu/attach_no_auto_no_libusb", ATTACH_PARAM(0, 0), attach);
+ g_test_add_data_func("/cd-emu/attach_auto_no_libusb", ATTACH_PARAM(1, 0), attach);
int ret = g_test_run();
commit 7d5e1c30058c7137b5cac5b654e176e6faeb69af
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:32 2019 +0200
test-cd-emu: Make sure we can call spice_usb_backend_channel_flush_writes
Currently we call this function when the SPICE channel is up
however this function should continue to work as in theory
the channel could avoid to handle the message and stop the flow
(for instance to implement some kind of flow limitation)
and so will need to call this function again.
This was failing in the first USB emulation implementation
causing a crash.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/cd-emu.c b/tests/cd-emu.c
index fb023a9..690423b 100644
--- a/tests/cd-emu.c
+++ b/tests/cd-emu.c
@@ -164,6 +164,10 @@ device_iteration(const int loop, const bool attach_on_connect)
g_assert_cmpint(hellos_sent, ==, hellos_expected);
g_assert_cmpint(messages_sent, >=, messages_expected);
+ spice_usb_backend_channel_flush_writes(usb_ch);
+ g_assert_cmpint(hellos_sent, ==, hellos_expected);
+ g_assert_cmpint(messages_sent, >=, messages_expected);
+
// send hello reply
if (loop == 0) {
DATA_START
commit 52074d7590979c4741609b1887258a2057776cf4
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:31 2019 +0200
test-cd-emu: Test detach and reattach
Make sure device can be detached and attached again.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/cd-emu.c b/tests/cd-emu.c
index fd91c41..fb023a9 100644
--- a/tests/cd-emu.c
+++ b/tests/cd-emu.c
@@ -127,6 +127,66 @@ static void decrement_allocated(gpointer data G_GNUC_UNUSED, GObject *old_gobjec
spice_usb_backend_read_guest_data(usb_ch, (uint8_t*)data, G_N_ELEMENTS(data)); \
} while(0)
+static void
+device_iteration(const int loop, const bool attach_on_connect)
+{
+ GError *err = NULL;
+ unsigned int hellos_expected, messages_expected;
+
+ hellos_expected = hellos_sent;
+ messages_expected = messages_sent;
+
+ if (ch_state == SPICE_CHANNEL_STATE_UNCONNECTED) {
+ ch_state = SPICE_CHANNEL_STATE_CONNECTING;
+ }
+ if (attach_on_connect) {
+ g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
+ g_assert_null(err);
+ if (ch_state == SPICE_CHANNEL_STATE_READY) {
+ hellos_expected = MIN(hellos_expected + 1, 1);
+ messages_expected++;
+ } else {
+ g_assert_cmpint(messages_sent, ==, messages_expected);
+ }
+ }
+ g_assert_cmpint(hellos_sent, ==, hellos_expected);
+ g_assert_cmpint(messages_sent, >=, messages_expected);
+
+ // try to get initial data
+ if (ch_state == SPICE_CHANNEL_STATE_CONNECTING) {
+ ch_state = SPICE_CHANNEL_STATE_READY;
+ spice_usb_backend_channel_flush_writes(usb_ch);
+ hellos_expected = MIN(hellos_expected + 1, 1);
+ messages_expected++;
+ }
+
+ // we should get an hello (only one!)
+ g_assert_cmpint(hellos_sent, ==, hellos_expected);
+ g_assert_cmpint(messages_sent, >=, messages_expected);
+
+ // send hello reply
+ if (loop == 0) {
+ DATA_START
+ 0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //000 ....D.......
+ 0x71,0x65,0x6d,0x75,0x20,0x75,0x73,0x62,0x2d,0x72,0x65,0x64, //00c qemu usb-red
+ 0x69,0x72,0x20,0x67,0x75,0x65,0x73,0x74,0x20,0x33,0x2e,0x30, //018 ir guest 3.0
+ 0x2e,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //024 .1..........
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //030 ............
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //03c ............
+ 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00, //048 ........
+ DATA_SEND;
+ }
+
+ if (!attach_on_connect) {
+ g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
+ g_assert_null(err);
+ }
+ g_assert_cmpint(hellos_sent, ==, 1);
+ g_assert_cmpint(messages_sent, >, 1);
+
+ spice_usb_backend_channel_detach(usb_ch);
+}
+
static void attach(const void *param)
{
const bool attach_on_connect = !!GPOINTER_TO_UINT(param);
@@ -170,44 +230,30 @@ static void attach(const void *param)
g_assert_true(create_emulated_cd(be, ¶ms, &err));
g_assert_null(err);
g_assert_nonnull(device);
+ g_assert_false(device->edev_configured);
usb_ch = spice_usb_backend_channel_new(be, SPICE_USBREDIR_CHANNEL(ch));
g_assert_nonnull(usb_ch);
- // attach on connect
- ch_state = SPICE_CHANNEL_STATE_CONNECTING;
- if (attach_on_connect) {
- g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
- g_assert_null(err);
+ for (int loop = 0; loop < 2; loop++) {
+ device_iteration(loop, attach_on_connect);
}
- g_assert_cmpint(hellos_sent, ==, 0);
- g_assert_cmpint(messages_sent, ==, 0);
- // try to get initial data
- ch_state = SPICE_CHANNEL_STATE_READY;
- spice_usb_backend_channel_flush_writes(usb_ch);
+/*
- // we should get an hello (only one!)
- g_assert_cmpint(hellos_sent, ==, 1);
- g_assert_cmpint(messages_sent, ==, 1);
+> to server/guest
+< to client from server/guest
- // send hello reply
- DATA_START
- 0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //000 ....D.......
- 0x71,0x65,0x6d,0x75,0x20,0x75,0x73,0x62,0x2d,0x72,0x65,0x64, //00c qemu usb-red
- 0x69,0x72,0x20,0x67,0x75,0x65,0x73,0x74,0x20,0x33,0x2e,0x30, //018 ir guest 3.0
- 0x2e,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //024 .1..........
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //030 ............
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //03c ............
- 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00, //048 ........
- DATA_SEND;
+> usb_redir_interface_info,
+> usb_redir_ep_info,
+> usb_redir_device_connect
- if (!attach_on_connect) {
- g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
- g_assert_null(err);
- }
- g_assert_cmpint(hellos_sent, ==, 1);
- g_assert_cmpint(messages_sent, >, 1);
+< usb_redir_reset
+< usb_redir_control_packet
+
+> usb_redir_control_packet
+
+*/
// cleanup
spice_usb_backend_device_unref(device);
commit 7cab37275bc129c36045f3075a8fcc778dac4379
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:30 2019 +0200
test-cd-emu: Test attach/detach emulated device
Mock some usb-backend functions to be able to simulate device
attachment and detachment.
Create session and channel to pass some valid pointer anyway.
Emulate channel state correctly.
Make sure HELLO packets are sent correctly at the beginning and
no more afterwards.
Test auto-connect enabled or disabled.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/cd-emu.c b/tests/cd-emu.c
index b7c6543..fd91c41 100644
--- a/tests/cd-emu.c
+++ b/tests/cd-emu.c
@@ -14,10 +14,27 @@
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/>.
*/
-#include <gio/gio.h>
+
+/* Mock some code in usb-backend.c
+ *
+ * We include directly the source we want to modify, this allows to:
+ * - access static functions;
+ * - access private declarations;
+ * - mock (replace) some external function calls.
+ * All without changing a single line of code, adding files or similar.
+ * This works as the linker prefer object symbols to library symbols;
+ * as the symbols here will be in an object and the other version is
+ * in a library this will work.
+ *
+ * The defines before the include allows to replace the external
+ * function we need to replace. You can always declare the original
+ * function and wrap it in the mock function if needed.
+ */
+#define spice_usbredir_write mock_spice_usbredir_write
+#define spice_channel_get_state mock_spice_channel_get_state
+#include "../src/usb-backend.c"
#include "usb-device-cd.h"
-#include "usb-emulation.h"
static SpiceUsbBackendDevice *device = NULL;
@@ -67,6 +84,150 @@ static void multiple(const void *param)
spice_usb_backend_delete(be);
}
+static unsigned int messages_sent = 0;
+static unsigned int hellos_sent = 0;
+static SpiceUsbBackendChannel *usb_ch;
+
+int
+mock_spice_usbredir_write(SpiceUsbredirChannel *channel, uint8_t *data, int count)
+{
+ messages_sent++;
+ g_assert_cmpint(count, >=, 4);
+ const uint32_t type = data[0] + data[1] * 0x100u + data[2] * 0x10000u + data[3] * 0x1000000u;
+ if (type == usb_redir_hello) {
+ hellos_sent++;
+ }
+
+ // return we handled the data
+ spice_usb_backend_return_write_data(usb_ch, data);
+ return count;
+}
+
+// channel state to return from Mock function
+static enum spice_channel_state ch_state = SPICE_CHANNEL_STATE_UNCONNECTED;
+
+enum spice_channel_state
+mock_spice_channel_get_state(SpiceChannel *channel)
+{
+ return ch_state;
+}
+
+// number of GObjects allocated we expect will be freed
+static unsigned gobjects_allocated = 0;
+static void decrement_allocated(gpointer data G_GNUC_UNUSED, GObject *old_gobject G_GNUC_UNUSED)
+{
+ g_assert_cmpint(gobjects_allocated, !=, 0);
+ gobjects_allocated--;
+}
+
+#define DATA_START \
+ do { static const uint8_t data[] = {
+#define DATA_SEND \
+ }; \
+ spice_usb_backend_read_guest_data(usb_ch, (uint8_t*)data, G_N_ELEMENTS(data)); \
+ } while(0)
+
+static void attach(const void *param)
+{
+ const bool attach_on_connect = !!GPOINTER_TO_UINT(param);
+
+ hellos_sent = 0;
+ messages_sent = 0;
+ ch_state = SPICE_CHANNEL_STATE_UNCONNECTED;
+
+ SpiceSession *session = spice_session_new();
+ g_assert_nonnull(session);
+ g_object_weak_ref(G_OBJECT(session), decrement_allocated, NULL);
+ SpiceChannel *ch = spice_channel_new(session, SPICE_CHANNEL_USBREDIR, 0);
+ g_assert_nonnull(ch);
+ g_object_weak_ref(G_OBJECT(ch), decrement_allocated, NULL);
+ gobjects_allocated = 2;
+
+ /*
+ * real test, allocate a channel usbredir, emulate device
+ * initialization.
+ * Filter some call.
+ * Start sequence:
+ * - spice_usb_backend_new
+ * - spice_usb_backend_register_hotplug
+ * - spice_usb_backend_create_emulated_device
+ * - spice_usb_backend_channel_new
+ * - spice_usb_backend_channel_attach (if redir on connect)
+ * - spice_usb_backend_channel_flush_writes
+ * - spice_usbredir_write_callback
+ * - spice_usb_backend_return_write_data
+ * - spice_usb_backend_read_guest_data
+ * - spice_usb_backend_channel_attach (if not redir on connect)
+ */
+ GError *err = NULL;
+ SpiceUsbBackend * be = spice_usb_backend_new(&err);
+ g_assert_nonnull(be);
+ g_assert_null(err);
+ spice_usb_backend_register_hotplug(be, NULL, test_hotplug_callback, &err);
+ g_assert_null(err);
+
+ CdEmulationParams params = { "test-cd-emu.iso", 1 };
+ g_assert_true(create_emulated_cd(be, ¶ms, &err));
+ g_assert_null(err);
+ g_assert_nonnull(device);
+
+ usb_ch = spice_usb_backend_channel_new(be, SPICE_USBREDIR_CHANNEL(ch));
+ g_assert_nonnull(usb_ch);
+
+ // attach on connect
+ ch_state = SPICE_CHANNEL_STATE_CONNECTING;
+ if (attach_on_connect) {
+ g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
+ g_assert_null(err);
+ }
+ g_assert_cmpint(hellos_sent, ==, 0);
+ g_assert_cmpint(messages_sent, ==, 0);
+
+ // try to get initial data
+ ch_state = SPICE_CHANNEL_STATE_READY;
+ spice_usb_backend_channel_flush_writes(usb_ch);
+
+ // we should get an hello (only one!)
+ g_assert_cmpint(hellos_sent, ==, 1);
+ g_assert_cmpint(messages_sent, ==, 1);
+
+ // send hello reply
+ DATA_START
+ 0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //000 ....D.......
+ 0x71,0x65,0x6d,0x75,0x20,0x75,0x73,0x62,0x2d,0x72,0x65,0x64, //00c qemu usb-red
+ 0x69,0x72,0x20,0x67,0x75,0x65,0x73,0x74,0x20,0x33,0x2e,0x30, //018 ir guest 3.0
+ 0x2e,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //024 .1..........
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //030 ............
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //03c ............
+ 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00, //048 ........
+ DATA_SEND;
+
+ if (!attach_on_connect) {
+ g_assert_true(spice_usb_backend_channel_attach(usb_ch, device, &err));
+ g_assert_null(err);
+ }
+ g_assert_cmpint(hellos_sent, ==, 1);
+ g_assert_cmpint(messages_sent, >, 1);
+
+ // cleanup
+ spice_usb_backend_device_unref(device);
+ device = NULL;
+ spice_usb_backend_channel_delete(usb_ch);
+ usb_ch = NULL;
+ spice_usb_backend_deregister_hotplug(be);
+ spice_usb_backend_delete(be);
+
+ // this it's the correct sequence to free session!
+ // g_object_unref is not enough, causing wrong reference countings
+ spice_session_disconnect(session);
+ g_object_unref(session);
+ while (g_main_context_iteration(NULL, FALSE)) {
+ continue;
+ }
+
+ g_assert_cmpint(gobjects_allocated, ==, 0);
+}
+
#define TEST_CD_ISO_FILE "test-cd-emu.iso"
static void
@@ -89,6 +250,8 @@ int main(int argc, char* argv[])
g_test_add_data_func("/cd-emu/simple", GUINT_TO_POINTER(1), multiple);
g_test_add_data_func("/cd-emu/multiple", GUINT_TO_POINTER(128), multiple);
+ g_test_add_data_func("/cd-emu/attach_no_auto", GUINT_TO_POINTER(0), attach);
+ g_test_add_data_func("/cd-emu/attach_auto", GUINT_TO_POINTER(1), attach);
int ret = g_test_run();
commit 6ad2ec5a81c2a58fcf5b9bf24fb8d85501d3b48a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:29 2019 +0200
build: Use a convenience library for tests
Instead of linking all object inside spice-client-glib build a library
from these object and link to each test.
This will allow to override some object file for mocking purposes.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/meson.build b/tests/meson.build
index 39eac9c..57bd2cc 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -21,12 +21,18 @@ if spice_gtk_has_polkit
]
endif
+# create a static library from a shared one extracting all objects
+# this allows to rewrite part of it if necessary for mocking
+test_lib = \
+ static_library('test-lib',
+ objects : spice_client_glib_lib.extract_all_objects())
+
foreach src : tests_sources
name = 'test- at 0@'.format(src).split('.')[0]
exe = executable(name,
sources : src,
c_args : '-DTESTDIR="@0@"'.format(meson.current_build_dir()),
- objects : spice_client_glib_lib.extract_all_objects(),
+ link_with : test_lib,
dependencies : spice_client_glib_dep)
if not name.contains('mock-acl-helper')
test(name, exe)
commit e679d87bc01588126faa8ac2cd8d4391b97fd397
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Sep 19 16:11:28 2019 +0200
test-cd-emu: Add base test for cd-emulation
Just allocate and free to test for base leaks and reference
counting.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/tests/cd-emu.c b/tests/cd-emu.c
new file mode 100644
index 0000000..b7c6543
--- /dev/null
+++ b/tests/cd-emu.c
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2019 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/>.
+*/
+#include <gio/gio.h>
+
+#include "usb-device-cd.h"
+#include "usb-emulation.h"
+
+static SpiceUsbBackendDevice *device = NULL;
+
+/* simple usb manager hotplug callback emulation. */
+static void
+test_hotplug_callback(void *user_data, SpiceUsbBackendDevice *dev, gboolean added)
+{
+ // ignore not emulated devices
+ const UsbDeviceInformation *info = spice_usb_backend_device_get_info(dev);
+ if (info->bus != BUS_NUMBER_FOR_EMULATED_USB) {
+ return;
+ }
+
+ if (added) {
+ g_assert_null(device);
+ device = spice_usb_backend_device_ref(dev);
+ } else {
+ g_assert_nonnull(device);
+ g_assert(device == dev);
+ spice_usb_backend_device_unref(dev);
+ device = NULL;
+ }
+}
+
+static void multiple(const void *param)
+{
+ guint limit = GPOINTER_TO_UINT(param);
+ CdEmulationParams params = { "test-cd-emu.iso", 1 };
+ GError *err = NULL;
+ SpiceUsbBackend * be = spice_usb_backend_new(&err);
+ g_assert_nonnull(be);
+ g_assert_null(err);
+ spice_usb_backend_register_hotplug(be, NULL, test_hotplug_callback, &err);
+ g_assert_null(err);
+ for (int i = 0; i < limit; i++) {
+ // allocate a CD emulation device
+ g_assert_true(create_emulated_cd(be, ¶ms, &err));
+ g_assert_null(err);
+ g_assert_nonnull(device);
+
+ // emulate automatic CD ejection, this should release the
+ // object
+ spice_usb_backend_device_eject(be, device);
+ g_assert_null(device);
+ }
+ spice_usb_backend_deregister_hotplug(be);
+ spice_usb_backend_delete(be);
+}
+
+#define TEST_CD_ISO_FILE "test-cd-emu.iso"
+
+static void
+write_test_iso(void)
+{
+ uint8_t sector[2048];
+ FILE *f = fopen(TEST_CD_ISO_FILE, "wb");
+ g_assert_nonnull(f);
+ memset(sector, 0, sizeof(sector));
+ strcpy((char*) sector, "sector 0");
+ fwrite(sector, sizeof(sector), 1, f);
+ fclose(f);
+}
+
+int main(int argc, char* argv[])
+{
+ write_test_iso();
+
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_data_func("/cd-emu/simple", GUINT_TO_POINTER(1), multiple);
+ g_test_add_data_func("/cd-emu/multiple", GUINT_TO_POINTER(128), multiple);
+
+ int ret = g_test_run();
+
+ unlink(TEST_CD_ISO_FILE);
+ return ret;
+}
diff --git a/tests/meson.build b/tests/meson.build
index 6c80776..39eac9c 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -10,6 +10,10 @@ if spice_gtk_has_phodav
tests_sources += 'pipe.c'
endif
+if spice_gtk_has_usbredir
+ tests_sources += 'cd-emu.c'
+endif
+
if spice_gtk_has_polkit
tests_sources += [
'usb-acl-helper.c',
More information about the Spice-commits
mailing list