From patchwork Tue Sep 19 01:55:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9957991 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 B2256601E9 for ; Tue, 19 Sep 2017 01:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 970FE28D07 for ; Tue, 19 Sep 2017 01:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BED228D1C; Tue, 19 Sep 2017 01:55:25 +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, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 38DC428D07 for ; Tue, 19 Sep 2017 01:55:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A19226E4BE; Tue, 19 Sep 2017 01:55:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE56B6E4BE for ; Tue, 19 Sep 2017 01:55:19 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 18 Sep 2017 18:55:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,415,1500966000"; d="scan'208";a="901590907" Received: from dk-thinkpad-x260.jf.intel.com (HELO localhost.localdomain) ([10.54.75.39]) by FMSMGA003.fm.intel.com with ESMTP; 18 Sep 2017 18:55:19 -0700 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Mon, 18 Sep 2017 18:55:09 -0700 Message-Id: <20170919015509.10736-1-dhinakaran.pandiyan@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: rodrigo.vivi@intel.com Subject: [Intel-gfx] [PATCH i-g-t] tests/psr: Don't strcmp CRCs that are not NULL terminated. 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 Switched to strncmp. Signed-off-by: Dhinakaran Pandiyan --- tests/kms_psr_sink_crc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index bd3fa5e9..795b6546 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -34,6 +34,7 @@ bool running_with_psr_disabled; #define CRC_BLACK "000000000000" +#define CRC_LEN 12 enum operations { PAGE_FLIP, @@ -243,7 +244,7 @@ static void get_sink_crc(data_t *data, char *crc) { usleep(300000); /* Black screen is always invalid */ - igt_assert(strcmp(crc, CRC_BLACK) != 0); + igt_assert(strncmp(crc, CRC_BLACK, CRC_LEN) != 0); } static bool is_green(char *crc) @@ -289,8 +290,8 @@ static void run_test(data_t *data) uint32_t handle = data->fb_white.gem_handle; igt_plane_t *test_plane; void *ptr; - char ref_crc[12]; - char crc[12]; + char ref_crc[CRC_LEN]; + char crc[CRC_LEN]; const char *expected = ""; /* Confirm that screen became Green */ @@ -347,9 +348,9 @@ static void run_test(data_t *data) memset(ptr, 0xff, data->mod_size); get_sink_crc(data, crc); if (data->test_plane == DRM_PLANE_TYPE_PRIMARY) - assert_or_manual(strcmp(ref_crc, crc) == 0, "screen WHITE"); + assert_or_manual(strncmp(ref_crc, crc, CRC_LEN) == 0, "screen WHITE"); else - assert_or_manual(strcmp(ref_crc, crc) == 0, + assert_or_manual(strncmp(ref_crc, crc, CRC_LEN) == 0, "GREEN background with WHITE box"); igt_info("Waiting 10s...\n"); @@ -392,7 +393,7 @@ static void run_test(data_t *data) break; } get_sink_crc(data, crc); - assert_or_manual(strcmp(ref_crc, crc) != 0, expected); + assert_or_manual(strncmp(ref_crc, crc, CRC_LEN) != 0, expected); } static void test_cleanup(data_t *data) {