Commit Graph

158 Commits

Author SHA1 Message Date
Pavel Grunt
ce6113d838 replay: Add an option to change video codec 2016-06-14 17:04:40 +02:00
Frediano Ziglio
2b58c60bb1 replay: Handle cursor commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-07 22:43:30 +01:00
Frediano Ziglio
1be06f188e make spice-server-replay use dynamic spice-server library
spice-server-replay is built with the same settings as tests.
Currently the tests links to a convenience spice-server library.
A convenience library is a static library build with object file
for a dynamic library.
This make all tests contain all spice-server library code and not
linking to the spice-server dynamic library (the .so).
It's not a problem for most tests however this make impossible for
spice-server-replay utility to be used with a dynamic spice-server
library (you have to recompile it including the library).
This is a pity as you could for instance compare your system
library behavior with the library you are developing.
Also if we decide to install in a future the utility for testing
we would have lot of code duplication.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:57:06 +01:00
Frediano Ziglio
fa0c32f120 remove a warning building a test
With my compile switches (which are mostly derived from RedHat spec
file) I'm getting this warning:

stream-test.c: In function 'sock_fd_read':
stream-test.c:66:43: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
             *fd = *((int *) CMSG_DATA(cmsg));
                                           ^

memcpy could decrease performance but as this is a test it's not
an issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:52:10 +01:00
Frediano Ziglio
1e4800507b use #include<> style for spice-common header inclusions.
The include directory is specified with the -I which is the directory
used directly by #include<>.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-09 12:45:27 +01:00
Uri Lublin
2480eb6979 replay: skip the first N (slow) commands
Note that the commands are executed by spice-server.
The "skip" is only done on the "sleep" part of the
"slow" command-line option.

This is helpful to run quickly through uninsteresting commands
in a beginning of a recorded file and going slowly when
interesting parts appear

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-16 10:09:07 +00:00
Uri Lublin
07cb94d7ab replay: count commands
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-16 10:08:48 +00:00
Uri Lublin
d82b8b0789 replay: do not use argv after g_option_context_parse
Apparently, after using g_option_context_parse with G_OPTION_REMAINING
argv is modified and should not be used.
This patch uses "file" instead of "argv" and makes sure
file is freed later.
No free is called upon error - exit takes care of it.
2016-03-03 11:57:44 +00:00
Michal Privoznik
2306c364d2 Update .gitignore files
The first part updates the .gitignore file in the root directory
because the file is obviously generated by automake but poison
our working tree.
The second part updates the .gitignore under server/tests/
directory because since 0db1137d we have a noinst test library
libtest.a. However, like in previous case, git should never track
this file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-25 09:12:51 +00:00
Jonathon Jongsma
1438b7ccf2 Add GObject to build requirements
Preparation for GObject-ifying some internals

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-16 11:22:04 +00:00
Jonathon Jongsma
de2572815b Add RedsState reference to RedsStream
Allows us to remove use of global 'reds' variable from reds-stream.c.
Requires changing the RedsStream constructor to accept a RedsState arg.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:45:46 +00:00
Frediano Ziglio
6e43433ec2 tests: add a new case for event loop timers
Check that cancelling a timer the timer callback is not called.

This can happen in latency code (red-channel.c).
In red_channel_client_cancel_ping_timer latency timer is cancelled and
state is set to PING_STATE_NONE however if timer was already active what
happens is that the red_channel_client_ping_timer is called and the line

  spice_assert(rcc->latency_monitor.state == PING_STATE_TIMER);

is triggered causing spice-server to abort.
This happens as GLib loop add all active sources to an array but if the
timer is deactivated before the event is dispatched the event will be
dispatched unless the source is destroyed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-02-12 17:44:47 +00:00
Marc-Andre Lureau
df7ba60503 tests: link test-qxl-parsing with libserver
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 17:33:15 +00:00
Frediano Ziglio
77adbb7574 replay: remove a message that could be caused by a race condition
The req_cmd_notification callback is called by spice-server when it
has processed all commands and wants to be notified (by a wakeup) that
new commands have been appended to the command queue.
Replay utility tries to fill the commands when it detects that
spice-server is trying to read commands but there are no more commands.
However, new commands are appended in a separate thread so if the main
red worker loop on spice-server is really tight this request can
happen.
Avoid printing any message on this condition, message will be appended
and loop woken up when replay code can do it.

Signed-by: Frediano Ziglio <figlio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-03 16:03:17 +00:00
Marc-Andre Lureau
15c908ef25 tests: make sure that the default rule builds all tests
The default rule being "all", it builds noinst_PROGRAMS but not
check_PROGRAMS. Let's build all the tests by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 11:36:10 +00:00
Frediano Ziglio
1ad571f576 replay: do not wake up loop too much
Send wakeups only when a command is available.
This emulate better what a guest driver should do (append the command
to the ring and then signal).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-26 12:46:32 +00:00
Jonathon Jongsma
77ae19c0c6 Replay: report error if we don't read the correct file header
The replay file should start with a header such as
  SPICE_REPLAY 1

