diff mbox

[i-g-t,3/3] tests/gem_reset_stats: Add test to check client bans

Message ID 1480599105-31479-3-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Dec. 1, 2016, 1:31 p.m. UTC
Client will get banned from creating new context
if it has managed to get > 3 context banned.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 tests/gem_reset_stats.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 5 deletions(-)

Comments

Chris Wilson Dec. 1, 2016, 2:06 p.m. UTC | #1
On Thu, Dec 01, 2016 at 03:31:45PM +0200, Mika Kuoppala wrote:
> Client will get banned from creating new context
> if it has managed to get > 3 context banned.

I'm not thrilled about baking that magic number into an ABI requirement.

Just make it N bans, test timing out after say 120s of happiness (with
skip)?
-Chris
diff mbox

Patch

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 669a30a..1b9b5cd 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -327,15 +327,15 @@  static void test_rs_ctx(const struct intel_execution_engine *e,
 	}
 }
 
-static void test_ban_ctx(const struct intel_execution_engine *e,
-			 const bool ban_default)
+static void __test_ban_ctx(int fd_bad,
+			   const struct intel_execution_engine *e,
+			   const bool ban_default)
 {
 	struct local_drm_i915_reset_stats rs_bad, rs_good;
-	int fd_bad, fd_good, i;
+	int fd_good, i;
 	uint32_t ctx_good, ctx_bad;
 	int active_count = 0, pending_count = 0;
 
-	fd_bad = drm_open_driver(DRIVER_INTEL);
 	fd_good = drm_open_driver(DRIVER_INTEL);
 
 	ctx_good = gem_context_create(fd_bad);
@@ -401,10 +401,44 @@  static void test_ban_ctx(const struct intel_execution_engine *e,
 	igt_assert_eq(rs_good.batch_active, 0);
 	igt_assert_eq(rs_good.batch_pending, 0);
 
-	close(fd_bad);
 	close(fd_good);
 }
 
+static void test_ban_ctx(const struct intel_execution_engine *e, bool ban_default)
+{
+	int fd;
+	fd = drm_open_driver(DRIVER_INTEL);
+
+	__test_ban_ctx(fd, e, ban_default);
+
+	close(fd);
+}
+
+static void test_ban_client(const struct intel_execution_engine *e)
+{
+	struct drm_i915_gem_context_create create;
+	int fd;
+	fd = drm_open_driver(DRIVER_INTEL);
+
+	__test_ban_ctx(fd, e, false);
+	igt_assert_lt(0, noop(fd, 0, e));
+
+	__test_ban_ctx(fd, e, false);
+	igt_assert_lt(0, noop(fd, 0, e));
+
+	__test_ban_ctx(fd, e, false);
+	igt_assert_lt(0, noop(fd, 0, e));
+
+	__test_ban_ctx(fd, e, false);
+
+	memset(&create, 0, sizeof(create));
+	igt_assert_eq(-1, igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create));
+	igt_assert_eq(-EIO, -errno);
+	igt_assert_lt(0, noop(fd, 0, e));
+
+	close(fd);
+}
+
 static void test_unrelated_ctx(const struct intel_execution_engine *e)
 {
 	int fd1,fd2;
@@ -844,6 +878,9 @@  igt_main
 		igt_subtest_f("ban-ctx-%s", e->name)
 			RUN_CTX_TEST(test_ban_ctx(e, false));
 
+		igt_subtest_f("ban-client-%s", e->name)
+			RUN_CTX_TEST(test_ban_client(e));
+
 		igt_subtest_f("reset-count-%s", e->name)
 			RUN_TEST(test_reset_count(e, false));