Commit Graph

254 Commits

Author SHA1 Message Date
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