diff --git a/tests/alpha-blending-test.c b/tests/alpha-blending-test.c index f9c591fc..e2936d4a 100644 --- a/tests/alpha-blending-test.c +++ b/tests/alpha-blending-test.c @@ -33,6 +33,7 @@ #include "weston-test-fixture-compositor.h" struct setup_args { + struct fixture_metadata meta; enum renderer_type renderer; }; @@ -40,8 +41,14 @@ static const int ALPHA_STEPS = 256; static const int BLOCK_WIDTH = 3; static const struct setup_args my_setup_args[] = { - { RENDERER_PIXMAN }, - { RENDERER_GL }, + { + .renderer = RENDERER_PIXMAN, + .meta.name = "pixman" + }, + { + .renderer = RENDERER_GL, + .meta.name = "GL" + }, }; static enum test_result_code @@ -57,7 +64,7 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg) return weston_test_harness_execute_as_client(harness, &setup); } -DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args); +DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); static void set_opaque_rect(struct client *client, diff --git a/tests/buffer-transforms-test.c b/tests/buffer-transforms-test.c index fdc86bba..26068729 100644 --- a/tests/buffer-transforms-test.c +++ b/tests/buffer-transforms-test.c @@ -33,11 +33,24 @@ #include "weston-test-fixture-compositor.h" #define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x -#define RENDERERS(s, t) \ - { RENDERER_PIXMAN, s, TRANSFORM(t) }, \ - { RENDERER_GL, s, TRANSFORM(t) } +#define RENDERERS(s, t) \ + { \ + .renderer = RENDERER_PIXMAN, \ + .scale = s, \ + .transform = WL_OUTPUT_TRANSFORM_ ## t, \ + .transform_name = #t, \ + .meta.name = "pixman " #s " " #t, \ + }, \ + { \ + .renderer = RENDERER_GL, \ + .scale = s, \ + .transform = WL_OUTPUT_TRANSFORM_ ## t, \ + .transform_name = #t, \ + .meta.name = "GL " #s " " #t, \ + } struct setup_args { + struct fixture_metadata meta; enum renderer_type renderer; int scale; enum wl_output_transform transform; @@ -70,7 +83,7 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg) return weston_test_harness_execute_as_client(harness, &setup); } -DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args); +DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); struct buffer_args { int scale; diff --git a/tests/output-transforms-test.c b/tests/output-transforms-test.c index 3ed19e39..b3425523 100644 --- a/tests/output-transforms-test.c +++ b/tests/output-transforms-test.c @@ -33,11 +33,24 @@ #include "weston-test-fixture-compositor.h" #define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x -#define RENDERERS(s, t) \ - { RENDERER_PIXMAN, s, TRANSFORM(t) }, \ - { RENDERER_GL, s, TRANSFORM(t) } +#define RENDERERS(s, t) \ + { \ + .renderer = RENDERER_PIXMAN, \ + .scale = s, \ + .transform = WL_OUTPUT_TRANSFORM_ ## t, \ + .transform_name = #t, \ + .meta.name = "pixman " #s " " #t, \ + }, \ + { \ + .renderer = RENDERER_GL, \ + .scale = s, \ + .transform = WL_OUTPUT_TRANSFORM_ ## t, \ + .transform_name = #t, \ + .meta.name = "GL " #s " " #t, \ + } struct setup_args { + struct fixture_metadata meta; enum renderer_type renderer; int scale; enum wl_output_transform transform; @@ -82,7 +95,7 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg) return weston_test_harness_execute_as_client(harness, &setup); } -DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args); +DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); struct buffer_args { int scale; diff --git a/tests/subsurface-shot-test.c b/tests/subsurface-shot-test.c index 4df9d3dc..d57c0f61 100644 --- a/tests/subsurface-shot-test.c +++ b/tests/subsurface-shot-test.c @@ -33,18 +33,29 @@ #include "weston-test-client-helper.h" #include "weston-test-fixture-compositor.h" -static const enum renderer_type renderers[] = { - RENDERER_PIXMAN, - RENDERER_GL, +struct setup_args { + struct fixture_metadata meta; + enum renderer_type renderer; +}; + +static const struct setup_args my_setup_args[] = { + { + .renderer = RENDERER_PIXMAN, + .meta.name = "pixman" + }, + { + .renderer = RENDERER_GL, + .meta.name = "GL" + }, }; static enum test_result_code -fixture_setup(struct weston_test_harness *harness, const enum renderer_type *arg) +fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg) { struct compositor_setup setup; compositor_setup_defaults(&setup); - setup.renderer = *arg; + setup.renderer = arg->renderer; setup.width = 320; setup.height = 240; setup.shell = SHELL_TEST_DESKTOP; @@ -52,7 +63,7 @@ fixture_setup(struct weston_test_harness *harness, const enum renderer_type *arg return weston_test_harness_execute_as_client(harness, &setup); } -DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, renderers); +DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); static struct wl_subcompositor * get_subcompositor(struct client *client) diff --git a/tests/viewporter-shot-test.c b/tests/viewporter-shot-test.c index b4f389c6..7a8226be 100644 --- a/tests/viewporter-shot-test.c +++ b/tests/viewporter-shot-test.c @@ -33,24 +33,35 @@ #include "weston-test-client-helper.h" #include "weston-test-fixture-compositor.h" -static const enum renderer_type renderers[] = { - RENDERER_PIXMAN, - RENDERER_GL, +struct setup_args { + struct fixture_metadata meta; + enum renderer_type renderer; +}; + +static const struct setup_args my_setup_args[] = { + { + .renderer = RENDERER_PIXMAN, + .meta.name = "pixman" + }, + { + .renderer = RENDERER_GL, + .meta.name = "GL" + }, }; static enum test_result_code fixture_setup(struct weston_test_harness *harness, - const enum renderer_type *renderer) + const struct setup_args *arg) { struct compositor_setup setup; compositor_setup_defaults(&setup); - setup.renderer = *renderer; + setup.renderer = arg->renderer; setup.shell = SHELL_TEST_DESKTOP; return weston_test_harness_execute_as_client(harness, &setup); } -DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, renderers); +DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); TEST(viewport_upscale_solid) diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h index 9e545cd9..7f736ec9 100644 --- a/tests/weston-test-runner.h +++ b/tests/weston-test-runner.h @@ -146,6 +146,20 @@ get_test_name(void); int get_test_fixture_index(void); +/** Metadata for fixture setup array elements + * + * Every type used as a fixture setup array's elements needs one member of + * this type, initialized. + * + * \sa DECLARE_FIXTURE_SETUP_WITH_ARG() + * + * \ingroup testharness + */ +struct fixture_metadata { + /** Human friendly name of the fixture setup */ + const char *name; +}; + /** Fixture setup array record * * Helper to store the attributes of the data array passed in to @@ -157,6 +171,7 @@ struct fixture_setup_array { const void *array; size_t element_size; int n_elements; + size_t meta_offset; }; const struct fixture_setup_array * @@ -222,18 +237,21 @@ fixture_setup_run_(struct weston_test_harness *harness, const void *arg_); * * \param func_ The function to be used as fixture setup. * \param array_ A static const array of arbitrary type. + * \param meta_ Name of the field with type struct fixture_metadata. * * \ingroup testharness */ -#define DECLARE_FIXTURE_SETUP_WITH_ARG(func_, array_) \ +#define DECLARE_FIXTURE_SETUP_WITH_ARG(func_, array_, meta_) \ const struct fixture_setup_array * \ fixture_setup_array_get_(void) \ { \ static const struct fixture_setup_array arr = { \ .array = array_, \ .element_size = sizeof(array_[0]), \ - .n_elements = ARRAY_LENGTH(array_) \ - }; \ + .n_elements = ARRAY_LENGTH(array_), \ + .meta_offset = offsetof(typeof(array_[0]), meta_), \ + }; \ + TYPEVERIFY(const struct fixture_metadata *, &array_[0].meta_); \ return &arr; \ } \ \