Commit Graph

68 Commits

Author SHA1 Message Date
Frediano Ziglio
3892983eda Use visibility instead of just filtering using version script
In case version script support is not available we can still
able to filter symbols exported.
This for instance will work with linkers not supporting
--version-script (like system MacOS one).
Use new version macros similar to Glib to detect also
deprecated function.
Tested that exported symbols remains the same from both Linux
and Windows shared libraries.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-07-09 08:25:14 +01:00
Marc-André Lureau
89208ee729 meson: fix a warning
WARNING: extract_all_objects called without setting recursive

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 11:22:43 +04:00
Frediano Ziglio
9def63a7a4 coroutine_gthread: Fix recursive yield
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:15 +01:00
Francesco Giudici
d41bf3e9f7 meson: fix indentation
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-03-05 18:44:17 +01:00
Frediano Ziglio
4c031d1ecd test-cd-emu: Avoid deadlock waiting for libusb event thread
Remove a race condition testing code with no libusb enabled.
Setting libusb_context field while the libusb event thread was using
causes a potential deadlock in the test.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-02-28 12:48:41 +00:00
Frediano Ziglio
d4f7a71508 Rename SpiceUsbBackendDevice to SpiceUsbDevice
They are the same structure now.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-01-19 11:21:34 +02:00
Francois Gouget
3e0eb9e056 build: Avoid line continuation for compatibility with older Meson
This fixes building spice-gtk on Debian 10.

See https://github.com/mesonbuild/meson/issues/4720.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-01-13 11:25:39 +00:00
Frediano Ziglio
ca6b5f384d test-cd-emu: Test no libusb context support
Although currently not supported by the code (libusb_context in
SpiceUsbBackend is never NULL), try to support it in order to be able to
have only emulated devices if the libusb layer is failing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:48 +01:00
Frediano Ziglio
7d5e1c3005 test-cd-emu: Make sure we can call spice_usb_backend_channel_flush_writes
Currently we call this function when the SPICE channel is up
however this function should continue to work as in theory
the channel could avoid to handle the message and stop the flow
(for instance to implement some kind of flow limitation)
and so will need to call this function again.
This was failing in the first USB emulation implementation
causing a crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:45 +01:00
Frediano Ziglio
52074d7590 test-cd-emu: Test detach and reattach
Make sure device can be detached and attached again.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:42 +01:00
Frediano Ziglio
7cab37275b test-cd-emu: Test attach/detach emulated device
Mock some usb-backend functions to be able to simulate device
attachment and detachment.
Create session and channel to pass some valid pointer anyway.
Emulate channel state correctly.
Make sure HELLO packets are sent correctly at the beginning and
no more afterwards.
Test auto-connect enabled or disabled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:40 +01:00
Frediano Ziglio
6ad2ec5a81 build: Use a convenience library for tests
Instead of linking all object inside spice-client-glib build a library
from these object and link to each test.
This will allow to override some object file for mocking purposes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:38 +01:00
Frediano Ziglio
e679d87bc0 test-cd-emu: Add base test for cd-emulation
Just allocate and free to test for base leaks and reference
counting.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:32 +01:00
Marc-André Lureau
9837f974cc Drop autotools
Maintaining 1 build system is hard. Maintaining 2 is even harder.

It seems the meson build system is now in good shape to replace
autotools. Like many desktop projects, let's move entirely to meson
and drop autotools support.

Known changes:
- generating changelog files in the dist tarball. This is not strictly
  required, and can be added back later.
- generated files are not included in the dist tarball. In some ways,
  this can be considered a good thing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-07-09 11:05:29 +01:00
Christophe Fergeau
eab33dca15 build: Remove need for --enable-static for building tests
Currently, spice-gtk tests are disabled if build of static libraries is
disabled. This commit introduces an intermediate
spice-client-glib-impl.la convenience library which will be used both
for generating the spice-client-glib-2.0 shared library (after applying
the version script), and to link the tests with.
This is better than using --enable-static as we don't need to rebuild
each object twice (static and shared).