Instead of soldiering on if we don't encounter this header, print a
warning and return NULL.  Also exit with a failure if spice_replay_new()
returns a NULL object in main.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-22 11:03:30 +00:00
Christophe Fergeau
6e407a81df event-loop: Remove template
Since SpiceCoreInterfaceInternal is a private data structure, we can
extend it as we see fit without breaking ABI. In particular, adding a
GMainContext member to it allows us to remove the need for
the event loop template which is currently included in the
basic_event_loop.c test file.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-21 14:19:24 +00:00
Christophe Fergeau
4b923347b7 test-loop: Improve basic_event_loop base_{timer, watch}_add
They call the functions provided by event_loop_core, but with a NULL
SpiceCoreInterfaceInternal parameter. It makes more sense to pass
event_loop_core rather than NULL.
This will allow to pass the GMainContext to be used through
SpiceCoreInterfaceInternal rather than through a template parameter.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-21 14:19:12 +00:00
Frediano Ziglio
a5a0d4a290 tests: test removed triggered timers are not called
This could happen for instance if a given timer remove all clients
which have associated timers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:57:01 +00:00
Frediano Ziglio
323dc46794 tests: add a test for event loop
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:59 +00:00
Frediano Ziglio
f3a7befafe tests: extract code for event loop
This code will be reused for main loop

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:33 +00:00
Frediano Ziglio
3686132923 tests: do not use default loop context
Make sure we don't handle event reserved to other loop contexts.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:28 +00:00
Frediano Ziglio
28c3585730 tests: remove leaks in test-qxl-parsing
This make happy address sanitizer during make check.
Otherwise memory leak detector can keep in and make tests fails.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 14:03:43 +00:00
Frediano Ziglio
e433a6634c replay: better documentation for -C and -S options
Document all possible values

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-15 15:42:19 +00:00
Frediano Ziglio
d80189b5ed replay: add streaming setting option
Add -S to allow to set a video streaming rule.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-15 15:04:52 +00:00
Marc-Andre Lureau
47df90a8ce stream-test: add batch test
Check that two consecutive msgfd are read back from two different reads.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-15 11:04:30 +00:00
Marc-Andre Lureau
0db1137dac build-sys: build a noinst libtest.a to link to
Group the test utility in a library, to avoid repeating the same
sources. In this case, automake already figues out what the source of
the programs to build is.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-15 09:58:54 +00:00
Frediano Ziglio
58c5713aa9 replay: remove command line memory leaks
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-15 08:58:12 +00:00
Marc-Andre Lureau
f438bd6ae9 tests: add fdpass stream test
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 11:04:49 +00:00
Frediano Ziglio
adc0751950 channel: add a new internal SpiceCoreInterface
Define an internal structure that matches 100% the ABI of the public one.
The structure will be changed by following patches.
See comments in "channel: add interface parameters to
SpiceCoreInterfaceInternal" patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:29:53 +00:00
Frediano Ziglio
d3b5d2c97e add some tests for cursors parsing
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 18:16:47 +00:00
Frediano Ziglio
6ea345b820 add test for QXL parsing functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 18:16:47 +00:00
Eduardo Lima (Etrunko)
8c6dcc5eaf server: Fix tests Makefile
As reported in https://bugs.freedesktop.org/show_bug.cgi?id=93520, the
build from git is failing in Archlinux systems with undefined
references to glib symbols.

This patch fixes the problem by simply reordering the order libraries
will be linked. Also, removes duplicate $(GLIB_LIBS) variable.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-08 12:23:54 +00:00
Pavel Grunt
952aaca3d7 syntax-check: Remove empty line at EOF
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 11:24:14 +00:00
Frediano Ziglio
cc5fa8fa9b replay: better help for -s option
-s accepts an option to delay command queueing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <mlureau@redhat.com>
2015-12-22 16:45:48 +00:00
Marc-Andre Lureau
3364af70a3 tests: remove test_util.h
Replace ASSERT() with spice_assert().

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-21 11:44:34 +00:00
Frediano Ziglio
f5f103b8d7 tests: remove unused macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-21 10:39:56 +00:00
Frediano Ziglio
b953a4e35f tests: reuse Makefile macro
For coherency use COMMON_BASE macro instead of including single
files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2015-12-15 17:39:49 +00:00
Frediano Ziglio
276d9f08cd tests: allocate memory in a coherent fashion
Do not free memory allocated with C functions (like calloc) using g_free;
although this is possible with default Glib allocator this is not safe.
Also use consistent allocation functions. All other spice-server code
does not use Glib allocations so for coherence do not use them for
watches.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2015-12-15 17:39:38 +00:00
Frediano Ziglio
c4c716ab18 stat: add test for statistic functions
Make sure code compile with and without statistics enabled (beside
printing functions).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:54 +00:00
Francois Gouget
9b42aafe31 server: Rename SUPPORT_AUTOMATED_TESTS to HAVE_AUTOMATED_TESTS
This improves consistency with spice-deps.m4 which names its
AM_CONDITIONAL() variables HAVE_XXX.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-08 15:39:11 +01:00
Alon Levy
aef334e6e8 tests: test_display_base: use a faster wakeup time to easily test multiple client blocking
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-04 11:46:27 +00:00
Frediano Ziglio
525cd67be7 server: rename files
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:54:32 +00:00
Christophe Fergeau
e5e3e9eefe Add missing license headers 2015-10-19 14:25:36 +02:00
Christophe Fergeau
c61a37603a syntax-check: Remove unused #include <strings.h> 2015-10-19 14:25:36 +02:00
Christophe Fergeau
c0b2b1fc49 syntax-check: Add missing #include <config.h> 2015-10-19 14:25:36 +02:00
Jeremy White
df0eab862c Update the .gitignore files for the new manual,
for a few newly generated tests, and for the spice-server.h.
2015-10-16 15:48:23 -05:00
Christophe Fergeau
5eaf659aa3 tests: Fix -Werror=format-zero-length build failure
replay.c: In function 'replay_channel_event':
replay.c:226:16: error: zero-length gnu_printf format string
[-Werror=format-zero-length]
     g_printerr("");
2015-09-29 18:59:54 +01:00
Frediano Ziglio
2a09a5fa36 replay: compatibility with former version
GMutex usage in replay.c was not working so replace with plain pthread.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-09-01 17:17:21 +01:00