From patchwork Wed Nov 18 12:57:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 7648511 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7926D9F1D3 for ; Wed, 18 Nov 2015 12:53:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 972702062A for ; Wed, 18 Nov 2015 12:53:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B4394205EE for ; Wed, 18 Nov 2015 12:53:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31D0B72164; Wed, 18 Nov 2015 04:53:23 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EAA372164 for ; Wed, 18 Nov 2015 04:53:22 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Nov 2015 04:53:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,313,1444719600"; d="scan'208";a="853827334" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 18 Nov 2015 04:53:11 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Wed, 18 Nov 2015 14:57:11 +0200 Message-Id: <1447851432-30880-2-git-send-email-jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447851432-30880-1-git-send-email-jani.nikula@intel.com> References: <1447851432-30880-1-git-send-email-jani.nikula@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [PATCH i-g-t 2/3] tests: add context param to pm_backlight tests 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-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 We'll be adding more context for the subtests than just the max brightness. Signed-off-by: Jani Nikula --- tests/pm_backlight.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/pm_backlight.c b/tests/pm_backlight.c index bdc0e33de94c..c199b9bf4baf 100644 --- a/tests/pm_backlight.c +++ b/tests/pm_backlight.c @@ -35,6 +35,10 @@ #include #include +struct context { + int max; +}; + #define TOLERANCE 5 /* percent */ #define BACKLIGHT_PATH "/sys/class/backlight/intel_backlight" @@ -107,41 +111,41 @@ static void test_and_verify(int val) igt_assert_lte(val - tolerance, result); } -static void test_brightness(int max) +static void test_brightness(struct context *context) { test_and_verify(0); - test_and_verify(max); - test_and_verify(max / 2); + test_and_verify(context->max); + test_and_verify(context->max / 2); } -static void test_bad_brightness(int max) +static void test_bad_brightness(struct context *context) { int val; /* First write some sane value */ - backlight_write(max / 2, "brightness"); + backlight_write(context->max / 2, "brightness"); /* Writing invalid values should fail and not change the value */ igt_assert_lt(backlight_write(-1, "brightness"), 0); backlight_read(&val, "brightness"); - igt_assert_eq(val, max / 2); - igt_assert_lt(backlight_write(max + 1, "brightness"), 0); + igt_assert_eq(val, context->max / 2); + igt_assert_lt(backlight_write(context->max + 1, "brightness"), 0); backlight_read(&val, "brightness"); - igt_assert_eq(val, max / 2); + igt_assert_eq(val, context->max / 2); igt_assert_lt(backlight_write(INT_MAX, "brightness"), 0); backlight_read(&val, "brightness"); - igt_assert_eq(val, max / 2); + igt_assert_eq(val, context->max / 2); } -static void test_fade(int max) +static void test_fade(struct context *context) { int i; static const struct timespec ts = { .tv_sec = 0, .tv_nsec = FADESPEED*1000000 }; /* Fade out, then in */ - for (i = max; i > 0; i -= max / FADESTEPS) { + for (i = context->max; i > 0; i -= context->max / FADESTEPS) { test_and_verify(i); nanosleep(&ts, NULL); } - for (i = 0; i <= max; i += max / FADESTEPS) { + for (i = 0; i <= context->max; i += context->max / FADESTEPS) { test_and_verify(i); nanosleep(&ts, NULL); } @@ -149,22 +153,23 @@ static void test_fade(int max) igt_main { - int max, old; + struct context context = {0}; + int old; igt_skip_on_simulation(); igt_fixture { /* Get the max value and skip the whole test if sysfs interface not available */ igt_skip_on(backlight_read(&old, "brightness")); - igt_assert(backlight_read(&max, "max_brightness") > -1); + igt_assert(backlight_read(&context.max, "max_brightness") > -1); } igt_subtest("basic-brightness") - test_brightness(max); + test_brightness(&context); igt_subtest("bad-brightness") - test_bad_brightness(max); + test_bad_brightness(&context); igt_subtest("fade") - test_fade(max); + test_fade(&context); igt_fixture { /* Restore old brightness */