test/libdrm_mock: take initial prop value as separate arg

drmModePropertyRes.values never holds the current value. Stop
abusing this field.
This commit is contained in:
Simon Ser 2023-02-15 18:38:59 +01:00
parent afeeafd6d7
commit 0811ce855b
5 changed files with 13 additions and 18 deletions

View file

@ -294,15 +294,14 @@ get_prop_index(uint32_t id)
uint32_t
liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane,
const drmModePropertyRes *prop)
const drmModePropertyRes *prop,
uint64_t value)
{
uint32_t prop_id;
prop_id = register_prop(prop);
plane->enabled_props[get_prop_index(prop_id)] = true;
if (prop->count_values == 1) {
plane->prop_values[get_prop_index(prop_id)] = prop->values[0];
}
plane->prop_values[get_prop_index(prop_id)] = value;
return prop_id;
}

View file

@ -42,6 +42,7 @@ liftoff_mock_plane_get_id(struct liftoff_mock_plane *plane);
uint32_t
liftoff_mock_plane_add_property(struct liftoff_mock_plane *plane,
const drmModePropertyRes *prop);
const drmModePropertyRes *prop,
uint64_t value);
#endif

View file

@ -46,7 +46,7 @@ test_basic(void)
* should mark that one as a possible candidate, but not the other
* one. */
strncpy(prop.name, "COLOR_RANGE", sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(mock_plane_ok, &prop);
liftoff_mock_plane_add_property(mock_plane_ok, &prop, 0);
drm_fd = liftoff_mock_drm_open();
device = liftoff_device_create(drm_fd);

View file

@ -360,17 +360,17 @@ run(const struct test_case *test)
prop_name = "alpha";
prop = (drmModePropertyRes){0};
strncpy(prop.name, prop_name, sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop, 0);
prop_name = "IN_FENCE_FD";
prop = (drmModePropertyRes){0};
strncpy(prop.name, prop_name, sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop, (uint64_t)-1);
prop_name = "FB_DAMAGE_CLIPS";
prop = (drmModePropertyRes){0};
strncpy(prop.name, prop_name, sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop);
liftoff_mock_plane_add_property(ctx.mock_plane, &prop, 0);
ctx.drm_fd = liftoff_mock_drm_open();
device = liftoff_device_create(ctx.drm_fd);

View file

@ -60,7 +60,7 @@ test_prop_default(const char *prop_name)
* device */
drmModePropertyRes prop = {0};
strncpy(prop.name, prop_name, sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(mock_plane_with_prop, &prop);
liftoff_mock_plane_add_property(mock_plane_with_prop, &prop, 0);
drm_fd = liftoff_mock_drm_open();
device = liftoff_device_create(drm_fd);
@ -139,7 +139,7 @@ test_ignore_alpha(void)
mock_plane = liftoff_mock_drm_create_plane(DRM_PLANE_TYPE_PRIMARY);
strncpy(prop.name, "alpha", sizeof(prop.name) - 1);
liftoff_mock_plane_add_property(mock_plane, &prop);
liftoff_mock_plane_add_property(mock_plane, &prop, 0);
drm_fd = liftoff_mock_drm_open();
device = liftoff_device_create(drm_fd);
@ -173,7 +173,6 @@ test_immutable_zpos(void)
{
struct liftoff_mock_plane *mock_plane1, *mock_plane2;
drmModePropertyRes prop = {0};
uint64_t prop_value;
int drm_fd;
struct liftoff_device *device;
struct liftoff_output *output;
@ -186,14 +185,10 @@ test_immutable_zpos(void)
strncpy(prop.name, "zpos", sizeof(prop.name) - 1);
prop.flags = DRM_MODE_PROP_IMMUTABLE;
prop.count_values = 1;
prop.values = &prop_value;
/* Plane 2 is always on top of plane 1, and this is immutable */
prop_value = 1;
liftoff_mock_plane_add_property(mock_plane1, &prop);
prop_value = 2;
liftoff_mock_plane_add_property(mock_plane2, &prop);
liftoff_mock_plane_add_property(mock_plane1, &prop, 1);
liftoff_mock_plane_add_property(mock_plane2, &prop, 2);
drm_fd = liftoff_mock_drm_open();
device = liftoff_device_create(drm_fd);