[PATCH i-g-t] tests/gem_ctx_param: Update invalid param

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since commit: drm/i915/scheduler: Support user-defined priorities, the
driver support an extra context param to set context's priority. Add
tests for that interface and update invalid tests.

Signed-off-by: Antonio Argenziano <antonio.argenziano@xxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Michal Winiarski <michal.winiarski@xxxxxxxxx>
---
 tests/gem_ctx_param.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 1 deletion(-)

diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index c20ae1ee..9a222e60 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -25,6 +25,7 @@
  */
 
 #include "igt.h"
+#include <limits.h>
 
 IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
 
@@ -136,11 +137,85 @@ igt_main
 		gem_context_set_param(fd, &arg);
 	}
 
+#define MAX_PRIO 1023
+#define MIN_PRIO -MAX_PRIO
+#define DEF_PRIO 0
+
+	arg.param = I915_CONTEXT_PARAM_PRIORITY;
+
+	igt_subtest("root-set-priority") {
+		arg.ctx_id = ctx;
+		arg.size = 0;
+
+		for (int i = MIN_PRIO; i <= MAX_PRIO; i += 1023) {
+			arg.value = i;
+			gem_context_set_param(fd, &arg);
+
+			gem_context_get_param(fd, &arg);
+			igt_assert(arg.value == i); /* Verify prio was set */
+		}
+	}
+
+	igt_subtest("root-set-priority-invalid-value") {
+		int prio_levels[] = {INT_MIN, MIN_PRIO - 1, MAX_PRIO + 1, INT_MAX};
+		int old_value;
+		arg.ctx_id = ctx;
+
+		gem_context_get_param(fd, &arg);
+		old_value = arg.value;
+
+		for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {
+			arg.value = prio_levels[i];
+			igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
+
+			gem_context_get_param(fd, &arg);
+			igt_assert(arg.value == old_value); /* Verify prio was not set */
+		}
+	}
+
+	igt_subtest("user-set-priority") {
+		arg.size = 0;
+
+		igt_fork(child, 1) {
+			igt_drop_root();
+			for (int i = MIN_PRIO; i <= DEF_PRIO; i += 1023) {
+				arg.value = i;
+				gem_context_set_param(fd, &arg);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert(arg.value == i); /* Verify prio was set */
+			}
+		}
+
+		igt_waitchildren();
+	}
+
+	igt_subtest("user-set-priority-invalid-value") {
+		int prio_levels[] = {DEF_PRIO + 1, MAX_PRIO};
+		arg.ctx_id = ctx;
+		arg.size = 0;
+
+		igt_fork(child, 1) {
+			igt_drop_root();
+
+			for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {
+				arg.value = prio_levels[i];
+				igt_assert_eq(__gem_context_set_param(fd, &arg), -EPERM);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert(arg.value == DEF_PRIO); /* Verify prio was not set */
+			}
+		}
+
+		igt_waitchildren();
+	}
+
+
 	/* NOTE: This testcase intentionally tests for the next free parameter
 	 * to catch ABI extensions. Don't "fix" this testcase without adding all
 	 * the tests for the new param first.
 	 */
-	arg.param = I915_CONTEXT_PARAM_BANNABLE + 1;
+	arg.param = I915_CONTEXT_PARAM_PRIORITY + 1;
 
 	igt_subtest("invalid-param-get") {
 		arg.ctx_id = ctx;
-- 
2.14.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux