diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-09-14 09:40:48 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-10-01 21:04:39 +0100 |
commit | 7ebb8bebcde790b8603f20cae63d2deb8c6bacb8 (patch) | |
tree | 05f0865bbede8a41e56b443e2e1e227cc68c6585 /tests/kms_getfb.c | |
parent | cab89ce2c5da684d01deff402d4e8e11441beadb (diff) |
igt/kms_getfb: Check the iface exists before use
If the driver doesn't support the getfb iface (e.g. because KMS has been
disabled), the ioctls will fail with ENOTSUP. This is expected, so skip
the test as nothing useful can be learnt.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'tests/kms_getfb.c')
-rw-r--r-- | tests/kms_getfb.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c index 81d796a4..07ffd79c 100644 --- a/tests/kms_getfb.c +++ b/tests/kms_getfb.c @@ -40,6 +40,40 @@ #include "drm.h" #include "drm_fourcc.h" +static bool has_getfb_iface(int fd) +{ + struct drm_mode_fb_cmd arg = { }; + int err; + + err = 0; + if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &arg)) + err = -errno; + switch (err) { + case -ENOTTY: /* ioctl unrecognised (kernel too old) */ + case -ENOTSUP: /* driver doesn't support KMS */ + return false; + default: + return true; + } +} + +static bool has_addfb2_iface(int fd) +{ + struct drm_mode_fb_cmd2 arg = { }; + int err; + + err = 0; + if (drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &arg)) + err = -errno; + switch (err) { + case -ENOTTY: /* ioctl unrecognised (kernel too old) */ + case -ENOTSUP: /* driver doesn't support KMS */ + return false; + default: + return true; + } +} + static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret) { struct drm_mode_fb_cmd2 add = { @@ -54,6 +88,7 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret) }; int size; + igt_require(has_addfb2_iface(fd)); igt_require_intel(fd); /* An explanation of the magic numbers can be found in kms_ccs.c. */ @@ -191,15 +226,16 @@ static void test_duplicate_handles(int fd) do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id); gem_close(fd, add.handles[0]); } - } igt_main { int fd; - igt_fixture + igt_fixture { fd = drm_open_driver_master(DRIVER_ANY); + igt_require(has_getfb_iface(fd)); + } igt_subtest_group test_handle_input(fd); |