From patchwork Tue Jun 30 11:31:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 6695231 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6673C05AC for ; Tue, 30 Jun 2015 11:31:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1E0C20525 for ; Tue, 30 Jun 2015 11:31:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D3C6C20425 for ; Tue, 30 Jun 2015 11:31:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 029366E96E; Tue, 30 Jun 2015 04:31:50 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id CAB086E96E for ; Tue, 30 Jun 2015 04:31:48 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 30 Jun 2015 04:31:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,377,1432623600"; d="scan'208";a="753194257" Received: from michelth-linux2.isw.intel.com ([10.102.226.189]) by fmsmga002.fm.intel.com with ESMTP; 30 Jun 2015 04:31:48 -0700 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Tue, 30 Jun 2015 12:31:46 +0100 Message-Id: <1435663906-11295-1-git-send-email-michel.thierry@intel.com> X-Mailer: git-send-email 2.4.5 Subject: [Intel-gfx] [PATCH i-g-t] lib: Add 64-bit version of igt_assert_cmp 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 igt_assert_cmp64 and its derivatives: - igt_assert_eq64 - igt_assert_neq64 - igt_assert_lte64 - igt_assert_lt64 Signed-off-by: Michel Thierry --- lib/igt_core.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/lib/igt_core.h b/lib/igt_core.h index 2b2b6e9..dd39521 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -333,6 +333,7 @@ void igt_exit(void) __attribute__((noreturn)); * Fails (sub-)test if the condition is not met * * Should be used everywhere where a test compares two integer values. + * For 64-bit values use igt_assert_cmp64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. @@ -365,6 +366,24 @@ void igt_exit(void) __attribute__((noreturn)); } while (0) /** + * igt_assert_cmp64: + * @n1: first value + * @cmp: compare operator + * @ncmp: negated version of @cmp + * @n2: second value + * + * Like igt_assert_cmpint(), but for long longs; + */ +#define igt_assert_cmp64(n1, cmp, ncmp, n2) \ + do { \ + long long __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ + #n1 " " #cmp " " #n2, \ + "error: %#llx " #ncmp " %#llx\n", __n1, __n2); \ + } while (0) + +/** * igt_assert_cmpdouble: * @n1: first value * @cmp: compare operator @@ -387,8 +406,8 @@ void igt_exit(void) __attribute__((noreturn)); * @n1: first integer * @n2: second integer * - * Fails (sub-)test if the two integers are not equal. Beware that for now this - * only works on integers. + * Fails (sub-)test if the two integers are not equal. Beware that this only + * works on integers. For 64-bit values, use igt_assert_eq64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. @@ -405,6 +424,15 @@ void igt_exit(void) __attribute__((noreturn)); #define igt_assert_eq_u32(n1, n2) igt_assert_cmpuint(n1, ==, !=, n2) /** + * igt_assert_eq64: + * @n1: first value + * @n2: second value + * + * Like igt_assert_eq(), but for long long. + */ +#define igt_assert_eq64(n1, n2) igt_assert_cmp64(n1, ==, !=, n2) + +/** * igt_assert_eq_double: * @n1: first double * @n2: second double @@ -418,8 +446,8 @@ void igt_exit(void) __attribute__((noreturn)); * @n1: first integer * @n2: second integer * - * Fails (sub-)test if the two integers are equal. Beware that for now this - * only works on integers. + * Fails (sub-)test if the two integers are equal. Beware that this only works + * on integers. For 64-bit values, use igt_assert_neq64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. @@ -427,12 +455,22 @@ void igt_exit(void) __attribute__((noreturn)); #define igt_assert_neq(n1, n2) igt_assert_cmpint(n1, !=, ==, n2) /** + * igt_assert_neq64: + * @n1: first value + * @n2: second value + * + * Like igt_assert_neq(), but for long long. + */ +#define igt_assert_neq64(n1, n2) igt_assert_cmp64(n1, !=, ==, n2) + +/** * igt_assert_lte: * @n1: first integer * @n2: second integer * * Fails (sub-)test if the second integers is greater than the first. - * Beware that for now this only works on integers. + * Beware that this only works on integers, for 64-bit values, use + * igt_assert_lte64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. @@ -440,12 +478,22 @@ void igt_exit(void) __attribute__((noreturn)); #define igt_assert_lte(n1, n2) igt_assert_cmpint(n1, <=, >, n2) /** + * igt_assert_lte64: + * @n1: first value + * @n2: second value + * + * Like igt_assert_lte(), but for long long. + */ +#define igt_assert_lte64(n1, n2) igt_assert_cmp64(n1, <=, >, n2) + +/** * igt_assert_lt: * @n1: first integer * @n2: second integer * * Fails (sub-)test if the second integers is strictly smaller than the first. - * Beware that for now this only works on integers. + * Beware that this only works on integers. For 64-bit values, use + * igt_assert_lt64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. @@ -453,6 +501,15 @@ void igt_exit(void) __attribute__((noreturn)); #define igt_assert_lt(n1, n2) igt_assert_cmpint(n1, <, >=, n2) /** + * igt_assert_lt64: + * @n1: first value + * @n2: second value + * + * Like igt_assert_lt(), but for long long. + */ +#define igt_assert_lt64(n1, n2) igt_assert_cmp64(n1, <, >=, n2) + +/** * igt_require: * @expr: condition to test *