This was inspired by similar work Fabiano Fidencio did in libosinfo:
https://www.redhat.com/archives/libosinfo/2018-November/msg00231.html

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-11-22 14:50:04 +01:00
Eduardo Lima (Etrunko)
a9c715ea09 tests: Add missing static statement
Fixes the following warnings:

../tests/usb-acl-helper.c:29:10: warning: no previous prototype for ‘abort_test’ [-Wmissing-prototypes]
 gboolean abort_test(gpointer user_data)
          ^~~~~~~~~~
../tests/usb-acl-helper.c:37:10: warning: no previous prototype for ‘cancel_test’ [-Wmissing-prototypes]
 gboolean cancel_test(gpointer user_data)
          ^~~~~~~~~~~

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2018-10-02 08:25:04 +01:00
Frediano Ziglio
17a318ee96 build: Make usb-acl-helper test work under Meson
Meson waits for pipes (stdout and stderr) to be not readable but
our mocking helper does not close these handles causing Meson
to exit with a stack trace.
Note that the fact that the helper is not closing the handles
is a wanted behaviour.

Already reported at https://github.com/mesonbuild/meson/issues/3967.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-09-05 15:51:16 +01:00
Eduardo Lima (Etrunko)
7a87356bd2 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>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-08-30 11:13:00 -03:00
Frediano Ziglio
08b5ffb3ff tests: Remove unused structure declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-04 16:12:34 +01:00
Eduardo Lima (Etrunko)
7d1197522f tests: Shut up warnings about unitialized struct fields
Build complains about lots of unitialized fields in TestCase definition,
for instance:

../tests/session.c:276:11: warning: missing initializer for field ‘message’ of ‘TestCase {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
           "spice://[::192.9.5.5]:5910" },
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/session.c:11:18: note: ‘message’ declared here
     const gchar *message;
                  ^~~~~~~
../tests/session.c:282:11: warning: missing initializer for field ‘unix_path’ of ‘TestCase {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
           "password may be visible in process listings"},
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-04-25 09:36:44 -03:00
Marc-André Lureau
d2700d3524 tests: add spice+tls:// tests
They couldn't not be introduced before, because the test needs both
parsing and generation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-03-02 17:16:17 +00:00
Marc-André Lureau
4e63a1339b uri: generate spice://host:port or spice+tls://host:port
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-03-02 17:16:17 +00:00
Marc-André Lureau
ac71650857 tests: add spice+unix:// URI checks
For some reason, the URIs test didn't include spice+unix:// checks,
probably because they came about the same time.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-02-13 08:56:05 +00:00
Marc-André Lureau
35701d818f tests/pipe: add write close/cancel tests
And a few cleanups.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-09-04 12:15:40 +02:00
Marc-André Lureau
1dd19d52a3 giopipe: input return 0 and no error when peer is already closed
The peer stream may be closed, but may have failed to close self,
because it has pending operations. In this case indicate EOS on read
rather than returning an error. self will be close eventually on
dispose.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-09-04 12:15:36 +02:00
Marc-André Lureau
94527a7e20 test-pipe: /pipe/readcancel is supposed to test cancel
Not to reproduce /pipe/readclose..

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-09-04 12:15:34 +02:00
Victor Toso
b312ca0809 build-sys: bump glib requirement 2.36 -> 2.46
At the moment:
- Fedora 26 has 2.52
- Fedora 25 has 2.50
- Fedora 24 has 2.48
- CentOS 7 has 2.46
- Debian 9 has 2.50

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-08-01 14:52:02 +02:00
Pavel Grunt
2528cd907b test-session: Fix comparison
The test was not executed because G_N_ELEMENTS is 0 for the pointer

Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-19 15:05:32 +02:00
Pavel Grunt
7b6cd9613f test-session: Add IPv6 tests 2016-10-17 20:07:15 +02:00
Pavel Grunt
b8749cc053 test-session: Test invalid URIs 2016-10-17 20:07:15 +02:00
Pavel Grunt
7e010e76ff test-session: Also test hostname, username and password 2016-10-17 20:07:15 +02:00
Pavel Grunt
36f28f4e47 test-session: Test alternative way for setting port
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-17 20:07:15 +02:00
Victor Toso
6f11f55996 tests: fix -Wall -Wextra compiler warnings
With -Wall a few -Wunused-variable and -Wunused-but-set-variable;
With -Wextra lots of -Wunused-parameter and a few -Wsign-compare.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-05 14:15:08 +02:00
Victor Toso
c2c74cac75 tests: set binaries to have 'test' name prefix
To follow test-spice-uri and test-file-transfer standard.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-03 14:36:43 +02:00
Pavel Grunt
b708989b12 util: Remove unused GError parameter
The parameter is removed from functions:
 get_line
 spice_convert_newlines
 spice_unix2dos
 spice_dos2unix

