Commit Graph

298 Commits

Author SHA1 Message Date
Frediano Ziglio
f4632931d5 test-codecs-parsing: Add test case
Check if encoder contains an invalid character.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-03 09:32:13 +01:00
Christophe Fergeau
0d38a122d6 test-agent-msg-filter: Adjust for recent logging changes
Now warnings are printed through g_warning which causes the test to
fail. We need to use g_test_expect_message() to prevent that failure.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-28 14:31:22 +01:00
Frediano Ziglio
27df2afe34 replay: Use GPid and G_PID_FORMAT for portability
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 11:14:19 +01:00
Frediano Ziglio
9663ae6785 Do not use bzero
Not defined in MingW.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-06-25 13:12:04 +01:00
Christophe Fergeau
47ca1f0da0 channel: Remove unused 3rd red_channel_register_client_cbs() arg
It was probably meant to be used as a "user_data" argument for the
various callbacks, but turns out not to be used.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-21 17:54:27 +01:00
Frediano Ziglio
87965d8dea ci: Add some needed Valgrind suppression rule
From Gitlab CI:

=17955== 16 bytes in 1 blocks are possibly lost in loss record 725 of 2,079
==17955==    at 0x4C2DBAB: malloc (vg_replace_malloc.c:299)
==17955==    by 0x4011D17: tls_get_addr_tail.isra.0 (in /usr/lib64/ld-2.27.so)
==17955==    by 0x4017997: __tls_get_addr (in /usr/lib64/ld-2.27.so)
==17955==    by 0xEE4534B: gnutls_rnd (in /usr/lib64/libgnutls.so.30.20.2)
==17955==    by 0xEE1F254: ??? (in /usr/lib64/libgnutls.so.30.20.2)
==17955==    by 0xEE1F947: ??? (in /usr/lib64/libgnutls.so.30.20.2)
==17955==    by 0xEE231B5: ??? (in /usr/lib64/libgnutls.so.30.20.2)
==17955==    by 0xEE24D67: gnutls_handshake (in /usr/lib64/libgnutls.so.30.20.2)
==17955==    by 0xEBD4FEA: ??? (in /usr/lib64/gio/modules/libgiognutls.so)
==17955==    by 0x7463936: g_task_thread_pool_thread (gtask.c:1331)
==17955==    by 0x7A3E932: g_thread_pool_thread_proxy (gthreadpool.c:307)
==17955==    by 0x7A3DF29: g_thread_proxy (gthread.c:784)
==17955==    by 0x8284563: start_thread (in /usr/lib64/libpthread-2.27.so)
==17955==    by 0x859631E: clone (in /usr/lib64/libc-2.27.so)
==17955==
==17955== 32 bytes in 1 blocks are possibly lost in loss record 1,234 of 2,079
==17955==    at 0x4C2DBAB: malloc (vg_replace_malloc.c:299)
==17955==    by 0x4011D17: tls_get_addr_tail.isra.0 (in /usr/lib64/ld-2.27.so)
==17955==    by 0x4017997: __tls_get_addr (in /usr/lib64/ld-2.27.so)
==17955==    by 0xCAA5173: __cxa_get_globals (in /usr/lib64/libstdc++.so.6.0.25)
==17955==    by 0xCAA6186: __cxa_throw (in /usr/lib64/libstdc++.so.6.0.25)
==17955==    by 0xC601457: ??? (in /usr/lib64/libproxy.so.1.0.0)
==17955==    by 0xC5F6BB6: ??? (in /usr/lib64/libproxy.so.1.0.0)
==17955==    by 0xC5F7089: ??? (in /usr/lib64/libproxy.so.1.0.0)
==17955==    by 0xC5F7470: px_proxy_factory_get_proxies (in /usr/lib64/libproxy.so.1.0.0)
==17955==    by 0xC3E64E3: ??? (in /usr/lib64/gio/modules/libgiolibproxy.so)
==17955==    by 0x7463936: g_task_thread_pool_thread (gtask.c:1331)
==17955==    by 0x7A3E932: g_thread_pool_thread_proxy (gthreadpool.c:307)
==17955==    by 0x7A3DF29: g_thread_proxy (gthread.c:784)
==17955==    by 0x8284563: start_thread (in /usr/lib64/libpthread-2.27.so)
==17955==    by 0x859631E: clone (in /usr/lib64/libc-2.27.so)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-05 15:25:13 +01:00
Frediano Ziglio
337dad1110 ci: Merge new Valgrind suppression rule from official glib.supp
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-05 15:25:07 +01:00
Victor Toso
12c2739b9e tests: add test-listen executable to gitignore
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-04-19 07:57:04 +01:00
Frediano Ziglio
2a3d562438 test-stream-device: Test we can read empty capabilities
Code can have problems reading empty messages, check we can
handle it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-04-11 12:34:27 +01:00
Frediano Ziglio
262af0a920 stream-device: Handle capabilities
Handle capabilities from guest device.
Send capability to the guest when device is opened.
Currently there's no capabilities set on the message sent.
On the tests we need to discard the capability message before
reading the error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-04-11 12:34:25 +01:00
Lukáš Hrázký
68b6211865 Rename the virtio port for streaming
The name 'com.redhat.stream.0' is too generic and in no way denotes it
belongs to SPICE. It is preferred to have the project's domain in the
name and Red Hat doesn't own the project. Rename it to
org.spice-space.stream.0.

Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-04-05 16:46:06 +02:00
Frediano Ziglio
f1b2d09b00 valgrind: Ignore some library leaks
Ignore getaddrinfo and libproxy leaks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-14 10:17:36 +00:00
Frediano Ziglio
f53f9725e1 test-listen: Increase failure timeout
The timeout is too short when the test run under Valgrind

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-14 10:17:34 +00:00
Frediano Ziglio
f91731541a test-listen: Fix some use after free
Do not dereference thread_data after has been freed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-03-13 14:02:59 +00:00
Christophe Fergeau
f4dd0f1aa7 test-listen: Add Unix socket test
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:41:00 +01:00
Christophe Fergeau
0308530d5e test-listen: Add TLS test
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:58 +01:00
Christophe Fergeau
d1d43223af test-listen: Add event loop helpers
These factor a bit of common code, and more importantly, help with
freeing all event loop related data at the end of each test.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:55 +01:00
Christophe Fergeau
a58d44cec3 test-listen: Add test case for port/address configuration
This test case will be testing the external spice-server API to
configure the address/port it's listening on. For now it sets up a
listening server, spawns a thread which is going to connect to that
port, and check it gets the REDQ magic upon connection. It will be
extended to test for Unix sockets, TLS sockets, ...

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:53 +01:00
Christophe Fergeau
1a230cdac0 tests: basic-event-loop: Silence debug message
There is currently a debug printf which is always shown when a mainloop
event is triggered. This is unlikely to be useful unless one is
debugging the event loop code.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:50 +01:00
Frediano Ziglio
e45e087617 test-stream-device: Check we don't read past data message
Test case for the issue fixed by previous commit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 12:56:43 +00:00
Frediano Ziglio
19d2e2e8b5 stream-device: Implement properly device reset on open/close
Due to the way Qemu handle the device, when an error occurs we must consume
all pending data inside the callback which reads data from the device.
If we don't flush this data, the next time spice-server tries to read from
the device (after the guest closes/reopens it), we'll be getting stale
data. This can happen because we cannot prevent the guest from writing to
the device even after it got in an error state.
This needs to be done within this callback, as QEMU returns 0 if you call
SpiceCharDeviceInterface::read() outside of it. QEMU invokes this callback
through a call to spice_server_char_device_wakeup.
On the test now we must test that we receive an error from the device.
Previously we checked that last part of the data was not read. Now
potentially all data are read, so we need another way to check the device
detected the error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 11:21:39 +00:00
Frediano Ziglio
5327d0f559 test-stream-device: Test batched multiple messages
Test all batched (send together) messages are handled correctly
and device is not stuck.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-02-27 10:41:19 +00:00
Frediano Ziglio
c5ad710056 test-stream-device: Better Qemu emulation for data reading
Qemu does not trigger a new data read if we don't read all data in
the buffer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-02-27 10:40:20 +00:00
Frediano Ziglio
c4a0505f6e Avoid some alignment warnings using clang
clang reports may warnings like:

