Fix printf format warnings

connection.c:530: warning: format '%lu' expects type 'long unsigned
int', but argument 2 has type 'unsigned int'

/connection.c:560: warning: format '%lu' expects type 'long unsigned
int', but argument 2 has type 'unsigned int'

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: put common test source files in a variable

Makes all test targets have the same common make dependencies.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: fail build if NDEBUG is defined

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: stylish test-runner.c

Fix a typo, add a comment, change the print format, and add a variable
that will ease implementing tests that are expected to fail.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: add support for tests expected to fail

Add a new macro FAIL_TEST that can be used to define tests that are
supposed to fail. To distinguish the supposed outcome of a test, add a
field to 'struct test'.

However, simply adding a field to 'struct test' will make all tests past
the first one in an executable to be garbage. Apparently, the variables
of type 'struct test' have different alignment when put into a special
section than otherwise, and the compiler will get the skip from one
'struct test' to the next wrong.

Explicitly specify the alingment of 'struct test' to be 16 bytes, which
is what it seems to be in the special section on x86_64.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: add sanity-test

Test the testing framework itself, so that it catches the errors we
expect it to.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: Make sure unused malloc() doesn't get optimized away
tests: Add more sanity test to make sure we catch different failure modes
protocol: Add ping event and corresponding pong request
tests: detect fd leaks

Detect file descriptor leaks in tests.

Add a sanity test to verify that we catch the leaks.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: plug fd leaks in free_source_with_data

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: support testing fd inheritance over exec

Add facility for testing how (many) file descriptors survive an exec.
This allows implementing O_CLOEXEC tests.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
os: wrap socket(SOCK_CLOEXEC) calls

Some system C libraries do not offer SOCK_CLOEXEC flag.

Add a new header for OS compatibility wrappers. Wrap socket() calls into
wl_os_socket_cloexec() which makes sure the O_CLOEXEC flag gets set on
the file descriptor.

On systems having SOCK_CLOEXEC this uses the old socket() call, and
falls back if it fails due to the flag (kernel not supporting it).

wayland-os.h is private and not exported.

Add close-on-exec tests for both normal and forced fallback paths.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
tests: add .gitignore

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Add wl_surface.enter and wl_surface.leave events

These events let us track when a surface enters or leaves the scanout region of
an output. This way if a surface moves to another output and that output is on
a different card, we can suggest the toolkit reallocate its buffers
appropriately.

Signed-off-by: Casey Dahlin <cdahlin@redhat.com>
Update TODO

Casey did surface.enter/leave.
connection: Dont put fds in the connection until we send the closure
connection: Move closure object out of wl_connection
connection: Make sure we can invoke closures built with wl_closure_vmarshal()
tests: Test invoking closures built with wl_closure_vmarshal()