diff --git a/compositor/main.c b/compositor/main.c index 72c47f7d..f673fa3a 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -816,6 +816,33 @@ weston_compositor_log_capabilities(struct weston_compositor *compositor) "presentation clock resolution: N/A\n"); } +static bool +check_compositor_capabilities(struct weston_compositor *compositor, + uint32_t mask) +{ + uint32_t missing = mask & ~compositor->capabilities; + unsigned i; + + if (missing == 0) + return true; + + weston_log("Quirk error, missing capabilities:\n"); + for (i = 0; i < ARRAY_LENGTH(capability_strings); i++) { + if (!(missing & capability_strings[i].bit)) + continue; + + weston_log_continue(STAMP_SPACE "- %s\n", + capability_strings[i].desc); + missing &= ~capability_strings[i].bit; + } + if (missing) { + weston_log_continue(STAMP_SPACE "- unlisted bits 0x%x\n", + missing); + } + + return false; +} + static void handle_primary_client_destroyed(struct wl_listener *listener, void *data) { @@ -3355,6 +3382,12 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data) goto out; } + if (!check_compositor_capabilities(wet.compositor, + test_data->test_quirks.required_capabilities)) { + ret = WET_MAIN_RET_MISSING_CAPS; + goto out; + } + weston_compositor_flush_heads_changed(wet.compositor); if (wet.init_failed) goto out; diff --git a/compositor/weston.h b/compositor/weston.h index 26807203..f166052f 100644 --- a/compositor/weston.h +++ b/compositor/weston.h @@ -95,6 +95,12 @@ text_backend_init(struct weston_compositor *ec); void text_backend_destroy(struct text_backend *text_backend); +/* + * Return value from wet_main() when + * weston_testsuite_quirks::required_capabilities are not met. + */ +#define WET_MAIN_RET_MISSING_CAPS 77 + int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data); diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 4daef0d3..a68febc5 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -198,6 +198,8 @@ struct weston_testsuite_quirks { bool gl_force_full_upload; /** Ensure GL shadow fb is used, and always repaint it fully. */ bool gl_force_full_redraw_of_shadow_fb; + /** Required enum weston_capability bit mask, otherwise skip run. */ + uint32_t required_capabilities; }; /** Weston test suite data that is given to compositor diff --git a/tests/weston-test-fixture-compositor.c b/tests/weston-test-fixture-compositor.c index 17160759..93d0fad0 100644 --- a/tests/weston-test-fixture-compositor.c +++ b/tests/weston-test-fixture-compositor.c @@ -42,6 +42,9 @@ #include "weston.h" #include "test-config.h" +static_assert(WET_MAIN_RET_MISSING_CAPS == RESULT_SKIP, + "wet_main() return value for skip is wrong"); + struct prog_args { int argc; char **argv;