diff --git a/compositor/main.c b/compositor/main.c index e7247c947..2c15d16aa 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -3283,15 +3283,12 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data) backend = weston_choose_default_backend(); } - wet.compositor = weston_compositor_create(display, log_ctx, &wet); + wet.compositor = weston_compositor_create(display, log_ctx, &wet, test_data); if (wet.compositor == NULL) { weston_log("fatal: failed to create compositor\n"); goto out; } - if (test_data) - weston_compositor_test_data_init(wet.compositor, test_data); - protocol_scope = weston_log_ctx_add_log_scope(log_ctx, "proto", "Wayland protocol dump for all clients.\n", diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 101b2b72d..44c7f24d6 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -197,6 +197,14 @@ struct weston_testsuite_quirks { }; /** Weston test suite data that is given to compositor + * + * It contains two members: + * + * 1. The struct weston_testsuite_quirks, which can be used by the tests to + * change certain behavior of Weston when running these tests. + * 2. The void *test_private_data member which can be used by the testsuite of + * projects that uses libweston in order to give arbitrary test data to the + * compositor. Its type should be defined by the testsuite of the project. * * \sa compositor_setup * \ingroup testharness @@ -1798,11 +1806,9 @@ weston_compositor_destroy(struct weston_compositor *ec); struct weston_compositor * weston_compositor_create(struct wl_display *display, - struct weston_log_context *log_ctx, void *user_data); + struct weston_log_context *log_ctx, void *user_data, + const struct weston_testsuite_data *test_data); -void -weston_compositor_test_data_init(struct weston_compositor *ec, - const struct weston_testsuite_data *test_data); void * weston_compositor_get_test_data(struct weston_compositor *ec); diff --git a/libweston/compositor.c b/libweston/compositor.c index 643425922..1a88f9644 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -7327,36 +7327,6 @@ debug_scene_graph_cb(struct weston_log_subscription *sub, void *data) weston_log_subscription_complete(sub); } -/** Init the compositor testsuite data - * - * The struct weston_testsuite_data contains two members: - * - * 1. The struct weston_testsuite_quirks, which can be used by the tests to - * change certain behavior of Weston when running these tests. - * - * 2. The void *test_private_data member which can be used by the test suite - * of projects that uses libweston in order to give arbitrary test data to the - * compositor. Its type should be defined by the test suite of the project. - * - * This function can be called at most once per compositor instance, just after - * creating the weston_compositor object and never again. This happens because - * changing the quirks after e.g. loading the backend is not going to work, - * there are certain behaviors that need to be set up before this point. - * - * \param ec The weston compositor. - * \param test_data The testsuite data. - * - * \ingroup compositor - * \sa weston_compositor_get_test_data - */ -WL_EXPORT void -weston_compositor_test_data_init(struct weston_compositor *ec, - const struct weston_testsuite_data *test_data) -{ - assert(ec->backend == NULL); - ec->test_data = *test_data; -} - /** Retrieve testsuite data from compositor * * The testsuite data can be defined by the test suite of projects that uses @@ -7383,6 +7353,7 @@ weston_compositor_get_test_data(struct weston_compositor *ec) * \param display The Wayland display to be used. * \param user_data A pointer to an object that can later be retrieved * \param log_ctx A pointer to weston_debug_compositor + * \param test_data Optional testsuite data, or NULL. * using the \ref weston_compositor_get_user_data function. * \return The compositor instance on success or NULL on failure. * @@ -7390,8 +7361,8 @@ weston_compositor_get_test_data(struct weston_compositor *ec) */ WL_EXPORT struct weston_compositor * weston_compositor_create(struct wl_display *display, - struct weston_log_context *log_ctx, - void *user_data) + struct weston_log_context *log_ctx, void *user_data, + const struct weston_testsuite_data *test_data) { struct weston_compositor *ec; struct wl_event_loop *loop; @@ -7403,6 +7374,9 @@ weston_compositor_create(struct wl_display *display, if (!ec) return NULL; + if (test_data) + ec->test_data = *test_data; + ec->weston_log_ctx = log_ctx; ec->wl_display = display; ec->user_data = user_data;