summaryrefslogtreecommitdiff
path: root/tests/kms_properties.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2017-04-12 17:08:40 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-04-12 17:21:24 +0200
commit1ace3e0210400b70c60fcac11217a5b28b20b86e (patch)
treea65ea672ddc5030137f09abd9fdb975a4c3d7e5d /tests/kms_properties.c
parent82fdfc65d81e08df08089c3c9cee65f9505c71e2 (diff)
tests/kms_properties: Add GET_PROPERTY ioctl sanity check
I've broken this accidentally. Let's make sure this doesn't happen anymore. Testcases suggested by Chris. Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'tests/kms_properties.c')
-rw-r--r--tests/kms_properties.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/kms_properties.c b/tests/kms_properties.c
index 591e1a01..c15026b8 100644
--- a/tests/kms_properties.c
+++ b/tests/kms_properties.c
@@ -358,6 +358,63 @@ static void test_object_invalid_properties(igt_display_t *display,
test_invalid_properties(display->drm_fd, id, type, output->id, DRM_MODE_OBJECT_CONNECTOR, atomic);
}
+static void get_prop_sanity(igt_display_t *display)
+{
+ int i, fd;
+ uint64_t *values;
+ struct drm_mode_property_enum *enums;
+
+ fd = display->drm_fd;
+
+ /*
+ * There's no way to enumerate all properties, we just have to
+ * brute-force the first few kms ids. 1000 should be enough.
+ */
+ for (i = 0; i < 1000; i++) {
+ struct drm_mode_get_property prop;
+
+ memset(&prop, 0, sizeof(prop));
+ prop.prop_id = i;
+
+ if (drmIoctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
+ continue;
+
+ if (prop.count_values) {
+ values = calloc(prop.count_values, sizeof(uint64_t));
+ igt_assert(values);
+ memset(values, 0x5c, sizeof(uint64_t)*prop.count_values);
+ prop.values_ptr = to_user_pointer(values);
+ }
+
+ /* despite what libdrm makes you believe, we never supply
+ * additional information for BLOB properties, only for enums
+ * and bitmasks */
+ igt_assert_eq(!!prop.count_enum_blobs,
+ !!(prop.flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)));
+ if (prop.flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK))
+ igt_assert(prop.count_enum_blobs == prop.count_values);
+
+ if (prop.count_enum_blobs) {
+ enums = calloc(prop.count_enum_blobs, sizeof(*enums));
+ memset(enums, 0x5c, sizeof(*enums)*prop.count_enum_blobs);
+ igt_assert(enums);
+ prop.enum_blob_ptr = to_user_pointer(enums);
+ }
+
+ do_ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop);
+
+ for (int j = 0; j < prop.count_values; j++) {
+ igt_assert(values[j] != 0x5c5c5c5c5c5c5c5cULL);
+
+ if (!(prop.flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)))
+ continue;
+ igt_assert(enums[j].value != 0x5c5c5c5c5c5c5c5cULL);
+ igt_assert(enums[j].value == values[j]);
+ igt_assert(enums[j].name[0] != '\0');
+ }
+ }
+}
+
static void invalid_properties(igt_display_t *display, bool atomic)
{
igt_output_t *output;
@@ -414,6 +471,9 @@ igt_main
igt_subtest("invalid-properties-atomic")
invalid_properties(&display, true);
+ igt_subtest("get_properties-sanity")
+ get_prop_sanity(&display);
+
igt_fixture {
igt_display_fini(&display);
}