Commits (24)
......@@ -4,8 +4,46 @@ Contributing to Wayland
Sending patches
Patches should be sent to **wayland-devel@lists.freedesktop.org**, using
`git send-email`. See [git documentation] for help.
Patches should be sent via
[GitLab merge requests](https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.html).
Wayland is
[hosted on freedesktop.org's GitLab](https://gitlab.freedesktop.org/wayland/wayland/):
in order to submit code, you should create an account on this GitLab instance,
fork the core Wayland repository, push your changes to a branch in your new
repository, and then submit these patches for review through a merge request.
Wayland formerly accepted patches via `git-send-email`, sent to
**wayland-devel@lists.freedesktop.org**; these were
[tracked using Patchwork](https://patchwork.freedesktop.org/project/wayland/).
Some old patches continue to be sent this way, and we may accept small new
patches sent to the list, but please send all new patches through GitLab merge
Formatting and separating commits
Unlike many projects using GitHub and GitLab, Wayland has a
[linear, 'recipe' style history](http://www.bitsnbites.eu/git-history-work-log-vs-recipe/).
This means that every commit should be small, digestible, stand-alone, and
functional. Rather than a purely chronological commit history like this:
connection: plug a fd leak
plug another fd leak
connection: init fds to -1
close all fds
refactor checks into a new function
don't close fds we handed out
we aim to have a clean history which only reflects the final state, broken up
into functional groupings:
connection: Refactor out closure allocation
connection: Clear fds we shouldn't close to -1
connection: Make wl_closure_destroy() close fds of undispatched closures
This ensures that the final patch series only contains the final state,
without the changes and missteps taken along the development process.
The first line of a commit message should contain a prefix indicating
what part is affected by the patch followed by one sentence that
......@@ -45,7 +83,7 @@ We won't reject patches that lack S-o-b, but it is strongly recommended.
When you re-send patches, revised or not, it would be very good to document the
changes compared to the previous revision in the commit message and/or the
cover letter. If you have already received Reviewed-by or Acked-by tags, you
merge request. If you have already received Reviewed-by or Acked-by tags, you
should evaluate whether they still apply and include them in the respective
commit messages. Otherwise the tags may be lost, reviewers miss the credit they
deserve, and the patches may cause redundant review effort.
......@@ -54,78 +92,37 @@ deserve, and the patches may cause redundant review effort.
Tracking patches and following up
[Wayland Patchwork](http://patchwork.freedesktop.org/project/wayland/list/) is
used for tracking patches to Wayland. Xwayland patches are tracked with the
[Xorg project](https://patchwork.freedesktop.org/project/Xorg/list/)
instead. Weston uses
[GitLab merge requests](https://gitlab.freedesktop.org/wayland/weston/merge_requests)
for code review, and does not use mailing list review at all.
Libinput patches, even though they use the same mailing list as
Wayland, are not tracked in the Wayland Patchwork.
The following applies only to Wayland.
If a patch is not found in Patchwork, there is a high possibility for it to be
forgotten. Patches attached to bug reports or not arriving to the mailing list
because of e.g. subscription issues will not be in Patchwork because Patchwork
only collects patches sent to the list.
When you send a revised version of a patch, it would be very nice to mark your
old patch as superseded (or rejected, if that is applicable). You can change
the status of your own patches by registering to Patchwork - ownership is
identified by email address you use to register. Updating your patch status
appropriately will help maintainer work.
The following patch states are found in Patchwork:
- **New**:
Patches under discussion or not yet processed.
- **Under review**:
Mostly unused state.
- **Accepted**:
The patch is merged in the master branch upstream, as is or slightly
- **Rejected**:
The idea or approach is rejected and cannot be fixed by revising
the patch.
- **RFC**:
Request for comments, not meant to be merged as is.
- **Not applicable**:
The email was not actually a patch, or the patch is not for Wayland.
Libinput patches are usually automatically ignored by Wayland
Patchwork, but if they get through, they will be marked as Not
- **Changes requested**:
Reviewers determined that changes to the patch are needed. The
submitter is expected to send a revised version. (You should
not wait for your patch to be set to this state before revising,
- **Awaiting upstream**:
Mostly unused as the patch is waiting for upstream actions but
is not shown in the default list, which means it is easy to
- **Superseded**:
A revised version of the patch has been submitted.
- **Deferred**:
Used mostly during freeze periods before releases, to temporarily
hide patches that cannot be merged during a freeze.
Note, that in the default listing, only patches in *New* or *Under review* are
There is also a command line interface to Patchwork called `pwclient`, see
for links where to get it and the sample `.pwclientrc` for Wayland.
Once submitted to GitLab, your patches will be reviewed by the Wayland
development team on GitLab. Review may be entirely positive and result in your
code landing instantly, in which case, great! You're done. However, we may ask
you to make some revisions: fixing some bugs we've noticed, working to a
slightly different design, or adding documentation and tests.
If you do get asked to revise the patches, please bear in mind the notes above.
You should use `git rebase -i` to make revisions, so that your patches follow
the clear linear split documented above. Following that split makes it easier
for reviewers to understand your work, and to verify that the code you're
submitting is correct.
A common request is to split single large patch into multiple patches. This can
happen, for example, if when adding a new feature you notice a bug elsewhere
which you need to fix to progress. Separating these changes into separate
commits will allow us to verify and land the bugfix quickly, pushing part of
your work for the good of everyone, whilst revision and discussion continues on
the larger feature part. It also allows us to direct you towards reviewers who
best understand the different areas you are working on.
When you have made any requested changes, please rebase the commits, verify
that they still individually look good, then force-push your new branch to
GitLab. This will update the merge request and notify everyone subscribed to
your merge request, so they can review it again.
There are also
[many GitLab CLI clients](https://about.gitlab.com/applications/#cli-clients),
if you prefer to avoid the web interface. It may be difficult to follow review
comments without using the web interface though, so we do recommend using this
to go through the review process, even if you use other clients to track the
list of available patches.
Coding style
......@@ -210,12 +210,15 @@ noinst_PROGRAMS = \
exec-fd-leak-checker \
noinst_LTLIBRARIES += libtest-runner.la
noinst_LTLIBRARIES += \
libtest-runner.la \
libtest_helpers_la_SOURCES = tests/test-helpers.c
libtest_runner_la_SOURCES = \
tests/test-runner.c \
tests/test-runner.h \
tests/test-helpers.c \
tests/test-compositor.h \
libtest_runner_la_LIBADD = \
......@@ -223,9 +226,9 @@ libtest_runner_la_LIBADD = \
libwayland-util.la \
libwayland-client.la \
libwayland-server.la \
libtest-helpers.la \
-lrt -ldl $(FFI_LIBS)
array_test_SOURCES = tests/array-test.c
array_test_LDADD = libtest-runner.la
client_test_SOURCES = tests/client-test.c
......@@ -270,7 +273,6 @@ protocol_logger_test_LDADD = libtest-runner.la
headers_test_SOURCES = tests/headers-test.c \
tests/headers-protocol-test.c \
headers_test_LDADD = libtest-runner.la
nodist_headers_test_SOURCES = \
protocol/wayland-server-protocol-core.h \
......@@ -280,13 +282,12 @@ cpp_compile_test_SOURCES = tests/cpp-compile-test.cpp
fixed_benchmark_SOURCES = tests/fixed-benchmark.c
fixed_benchmark_LDADD = libtest-runner.la
os_wrappers_test_SOURCES = tests/os-wrappers-test.c
os_wrappers_test_LDADD = libtest-runner.la
exec_fd_leak_checker_SOURCES = tests/exec-fd-leak-checker.c
exec_fd_leak_checker_LDADD = libtest-runner.la
exec_fd_leak_checker_LDADD = libtest-helpers.la
EXTRA_DIST += tests/scanner-test.sh \
protocol/tests.xml \
......@@ -102,9 +102,6 @@ Clients and ports
- Investigate DirectFB on Wayland (or is that Wayland on DirectFB?)
- SDL port, bnf has work in progress here:
m4_define([wayland_major_version], [1])
m4_define([wayland_minor_version], [16])
m4_define([wayland_minor_version], [17])
m4_define([wayland_micro_version], [0])
......@@ -94,6 +94,8 @@
summary="method doesn't exist on the specified interface"/>
<entry name="no_memory" value="2"
summary="server is out of memory"/>
<entry name="implementation" value="3"
summary="implementation error in compositor"/>
<event name="delete_id">
......@@ -1397,9 +1399,9 @@
and clears pending damage. The server will clear the current
damage as it repaints the surface.
Alternatively, damage can be posted with wl_surface.damage_buffer
which uses buffer coordinates instead of surface coordinates,
and is probably the preferred and intuitive way of doing this.
Note! New clients should not use this request. Instead damage can be
posted with wl_surface.damage_buffer which uses buffer coordinates
instead of surface coordinates.
<arg name="x" type="int" summary="surface-local x coordinate"/>
<arg name="y" type="int" summary="surface-local y coordinate"/>
......@@ -1660,7 +1662,7 @@
<interface name="wl_seat" version="6">
<interface name="wl_seat" version="7">
<description summary="group of input devices">
A seat is a group of keyboards, pointer and touch devices. This
object is published as a global during start up, or when such a
......@@ -1769,7 +1771,7 @@
<interface name="wl_pointer" version="6">
<interface name="wl_pointer" version="7">
<description summary="pointer input device">
The wl_pointer interface represents one or more input devices,
such as mice, which control the pointer location and pointer_focus
......@@ -2092,7 +2094,7 @@
<interface name="wl_keyboard" version="6">
<interface name="wl_keyboard" version="7">
<description summary="keyboard input device">
The wl_keyboard interface represents one or more keyboards
associated with a seat.
......@@ -2113,6 +2115,9 @@
<description summary="keyboard mapping">
This event provides a file descriptor to the client which can be
memory-mapped to provide a keyboard mapping description.
From version 7 onwards, the fd must be mapped with MAP_PRIVATE by
the recipient, as MAP_SHARED may fail.
<arg name="format" type="uint" enum="keymap_format" summary="keymap format"/>
<arg name="fd" type="fd" summary="keymap file descriptor"/>
......@@ -2203,7 +2208,7 @@
<interface name="wl_touch" version="6">
<interface name="wl_touch" version="7">
<description summary="touchscreen input device">
The wl_touch interface represents a touchscreen
associated with a seat.
......@@ -2402,6 +2407,13 @@
The physical size can be set to zero if it doesn't make sense for this
output (e.g. for projectors or virtual outputs).
Note: wl_output only advertises partial information about the output
position and identification. Some compositors, for instance those not
implementing a desktop-style output layout or those exposing virtual
outputs, might fake this information. Instead of using x and y, clients
should use xdg_output.logical_position. Instead of using make and model,
clients should use xdg_output.name and xdg_output.description.
<arg name="x" type="int"
summary="x position within the global compositor space"/>
......@@ -2446,7 +2458,17 @@
the output device. This is not necessarily the same as
the output size in the global compositor space. For instance,
the output may be scaled, as described in wl_output.scale,
or transformed, as described in wl_output.transform.
or transformed, as described in wl_output.transform. Clients
willing to retrieve the output size in the global compositor
space should use xdg_output.logical_size instead.
Clients should not use the refresh rate to schedule frames. Instead,
they should use the wl_surface.frame event or the presentation-time
Note: this information is not always meaningful for all outputs. Some
compositors, such as those exposing virtual outputs, might fake the
refresh rate or the size.
<arg name="flags" type="uint" enum="mode" summary="bitfield of mode flags"/>
<arg name="width" type="int" summary="width of the mode in hardware units"/>
......@@ -695,6 +695,14 @@ wl_connection_demarshal(struct wl_connection *connection,
struct wl_closure *closure;
struct wl_array *array_extra;
/* Space for sender_id and opcode */
if (size < 2 * sizeof *p) {
wl_log("message too short, invalid header\n");
wl_connection_consume(connection, size);
errno = EINVAL;
return NULL;
closure = wl_closure_init(message, size, &num_arrays, NULL);
if (closure == NULL) {
wl_connection_consume(connection, size);
......@@ -1278,7 +1286,10 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
case 's':
fprintf(stderr, "\"%s\"", closure->args[i].s);
if (closure->args[i].s)
fprintf(stderr, "\"%s\"", closure->args[i].s);
fprintf(stderr, "nil");
case 'o':
if (closure->args[i].o)
......@@ -35,7 +35,6 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <expat.h>
#include <getopt.h>
#include <limits.h>
#include <unistd.h>
......@@ -48,6 +47,10 @@ extern char DTD_DATA_begin;
extern int DTD_DATA_len;
/* Expat must be included after libxml as both want to declare XMLCALL; see
* the Git commit that 'git blame' for this comment points to for more. */
#include <expat.h>
#include "wayland-util.h"
#define PROGRAM_NAME "wayland-scanner"
......@@ -133,6 +136,7 @@ is_dtd_valid(FILE *input, const char *filename)
rc = xmlValidateDtd(dtdctx, doc, dtd);
/* xmlIOParseDTD consumes buffer */
......@@ -370,7 +374,7 @@ desc_dump(char *desc, const char *fmt, ...)
static void
static void __attribute__ ((noreturn))
fail(struct location *loc, const char *msg, ...)
va_list ap;
......@@ -432,6 +436,7 @@ free_arg(struct arg *arg)
......@@ -185,6 +185,9 @@ display_protocol_error(struct wl_display *display, uint32_t code,
err = ENOMEM;
err = EPROTO;
err = EFAULT;
......@@ -324,6 +324,10 @@ wl_client_get_object(struct wl_client *client, uint32_t id);
wl_client_post_no_memory(struct wl_client *client);
wl_client_post_implementation_error(struct wl_client *client,
const char* msg, ...) WL_PRINTF(2,3);
wl_client_add_resource_created_listener(struct wl_client *client,
struct wl_listener *listener);
......@@ -273,17 +273,14 @@ wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode, ...)
wl_resource_queue_event_array(resource, opcode, args);
wl_resource_post_error(struct wl_resource *resource,
uint32_t code, const char *msg, ...)
static void
wl_resource_post_error_vargs(struct wl_resource *resource,
uint32_t code, const char *msg, va_list argp)
struct wl_client *client = resource->client;
char buffer[128];
va_list ap;
va_start(ap, msg);
vsnprintf(buffer, sizeof buffer, msg, ap);
vsnprintf(buffer, sizeof buffer, msg, argp);
* When a client aborts, its resources are destroyed in id order,
......@@ -298,6 +295,18 @@ wl_resource_post_error(struct wl_resource *resource,
WL_DISPLAY_ERROR, resource, code, buffer);
client->error = 1;
wl_resource_post_error(struct wl_resource *resource,
uint32_t code, const char *msg, ...)
va_list ap;
va_start(ap, msg);
wl_resource_post_error_vargs(resource, code, msg, ap);
static void
......@@ -641,6 +650,30 @@ wl_client_post_no_memory(struct wl_client *client)
/** Report an internal server error
* \param client The client object
* \param msg A printf-style format string
* \param ... Format string arguments
* Report an unspecified internal implementation error and disconnect
* the client.
* \memberof wl_client
wl_client_post_implementation_error(struct wl_client *client,
char const *msg, ...)
va_list ap;
va_start(ap, msg);
msg, ap);
wl_resource_post_no_memory(struct wl_resource *resource)
......@@ -68,6 +68,20 @@ extern "C" {
#define WL_PRINTF(x, y)
/** \class wl_object
* \brief A protocol object.
* A `wl_object` is an opaque struct identifying the protocol object
* underlying a `wl_proxy` or `wl_resource`.
* \note Functions accessing a `wl_object` are not normally used by client code.
* Clients should normally use the higher level interface generated by the
* scanner to interact with compositor objects.
struct wl_object;
* Protocol message signature
......@@ -752,3 +752,90 @@ TEST(closure_leaks_after_error)
/** Raw read from socket expecting wl_display.error
* \param sockfd The socket to read from.
* \param expected_error The expected wl_display error code.
* Reads the socket and manually parses one message, expecting it to be a
* wl_display.error with the wl_display as the originating object.
* Asserts that the received error code is expected_error.
static void
expect_error_recv(int sockfd, uint32_t expected_error)
uint32_t buf[1024];
ssize_t slen;
uint32_t opcode;
int str_len;
slen = recv(sockfd, buf, sizeof buf, 0);
assert(slen >= 2 * (ssize_t)sizeof (uint32_t));
opcode = buf[1] & 0xffff;
fprintf(stderr, "Received %zd bytes, object %u, opcode %u\n",
slen, buf[0], opcode);
/* check error event */
assert(buf[0] == 1);
assert(opcode == WL_DISPLAY_ERROR);
str_len = buf[4];
assert(str_len > 0);
assert(str_len <= slen - 5 * (ssize_t)sizeof (uint32_t));
fprintf(stderr, "Error event on object %u, code %u, message \"%*s\"\n",
buf[2], buf[3], str_len, (const char *)&buf[5]);
assert(buf[3] == expected_error);
/* A test for https://gitlab.freedesktop.org/wayland/wayland/issues/52
* trying to provoke a read from uninitialized memory in
* wl_connection_demarshal() for sender_id and opcode.
* This test might not fail as is even with #52 unfixed, since there is no way
* to detect what happens and the crash with zero size depends on stack content.
* However, running under Valgrind would point out invalid reads and use of
* uninitialized values.
struct wl_display *display;
struct wl_client *client;
int s[2];
uint32_t msg[3];
int bogus_size;
* The manufactured message has real size 12. Test all bogus sizes
* smaller than that, and zero as the last one since wl_closure_init
* handles zero specially and having garbage in the stack makes it more
* likely to crash in wl_connection_demarshal.
for (bogus_size = 11; bogus_size >= 0; bogus_size--) {
fprintf(stderr, "* bogus size %d\n", bogus_size);
assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
display = wl_display_create();
client = wl_client_create(display, s[0]);
/* manufacture a request that lies about its size */
msg[0] = 1; /* sender id: wl_display */
msg[1] = (bogus_size << 16) | WL_DISPLAY_SYNC; /* size and opcode */
msg[2] = 2; /* sync argument: new_id for wl_callback */
assert(send(s[1], msg, sizeof msg, 0) == sizeof msg);
wl_event_loop_dispatch(wl_display_get_event_loop(display), 0);
expect_error_recv(s[1], WL_DISPLAY_ERROR_INVALID_METHOD);
/* Do not wl_client_destroy, the error already caused it. */
......@@ -419,6 +419,46 @@ TEST(post_nomem_tst)
static void
struct client *c = client_connect();
struct wl_seat *seat = client_get_seat(c);
uint32_t object_id, protocol_error;
const struct wl_interface *interface;
assert(stop_display(c, 1) == -1);
int err = wl_display_get_error(c->wl_display);
fprintf(stderr, "Err is %i\n", err);
assert(err == EPROTO);
protocol_error = wl_display_get_protocol_error(c->wl_display,
assert(protocol_error == WL_DISPLAY_ERROR_IMPLEMENTATION);
assert(interface == &wl_display_interface);
wl_proxy_destroy((struct wl_proxy *) seat);
struct display *d = display_create();
struct client_info *cl;
wl_global_create(d->wl_display, &wl_seat_interface,
1, d, bind_seat);
cl = client_create_noarg(d, post_implementation_error_main);
wl_client_post_implementation_error(cl->wl_client, "Error %i", 20);
static void
register_reading(struct wl_display *display)
......@@ -35,7 +35,7 @@
#include "test-compositor.h"
extern int leak_check_enabled;
extern int fd_leak_check_enabled;
......@@ -70,8 +70,10 @@ FAIL_TEST(fail_kill)
char * volatile *null = 0;
* (char **) 0 = "Goodbye, world";
*null = "Goodbye, world";
......@@ -81,71 +83,11 @@ FAIL_TEST(sanity_assert)
void *p;
p = malloc(10); /* memory leak */
assert(p); /* assert that we got memory, also prevents
* the malloc from getting optimized away. */
free(NULL); /* NULL must not be counted */
volatile void *mem;
/* normally this should be on the beginning of the test.
* Here we need to be sure, that the leak checks are
* turned on */
mem = malloc(16);
struct wl_array array;
/* call into library that calls malloc */
wl_array_add(&array, 14);
/* not freeing array, must leak */
struct display *d = display_create();
client_create_noarg(d, sanity_malloc_direct);
struct display *d = display_create();
client_create_noarg(d, sanity_malloc_indirect);
int fd[2];
/* leak 2 file descriptors */
if (pipe(fd) < 0)
......@@ -183,7 +125,7 @@ sanity_fd_no_leak(void)
int fd[2];
/* leak 2 file descriptors */
if (pipe(fd) < 0)
......@@ -42,7 +42,7 @@
* See `man 7 unix`.
static const struct sockaddr_un example_sockaddr_un;
static struct sockaddr_un example_sockaddr_un;
#define TOO_LONG (1 + sizeof example_sockaddr_un.sun_path)
......@@ -69,6 +69,11 @@ TEST(socket_path_overflow_client_connect)
d = wl_display_connect(path);
assert(d == NULL);
assert(errno == ENAMETOOLONG);
/* This is useless, but prevents a warning about example_sockaddr_un
* being discarded from the compilation unit. */
strcpy(example_sockaddr_un.sun_path, "happy now clang?");
assert(example_sockaddr_un.sun_path[0] != '\0');
......@@ -156,7 +156,7 @@ run_client(void (*client_main)(void *data), void *data,
int wayland_sock, int client_pipe)
char s[8];
int cur_alloc, cur_fds;
int cur_fds;
int can_continue = 0;
/* Wait until display signals that client can continue */
......@@ -169,7 +169,6 @@ run_client(void (*client_main)(void *data), void *data,
snprintf(s, sizeof s, "%d", wayland_sock);
setenv("WAYLAND_SOCKET", s, 0);
cur_alloc = get_current_alloc_num();
cur_fds = count_open_fds();
......@@ -182,7 +181,7 @@ run_client(void (*client_main)(void *data), void *data,
if (!getenv("WAYLAND_SOCKET"))
check_leaks(cur_alloc, cur_fds);
static struct client_info *
......@@ -44,16 +44,10 @@
#include "test-runner.h"
static int num_alloc;
static void* (*sys_malloc)(size_t);
static void (*sys_free)(void*);
static void* (*sys_realloc)(void*, size_t);
static void* (*sys_calloc)(size_t, size_t);
/* when set to 1, check if tests are not leaking memory and opened files.
/* when set to 1, check if tests are not leaking opened files.
* It is turned on by default. It can be turned off by
* WAYLAND_TEST_NO_LEAK_CHECK environment variable. */
int leak_check_enabled;
int fd_leak_check_enabled;
/* when this var is set to 0, every call to test_set_timeout() is
* suppressed - handy when debugging the test. Can be set by
......@@ -65,40 +59,6 @@ static int is_atty = 0;
extern const struct test __start_test_section, __stop_test_section;
__attribute__ ((visibility("default"))) void *
malloc(size_t size)
return sys_malloc(size);
__attribute__ ((visibility("default"))) void
free(void* mem)
if (mem != NULL)
__attribute__ ((visibility("default"))) void *
realloc(void* mem, size_t size)
if (mem == NULL)
return sys_realloc(mem, size);
__attribute__ ((visibility("default"))) void *
calloc(size_t nmemb, size_t size)
if (sys_calloc == NULL)
return NULL;
return sys_calloc(nmemb, size);
static const struct test *
find_test(const char *name)
......@@ -156,25 +116,12 @@ sigalrm_handler(int signum)
return num_alloc;
check_leaks(int supposed_alloc, int supposed_fds)
check_fd_leaks(int supposed_fds)
int num_fds;
if (leak_check_enabled) {
if (supposed_alloc != num_alloc) {
fprintf(stderr, "Memory leak detected in test. "
"Allocated %d blocks, unfreed %d\n", num_alloc,
num_alloc - supposed_alloc);
if (fd_leak_check_enabled) {
num_fds = count_open_fds();
if (supposed_fds != num_fds) {
fprintf(stderr, "fd leak detected in test. "
......@@ -183,14 +130,14 @@ check_leaks(int supposed_alloc, int supposed_fds)
} else {
fprintf(stderr, "Leak checks disabled\n");
fprintf(stderr, "FD leak checks disabled\n");
static void
run_test(const struct test *t)
int cur_alloc, cur_fds;
int cur_fds;
struct sigaction sa;
if (timeouts_enabled) {
......@@ -200,7 +147,7 @@ run_test(const struct test *t)
assert(sigaction(SIGALRM, &sa, NULL) == 0);
cur_alloc = get_current_alloc_num();
//cur_alloc = get_current_alloc_num();
cur_fds = count_open_fds();
......@@ -209,7 +156,7 @@ run_test(const struct test *t)
if (timeouts_enabled)
check_leaks(cur_alloc, cur_fds);
......@@ -348,20 +295,14 @@ int main(int argc, char *argv[])
int total, pass;
siginfo_t info;
/* Load system malloc, free, and realloc */
sys_calloc = dlsym(RTLD_NEXT, "calloc");
sys_realloc = dlsym(RTLD_NEXT, "realloc");
sys_malloc = dlsym(RTLD_NEXT, "malloc");
sys_free = dlsym(RTLD_NEXT, "free");
if (isatty(fileno(stderr)))
is_atty = 1;
if (is_debugger_attached()) {
leak_check_enabled = 0;
fd_leak_check_enabled = 0;
timeouts_enabled = 0;
} else {
leak_check_enabled = !getenv("WAYLAND_TEST_NO_LEAK_CHECK");
fd_leak_check_enabled = !getenv("WAYLAND_TEST_NO_LEAK_CHECK");
timeouts_enabled = !getenv("WAYLAND_TEST_NO_TIMEOUTS");
......@@ -63,11 +63,8 @@ count_open_fds(void);
exec_fd_leak_check(int nr_expected_fds); /* never returns */
check_leaks(int supposed_allocs, int supposed_fds);
check_fd_leaks(int supposed_fds);
* set/reset the timeout in seconds. The timeout starts
......@@ -89,10 +86,10 @@ test_sleep(unsigned int);
do { \
extern int leak_check_enabled; \
leak_check_enabled = 0; \
do { \
extern int fd_leak_check_enabled; \
fd_leak_check_enabled = 0; \
} while (0);