Commit Graph

448 Commits

Author SHA1 Message Date
Frediano Ziglio
a68fd56b41 ci: Add test for websockets
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:19:43 +01:00
Frediano Ziglio
c1c5d8bf5a websocket: Handle continuation and 0-size frames
The WebSocket protocol allows 0-size frames so a returned lenth of
0 does not only mean an issue but it's perfectly expected.
This is also required by WebSocket specification.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:19:13 +01:00
Frediano Ziglio
9d6a438aae websocket: Handle text data
Allows to specify and get frame type.
Type and flags are returned calling websocket_read and returned
calling websocket_write or websocket_writev.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:19:10 +01:00
Frediano Ziglio
975d444f21 test-websocket: Write a test helper to make possible to run Autobahn testsuite
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:19:05 +01:00
Frediano Ziglio
89b0a07c72 test-glib-compat: Fix G_PID_FORMAT definition for old systems
The G_PID_FORMAT constant is defined only if GLib does not support it.
The constant was wrongly defined.
Jessie Debian 32 shows this issue (printf format error).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:17 +01:00
Christian Ehrhardt
19f9f454e0 test: fix test-qxl-parsing on ppc64el and armhf
On ppc64el and armhf the handling of "1 << mem_info.memslot_id_shift"
will end up beign a zero which breaks the test.

Marking the implicit value 1 as a 64 bit value (to match the uint64_t
target) fixes the issue.

Fixes #31

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 14:47:15 +01:00
Frediano Ziglio
753ebc0e7c test-display-base: Use SPICE_CONTAINEROF to avoid alignment warning
This change prevent a warning issued by GCC 9 and potentially
other compilers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-05-13 14:13:21 +01:00
Frediano Ziglio
d417a0bdfd Disable recording filtering for Windows
Although this feature can be ported to Windows doing so would
require the usage of g_spawn_async_with_fds, which is only available
in GLib 2.58 or some specific Win32 code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:33 +01:00
Frediano Ziglio
fd90a9d084 tests: Exclude tests that cannot work on Windows
test-stream test is passing file descriptor using Unix socket.
test-stat-file needs some porting work of mmap feature.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:28 +01:00
Frediano Ziglio
524acca643 windows: Disable code not working on Windows
- global signals;
- CLOEXEC flag;
- mmap and statistics;
- IPTOS_LOWDELAY flag;
- Unix sockets;
- sharing file descriptors through Unix sockets;
- TCP_CORK flag.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:22 +01:00
Frediano Ziglio
c8ab3c2c98 test-channel: Use socket compatibility layer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:20 +01:00
Frediano Ziglio
5ab0667eff test-leaks: Use socket compatibility layer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:18 +01:00
Frediano Ziglio
8031558ee3 tests: Provide alarm replacement for Windows
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:13:58 +01:00
Frediano Ziglio
0643d67557 build: Detect Windows build and change some definitions
Windows needs some specific setting to use network.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:13:48 +01:00
Frediano Ziglio
ed68d491fd Do not check for HAVE_CONFIG_H
This should always be defined and including config.h is a requirement.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-04-30 09:26:55 +01:00
Jonathon Jongsma
14403117b5 Make channel client callbacks virtual functions
Rather than having an API to register client callbacks for each channel
type, make them vfuncs.

Since the client callbacks are registered identically for each channel
of the same type, it doesn't make sense for to require these to be
registered separately for each object.  It's cleaner to have these be
per-class properties, so they've been converted to virtual functions.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-28 20:20:25 +00:00
Frediano Ziglio
52f716e1d2 test-stream-device: Remove interface before next loop
We should not reuse the same interface twice as doing so will
cause dangling pointers.
Unregister it at every iteration.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-19 13:59:04 +00:00
Frediano Ziglio
89796d2446 test-stat: Adjust delay checks
usleep under Windows does not seem to have the required precision.
Use milliseconds and adjust check times according.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-03-06 11:59:54 +00:00
Frediano Ziglio
b9e24dba58 test-stream-device: Check monitor ID messages
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-02-12 22:34:40 +00:00
Christophe Fergeau
a4a16ac42d memslot: Fix off-by-one error in group/slot boundary check
RedMemSlotInfo keeps an array of groups, and each group contains an
array of slots. Unfortunately, these checks are off by 1, they check
that the index is greater or equal to the number of elements in the
array, while these arrays are 0 based. The check should only check for
strictly greater than the number of elements.

