tests: introduce struct fixture_metadata

This allows tests to give a meaningful name for their fixture setups
when they use more than one of them.

If a test uses DECLARE_FIXTURE_SETUP_WITH_ARG(), it must now pass a
third argument naming the field which is struct fixture_metadata. This
also means that the fixture setup data must now be a struct, it cannot
be a plain type anymore. A compiler error is generated if the field type
is not the expected one.

All tests using DECLARE_FIXTURE_SETUP_WITH_ARG() and converted to the
new form and given names for their fixture setups.

The fixture setup names not actually used yet, that will be another
patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago committed by Pekka Paalanen
parent eb5a95bfc9
commit ef81388466
  1. 13
      tests/alpha-blending-test.c
  2. 21
      tests/buffer-transforms-test.c
  3. 21
      tests/output-transforms-test.c
  4. 23
      tests/subsurface-shot-test.c
  5. 23
      tests/viewporter-shot-test.c
  6. 24
      tests/weston-test-runner.h

@ -33,6 +33,7 @@
#include "weston-test-fixture-compositor.h" #include "weston-test-fixture-compositor.h"
struct setup_args { struct setup_args {
struct fixture_metadata meta;
enum renderer_type renderer; enum renderer_type renderer;
}; };
@ -40,8 +41,14 @@ static const int ALPHA_STEPS = 256;
static const int BLOCK_WIDTH = 3; static const int BLOCK_WIDTH = 3;
static const struct setup_args my_setup_args[] = { 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 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); 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 static void
set_opaque_rect(struct client *client, set_opaque_rect(struct client *client,

@ -33,11 +33,24 @@
#include "weston-test-fixture-compositor.h" #include "weston-test-fixture-compositor.h"
#define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x #define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x
#define RENDERERS(s, t) \ #define RENDERERS(s, t) \
{ RENDERER_PIXMAN, s, TRANSFORM(t) }, \ { \
{ RENDERER_GL, s, TRANSFORM(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 setup_args {
struct fixture_metadata meta;
enum renderer_type renderer; enum renderer_type renderer;
int scale; int scale;
enum wl_output_transform transform; 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); 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 { struct buffer_args {
int scale; int scale;

@ -33,11 +33,24 @@
#include "weston-test-fixture-compositor.h" #include "weston-test-fixture-compositor.h"
#define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x #define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x
#define RENDERERS(s, t) \ #define RENDERERS(s, t) \
{ RENDERER_PIXMAN, s, TRANSFORM(t) }, \ { \
{ RENDERER_GL, s, TRANSFORM(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 setup_args {
struct fixture_metadata meta;
enum renderer_type renderer; enum renderer_type renderer;
int scale; int scale;
enum wl_output_transform transform; 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); 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 { struct buffer_args {
int scale; int scale;

@ -33,18 +33,29 @@
#include "weston-test-client-helper.h" #include "weston-test-client-helper.h"
#include "weston-test-fixture-compositor.h" #include "weston-test-fixture-compositor.h"
static const enum renderer_type renderers[] = { struct setup_args {
RENDERER_PIXMAN, struct fixture_metadata meta;
RENDERER_GL, 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 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; struct compositor_setup setup;
compositor_setup_defaults(&setup); compositor_setup_defaults(&setup);
setup.renderer = *arg; setup.renderer = arg->renderer;
setup.width = 320; setup.width = 320;
setup.height = 240; setup.height = 240;
setup.shell = SHELL_TEST_DESKTOP; 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); 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 * static struct wl_subcompositor *
get_subcompositor(struct client *client) get_subcompositor(struct client *client)

@ -33,24 +33,35 @@
#include "weston-test-client-helper.h" #include "weston-test-client-helper.h"
#include "weston-test-fixture-compositor.h" #include "weston-test-fixture-compositor.h"
static const enum renderer_type renderers[] = { struct setup_args {
RENDERER_PIXMAN, struct fixture_metadata meta;
RENDERER_GL, 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 static enum test_result_code
fixture_setup(struct weston_test_harness *harness, fixture_setup(struct weston_test_harness *harness,
const enum renderer_type *renderer) const struct setup_args *arg)
{ {
struct compositor_setup setup; struct compositor_setup setup;
compositor_setup_defaults(&setup); compositor_setup_defaults(&setup);
setup.renderer = *renderer; setup.renderer = arg->renderer;
setup.shell = SHELL_TEST_DESKTOP; setup.shell = SHELL_TEST_DESKTOP;
return weston_test_harness_execute_as_client(harness, &setup); 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) TEST(viewport_upscale_solid)

@ -146,6 +146,20 @@ get_test_name(void);
int int
get_test_fixture_index(void); 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 /** Fixture setup array record
* *
* Helper to store the attributes of the data array passed in to * Helper to store the attributes of the data array passed in to
@ -157,6 +171,7 @@ struct fixture_setup_array {
const void *array; const void *array;
size_t element_size; size_t element_size;
int n_elements; int n_elements;
size_t meta_offset;
}; };
const struct fixture_setup_array * 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 func_ The function to be used as fixture setup.
* \param array_ A static const array of arbitrary type. * \param array_ A static const array of arbitrary type.
* \param meta_ Name of the field with type struct fixture_metadata.
* *
* \ingroup testharness * \ingroup testharness
*/ */
#define DECLARE_FIXTURE_SETUP_WITH_ARG(func_, array_) \ #define DECLARE_FIXTURE_SETUP_WITH_ARG(func_, array_, meta_) \
const struct fixture_setup_array * \ const struct fixture_setup_array * \
fixture_setup_array_get_(void) \ fixture_setup_array_get_(void) \
{ \ { \
static const struct fixture_setup_array arr = { \ static const struct fixture_setup_array arr = { \
.array = array_, \ .array = array_, \
.element_size = sizeof(array_[0]), \ .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; \ return &arr; \
} \ } \
\ \

Loading…
Cancel
Save