Commit Graph

34 Commits

Author SHA1 Message Date
Jonas Ådahl
046012a6cf tests: Pass argument to client main
Change the API to pass an "void *" argument to the client main
function, allowing the caller to call the same main function with
different input.

A helper (client_create_noarg) is added for when no argument is passed,
and the existing test cases are changed to use this function instead.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-01-16 16:37:37 +08:00
Bryce Harrington
773babedfc tests: Update boilerplate from MIT X11 license to MIT Expat license
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-12 15:31:24 -07:00
Michael Vetter
b409c919a2 remove trailing whitespaces
Remove trailing whitespaces because they are not needed and jumping to
the end of al ine should do just that and not jump to the whitespace.
2015-05-15 13:10:15 -07:00
Marek Chalupa
2e20270280 connection-test: add tests for closure leaks
When we destroy closure, we are leaking memory sometimes.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2015-01-28 17:17:13 +00:00
Benjamin Herr
391820b0d6 connection: Leave fd open in wl_connection_destroy
Calling close() on the same file descriptor that a previous call to
close() already closed is wrong, and racy if another thread received
that same file descriptor as a eg. new socket or actual file.

There are two situations where wl_connection_destroy() would close its
file descriptor and then another function up in the call chain would
close the same file descriptor:

  * When wl_client_create() fails after calling wl_connection_create(),
    it will call wl_connection_destroy() before returning. However, its
    caller will always close the file descriptor if wl_client_create()
    fails.

  * wl_display_disconnect() unconditionally closes the display file
    descriptor and also calls wl_connection_destroy().

So these two seem to expect wl_connection_destroy() to leave the file
descriptor open. The other caller of wl_connection_destroy(),
wl_client_destroy(), does however expect wl_connection_destroy() to
close its file descriptor, alas.

This patch changes wl_connection_destroy() to indulge this majority of
two callers by simply not closing the file descriptor. For the benefit
of wl_client_destroy(), wl_connection_destroy() then returns the
unclosed file descriptor so that wl_client_destroy() can close it
itself.

Since wl_connection_destroy() is a private function called from few
places, changing its semantics seemed like the more expedient way to
address the double-close() problem than shuffling around the logic in
wl_client_create() to somehow enable it to always avoid calling
wl_connection_destroy().

Signed-off-by: Benjamin Herr <ben@0x539.de>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-04 11:26:22 +02:00
U. Artie Eoff
b41ded812d connection-test: check malloc result
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 14:59:33 -07:00
Ander Conselvan de Oliveira
bfc93649cb connection: Don't write past the end of the connection buffer
If a message was too big to fit in the connection buffer, the code
in wl_buffer_put would just write past the end of it.

I haven't seen any real world use case that would trigger this bug, but
it was possible to trigger it by sending a long enough string to the
wl_data_source.offer request.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=69267
2014-04-21 14:51:42 -07:00
U. Artie Eoff
3a1be1e6fe connection-test: assert closure is not NULL before invoking it
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
Jason Ekstrand
57f74af278 Update tests for wl_map changes and add a map_flags test 2013-06-05 17:55:14 -04:00
Jason Ekstrand
ca5b1946cb Change wl_closure_invoke to take an opcode instead of an actual function pointer
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-03-18 23:04:32 -04:00
Jonas Ådahl
cb73bffed5 client: Invoke new_id closure arguments as pointers instead of integers
This commit adds a flags parameter to wl_closure_invoke(). The so far
added flags are ment to specify if the invokation is client side or
server side. When on the server side, closure arguments of type 'new_id'
should be invoked as a integer id while on the client side they should
be invoked as a pointer to a proxy object.

This fixes a bug happening when the address of a client side 'new_id'
proxy object did not fit in a 32 bit integer.

krh: Squashed test suite compile fix from Jason Ekstrand.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-03-17 16:39:48 -04:00
Pekka Paalanen
bfdf44ec48 tests: rename temporary files
This is libwayland, not weston, so call the temporary files
wayland-tests-*, not weston-tests-*.

This is a candidate for the stable branch.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-12-03 10:10:22 -05:00
Sven Joachim
7415e8eb05 tests: Don't leave temporary files behind
Signed-off-by: Sven Joachim <svenjoac@gmx.de>
2012-12-03 09:55:58 -05:00
Kristian Høgsberg
53d24713a3 Change filedescriptor API to be thread safe
The update callback for the file descriptors was always a bit awkward and
un-intuitive.  The idea was that whenever the protocol code needed to
write data to the fd it would call the 'update' function.  This function
would adjust the mainloop so that it polls for POLLOUT on the fd so we
can eventually flush the data to the socket.

