From patchwork Fri Apr 22 10:18:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 8908761 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 A75139F1D3 for ; Fri, 22 Apr 2016 10:18:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D376E2024F for ; Fri, 22 Apr 2016 10:18:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C1621201EF for ; Fri, 22 Apr 2016 10:18:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 024686EE7B; Fri, 22 Apr 2016 10:18:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 393DA6EE7B for ; Fri, 22 Apr 2016 10:18:48 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 22 Apr 2016 03:18:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,516,1455004800"; d="scan'208";a="964190461" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 22 Apr 2016 03:18:27 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Fri, 22 Apr 2016 13:18:18 +0300 Message-Id: <1461320298-23146-1-git-send-email-jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [PATCH i-g-t] tests/kms_sink_crc_basic: clean up assert_color and provide more details 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=-5.2 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 can simply sscanf the crc in one go. Also split up the igt asserts to get better details about what went wrong. Signed-off-by: Jani Nikula --- tests/kms_sink_crc_basic.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c index e47b8b513393..9fac958f2142 100644 --- a/tests/kms_sink_crc_basic.c +++ b/tests/kms_sink_crc_basic.c @@ -62,40 +62,24 @@ static void get_crc(char *crc) { igt_assert(strcmp(crc, CRC_BLACK) != 0); } -static void assert_color(char *crc, enum color color) +static void assert_color(const char *crc, enum color color) { - char color_mask[5] = "FFFF\0"; - char rs[5], gs[5], bs[5]; - unsigned int rh, gh, bh, mask; + unsigned int r, g, b; int ret; - sscanf(color_mask, "%4x", &mask); - - memcpy(rs, &crc[0], 4); - rs[4] = '\0'; - ret = sscanf(rs, "%4x", &rh); - igt_require(ret > 0); - - memcpy(gs, &crc[4], 4); - gs[4] = '\0'; - ret = sscanf(gs, "%4x", &gh); - igt_require(ret > 0); - - memcpy(bs, &crc[8], 4); - bs[4] = '\0'; - ret = sscanf(bs, "%4x", &bh); - igt_require(ret > 0); + ret = sscanf(crc, "%4x%4x%4x", &r, &g, &b); + igt_assert_eq(ret, 3); switch (color) { case RED: - igt_assert((rh & mask) != 0 && - (gh & mask) == 0 && - (bh & mask) == 0); + igt_assert_lt(0, r); + igt_assert_eq(0, g); + igt_assert_eq(0, b); break; case GREEN: - igt_assert((rh & mask) == 0 && - (gh & mask) != 0 && - (bh & mask) == 0); + igt_assert_eq(0, r); + igt_assert_lt(0, g); + igt_assert_eq(0, b); break; default: igt_fail(IGT_EXIT_FAILURE);