From patchwork Wed Apr 2 11:06:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Antti_Koskip=C3=A4=C3=A4?= X-Patchwork-Id: 3928181 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 101D1BF540 for ; Wed, 2 Apr 2014 11:07:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FA7D2025A for ; Wed, 2 Apr 2014 11:07:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 56D0F2025B for ; Wed, 2 Apr 2014 11:07:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0D346EA62; Wed, 2 Apr 2014 04:07:25 -0700 (PDT) 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 C77716EA63 for ; Wed, 2 Apr 2014 04:07:23 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 02 Apr 2014 04:07:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,779,1389772800"; d="scan'208";a="512776548" Received: from unknown (HELO sahapukki.fi.intel.com) ([10.237.72.180]) by fmsmga002.fm.intel.com with ESMTP; 02 Apr 2014 04:06:31 -0700 From: Antti Koskipaa To: intel-gfx@lists.freedesktop.org Date: Wed, 2 Apr 2014 14:06:26 +0300 Message-Id: <1396436790-14313-4-git-send-email-antti.koskipaa@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1396436790-14313-1-git-send-email-antti.koskipaa@linux.intel.com> References: <1396436790-14313-1-git-send-email-antti.koskipaa@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/7] kms_cursor_crc: Use a function pointer to call test 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 More tests are coming, and this allows us to not repeat the boilerplate code in run_test() for each subtest. Signed-off-by: Antti Koskipaa --- tests/kms_cursor_crc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c index 8802da6..60b50b5 100644 --- a/tests/kms_cursor_crc.c +++ b/tests/kms_cursor_crc.c @@ -54,6 +54,7 @@ typedef struct { igt_crc_t ref_crc; bool crc_must_match; int left, right, top, bottom; + int curw, curh; /* cursor size */ } test_data_t; static void draw_cursor(cairo_t *cr, int x, int y, int w) @@ -133,12 +134,14 @@ static void do_test(test_data_t *test_data, } static void test_crc(test_data_t *test_data, - bool onscreen, int cursor_w, int cursor_h) + bool onscreen) { int left = test_data->left; int right = test_data->right; int top = test_data->top; int bottom = test_data->bottom; + int cursor_w = test_data->curw; + int cursor_h = test_data->curh; if (onscreen) { /* cursor onscreen, crc should match, except when white visible cursor is used */ @@ -228,6 +231,8 @@ static bool prepare_crtc(test_data_t *test_data, igt_output_t *output, test_data->right = mode->hdisplay - cursor_w; test_data->top = 0; test_data->bottom = mode->vdisplay - cursor_h; + test_data->curw = cursor_w; + test_data->curh = cursor_h; /* make sure cursor is disabled */ cursor_disable(test_data); @@ -255,7 +260,7 @@ static void cleanup_crtc(test_data_t *test_data, igt_output_t *output) igt_output_set_pipe(output, PIPE_ANY); } -static void run_test(data_t *data, bool onscreen, int cursor_w, int cursor_h) +static void run_test(data_t *data, void (*testfunc)(test_data_t *, bool), bool onscreen, int cursor_w, int cursor_h) { igt_display_t *display = &data->display; igt_output_t *output; @@ -279,7 +284,7 @@ static void run_test(data_t *data, bool onscreen, int cursor_w, int cursor_h) igt_subtest_name(), pipe_name(test_data.pipe), igt_output_name(output)); - test_crc(&test_data, onscreen, cursor_w, cursor_h); + testfunc(&test_data, onscreen); fprintf(stdout, "\n%s on pipe %c, connector %s: PASSED\n\n", igt_subtest_name(), pipe_name(test_data.pipe), @@ -321,9 +326,9 @@ static void run_test_generic(data_t *data, int cursor_max_size) /* Using created cursor FBs to test cursor support */ igt_subtest_f("cursor-%s-onscreen", c_size) - run_test(data, true, cursor_size, cursor_size); + run_test(data, test_crc, true, cursor_size, cursor_size); igt_subtest_f("cursor-%s-offscreen", c_size) - run_test(data, false, cursor_size, cursor_size); + run_test(data, test_crc, false, cursor_size, cursor_size); } }