summaryrefslogtreecommitdiff
path: root/tests/kms_vblank.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-09-04 19:38:46 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-09-05 09:17:15 +0100
commitc829766f3651c207e6fa4d38aaa7359ae276fb6c (patch)
tree4b4ae9dbd7844612395069ffc6a0a5364ba144c1 /tests/kms_vblank.c
parente0c3033a57d85c0d2eb33af0451afa16edc79f10 (diff)
igt/kms_vblank: Exercise some EINVAL
Feed some impossible garbage into drmWaitVblank and expect the kernel to report EINVAL. v2: Cancel the double negative of ~invalid_flags Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/kms_vblank.c')
-rw-r--r--tests/kms_vblank.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index b3cd2d93..1c0771c6 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -455,6 +455,48 @@ static void run_subtests_for_pipe(data_t *data)
}
}
+static void invalid_subtest(data_t *data, int fd)
+{
+ union drm_wait_vblank vbl;
+ unsigned long valid_flags;
+
+ igt_display_require_output_on_pipe(&data->display, 0);
+
+ /* First check all is well with a simple query */
+ memset(&vbl, 0, sizeof(vbl));
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ igt_assert_eq(wait_vblank(fd, &vbl), 0);
+
+ valid_flags = (_DRM_VBLANK_TYPES_MASK |
+ _DRM_VBLANK_FLAGS_MASK |
+ _DRM_VBLANK_HIGH_CRTC_MASK);
+
+ /* pick some interesting invalid permutations */
+ memset(&vbl, 0, sizeof(vbl));
+ vbl.request.type = _DRM_VBLANK_RELATIVE | ~valid_flags;
+ igt_assert_eq(wait_vblank(fd, &vbl), -EINVAL);
+ for (int bit = 0; bit < 32; bit++) {
+ int err;
+
+ if (valid_flags & (1 << bit))
+ continue;
+
+ memset(&vbl, 0, sizeof(vbl));
+ vbl.request.type = _DRM_VBLANK_RELATIVE | (1 << bit);
+ err = wait_vblank(fd, &vbl);
+ igt_assert_f(err == -EINVAL,
+ "vblank wait with invalid request.type bit %d [0x%08x] did not report -EINVAL, got %d\n",
+ bit, 1 << bit, err);
+ }
+
+ /* check the maximum pipe, nobody should have that many pipes! */
+ memset(&vbl, 0, sizeof(vbl));
+ vbl.request.type = _DRM_VBLANK_RELATIVE;
+ vbl.request.type |= _DRM_VBLANK_SECONDARY;
+ vbl.request.type |= _DRM_VBLANK_FLAGS_MASK;
+ igt_assert_eq(wait_vblank(fd, &vbl), -EINVAL);
+}
+
igt_main
{
int fd;
@@ -469,6 +511,9 @@ igt_main
igt_display_require_output(&data.display);
}
+ igt_subtest("invalid")
+ invalid_subtest(&data, fd);
+
igt_subtest("crtc-id")
crtc_id_subtest(&data, fd);