It was introduced in 75f1ea3ee9
but never used

Acked-by: Marc-André Lureau <mlureau@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-02 13:14:17 +02:00
Christophe Fergeau
377842b94d test-file-transfer: Don't leak GError
Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-03 15:27:27 +02:00
Christophe Fergeau
66d8e2ee50 test-file-transfer: Don't leak GFileInfo
The GFileInfo returned by spice_file_transfer_task_init_task_finish()
must be unref'ed when no longer needed.

Acked-by: Victor Toso <victortoso@redhat.com>
2016-08-03 15:27:24 +02:00
Victor Toso
95c570274f tests: file-transfer agent cancel
Agent only can only send error or cancel from a transfer operation
after it was initialized. From SpiceFileTransferTask point of view,
error and cancellation is an GError with different code so testing
only cancel seems enough.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-07-07 16:19:23 +02:00
Victor Toso
5dc16d27c0 tests: file-transfer cancel on read async
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-07-07 16:19:23 +02:00
Victor Toso
9d16aced7f tests: file-transfer cancel on task init
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-07-07 16:19:23 +02:00
Victor Toso
bee52d2ba7 tests: file-transfer include simple tests
This only includes a simple test for file-transfer with a small
summary of the possible situations of the test.

As the test is specifically for SpiceFileTransferTask, we don't create
a SpiceMainChannel.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-07-07 16:19:23 +02:00
Pavel Grunt
8cf25bea7b tests-uri: Define g_assert_nonnull
It is available since Glib 2.40
2016-06-13 13:07:47 +02:00
Pavel Grunt
b542dfa2d5 spice-uri: Add ipv6 support
Just basic support -  http://user:password@[host]:port

Resolves: rhbz#1335239
2016-06-02 10:26:10 +02:00
Pavel Grunt
8dcb4129ac spice-uri: Validate uri scheme
Related: rhbz#1335239

Acked-by: Victor Toso <victortoso@redhat.com>
2016-06-02 10:26:10 +02:00
Pavel Grunt
eacbe261d4 spice-uri: Check if port is in allowed range
Use g_ascii_strtoll because it helps to detect overflow.

Related: rhbz#1335239

Acked-by: Victor Toso <victortoso@redhat.com>
2016-06-02 10:26:10 +02:00
Pavel Grunt
85051b06c1 spice-uri: Do not allow empty port string
Related: rhbz#1335239

Acked-by: Victor Toso <victortoso@redhat.com>
2016-06-02 10:26:10 +02:00
Pavel Grunt
024eccefba spice-uri: Reset SpiceURI before parsing
Avoid using old values after parsing a new uri.

Related: rhbz#1335239
2016-06-02 10:26:10 +02:00
Pavel Grunt
dab190d8d2 tests: Add test for SpiceURI
Related: rhbz#1335239
2016-06-02 10:26:10 +02:00
Victor Toso
756f1fe8aa tests: fix build with smartcard enabled
In file included from
../spice-common/common/client_marshallers.h:29:0,
from ../src/spice-channel-priv.h:35,
from ../src/spice-file-transfer-task-priv.h:28,
from file-transfer.c:3:
../spice-common/common/messages.h:45:23: fatal error: libcacard.h: No such file or directory
compilation terminated.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-06-01 09:32:27 +02:00
Pavel Grunt
0a9ec4ec01 Adjust to GLib 2.36
Dependency since 8693e7d3f7

Remove glib-compat files and most of GLIB_CHECK_VERSION guards

Acked-by: Victor Toso <victortoso@redhat.com>
2016-03-18 11:42:31 +01:00