2012-12-08 01:50:29 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
2012-12-08 01:50:29 +04:00
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2012-12-08 01:50:29 +04:00
|
|
|
*/
|
|
|
|
|
2013-10-30 00:13:45 +04:00
|
|
|
#include "config.h"
|
|
|
|
|
2016-07-19 14:16:27 +03:00
|
|
|
#include <stdint.h>
|
2012-12-08 01:50:29 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
2015-03-30 13:37:55 +03:00
|
|
|
#include <string.h>
|
2019-04-27 00:57:31 +03:00
|
|
|
#include <errno.h>
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <pthread.h>
|
2023-06-28 13:45:07 +03:00
|
|
|
#include <semaphore.h>
|
2014-11-20 04:18:34 +03:00
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
#include <libweston/weston-log.h>
|
2019-07-16 23:44:21 +03:00
|
|
|
#include "backend.h"
|
2019-07-10 17:32:42 +03:00
|
|
|
#include "libweston-internal.h"
|
2016-06-03 16:45:21 +03:00
|
|
|
#include "compositor/weston.h"
|
2015-02-24 18:32:14 +03:00
|
|
|
#include "weston-test-server-protocol.h"
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
#include "weston.h"
|
|
|
|
#include "weston-testsuite-data.h"
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2015-06-16 01:37:10 +03:00
|
|
|
#include "shared/helpers.h"
|
2017-11-24 19:01:46 +03:00
|
|
|
#include "shared/timespec-util.h"
|
2023-06-28 13:43:03 +03:00
|
|
|
#include "shared/xalloc.h"
|
2015-06-16 01:37:10 +03:00
|
|
|
|
2017-11-29 04:42:47 +03:00
|
|
|
#define MAX_TOUCH_DEVICES 32
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_test {
|
|
|
|
struct weston_compositor *compositor;
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
struct wl_listener destroy_listener;
|
|
|
|
|
|
|
|
struct weston_log_scope *log;
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_layer layer;
|
2015-03-30 16:17:40 +03:00
|
|
|
struct weston_seat seat;
|
2017-11-29 04:42:47 +03:00
|
|
|
struct weston_touch_device *touch_device[MAX_TOUCH_DEVICES];
|
|
|
|
int nr_touch_devices;
|
2018-01-26 19:48:00 +03:00
|
|
|
bool is_seat_initialized;
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
|
|
|
|
pthread_t client_thread;
|
|
|
|
struct wl_event_source *client_source;
|
2023-06-28 13:43:03 +03:00
|
|
|
|
|
|
|
struct wl_list output_list;
|
|
|
|
struct wl_listener output_created_listener;
|
|
|
|
struct wl_listener output_destroyed_listener;
|
2012-12-08 01:50:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_test_surface {
|
|
|
|
struct weston_surface *surface;
|
2021-05-21 16:03:08 +03:00
|
|
|
struct wl_listener surface_destroy_listener;
|
Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
2012-12-08 01:50:29 +04:00
|
|
|
int32_t x, y;
|
|
|
|
struct weston_test *test;
|
|
|
|
};
|
|
|
|
|
2023-06-28 13:43:03 +03:00
|
|
|
struct weston_test_output {
|
|
|
|
struct weston_test *test;
|
|
|
|
struct weston_output *output;
|
|
|
|
struct wl_listener repaint_listener;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
static void
|
|
|
|
maybe_breakpoint(struct weston_test *test,
|
|
|
|
enum weston_test_breakpoint breakpoint,
|
|
|
|
void *resource)
|
|
|
|
{
|
|
|
|
struct wet_test_pending_breakpoint *bp, *tmp;
|
|
|
|
struct wet_testsuite_data *tsd = weston_compositor_get_test_data(test->compositor);
|
|
|
|
|
|
|
|
wl_list_for_each_safe(bp, tmp, &tsd->breakpoints.list, link) {
|
|
|
|
struct wet_test_active_breakpoint *active_bp;
|
|
|
|
|
|
|
|
if (breakpoint != bp->breakpoint)
|
|
|
|
continue;
|
|
|
|
if (bp->resource && resource != bp->resource)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Remove this breakpoint from the list; ownership passes to
|
|
|
|
* the active breakpoint */
|
|
|
|
wl_list_remove(&bp->link);
|
|
|
|
|
|
|
|
/* The active breakpoint and the pending one which triggered it
|
|
|
|
* are now owned by the client */
|
|
|
|
active_bp = xzalloc(sizeof(*active_bp));
|
|
|
|
active_bp->compositor = test->compositor;
|
|
|
|
active_bp->resource = resource;
|
|
|
|
active_bp->template_ = bp;
|
|
|
|
|
|
|
|
/* Wake the client with the active breakpoint, and wait for it
|
|
|
|
* to return control */
|
|
|
|
tsd->breakpoints.active_bp = active_bp;
|
|
|
|
wet_test_post_sem(&tsd->breakpoints.client_break);
|
|
|
|
wet_test_wait_sem(&tsd->breakpoints.server_release);
|
|
|
|
|
|
|
|
/* Only ever trigger a single breakpoint at a time */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-28 13:43:03 +03:00
|
|
|
static void
|
|
|
|
output_repaint_listener(struct wl_listener *listener, void *data)
|
|
|
|
{
|
2023-06-28 13:45:07 +03:00
|
|
|
struct weston_test_output *to =
|
|
|
|
container_of(listener, struct weston_test_output,
|
|
|
|
repaint_listener);
|
|
|
|
struct weston_head *head;
|
|
|
|
|
|
|
|
wl_list_for_each(head, &to->output->head_list, output_link) {
|
|
|
|
maybe_breakpoint(to->test, WESTON_TEST_BREAKPOINT_POST_REPAINT,
|
|
|
|
head);
|
|
|
|
}
|
2023-06-28 13:43:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
output_created_listener(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_output *output = data;
|
|
|
|
struct weston_test_output *to = xzalloc(sizeof(*to));
|
|
|
|
struct weston_test *test =
|
|
|
|
container_of(listener, struct weston_test,
|
|
|
|
output_created_listener);
|
|
|
|
|
|
|
|
to->test = test;
|
|
|
|
to->output = output;
|
|
|
|
to->repaint_listener.notify = output_repaint_listener;
|
|
|
|
wl_signal_add(&output->frame_signal, &to->repaint_listener);
|
|
|
|
wl_list_insert(&test->output_list, &to->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
output_destroyed_listener(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_output *output = data;
|
|
|
|
struct weston_test_output *to, *tmp;
|
|
|
|
struct weston_test *test =
|
|
|
|
container_of(listener, struct weston_test,
|
|
|
|
output_destroyed_listener);
|
|
|
|
|
|
|
|
wl_list_for_each_safe(to, tmp, &test->output_list, link) {
|
|
|
|
if (to->output != output)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wl_list_remove(&to->repaint_listener.link);
|
|
|
|
wl_list_remove(&to->link);
|
|
|
|
free(to);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 04:42:47 +03:00
|
|
|
static void
|
|
|
|
touch_device_add(struct weston_test *test)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
int i = test->nr_touch_devices;
|
|
|
|
|
|
|
|
assert(i < MAX_TOUCH_DEVICES);
|
|
|
|
assert(!test->touch_device[i]);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof buf, "test-touch-device-%d", i);
|
|
|
|
|
|
|
|
test->touch_device[i] = weston_touch_create_touch_device(
|
|
|
|
test->seat.touch_state, buf, NULL, NULL);
|
|
|
|
test->nr_touch_devices++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
touch_device_remove(struct weston_test *test)
|
|
|
|
{
|
|
|
|
int i = test->nr_touch_devices - 1;
|
|
|
|
|
|
|
|
assert(i >= 0);
|
|
|
|
assert(test->touch_device[i]);
|
|
|
|
weston_touch_device_destroy(test->touch_device[i]);
|
|
|
|
test->touch_device[i] = NULL;
|
|
|
|
--test->nr_touch_devices;
|
|
|
|
}
|
|
|
|
|
2018-01-26 19:48:00 +03:00
|
|
|
static int
|
|
|
|
test_seat_init(struct weston_test *test)
|
|
|
|
{
|
2018-02-26 15:14:14 +03:00
|
|
|
assert(!test->is_seat_initialized &&
|
|
|
|
"Trying to add already added test seat");
|
|
|
|
|
2018-01-26 19:48:00 +03:00
|
|
|
/* create our own seat */
|
|
|
|
weston_seat_init(&test->seat, test->compositor, "test-seat");
|
|
|
|
test->is_seat_initialized = true;
|
|
|
|
|
|
|
|
/* add devices */
|
|
|
|
weston_seat_init_pointer(&test->seat);
|
|
|
|
if (weston_seat_init_keyboard(&test->seat, NULL) < 0)
|
|
|
|
return -1;
|
|
|
|
weston_seat_init_touch(&test->seat);
|
2017-11-29 04:42:47 +03:00
|
|
|
touch_device_add(test);
|
2018-01-26 19:48:00 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-26 15:14:14 +03:00
|
|
|
static void
|
|
|
|
test_seat_release(struct weston_test *test)
|
|
|
|
{
|
2017-11-29 04:42:47 +03:00
|
|
|
while (test->nr_touch_devices > 0)
|
|
|
|
touch_device_remove(test);
|
|
|
|
|
2018-02-26 15:14:14 +03:00
|
|
|
assert(test->is_seat_initialized &&
|
|
|
|
"Trying to release already released test seat");
|
|
|
|
test->is_seat_initialized = false;
|
|
|
|
weston_seat_release(&test->seat);
|
|
|
|
memset(&test->seat, 0, sizeof test->seat);
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
static struct weston_seat *
|
|
|
|
get_seat(struct weston_test *test)
|
|
|
|
{
|
2015-03-30 16:17:40 +03:00
|
|
|
return &test->seat;
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
struct weston_seat *seat = get_seat(test);
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
weston_test_send_pointer_position(resource,
|
|
|
|
wl_fixed_from_double(pointer->pos.c.x),
|
|
|
|
wl_fixed_from_double(pointer->pos.c.y));
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-04 17:02:26 +03:00
|
|
|
test_surface_committed(struct weston_surface *surface,
|
|
|
|
struct weston_coord_surface new_origin)
|
2012-12-08 01:50:29 +04:00
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
struct weston_test_surface *test_surface = surface->committed_private;
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_test *test = test_surface->test;
|
2022-11-09 22:39:08 +03:00
|
|
|
struct weston_coord_global pos;
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2023-06-28 19:24:30 +03:00
|
|
|
if (!weston_surface_has_content(surface))
|
|
|
|
return;
|
|
|
|
|
2023-06-28 19:21:17 +03:00
|
|
|
weston_surface_map(test_surface->surface);
|
|
|
|
|
2022-11-09 22:39:08 +03:00
|
|
|
pos.c = weston_coord(test_surface->x, test_surface->y);
|
|
|
|
weston_view_set_position(test_surface->view, pos);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2023-06-28 19:22:14 +03:00
|
|
|
if (wl_list_empty(&test_surface->view->layer_link.link)) {
|
|
|
|
weston_view_move_to_layer(test_surface->view,
|
|
|
|
&test->layer.view_list);
|
|
|
|
}
|
|
|
|
|
2013-11-14 09:55:57 +04:00
|
|
|
weston_view_update_transform(test_surface->view);
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
|
2021-05-21 16:03:08 +03:00
|
|
|
static int
|
|
|
|
test_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|
|
|
{
|
2021-07-31 18:25:41 +03:00
|
|
|
return snprintf(buf, len, "test suite surface");
|
2021-05-21 16:03:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_surface_destroy(struct weston_test_surface *test_surface)
|
|
|
|
{
|
|
|
|
weston_view_destroy(test_surface->view);
|
|
|
|
|
|
|
|
test_surface->surface->committed = NULL;
|
|
|
|
test_surface->surface->committed_private = NULL;
|
|
|
|
weston_surface_set_label_func(test_surface->surface, NULL);
|
|
|
|
|
|
|
|
wl_list_remove(&test_surface->surface_destroy_listener.link);
|
|
|
|
free(test_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_surface_handle_surface_destroy(struct wl_listener *l, void *data)
|
|
|
|
{
|
|
|
|
struct weston_test_surface *test_surface =
|
|
|
|
wl_container_of(l, test_surface, surface_destroy_listener);
|
|
|
|
|
|
|
|
assert(test_surface->surface == data);
|
|
|
|
|
|
|
|
test_surface_destroy(test_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct weston_test_surface *
|
|
|
|
weston_test_surface_create(struct wl_resource *test_resource,
|
|
|
|
struct weston_surface *surface)
|
|
|
|
{
|
|
|
|
struct wl_client *client = wl_resource_get_client(test_resource);
|
|
|
|
struct wl_resource *display_resource;
|
|
|
|
struct weston_test_surface *test_surface;
|
|
|
|
|
|
|
|
test_surface = zalloc(sizeof *test_surface);
|
|
|
|
if (!test_surface)
|
|
|
|
goto err_post_no_mem;
|
|
|
|
|
|
|
|
test_surface->surface = surface;
|
|
|
|
test_surface->test = wl_resource_get_user_data(test_resource);
|
|
|
|
|
|
|
|
test_surface->view = weston_view_create(surface);
|
|
|
|
if (!test_surface->view)
|
|
|
|
goto err_free_surface;
|
|
|
|
|
|
|
|
/* Protocol does not define this error so abuse wl_display */
|
|
|
|
display_resource = wl_client_get_object(client, 1);
|
|
|
|
if (weston_surface_set_role(surface, "weston_test_surface",
|
|
|
|
display_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT) < 0)
|
|
|
|
goto err_free_view;
|
|
|
|
|
|
|
|
surface->committed_private = test_surface;
|
|
|
|
surface->committed = test_surface_committed;
|
|
|
|
weston_surface_set_label_func(surface, test_surface_get_label);
|
|
|
|
|
|
|
|
test_surface->surface_destroy_listener.notify =
|
|
|
|
test_surface_handle_surface_destroy;
|
|
|
|
wl_signal_add(&surface->destroy_signal,
|
|
|
|
&test_surface->surface_destroy_listener);
|
|
|
|
|
|
|
|
return test_surface;
|
|
|
|
|
|
|
|
err_free_view:
|
|
|
|
weston_view_destroy(test_surface->view);
|
|
|
|
|
|
|
|
err_free_surface:
|
|
|
|
free(test_surface);
|
|
|
|
|
|
|
|
err_post_no_mem:
|
|
|
|
wl_resource_post_no_memory(test_resource);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
static void
|
|
|
|
move_surface(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
int32_t x, int32_t y)
|
|
|
|
{
|
2013-06-26 00:18:35 +04:00
|
|
|
struct weston_surface *surface =
|
|
|
|
wl_resource_get_user_data(surface_resource);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_test_surface *test_surface;
|
2021-05-21 16:03:08 +03:00
|
|
|
struct wl_resource *display_resource;
|
|
|
|
|
|
|
|
if (surface->committed &&
|
|
|
|
surface->committed != test_surface_committed) {
|
|
|
|
display_resource = wl_client_get_object(client, 1);
|
|
|
|
wl_resource_post_error(display_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"weston_test.move_surface: wl_surface@%u has a role.",
|
|
|
|
wl_resource_get_id(surface_resource));
|
|
|
|
return;
|
|
|
|
}
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
test_surface = surface->committed_private;
|
2021-05-21 16:03:08 +03:00
|
|
|
if (!test_surface)
|
|
|
|
test_surface = weston_test_surface_create(resource, surface);
|
|
|
|
if (!test_surface)
|
|
|
|
return;
|
2012-12-08 01:50:29 +04:00
|
|
|
|
|
|
|
test_surface->x = x;
|
|
|
|
test_surface->y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
move_pointer(struct wl_client *client, struct wl_resource *resource,
|
2017-12-13 14:27:55 +03:00
|
|
|
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
|
2012-12-08 01:50:29 +04:00
|
|
|
int32_t x, int32_t y)
|
|
|
|
{
|
2013-06-26 00:18:35 +04:00
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_seat *seat = get_seat(test);
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
2014-10-05 23:39:14 +04:00
|
|
|
struct weston_pointer_motion_event event = { 0 };
|
2022-02-04 01:40:10 +03:00
|
|
|
struct weston_coord_global pos;
|
2017-11-24 19:01:46 +03:00
|
|
|
struct timespec time;
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2022-02-04 01:40:10 +03:00
|
|
|
pos.c = weston_coord(x, y);
|
2014-10-05 23:39:14 +04:00
|
|
|
event = (struct weston_pointer_motion_event) {
|
|
|
|
.mask = WESTON_POINTER_MOTION_REL,
|
2023-07-18 21:51:07 +03:00
|
|
|
.rel = weston_coord_global_sub(pos, pointer->pos).c,
|
2014-10-05 23:39:14 +04:00
|
|
|
};
|
2022-02-04 01:40:10 +03:00
|
|
|
|
2017-12-13 14:27:55 +03:00
|
|
|
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
2017-11-24 19:01:46 +03:00
|
|
|
|
|
|
|
notify_motion(seat, &time, &event);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
|
|
|
notify_pointer_position(test, resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_button(struct wl_client *client, struct wl_resource *resource,
|
2017-12-13 14:27:55 +03:00
|
|
|
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
|
2012-12-08 01:50:29 +04:00
|
|
|
int32_t button, uint32_t state)
|
|
|
|
{
|
2017-11-16 19:20:55 +03:00
|
|
|
struct timespec time;
|
|
|
|
|
2013-06-26 00:18:35 +04:00
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_seat *seat = get_seat(test);
|
|
|
|
|
2017-12-13 14:27:55 +03:00
|
|
|
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
2017-11-16 19:20:55 +03:00
|
|
|
|
|
|
|
notify_button(seat, &time, button, state);
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
|
2017-12-18 13:16:55 +03:00
|
|
|
static void
|
|
|
|
send_axis(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
|
|
|
|
uint32_t axis, wl_fixed_t value)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
|
|
|
struct weston_seat *seat = get_seat(test);
|
|
|
|
struct timespec time;
|
|
|
|
struct weston_pointer_axis_event axis_event;
|
|
|
|
|
|
|
|
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
|
|
|
axis_event.axis = axis;
|
|
|
|
axis_event.value = wl_fixed_to_double(value);
|
|
|
|
axis_event.has_discrete = false;
|
|
|
|
axis_event.discrete = 0;
|
|
|
|
|
|
|
|
notify_axis(seat, &time, &axis_event);
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
static void
|
|
|
|
activate_surface(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
struct weston_surface *surface = surface_resource ?
|
2013-06-26 00:18:35 +04:00
|
|
|
wl_resource_get_user_data(surface_resource) : NULL;
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_seat *seat;
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard;
|
2012-12-08 01:50:29 +04:00
|
|
|
|
|
|
|
seat = get_seat(test);
|
2015-08-01 00:55:32 +03:00
|
|
|
keyboard = weston_seat_get_keyboard(seat);
|
2012-12-08 01:50:29 +04:00
|
|
|
if (surface) {
|
2016-06-30 05:04:06 +03:00
|
|
|
weston_seat_set_keyboard_focus(seat, surface);
|
2015-08-01 00:55:32 +03:00
|
|
|
notify_keyboard_focus_in(seat, &keyboard->keys,
|
2012-12-08 01:50:29 +04:00
|
|
|
STATE_UPDATE_AUTOMATIC);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
notify_keyboard_focus_out(seat);
|
2016-06-30 05:04:06 +03:00
|
|
|
weston_seat_set_keyboard_focus(seat, surface);
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_key(struct wl_client *client, struct wl_resource *resource,
|
2017-12-13 14:27:57 +03:00
|
|
|
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
|
2012-12-08 01:50:29 +04:00
|
|
|
uint32_t key, enum wl_keyboard_key_state state)
|
|
|
|
{
|
2013-06-26 00:18:35 +04:00
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct weston_seat *seat = get_seat(test);
|
2017-11-16 19:20:57 +03:00
|
|
|
struct timespec time;
|
|
|
|
|
2017-12-13 14:27:57 +03:00
|
|
|
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2017-11-16 19:20:57 +03:00
|
|
|
notify_key(seat, &time, key, state, STATE_UPDATE_AUTOMATIC);
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|
|
|
|
|
2015-03-30 13:37:55 +03:00
|
|
|
static void
|
|
|
|
device_release(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, const char *device)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
|
|
|
struct weston_seat *seat = get_seat(test);
|
|
|
|
|
|
|
|
if (strcmp(device, "pointer") == 0) {
|
|
|
|
weston_seat_release_pointer(seat);
|
|
|
|
} else if (strcmp(device, "keyboard") == 0) {
|
|
|
|
weston_seat_release_keyboard(seat);
|
|
|
|
} else if (strcmp(device, "touch") == 0) {
|
2017-11-29 04:42:47 +03:00
|
|
|
touch_device_remove(test);
|
2015-03-30 13:37:55 +03:00
|
|
|
weston_seat_release_touch(seat);
|
|
|
|
} else if (strcmp(device, "seat") == 0) {
|
2018-02-26 15:14:14 +03:00
|
|
|
test_seat_release(test);
|
2015-03-30 13:37:55 +03:00
|
|
|
} else {
|
|
|
|
assert(0 && "Unsupported device");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_add(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, const char *device)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
|
|
|
struct weston_seat *seat = get_seat(test);
|
|
|
|
|
|
|
|
if (strcmp(device, "pointer") == 0) {
|
|
|
|
weston_seat_init_pointer(seat);
|
|
|
|
} else if (strcmp(device, "keyboard") == 0) {
|
|
|
|
weston_seat_init_keyboard(seat, NULL);
|
|
|
|
} else if (strcmp(device, "touch") == 0) {
|
|
|
|
weston_seat_init_touch(seat);
|
2017-11-29 04:42:47 +03:00
|
|
|
touch_device_add(test);
|
2018-01-26 19:48:00 +03:00
|
|
|
} else if (strcmp(device, "seat") == 0) {
|
|
|
|
test_seat_init(test);
|
2015-03-30 13:37:55 +03:00
|
|
|
} else {
|
|
|
|
assert(0 && "Unsupported device");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-13 14:27:58 +03:00
|
|
|
static void
|
|
|
|
send_touch(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
|
|
|
|
int32_t touch_id, wl_fixed_t x, wl_fixed_t y, uint32_t touch_type)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
2018-02-26 15:43:00 +03:00
|
|
|
struct weston_touch_device *device = test->touch_device[0];
|
2017-12-13 14:27:58 +03:00
|
|
|
struct timespec time;
|
2023-02-07 16:08:54 +03:00
|
|
|
struct weston_coord_global pos;
|
2017-12-13 14:27:58 +03:00
|
|
|
|
2018-02-26 15:43:00 +03:00
|
|
|
assert(device);
|
|
|
|
|
2017-12-13 14:27:58 +03:00
|
|
|
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
|
|
|
|
|
2023-02-07 16:13:48 +03:00
|
|
|
if (touch_type == WL_TOUCH_UP) {
|
|
|
|
if (x != 0 || y != 0) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
WESTON_TEST_ERROR_TOUCH_UP_WITH_COORDINATE,
|
|
|
|
"Test protocol sent valid "
|
|
|
|
"coordinates with WL_TOUCH_UP");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-07 16:08:54 +03:00
|
|
|
notify_touch(device, &time, touch_id, NULL, touch_type);
|
|
|
|
} else {
|
|
|
|
pos.c = weston_coord_from_fixed(x, y);
|
|
|
|
notify_touch(device, &time, touch_id, &pos, touch_type);
|
|
|
|
}
|
2017-12-13 14:27:58 +03:00
|
|
|
}
|
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
static void
|
|
|
|
client_break(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t _breakpoint, uint32_t resource_id)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
|
|
|
struct wet_testsuite_data *tsd = weston_compositor_get_test_data(test->compositor);
|
|
|
|
struct wet_test_pending_breakpoint *bp;
|
|
|
|
enum weston_test_breakpoint breakpoint = _breakpoint;
|
|
|
|
|
|
|
|
bp = calloc(1, sizeof(*bp));
|
|
|
|
bp->breakpoint = breakpoint;
|
|
|
|
|
|
|
|
if (resource_id != 0) {
|
|
|
|
struct wl_resource *resource =
|
|
|
|
wl_client_get_object(client, resource_id);
|
|
|
|
assert(resource);
|
|
|
|
bp->resource = wl_resource_get_user_data(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_insert(&tsd->breakpoints.list, &bp->link);
|
|
|
|
}
|
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
static const struct weston_test_interface test_implementation = {
|
2012-12-08 01:50:29 +04:00
|
|
|
move_surface,
|
|
|
|
move_pointer,
|
|
|
|
send_button,
|
2017-12-18 13:16:55 +03:00
|
|
|
send_axis,
|
2012-12-08 01:50:29 +04:00
|
|
|
activate_surface,
|
2013-10-30 00:13:45 +04:00
|
|
|
send_key,
|
2015-03-30 13:37:55 +03:00
|
|
|
device_release,
|
|
|
|
device_add,
|
2017-12-13 14:27:58 +03:00
|
|
|
send_touch,
|
2023-06-28 13:45:07 +03:00
|
|
|
client_break,
|
2012-12-08 01:50:29 +04:00
|
|
|
};
|
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
static void
|
|
|
|
destroy_test(struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
struct weston_test *test = wl_resource_get_user_data(resource);
|
|
|
|
struct wet_testsuite_data *tsd = weston_compositor_get_test_data(test->compositor);
|
|
|
|
|
|
|
|
assert(tsd->wl_client);
|
|
|
|
tsd->wl_client = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
static void
|
|
|
|
bind_test(struct wl_client *client, void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
|
|
|
struct weston_test *test = data;
|
2023-06-28 13:45:07 +03:00
|
|
|
struct wet_testsuite_data *tsd = weston_compositor_get_test_data(test->compositor);
|
2012-12-08 01:50:29 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
resource = wl_resource_create(client, &weston_test_interface, 1, id);
|
2014-07-11 14:33:02 +04:00
|
|
|
if (!resource) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-04 02:13:33 +04:00
|
|
|
wl_resource_set_implementation(resource,
|
2023-06-28 13:45:07 +03:00
|
|
|
&test_implementation, test,
|
|
|
|
destroy_test);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
/* There can only be one wl_client bound */
|
|
|
|
assert(!tsd->wl_client);
|
|
|
|
tsd->wl_client = client;
|
2012-12-08 01:50:29 +04:00
|
|
|
notify_pointer_position(test, resource);
|
|
|
|
}
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
static void
|
|
|
|
client_thread_cleanup(void *data_)
|
|
|
|
{
|
|
|
|
struct wet_testsuite_data *data = data_;
|
|
|
|
|
|
|
|
close(data->thread_event_pipe);
|
|
|
|
data->thread_event_pipe = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
client_thread_routine(void *data_)
|
|
|
|
{
|
|
|
|
struct wet_testsuite_data *data = data_;
|
|
|
|
|
|
|
|
pthread_setname_np(pthread_self(), "client");
|
|
|
|
pthread_cleanup_push(client_thread_cleanup, data);
|
|
|
|
data->run(data);
|
|
|
|
pthread_cleanup_pop(true);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
client_thread_join(struct weston_test *test)
|
|
|
|
{
|
|
|
|
assert(test->client_source);
|
|
|
|
|
|
|
|
pthread_join(test->client_thread, NULL);
|
|
|
|
wl_event_source_remove(test->client_source);
|
|
|
|
test->client_source = NULL;
|
|
|
|
|
|
|
|
weston_log_scope_printf(test->log, "Test thread reaped.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
handle_client_thread_event(int fd, uint32_t mask, void *data_)
|
|
|
|
{
|
|
|
|
struct weston_test *test = data_;
|
|
|
|
|
|
|
|
weston_log_scope_printf(test->log,
|
|
|
|
"Received thread event mask 0x%x\n", mask);
|
|
|
|
|
|
|
|
if (mask != WL_EVENT_HANGUP)
|
|
|
|
weston_log("%s: unexpected event %u\n", __func__, mask);
|
|
|
|
|
|
|
|
client_thread_join(test);
|
|
|
|
weston_compositor_exit(test->compositor);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
create_client_thread(struct weston_test *test, struct wet_testsuite_data *data)
|
|
|
|
{
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
int pipefd[2] = { -1, -1 };
|
|
|
|
sigset_t saved;
|
|
|
|
sigset_t blocked;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
weston_log_scope_printf(test->log, "Creating a thread for running tests...\n");
|
|
|
|
|
|
|
|
if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) < 0) {
|
|
|
|
weston_log("Creating pipe for a client thread failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(test->compositor->wl_display);
|
|
|
|
test->client_source = wl_event_loop_add_fd(loop, pipefd[0],
|
|
|
|
WL_EVENT_READABLE,
|
|
|
|
handle_client_thread_event,
|
|
|
|
test);
|
|
|
|
close(pipefd[0]);
|
|
|
|
|
|
|
|
if (!test->client_source) {
|
|
|
|
weston_log("Adding client thread fd to event loop failed.\n");
|
|
|
|
goto out_pipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->thread_event_pipe = pipefd[1];
|
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
ret = sem_init(&data->breakpoints.client_break, 0, 0);
|
|
|
|
if (ret != 0) {
|
|
|
|
weston_log("Creating breakpoint semaphore failed: %s (%d)\n",
|
|
|
|
strerror(errno), errno);
|
|
|
|
goto out_source;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sem_init(&data->breakpoints.server_release, 0, 0);
|
|
|
|
if (ret != 0) {
|
|
|
|
weston_log("Creating release semaphore failed: %s (%d)\n",
|
|
|
|
strerror(errno), errno);
|
|
|
|
goto out_source;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
/* Ensure we don't accidentally get signals to the thread. */
|
|
|
|
sigfillset(&blocked);
|
|
|
|
sigdelset(&blocked, SIGSEGV);
|
|
|
|
sigdelset(&blocked, SIGFPE);
|
|
|
|
sigdelset(&blocked, SIGILL);
|
|
|
|
sigdelset(&blocked, SIGCONT);
|
|
|
|
sigdelset(&blocked, SIGSYS);
|
|
|
|
if (pthread_sigmask(SIG_BLOCK, &blocked, &saved) != 0)
|
|
|
|
goto out_source;
|
|
|
|
|
|
|
|
ret = pthread_create(&test->client_thread, NULL,
|
|
|
|
client_thread_routine, data);
|
|
|
|
|
|
|
|
pthread_sigmask(SIG_SETMASK, &saved, NULL);
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
weston_log("Creating client thread failed: %s (%d)\n",
|
|
|
|
strerror(ret), ret);
|
|
|
|
goto out_source;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_source:
|
|
|
|
data->thread_event_pipe = -1;
|
|
|
|
wl_event_source_remove(test->client_source);
|
|
|
|
test->client_source = NULL;
|
|
|
|
|
|
|
|
out_pipe:
|
|
|
|
close(pipefd[1]);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
idle_launch_testsuite(void *test_)
|
|
|
|
{
|
|
|
|
struct weston_test *test = test_;
|
2020-10-19 22:06:22 +03:00
|
|
|
struct wet_testsuite_data *data = weston_compositor_get_test_data(test->compositor);
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
2023-07-04 00:39:38 +03:00
|
|
|
wl_list_init(&data->breakpoints.list);
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
switch (data->type) {
|
|
|
|
case TEST_TYPE_CLIENT:
|
|
|
|
if (create_client_thread(test, data) < 0) {
|
|
|
|
weston_log("Error: creating client thread for test suite failed.\n");
|
|
|
|
weston_compositor_exit_with_code(test->compositor,
|
|
|
|
RESULT_HARD_ERROR);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEST_TYPE_PLUGIN:
|
|
|
|
data->compositor = test->compositor;
|
|
|
|
weston_log_scope_printf(test->log,
|
|
|
|
"Running tests from idle handler...\n");
|
|
|
|
data->run(data);
|
|
|
|
weston_compositor_exit(test->compositor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEST_TYPE_STANDALONE:
|
|
|
|
weston_log("Error: unknown test internal type %d.\n",
|
|
|
|
data->type);
|
|
|
|
weston_compositor_exit_with_code(test->compositor,
|
|
|
|
RESULT_HARD_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_compositor_destroy(struct wl_listener *listener,
|
|
|
|
void *weston_compositor)
|
|
|
|
{
|
2023-06-28 13:43:03 +03:00
|
|
|
struct weston_compositor *compositor = weston_compositor;
|
2023-06-28 13:45:07 +03:00
|
|
|
struct wet_testsuite_data *data;
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
struct weston_test *test;
|
2023-06-28 13:43:03 +03:00
|
|
|
struct weston_output *output;
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
|
|
|
|
test = wl_container_of(listener, test, destroy_listener);
|
2023-06-28 13:45:07 +03:00
|
|
|
data = weston_compositor_get_test_data(test->compositor);
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
|
2022-01-19 19:40:06 +03:00
|
|
|
wl_list_remove(&test->destroy_listener.link);
|
2023-06-28 13:43:03 +03:00
|
|
|
wl_list_remove(&test->output_created_listener.link);
|
|
|
|
wl_list_remove(&test->output_destroyed_listener.link);
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
output_destroyed_listener(&test->output_destroyed_listener,
|
|
|
|
output);
|
|
|
|
}
|
2022-01-19 19:40:06 +03:00
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
if (test->client_source) {
|
|
|
|
weston_log_scope_printf(test->log, "Cancelling client thread...\n");
|
|
|
|
pthread_cancel(test->client_thread);
|
|
|
|
client_thread_join(test);
|
|
|
|
}
|
|
|
|
|
2020-02-03 03:59:52 +03:00
|
|
|
if (test->is_seat_initialized)
|
|
|
|
test_seat_release(test);
|
|
|
|
|
2023-06-28 13:45:07 +03:00
|
|
|
data->wl_client = NULL;
|
|
|
|
|
2020-02-03 03:59:52 +03:00
|
|
|
wl_list_remove(&test->layer.view_list.link);
|
|
|
|
wl_list_remove(&test->layer.link);
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
weston_log_scope_destroy(test->log);
|
2020-02-03 03:59:52 +03:00
|
|
|
free(test);
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
WL_EXPORT int
|
2016-12-02 16:21:46 +03:00
|
|
|
wet_module_init(struct weston_compositor *ec,
|
|
|
|
int *argc, char *argv[])
|
2012-12-08 01:50:29 +04:00
|
|
|
{
|
|
|
|
struct weston_test *test;
|
2023-06-28 13:43:03 +03:00
|
|
|
struct weston_output *output;
|
2012-12-08 01:50:29 +04:00
|
|
|
struct wl_event_loop *loop;
|
|
|
|
|
2013-08-08 05:57:05 +04:00
|
|
|
test = zalloc(sizeof *test);
|
2012-12-08 01:50:29 +04:00
|
|
|
if (test == NULL)
|
|
|
|
return -1;
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
if (!weston_compositor_add_destroy_listener_once(ec,
|
|
|
|
&test->destroy_listener,
|
|
|
|
handle_compositor_destroy)) {
|
|
|
|
free(test);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
test->compositor = ec;
|
2016-12-17 15:40:51 +03:00
|
|
|
weston_layer_init(&test->layer, ec);
|
|
|
|
weston_layer_set_position(&test->layer, WESTON_LAYER_POSITION_CURSOR - 1);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2023-06-28 13:43:03 +03:00
|
|
|
wl_list_init(&test->output_list);
|
|
|
|
wl_list_for_each(output, &ec->output_list, link)
|
|
|
|
output_created_listener(&test->output_created_listener, output);
|
|
|
|
test->output_created_listener.notify = output_created_listener;
|
|
|
|
wl_signal_add(&ec->output_created_signal, &test->output_created_listener);
|
|
|
|
test->output_destroyed_listener.notify = output_destroyed_listener;
|
|
|
|
wl_signal_add(&ec->output_destroyed_signal,
|
|
|
|
&test->output_destroyed_listener);
|
|
|
|
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
test->log = weston_compositor_add_log_scope(ec, "test-harness-plugin",
|
|
|
|
"weston-test plugin's own actions",
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
if (wl_global_create(ec->wl_display, &weston_test_interface, 1,
|
2013-07-09 03:03:57 +04:00
|
|
|
test, bind_test) == NULL)
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
goto out_free;
|
2012-12-08 01:50:29 +04:00
|
|
|
|
2018-01-26 19:48:00 +03:00
|
|
|
if (test_seat_init(test) == -1)
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
goto out_free;
|
2015-03-30 16:17:40 +03:00
|
|
|
|
2012-12-08 01:50:29 +04:00
|
|
|
loop = wl_display_get_event_loop(ec->wl_display);
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
wl_event_loop_add_idle(loop, idle_launch_testsuite, test);
|
2012-12-08 01:50:29 +04:00
|
|
|
|
|
|
|
return 0;
|
tests: thread-based client harness
This replaces the old test harness with a new one.
The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.
The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.
The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.
The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.
This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.
Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.
The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-01 15:02:15 +03:00
|
|
|
|
|
|
|
out_free:
|
|
|
|
wl_list_remove(&test->destroy_listener.link);
|
|
|
|
free(test);
|
|
|
|
return -1;
|
2012-12-08 01:50:29 +04:00
|
|
|
}
|