For the group array, this is not a big issue, as these memslot groups
are created by spice-server users (eg QEMU), and the group ids used to
index that array are also generated by the spice-server user, so it
should not be possible for the guest to set them to arbitrary values.

The slot id is more problematic, as it's calculated from a QXLPHYSICAL
address, and such addresses are usually set by the guest QXL driver, so
the guest can set these to arbitrary values, including malicious values,
which are probably easy to build from the guest PCI configuration.

This patch fixes the arrays bound check, and adds a test case for this.
This fixes CVE-2019-3813.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-02-05 14:05:49 +01:00
Frediano Ziglio
ec71c795f3 replay: Port to Windows
Client process termination did not work for Windows, used Win32
APIs.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-31 11:03:19 +00:00
Frediano Ziglio
aed85f0ff1 test-listen: Exclude Unix sockets part under Windows
Windows does not support Unix sockets.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-31 10:59:39 +00:00
Frediano Ziglio
f8e8ac4910 windows: Do not include headers not available on Windows
This is a preparatory patch for next portability patches

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-31 10:48:34 +00:00
Frediano Ziglio
c55058563f test-display-base: Remove error from "make syntax-check"
Due to previous commit "make syntax-check" command reports:

prohibit_signal_without_use
server/tests/test-display-base.c
maint.mk: the above files include signal.h but don't use it
make: *** [maint.mk:639: sc_prohibit_signal_without_use] Error 1

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-03 15:10:19 +00:00
Frediano Ziglio
5cbdf1a235 test-display-base: Port to Windows
Use GLib function to launch and wait process exit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-03 13:08:17 +00:00
Frediano Ziglio
f5103aed1f replay: Force binary mode on input on Windows
If input contains the binary record we can't have it modified
during read.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-03 13:07:02 +00:00
Frediano Ziglio
27fc91986d test-playback: Simplify wave generation formulae
Split level computation, make clear is a sine wave on both channels.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-25 10:14:12 +00:00
Frediano Ziglio
cc9ddd6c1d test-playback: Remove obsolete debug
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-25 10:14:10 +00:00
Frediano Ziglio
f76d0bffed test-playback: Update misleading comments
We are waiting for a client connection, channel is already there

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-25 10:14:08 +00:00
Frediano Ziglio
10b93025f2 test-playback: Remove useless check for "frame"
We just fill it up, can't be NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-25 10:14:05 +00:00
Frediano Ziglio
ecb6f224cf tests/pki: Use CA/certificate valid until 2048 and with 2048 bits
This changes tests/pki/server-cert.pem and tests/pki/ca-cert.pem to have
2048 bits. These certificates were generated using the
instructions on https://www.spice-space.org/spice-user-manual.html
The -subj args were omitted, and the defaults suggested by openssl used.
The -days parameter was changed to -days 10950, the bits to 2048.

This fixes https://gitlab.freedesktop.org/spice/spice/issues/27.

