[igt-dev] [PATCH i-g-t 5/8] tests/kms_lease: improve lesssee_list subtests
Daniel Vetter
daniel.vetter at ffwll.ch
Fri Nov 2 20:53:47 UTC 2018
It failed to clear the pad, which made me realize that it's missing
a few paranoid checks.
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
tests/kms_lease.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index f4e1082cbb2a..5d2f554d9bfc 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -317,9 +317,17 @@ static void lessee_list(data_t *data)
struct local_drm_mode_list_lessees mll;
uint32_t lessees[1];
+ mll.pad = 0;
+
/* Create a valid lease */
igt_assert_eq(make_lease(data, &lease), 0);
+ /* check for nested leases */
+ mll.count_lessees = 0;
+ mll.lessees_ptr = 0;
+ igt_assert_eq(list_lessees(lease.fd, &mll), 0);
+ igt_assert_eq(mll.count_lessees, 0);
+
/* Get the number of lessees */
mll.count_lessees = 0;
mll.lessees_ptr = 0;
@@ -328,6 +336,9 @@ static void lessee_list(data_t *data)
/* Make sure there's a single lessee */
igt_assert_eq(mll.count_lessees, 1);
+ /* invalid ptr */
+ igt_assert_eq(list_lessees(data->master.fd, &mll), -EFAULT);
+
mll.lessees_ptr = (uint64_t) (uintptr_t) &lessees[0];
igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
@@ -338,7 +349,16 @@ static void lessee_list(data_t *data)
/* Make sure the listed lease is the same as the one we created */
igt_assert_eq(lessees[0], lease.lessee_id);
+ /* invalid pad */
+ mll.pad = -1;
+ igt_assert_eq(list_lessees(data->master.fd, &mll), -EINVAL);
+ mll.pad = 0;
+
terminate_lease(&lease);
+
+ /* Make sure the lease is gone */
+ igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
+ igt_assert_eq(mll.count_lessees, 0);
}
/* Test getting the contents of a lease */
--
2.14.4
More information about the igt-dev
mailing list