The problem is that in multi-threaded applications, any thread can issue
a request, which writes data to the output buffer and thus triggers the
update callback.  Thus, we'll be calling out with the display mutex
held and may call from any thread.

The solution is to eliminate the udpate callback and just require that
the application or server flushes all connection buffers before blocking.
This turns out to be a simpler API, although we now require clients to
deal with EAGAIN and non-blocking writes.  It also saves a few syscalls,
since the socket will be writable most of the time and most writes will
complete, so we avoid changing epoll to poll for POLLOUT, then write and
then change it back for each write.
2012-10-10 20:59:00 -04:00
Daniel Stone
3ec40512c7 More consistent ID printing
Use unsigned rather than signed for IDs, so they match up with what we
see in other prints.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:17:10 -04:00
Christopher James Halse Rogers
161c690b55 protocol: Add explicit nullable types
Most of the time it does not make sense to pass a NULL object, string, or array
to a protocol request. This commit adds an explicit “allow-null” attribute
to mark the request arguments where NULL makes sense.

Passing a NULL object, string, or array to a protocol request which is not
marked as allow-null is now an error. An implementation will never receive
a NULL value for these arguments from a client.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-07-02 13:53:02 -04:00
Dylan Noblesmith
b486e3aba5 tests: fix make check for out-of-tree builds
It was failing with missing include files.

While here, destroy the ugly "../src/..." include
paths used in the tests that was just hacking around
this problem in the Makefile:

sed -i s/..\\/src\\/// tests/*.c
2012-06-30 19:58:37 +00:00
Kristian Høgsberg
b576443a0e tests: Update test cases to new closure allocate convention 2012-06-15 16:09:39 -04:00
Daniel Stone
c5aba11acc Add support for signed 24.8 decimal numbers
'fixed' is a signed decimal type which offers a sign bit, 23 bits of
integer precision, and 8 bits of decimal precision.  This is exposed as
an opaque struct with conversion helpers to and from double and int on
the C API side.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:39 -04:00
Kristian Høgsberg
e7dd32710f tests: Test invoking closures built with wl_closure_vmarshal() 2012-04-22 14:17:27 -04:00
Kristian Høgsberg
1901d66ffc connection: Move closure object out of wl_connection 2012-04-22 13:49:35 -04:00
Kristian Høgsberg
ac06144cc9 tests: Fix signedness warnings 2012-04-13 10:11:11 -04:00
Kristian Høgsberg
9086b60d81 connection-test: Add test case to stress connection buffers
This catches the bug fixed in cab70c9e5d.
2012-03-24 14:35:53 -04:00
Kristian Høgsberg
b01ae07727 connection-test: Test fd transport 2012-03-24 14:27:30 -04:00
Kristian Høgsberg
fa4769cadd connection-test: Add more test cases 2012-03-23 16:57:34 -04:00
Kristian Høgsberg
33ad8a3315 connection-test: Store expected result in struct marshal_data 2012-03-23 16:56:19 -04:00
Kristian Høgsberg
0ca52cce98 tests: Add marshal+demarshal connection test 2012-03-23 11:41:34 -04:00
Kristian Høgsberg
f67f6395b1 tests: Use different connections for read and write tests
The connection tests so far only use one connection at a time, but this
prepares for tests that use a connection on both sides of the socket.
2012-03-23 11:32:17 -04:00
Kristian Høgsberg
7746a80e2a tests: Remove debug printf 2012-03-21 10:32:06 -04:00
Kristian Høgsberg
4bc5a0ab2c tests: Add demarshal tests 2012-03-05 22:26:17 -05:00
Kristian Høgsberg
b2afde6f18 tests: Add more marshal tests 2012-03-05 21:53:38 -05:00
Kristian Høgsberg
d86718fc33 tests: Simplify connection tests a bit 2012-03-05 21:40:01 -05:00
Kristian Høgsberg
87a1e59992 tests: Add connection marshalling tests 2012-03-03 00:29:21 -05:00
Kristian Høgsberg
22834deca7 tests: Add connection tests 2012-03-02 23:59:50 -05:00