From patchwork Fri May 2 11:16:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 4101711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ACC439F169 for ; Fri, 2 May 2014 11:17:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D59A220127 for ; Fri, 2 May 2014 11:17:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0EB77200DF for ; Fri, 2 May 2014 11:17:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9BAF56EEFB; Fri, 2 May 2014 04:17:18 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 91D506EEFB for ; Fri, 2 May 2014 04:17:17 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 02 May 2014 04:17:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,972,1389772800"; d="scan'208";a="524904011" Received: from gaia.fi.intel.com (HELO gaia) ([10.237.66.160]) by fmsmga001.fm.intel.com with ESMTP; 02 May 2014 04:17:15 -0700 Received: by gaia (Postfix, from userid 1000) id 70D0140BF8; Fri, 2 May 2014 14:16:29 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Fri, 2 May 2014 14:16:28 +0300 Message-Id: <1399029388-28462-1-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398928724-4997-1-git-send-email-chris@chris-wilson.co.uk> References: <1398928724-4997-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 1/1] tests/gem_reset_stats: EPERM check not needed X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Without root we used to get EPERM if we tried to aquire default context statistics. Now we have per fd statistics so only thing which is hidden from us without root access, is the global reset count. Drop EPERM and check that global reset count is always zero for nonroot. Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index c227798..898f696 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -913,11 +913,7 @@ static void test_reset_count(const bool create_ctx) igt_drop_root(); c2 = get_reset_count(fd, ctx); - - if (ctx == 0) - igt_assert(c2 == -EPERM); - else - igt_assert(c2 == 0); + igt_assert(c2 == 0); } igt_waitchildren(); @@ -952,45 +948,37 @@ static int _test_params(int fd, int ctx, uint32_t flags, uint32_t pad) return 0; } -typedef enum { root = 0, user } cap_t; - -static void _check_param_ctx(const int fd, const int ctx, const cap_t cap) +static void _check_param_ctx(const int fd, const int ctx) { const uint32_t bad = rand() + 1; - if (ctx == 0) { - if (cap == root) - igt_assert(_test_params(fd, ctx, 0, 0) == 0); - else - igt_assert(_test_params(fd, ctx, 0, 0) == -EPERM); - } - + igt_assert(_test_params(fd, ctx, 0, 0) == 0); igt_assert(_test_params(fd, ctx, 0, bad) == -EINVAL); igt_assert(_test_params(fd, ctx, bad, 0) == -EINVAL); igt_assert(_test_params(fd, ctx, bad, bad) == -EINVAL); } -static void check_params(const int fd, const int ctx, cap_t cap) +static void check_params(const int fd, const int ctx) { igt_assert(ioctl(fd, GET_RESET_STATS_IOCTL, 0) == -1); igt_assert(_test_params(fd, 0xbadbad, 0, 0) == -ENOENT); - _check_param_ctx(fd, ctx, cap); + _check_param_ctx(fd, ctx); } static void _test_param(const int fd, const int ctx) { - check_params(fd, ctx, root); + check_params(fd, ctx); igt_fork(child, 1) { - check_params(fd, ctx, root); + check_params(fd, ctx); igt_drop_root(); - check_params(fd, ctx, user); + check_params(fd, ctx); } - check_params(fd, ctx, root); + check_params(fd, ctx); igt_waitchildren(); }