From patchwork Mon Aug 14 09:25:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9898403 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 30EF860230 for ; Mon, 14 Aug 2017 09:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F132859A for ; Mon, 14 Aug 2017 09:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 179DA2859F; Mon, 14 Aug 2017 09:25:30 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 8088A2859A for ; Mon, 14 Aug 2017 09:25:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 424FF89E4C; Mon, 14 Aug 2017 09:25:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A9C089E4C for ; Mon, 14 Aug 2017 09:25:27 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id r77so13771194wmd.2 for ; Mon, 14 Aug 2017 02:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id; bh=fa6aQ9xwOcvtIgAxqDx5Rj52eom3rEh1WmtlYl+rIjo=; b=AEMsxHIQli8GHR7WmRArxlKrRmrW0kKGmKMeph9+9gl4JYX8pmHQXt8B1e+wTDN1u/ Y59cCibIcL4N413LAV3ppINrugu30mjKWtfgnmgRzhejWqQKsskXkWHWRKDo76f5QaB9 SvRjKrReIilZ67UHoTTBaNiSkD+xNZUx5cAdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fa6aQ9xwOcvtIgAxqDx5Rj52eom3rEh1WmtlYl+rIjo=; b=BKK7PoOnT+m4G9BgqYidYiTXaI1N2VFWTt/JGTs2PLVhpGXoo4gQLh1GbaytxzzRQL acD53nc10Gu3LlL/7W3S7yBFROCLC3qlc4tqyv19JaU9fhm7BC8oZCAoWpYjtdzmHPLo UTmQDHvc1aioFNx7i5YYRKS4yWq7JRebSFkvn65frUKoW9r93xbpt/uVc5hkoInd79JN v/LIVdQV+lYp/Keq6+CsjDxicSCs5nRAR71V/LSHEr4esudHpWB/xlr5y2Id+8KZJX1d sbe12IuOpWphwcyoPXPukMuasUJHwCwvPWZ7KsZo9PhFOTLWfPxcY9MAoiz0abnlHcMe UJQw== X-Gm-Message-State: AHYfb5hsBqwvmPAvs4xzwpc0gT7cjo+cXu8r6Exdbi5jMwacivtYyaPP TKluswnEJhRBLqMlic8= X-Received: by 10.80.132.69 with SMTP id 63mr23817928edp.136.1502702725343; Mon, 14 Aug 2017 02:25:25 -0700 (PDT) Received: from wespe.ffwll.local ([2a02:168:56e6:0:6631:50ff:fe8d:fd2e]) by smtp.gmail.com with ESMTPSA id n59sm4017539edc.31.2017.08.14.02.25.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 02:25:24 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Mon, 14 Aug 2017 11:25:18 +0200 Message-Id: <1502702718-6025-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.5 Cc: Daniel Vetter , Paulo Zanoni , Daniel Vetter Subject: [Intel-gfx] [PATCH i-g-t] tests/kms_frontbuffer_tracking: convert macros to functions 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 Macros that should be C functions but aren't are really hard to read and confusing. Convert them over. v2: Clean up commit message and keep printing the line numbers (Paulo). Cc: Paulo Zanoni Signed-off-by: Daniel Vetter --- tests/kms_frontbuffer_tracking.c | 166 ++++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 82 deletions(-) diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index e03524f1c45b..8d11dc065623 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -1677,88 +1677,90 @@ static int adjust_assertion_flags(const struct test_mode *t, int flags) return flags; } -#define do_crc_assertions(flags, mandatory_sink_crc) do { \ - int flags__ = (flags); \ - struct both_crcs crc_; \ - \ - if (!opt.check_crc || (flags__ & DONT_ASSERT_CRC)) \ - break; \ - \ - collect_crcs(&crc_, mandatory_sink_crc); \ - print_crc("Calculated CRC:", &crc_); \ - \ - igt_assert(wanted_crc); \ - igt_assert_crc_equal(&crc_.pipe, &wanted_crc->pipe); \ - if (mandatory_sink_crc) \ - assert_sink_crc_equal(&crc_.sink, &wanted_crc->sink); \ - else if (sink_crc.reliable && \ - !sink_crc_equal(&crc_.sink, &wanted_crc->sink)) \ - igt_info("Sink CRC differ, but not required\n"); \ -} while (0) - -#define do_status_assertions(flags_) do { \ - if (!opt.check_status) { \ - /* Make sure we settle before continuing. */ \ - sleep(1); \ - break; \ - } \ - \ - if (flags_ & ASSERT_FBC_ENABLED) { \ - igt_require(!fbc_not_enough_stolen()); \ - igt_require(!fbc_stride_not_supported()); \ - if (!fbc_wait_until_enabled()) { \ - fbc_print_status(); \ - igt_assert_f(false, "FBC disabled\n"); \ - } \ - \ - if (opt.fbc_check_compression) \ - igt_assert(fbc_wait_for_compression()); \ - } else if (flags_ & ASSERT_FBC_DISABLED) { \ - igt_assert(!fbc_wait_until_enabled()); \ - } \ - \ - if (flags_ & ASSERT_PSR_ENABLED) { \ - if (!psr_wait_until_enabled()) { \ - psr_print_status(); \ - igt_assert_f(false, "PSR disabled\n"); \ - } \ - } else if (flags_ & ASSERT_PSR_DISABLED) { \ - igt_assert(!psr_wait_until_enabled()); \ - } \ -} while (0) - -#define do_assertions(flags) do { \ - int flags_ = adjust_assertion_flags(t, (flags)); \ - bool mandatory_sink_crc = t->feature & FEATURE_PSR; \ - \ - wait_user(2, "Paused before assertions."); \ - \ - /* Check the CRC to make sure the drawing operations work \ - * immediately, independently of the features being enabled. */ \ - do_crc_assertions(flags_, mandatory_sink_crc); \ - \ - /* Now we can flush things to make the test faster. */ \ - do_flush(t); \ - \ - do_status_assertions(flags_); \ - \ - /* Check CRC again to make sure the compressed screen is ok, \ - * except if we're not drawing on the primary screen. On this \ - * case, the first check should be enough and a new CRC check \ - * would only delay the test suite while adding no value to the \ - * test suite. */ \ - if (t->screen == SCREEN_PRIM) \ - do_crc_assertions(flags_, mandatory_sink_crc); \ - \ - if (fbc.supports_last_action && opt.fbc_check_last_action) { \ - if (flags_ & ASSERT_LAST_ACTION_CHANGED) \ - igt_assert(fbc_last_action_changed()); \ - else if (flags_ & ASSERT_NO_ACTION_CHANGE) \ - igt_assert(!fbc_last_action_changed()); \ - } \ - \ - wait_user(1, "Paused after assertions."); \ -} while (0) +static void do_crc_assertions(int flags, bool mandatory_sink_crc) +{ + struct both_crcs crc; + + if (!opt.check_crc || (flags & DONT_ASSERT_CRC)) + return; + + collect_crcs(&crc, mandatory_sink_crc); + print_crc("Calculated CRC:", &crc); + + igt_assert(wanted_crc); + igt_assert_crc_equal(&crc.pipe, &wanted_crc->pipe); + if (mandatory_sink_crc) + assert_sink_crc_equal(&crc.sink, &wanted_crc->sink); + else if (sink_crc.reliable && + !sink_crc_equal(&crc.sink, &wanted_crc->sink)) + igt_info("Sink CRC differ, but not required\n"); +} + +static void do_status_assertions(int flags) +{ + if (!opt.check_status) { + /* Make sure we settle before continuing. */ + sleep(1); + return; + } + + if (flags & ASSERT_FBC_ENABLED) { + igt_require(!fbc_not_enough_stolen()); + igt_require(!fbc_stride_not_supported()); + if (!fbc_wait_until_enabled()) { + fbc_print_status(); + igt_assert_f(false, "FBC disabled\n"); + } + + if (opt.fbc_check_compression) + igt_assert(fbc_wait_for_compression()); + } else if (flags & ASSERT_FBC_DISABLED) { + igt_assert(!fbc_wait_until_enabled()); + } + + if (flags & ASSERT_PSR_ENABLED) { + if (!psr_wait_until_enabled()) { + psr_print_status(); + igt_assert_f(false, "PSR disabled\n"); + } + } else if (flags & ASSERT_PSR_DISABLED) { + igt_assert(!psr_wait_until_enabled()); + } +} + +static void do_assertions(int flags) +{ + flags = adjust_assertion_flags(t, flags); + bool mandatory_sink_crc = t->feature & FEATURE_PSR; + + wait_user(2, "Paused before assertions."); + + /* Check the CRC to make sure the drawing operations work + * immediately, independently of the features being enabled. */ + do_crc_assertions(flags, mandatory_sink_crc); + + /* Now we can flush things to make the test faster. */ + do_flush(t); + + do_status_assertions(flags); + + /* Check CRC again to make sure the compressed screen is ok, + * except if we're not drawing on the primary screen. On this + * case, the first check should be enough and a new CRC check + * would only delay the test suite while adding no value to the + * test suite. */ + if (t->screen == SCREEN_PRIM) + do_crc_assertions(flags, mandatory_sink_crc); + + if (fbc.supports_last_action && opt.fbc_check_last_action) { + if (flags & ASSERT_LAST_ACTION_CHANGED) + igt_assert(fbc_last_action_changed()); + else if (flags_ & ASSERT_NO_ACTION_CHANGE) + igt_assert(!fbc_last_action_changed()); + } + + wait_user(1, "Paused after assertions."); +} static void enable_prim_screen_and_wait(const struct test_mode *t) {