Some distros are starting to use stricter settings for their openssl
configuration, which forbids 1024 bit keys, and causes test suite
failures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-12-07 12:31:11 +00:00
Christophe Fergeau
8669c933ff qxl: Add red_surface_cmd_{new, ref, unref} helpers
Currently, RedWorker is using stack-allocated variables for RedSurfaceCmd.
Surface commands are rare enough that we can dynamically allocate them
instead, and make the API in red-parse-qxl.h consistent with how other
QXL commands are handled.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:58 +00:00
Christophe Fergeau
fb3c602d75 qxl: Add red_cursor_cmd_{new, ref, unref} helpers
Currently, the cursor channel is allocating RedCursorCmd instances itself, and then
calling into red-parse-qxl.h to initialize it, and doing something
similar when releasing the data. This commit moves this common code to
red-parse-qxl.[ch]
The ref/unref are not strictly needed, red_cursor_cmd_free() would
currently be enough, but this makes the API consistent with
red_drawable_{new,ref,unref}.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-12-06 13:03:36 +00:00
Frediano Ziglio
70f56ad2fa tests: Use g_assert_(non)null instead of g_assert
Just a style change, on more recent GLib would print a more
friendly error report.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-12-04 09:03:27 +00:00
Frediano Ziglio
ac14cd5378 tests: Add a small test for red_record_ APIs
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-11-16 17:39:15 +00:00
Frediano Ziglio
96160ae50c test-leaks: Avoid clashing with test-display-base ports
Is possible that port 5913 is already in use as tests that uses
test_new will attempt to use ports from 5912 to 5921 so use a port
not in that range.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-11-16 16:37:27 +00:00
Frediano Ziglio
1bad26b663 test-display-base: Fix warning message avoidance
test_new function attempts to detect attempts to listen to tcp ports
already in listening state detecting some messages during
spice_server_init. However the check is wrong (broken in recent
34a44d3e94 "test-display-base: Avoid spurious errors due to listen
failures") and incomplete (missing message).

To better test this conditions put some of the ports in listening
state (like with a "nc -l 5912 & nc -l 5913 &" command) and run
tests in parallel (like with a "make check -j" command).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-11-16 16:37:20 +00:00
Frediano Ziglio
91b15b6de3 ci: Ignore leak from GnuTLS p11 call
Fix Fedora 29 one-time leak.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-11-16 15:28:32 +00:00
Frediano Ziglio
e02d58f0a7 ci: Merge new glib.supp file
Merge from GLib master repository.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-11-16 15:28:32 +00:00
Frediano Ziglio
34a44d3e94 test-display-base: Avoid spurious errors due to listen failures
To set up a listening socket usually you call in sequence:
- socket;
- bind;
- listen.
If you try to bind() to a port when another socket is already
listening on that port, the bind() will fail.
However, it is possible that the bind() may succeed and the listen()
will fail, as demonstrated in the following sequence:
- socket() create socket 1;
- bind() to port N on socket 1;
- socket() create socket 2;
- bind() to port N on socket 2;
- listen() on socket 1;
- listen() on socket 2 <-- failure.

When running tests (especially multiple tests running in parallel), it
may sometimes happen that there are other tests already listening on
the port that we are trying to use. In this case, we want to ignore
this error and simply try to listen on a different port. We already
attempted to handle this scenario, but we were only ignoring bind()
errors and not listen() errors. So in the scenario mentioned above,
the listen() error was causing the entire test to fail instead of
allowing us to try to listen on another port.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-11-10 08:19:01 +00:00
Eduardo Lima (Etrunko)
495d1612c4 Add support for building with meson/ninja
In a comparison with current autotools build system, meson/ninja
provides a huge improvement in build speed, while keeping the same
functionalities currently available and being considered more user
friendly.

The new system coexists within the same repository with the current one,
so we can do more extensive testing of its functionality before deciding
if the old system can be removed, or for some reason, has to stay for
good.

- Meson: https://mesonbuild.com

  This is the equivalent of autogen/configure step in autotools. It
  generates the files that will be used by ninja to actually build the
  source code.

  The project has received lots of traction recently, with many GNOME
  projects willing to move to this new build system. The following wiki
  page has more details of the status of the many projects being ported:

    https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting

  Meson has a python-like syntax, easy to read, and the documentation
  on the project is very complete, with a dedicated page on how to port
  from autotools, explaining how most common use cases can be
  implemented using meson.

    http://mesonbuild.com/Porting-from-autotools.html

  Other important sources of information:

    http://mesonbuild.com/howtox.html
    http://mesonbuild.com/Syntax.html
    http://mesonbuild.com/Reference-manual.html

- Ninja: https://ninja-build.org

  Ninja is the equivalent of make in an autotools setup, which actually
  builds the source code. It has being used by large and complex
  projects such as Google Chrome, Android and LLVM. There is not much to
  say about ninja (other than it is much faster than make) because we
  won't interact directly with it as much, as meson does the middle man
  job here. The reasoning for creating ninja in the first place is
  explained on the following post:

    http://neugierig.org/software/chromium/notes/2011/02/ninja.html

  Also its manual provides more in-depth information about the design
  principles:

    https://ninja-build.org/manual.html

- Basic workflow:

  Meson package is available for most if not all distros, so, taking
  Fedora as an example, we only need to run:

    # dnf -y install meson ninja-build.

  With Meson, building in-tree is not possible at all, so we need to
  pass a directory as argument to meson where we want the build to be
  done. This has the advantage of creating builds with different options
  under the same parent directory, e.g.:

    $ meson ./build --prefix=/usr
    $ meson ./build-extra -Dextra-checks=true -Dalignment-checks=true

  After configuration is done, we call ninja to actually do the build.

    $ ninja -C ./build
    $ ninja -C ./build install

  Ninja defaults to parallel builds, and this can be changed with the -j
  flag.

    $ ninja -j 10 -C ./build

- Hacking:

  * meson.build: Mandatory for the project root and usually found under
                 each directory you want something to be built.

  * meson_options.txt: Options that can interfere with the result of the
                       build.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-08-30 11:10:45 -03:00
Lukáš Hrázký
5c98338479 test-stream-device: Expect the g_log warning about invalid message
Fixes test-stream-device after adding a log warning about an invalid
message received on the stream device, glib tests fail on unexpected
warning messages.

Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-08-09 11:28:29 +01:00
Eduardo Lima (Etrunko)
b0e141b387 build: Move spice-common to subprojects/ directory
The reason for this commit is that Meson expects all submodules to be
placed in this subdirectory, and since autotools build is more flexible
in this case, we make some small adjustments to configure.ac and
Makefile.am files to accommodate for this change.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-07-23 14:49:19 -03:00
Frediano Ziglio
4d162260fc test-stream-device: Check data are sent together
Check that data sent to device are collapsed in a single message.
The StreamChannel object is mocked in the test.
This checks that commit dcc3f995d9
("stream-device: handle_data: send whole message") is doing the
right thing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 14:12:31 +01:00
Frediano Ziglio
91aa8ac830 test-stream-device: Factor out a function to start the test
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 14:12:28 +01:00
Frediano Ziglio
2f3634441f test-stream-device: Put common parts in setup/teardown functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 14:12:26 +01:00
Frediano Ziglio
e3bb59c76b test-stream-device: Check server detect and signal huge data
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 14:12:22 +01:00
Frediano Ziglio
c66a312137 red-stream-device: Fix and check empty data messages
If guest sent an empty data message this was not parsed correctly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-19 14:12:17 +01:00
Christophe Fergeau
014e4d7263 tests: Add G_PID_FORMAT to glib compat header
G_PID_FORMAT was only added in glib 2.50.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-07-08 16:24:35 +01:00
Frediano Ziglio
3f6ac2bccf reds: Fix one case parsing invalid codec string
In case we pass something like "spice:mjpeg$%*" the last part is
ignore making the string parse correctly.
A single pair should end by either string terminator or pair terminator.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-03 09:32:20 +01:00
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
Jonathon Jongsma
a5aa2a2261 Use standard "Red" namespace
The objects RedsStream and RedsSASL are currently using the namespace
"Reds" rather than the standard "Red" namespace used throughout the rest
of the project. Change these to be consistent. This also means changing
method names and some related enumeration types.

The files were also renamed to reflect the change:
  reds-stream.[ch] -> red-stream.[ch]

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-21 08:47:02 +01:00
Frediano Ziglio
e16d7788db tests: Check leaks registering migration interface
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-13 17:10:59 +01:00
Christophe Fergeau
67484cd98b tests: Automatically determine free port to use
Currently, the port used by most tests is hardcoded to 5912. However,
the test suite can be run in parallel, so if 2 tests run in parallel,
the 2nd one is not going to be able to bind to port 5912 and will fail.

After this commit, test_new() will try to find a free port between 5912
and 5922 and will abort if it can't find any.

The issue can be reproduced by adding a usleep(1000000) to the beginning
of test_destroy().

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-21 17:32:23 +02:00
Frediano Ziglio
1de104acfe tests: Add a test to check tight loop during ack waiting
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-19 10:50:39 +01:00
Frediano Ziglio
328a4a9b28 tests: Rename stat-main.c to test-stat.c
All main test module have this test-XXXX.c naming, make
test-stat coherent.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:50:26 +01:00
Frediano Ziglio
c64fe795c9 tests: Separate Makefile.am in sections
Put non-trivial programs in separate sections, which makes it easier to
understand the relationship between macros.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:49:40 +01:00
Frediano Ziglio
ddec15dea9 tests: Ignore test output results
New automake test harness produce *.log and *.trs files for
each test.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 13:15:57 +01:00
Frediano Ziglio
3dc6bc76f1 tests: Avoid to disable all deprecation warnings just for expect functions
In case GLib don't provide these functions we use replacements so
there's no need to have a warning if these functions are called.
This potentially capture other compatibility issues in the tests
that would be ignored having all deprecation warnings disabled.
Tested with GLib 2.28 and 2.52.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 14:17:53 +01:00
Frediano Ziglio
14828bfdfc test-gst: Free pipelines
Pipelines are never freed.
These are detected as leaks by leak detector tools like address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:08:10 +01:00
Frediano Ziglio
9bb2388f75 test-gst: Remove options parsing leaks
Command line options are not freed at the end of the program.
These are detected as leaks by leak detector tools like address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:08:10 +01:00
Frediano Ziglio
f35843ee6f test-gst: Remove useless check
encoder_name is never NULL as already initialized with "mjpeg" value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 13:07:51 +01:00
Frediano Ziglio
8856d518ee tests: Check leaks in spice_server_add_ssl_client
Currently is possible to trigger a leak by passing an invalid
connection.
This can happen if the client opens a connection and then closes it
without writing or reading any data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-12 11:58:01 +01:00
Frediano Ziglio
e595b18282 tests: Make test-two-servers work
This test runs 2 spice server in one program.
Use two different tcp port to be able to connect to both servers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
8f872043b3 tests: Make test-empty-success automated
Add some check that something happened during creation/destruction.
Set as running on "make check".

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
0905a95d3a tests: Make test-fail-on-null-core-interface an automated test
Update to Glib style to catch warning.
Initialize properly the structure (invalid) provided.
Check results of spice_server_init.
Remove leaks.
Enable as check.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
544f5d7ed3 tests: Update README
Update tests names.
Remove tetris comments, never available and not planned.
Update some notes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
6517ea5cbb test-display-base: Always compile with AUTOMATED_TESTS enabled
There's no need to not compile this feature, it just enable
a parameters which must be passed in order to change test
behaviour.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
06380a737b tests: Allow to quit the message loop
This allows to end the loop to end some tests.
Currently different tests enter the loop but never exit from
them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
eb70454de3 test-display-base: Do not assume LP64 architecture on 64 bit
In C the sizeof(long) can be different than sizeof(void*),
use proper type.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
6745d048c5 test-display-base: Use spice allocation helpers
Do not use calloc and malloc directly without checking
the result. Use instead spice functions to get a nice
error in case of allocation failures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
416c58c348 test-display-base: Avoid cursor move command leaks
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
230dcf82c3 test-display-base: Avoid global buffer overflow
For some reasons (documented in cursor_init) the function
uses 128 extra bytes of data causing a reading buffer overflow.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
8bf7c7803d test-display-base: Protect the wake up timer start with a mutex
Timers in spice server are supposed to be used in a single thread
context. To avoid problems, protect the usage from multiple
thread with a mutex.
This sometimes caused a crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
6daf2d115b test-display-base: Avoid usage after free when the wakeup timer is freed
The wakeup timer is used by the worker thread and by the
main thread.
Destroying the object before destroying the worker thread
can lead to use after free.
Destroying the worker thread first makes sure we don't race.
This is detected easily when compiling the test with address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:18 +01:00
Frediano Ziglio
574574e425 test-display-base: Protect command ring with a mutex
The ring is accessed by multiple thread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 08:54:14 +01:00
Frediano Ziglio
f73fbdcae5 test-display-base: Use unsigned numbers for command ring indexes
As the indexes are used to compute the index inside an array
using modulo operation when a signed value overflows, the
modulo becames negative, causing a buffer underflow.
Unlikely to happens (take lot of time) but is safer that way.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-07 06:44:58 +01:00
Jonathon Jongsma
407ad2d63f tests: destroy test object
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-09-02 08:07:38 +01:00
Frediano Ziglio
de88e4d6b2 tests: Make variables static where possible
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:02:36 +01:00
Frediano Ziglio
55bb4f2395 tests: Remove unused declarations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:02:36 +01:00
Frediano Ziglio
581b289825 tests: Avoid leaking list of commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:02:36 +01:00
Frediano Ziglio
69356fabcb tests: Pass command list as constant
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:02:36 +01:00
Frediano Ziglio
ea58b27aff tests: Reuse G_N_ELEMENTS instead of COUNT
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:02:36 +01:00
Michal Privoznik
7254169f7f tests: Initialize all members of SpiceBaseInterface struct
When compiling, -Werror=missing-field-initializers is enabled.
However, some gcc versions (like Gentoo 4.9.4 one) fail to see
that all the members of the SpiceBaseInterface struct are
initialized:

test-display-base.c:844:5: error: missing initializer for field
'description' of 'SpiceBaseInterface'
[-Werror=missing-field-initializers] .base.description   = "test
spice virtual channel char device",

The solution is to initialize .base member as a structure at once
instead of multiple times per each member.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-06-23 10:09:50 +01:00
Frediano Ziglio
ba9656757e red-parse-qxl: s/true/false
Reverse return values of the various bool methods so that 'true' means
success, and 'false' failure rather than the opposite.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-02 11:30:47 +02:00
Frediano Ziglio
dfe9fe9ebe test: Add vp9 support to GStreamer test
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-07 16:45:54 +01:00
Frediano Ziglio
5d046d9b2d red-channel: Initialize statistic node correctly
Doing a memset(0) on a SpiceStatNode does not create an empty/unattached
node, but instead creates a node '0'. This node could be non-existing,
or totally unrelated.
This patch creates a default '0' node as soon as the file is created.
This will make the behaviour of 0-filled nodes more in line with what
one would expect.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-31 11:02:02 +01:00
Frediano Ziglio
7d86223e21 Fix minor incompatibilities with RHEL6
Include missing pthread header.
Avoid undeclared functions in test-glib-compat.c including
proper/correct header.
Define missing g_assert_true and g_assert_false.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-30 10:50:09 +01:00
Frediano Ziglio
3c78882884 test-leaks: Document test program
This test needs some additional setup to do its job.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-24 11:58:16 +00:00
Frediano Ziglio
76b7f943e4 Some automatic check on video encoders
Stress a bit video encoders.
This check different combination of
- encoder type;
- image formats;
- image clipping (encoding partial frames);
- handling frames split into chunks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-23 12:52:58 +00:00
Christophe Fergeau
7b5e294a36 tests/pki: Use CA/certificate valid until 2048
As pointed out by danpb, tests/pki/server-cert.pem is only valid until
Fri Nov 29 15:51:44 UTC 2019

This changes tests/pki/server-cert.pem and tests/pki/ca-cert.pem to be
valid until 2048. These certificates were generated using the
instructions on https://www.spice-space.org/page/SSLConnection
The -subj args were omitted, and the defaults suggested by openssl used.
The -days parameter was changed to -days 10950.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-23 12:02:47 +01:00
Christophe Fergeau
759fdfc6d1 build-sys: Add tests/pki to EXTRA_DIST
This fixes make distcheck

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-23 12:02:47 +01:00
Christophe Fergeau
844544f8be build-sys: Add make check-valgrind target
This allows to run automatically our test-suite with valgrind to test
for memory leaks.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-21 16:34:56 +01:00
Christophe Fergeau
02d42d4f00 tests: Port test-qxl-parsing to GTest
test-qxl-parsing is really a series of several tests. Porting it to
GTest makes this more obvious. This also has the side-effect of making
it more friendly to 'make check-valgrind' (which would fail on SIGALRM,
and on unexpected g_warning()).

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-21 16:34:56 +01:00
Frediano Ziglio
312c0aadf0 test-leaks: Checks some leaks using TLS
Verify stuff are freed correctly (like TLS context).
The different PKI file required are generated with
base values (localhost and rsa 1024).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-08 12:21:15 +00:00
Frediano Ziglio
df48918dd0 test-leaks: Test that creating and destroying spicevmc does not leak
Add and remove some vmc device to check for leaking.
These combination assure that currently implemented type
of devices (webdav, usb and generic) are checked.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-08 12:21:09 +00:00
Frediano Ziglio
a22a76371e tests: Reuse GLib compatibility code
Instead of disabling the code use the compatibility functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:43 +00:00
Frediano Ziglio
73f8a65d06 tests: Move some specific GLib compatibility to compatibility file
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:41 +00:00
Frediano Ziglio
b7a7ed3900 tests: Move some glib compatibility code to a separate file
Allow to reuse this code in other tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-03 16:49:36 +00:00
Frediano Ziglio
cdd1e69b28 main-dispatcher: Remove watch leak
Watch was added but never removed.
The added basic_event_loop_destroy() addition allows to see that
this leak is gone).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-02 11:15:28 +00:00
Christophe Fergeau
be4ceb4e24 test-vdagent: Make test case more useful
This switches the test to using the GTest API, and add several tests
related to https://bugzilla.redhat.com/show_bug.cgi?id=1411194

This uses some API not available in glib 2.28, so this checks we have a
new enough glib before building this test, and disables warnings when
using too new glib API when building it.

The "multiple-vmc-devices" is based off code written by Frediano Ziglio.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-01 18:02:37 +01:00