test-display-base.c:252:11: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    dst = (uint32_t *)bitmap;
          ^~~~~~~~~~~~~~~~~~

Use SPICE_ALIGNED_CAST/SPICE_UNALIGNED_CAST macros in common/mem.h to
mark the cast safe or possibly unsafe.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:35:46 +00:00
Frediano Ziglio
4a0149bb1f tests: Avoid some possible not initialized warning from Clang
Not really possible but clang raise these warnings:

test-sasl.c:555:13: error: variable 'is_ok' is uninitialized when used here [-Werror,-Wuninitialized]
        if (is_ok) {
            ^~~~~
test-sasl.c:553:22: note: initialize the variable 'is_ok' to silence this warning
        uint8_t is_ok;
                     ^
                      = '\0'

test-gst.c:792:18: error: variable 'height' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
                                                           ^~~~
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^~~~
test-gst.c:799:17: note: uninitialized use occurs here
    bitmap->y = height;
                ^~~~~~
test-gst.c:792:18: note: remove the '&&' if its condition is always true
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
                                                           ^
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^
test-gst.c:791:23: note: initialize the variable 'height' to silence this warning
    gint width, height;
                      ^
                       = 0

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:31:40 +00:00
Frediano Ziglio
a5b26585a1 replay: Do not use obsolete set_mm_time callback
Marked as obsolete with clang and some options is detected as
error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:31:40 +00:00
Frediano Ziglio
8d79d8887d tests: Remove test-just-sockets-no-ssl
This call sequence is included in test-display-base used in different
tests, no reason to have this test.
Also this test is not actually used for automated tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 16:32:21 +00:00
Frediano Ziglio
3625f3cfd1 basic-event-loop: Document why code does not use default GLib context
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 12:40:35 +00:00
Frediano Ziglio
7a25e46c8b Minor compatibility with FreeBSD system
Some additional header are needed to avoid undefined types.
SOL_TCP and IPPROTO_TCP have the same value in Linux but SOL_TCP
is not defined in FreeBSD.
Provide pthread_setname_np using pthread_set_name_np (same parameters).

Patch is based on a patch from Oleg Ginzburg <olevole@olevole.ru>

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-15 16:52:57 +00:00
Frediano Ziglio
55e4211456 test-display-base: Do not use obsolete set_mm_time callback
Marked as obsolete with clang and some options is detected as
error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-10 15:50:24 +00:00
Frediano Ziglio
6543bef0cb test-sasl: Test how to server reports the failure
The server on failure can just disconnect the client or report the
error. The error report can be done using new protocol 2 or just
a number (like protocol 1).
Detect the failure report to make possible to check it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:02 +00:00
Frediano Ziglio
0e533dfec5 test-sasl: Add tests for different failures and cases
Use some flags to specify which behaviour to change and different test
cases to test them.
Some cases specify when client stop sending data at different steps of
the process.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:00 +00:00
Frediano Ziglio
9881702df2 test-sasl: Add tests for different mechanism names
Try different connections with different tricky names.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:05:58 +00:00
Frediano Ziglio
cbc082ba06 test-sasl: Base test, connect using SASL
Create a thread that emulates a client and starts SASL authentication

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:05:56 +00:00
Frediano Ziglio
9aa2605611 test-sasl: Add code to mocking functions to test state
Check some functions are called in a given sequence.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:05:54 +00:00
Frediano Ziglio
aeb8bbe5ac test-sasl: Initial SASL test
Not currently working, is defining SASL functions used by the code.
As the symbols defined in the objects have more priority than the ones
defined by the libraries these function take precedence compared to
system library.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:05:49 +00:00
Frediano Ziglio
e26cbdb175 tests: Avoid cast from integer of wrong size
These cast causes warnings if a 32 bit target is used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 16:50:32 +00:00
Frediano Ziglio
ddf3b836bb test-channel: Use correct endianness for ack message
Network fields should be encoded as little endian.
This was discovered using an emulated MIPS machine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 16:50:32 +00:00
Victor Toso
07c7e236fc clang: remove double promotion
> test-display-resolution-changes.c:55:60: error: implicit conversion
> increases floating-point precision: 'float' to 'double'
>       command->create_primary.width = 800 + sin((float)count / 6) * 200;
>                                             ~~~ ~~~~~~~~~~~~~^~~
> test-display-resolution-changes.c:56:61: error: implicit conversion
> increases floating-point precision: 'float' to 'double'
>       command->create_primary.height = 600 + cos((float)count / 6) * 200;
>                                              ~~~ ~~~~~~~~~~~~~^~~

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-01-08 10:20:30 +00:00
Frediano Ziglio
fc1005718f build-sys: Ignore generated test-channel and test-stream-device files
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-12-17 17:33:07 +00:00
Frediano Ziglio
7cbc80ed04 build-sys: Remove useless definition
The default LDADD already include libserver.la.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-12 06:59:25 +00:00
Uri Lublin
ee87a36e95 test-stream: initialize msg.msg_flags
Coverity complains the field is not initialized.
That's true but man recvmsg specifies that this
field is set by recvmsg.

To make coverity happy, initialize this field.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-11 10:16:11 +00:00
Christophe Fergeau
1170282cec build: Use $(srcdir) when it makes sense
There are a few places which use $(top_srcdir) when $(srcdir) would be
equally valid.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-08 14:30:51 +01:00
Frediano Ziglio
7569ff3cc8 test-vdagent: Remove useless MIN definition
Already defined by GLib headers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Maybe this check should just be removed?
2017-12-05 10:54:09 +00:00
Frediano Ziglio
ddf7b366b1 Use verify instead of G_STATIC_ASSERT
verify guarantee that the condition is always a compile
time constant.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:49:46 +00:00
Frediano Ziglio
8e276278e5 tests: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:31:52 +00:00
Frediano Ziglio
137d9ec8e9 test-stream-device: Check incomplete reads of StreamMsgFormat
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-11-27 21:38:02 +00:00
Frediano Ziglio
d61fce91ee inputs-channels: Remove leak using tablet device
Current code does not free allocated tablet resources.
When a tablet is added some resources are allocated.
Resources should be released either removing the tablet or
freeing spice server object.
Added a test to check these conditions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-22 16:44:09 +00:00
Frediano Ziglio
d57b61a584 tests: Add a test for streaming devices
Currently create device, open it and pass some messages checking
they are handled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 10:02:50 +00:00
Frediano Ziglio
de5b166b71 Remove common/mem.h includes
common/mem.h contains mainly memory allocation functions.
As we decided to move to Glib calls directly avoid to include
function declaration we should not use anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:27:09 +00:00