From patchwork Fri Dec 15 19:01:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10115871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A689C60231 for ; Fri, 15 Dec 2017 19:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 985552A0F1 for ; Fri, 15 Dec 2017 19:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C4E32A0F9; Fri, 15 Dec 2017 19:01:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C0D52A0F1 for ; Fri, 15 Dec 2017 19:01:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75AA56E896; Fri, 15 Dec 2017 19:01:16 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 715336E896 for ; Fri, 15 Dec 2017 19:01:15 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2017 11:01:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,406,1508828400"; d="scan'208";a="2864669" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by fmsmga008.fm.intel.com with ESMTP; 15 Dec 2017 11:01:14 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Fri, 15 Dec 2017 11:01:11 -0800 Message-Id: <20171215190111.14866-1-antonio.argenziano@intel.com> X-Mailer: git-send-email 2.14.2 Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_ctx_param: Update invalid param X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Chris Wilson Cc: Michal Winiarski --- 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 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;