lib: Add 64-bit version of igt_assert_cmp
PATCH 1/1 lib: Add 64-bit version of igt_assert_cmp
igt_assert_cmp64 and its derivatives:
- igt_assert_eq64
- igt_assert_neq64
- igt_assert_lte64
- igt_assert_lt64
--- lib/igt_core.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-)
lib/igt_core.h +63 -6
@@ -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 *
Signature · 6 lines
2.4.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 33 lines · Michel Thierry
igt_assert_cmp64and its derivatives:
-igt_assert_eq64
-igt_assert_neq64
-igt_assert_lte64
-igt_assert_lt64Signed-off-by Michel Thierry <[email protected]>--- lib/igt_core.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-)lib/igt_core.h +7
-0@@ -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 +*
lib/igt_core.h void igt_exit(void) __attribute__((noreturn)); · line 384
Quoted 10 lines
lib/igt_core.h +10
-0+* 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)
A new igt_assert_cmp_t?
#define igt_assert_cmp_t(T, n1, cmp, ncmp, n2) do {\
T __n1 = (n1), __n2 = (n2); \
if (!(__n1 cmp __n2)) \
__igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
#n1 " " #cmp " " #n2, \
"error: %#llx " #ncmp " %#llx\n", __n1, __n2); \
} while (0)
#define igt_assert_cmpint(n1, cmp, ncmp, n2) \
igt_assert_cmp_t(int, n1, cmp, ncmp, n2)
#define igt_assert_cmp64(n1, cmp, ncmp, n2) \
igt_assert_cmp_t(long long, n1, cmp, ncmp, n2)That at least hides the ugliest of macros and stops it reproducing at an alarming rate. Whether it is worth creating igt_assert_eq_t and friends just to avoid duplicating the (cmp, ncmp) is debatable. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 47 lines · Chris Wilson
Quoted 33 lines · Michel Thierry
igt_assert_cmp64and its derivatives:
-igt_assert_eq64
-igt_assert_neq64
-igt_assert_lte64
-igt_assert_lt64Signed-off-by Michel Thierry <[email protected]>--- lib/igt_core.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-)lib/igt_core.h +7
-0@@ -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 +* lib/igt_core.h void igt_exit(void) __attribute__((noreturn)); · line 384
Quoted 10 lines
lib/igt_core.h +10
-0+* 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)A new
igt_assert_cmp_t?
Quoted 6 lines
#define igt_assert_cmp_t(T, n1, cmp, ncmp, n2) do {\
T __n1 = (n1), __n2 = (n2); \
if (!(__n1 cmp __n2)) \
__igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
#n1 " " #cmp " " #n2, \
"error: %#llx " #ncmp " %#llx\n", __n1, __n2); \I'll also need to cast __n1 and __n2 to long long, or it will throw warnings about format '%llx' getting an uint32. Ok?
Quoted 8 lines
} while (0) #define igt_assert_cmpint(n1, cmp, ncmp, n2) \ igt_assert_cmp_t(int, n1, cmp, ncmp, n2) #define igt_assert_cmp64(n1, cmp, ncmp, n2) \ igt_assert_cmp_t(long long, n1, cmp, ncmp, n2)
Quoted 5 lines
That at least hides the ugliest of macros and stops it reproducing at an alarming rate. Whether it is worth creating
igt_assert_eq_tand friends just to avoid duplicating the (cmp, ncmp) is debatable. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 2 lines · Michel Thierry
I'll also need to cast
__n1and__n2to long long, or it will throw warnings about format '%llx' getting an uint32. Ok?
Ok, or we can add the format specifier along with T. The latter is definitely useful so that we can have hex variants. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 7 lines · Michel Thierry
igt_assert_cmp64and its derivatives:
-igt_assert_eq64
-igt_assert_neq64
-igt_assert_lte64
-igt_assert_lt64Signed-off-by Michel Thierry <[email protected]>
Care to update the lib/igt.coccie script and run in and add those changes in a 2nd patch? Always good to keep the refactoring tools updated too. -Daniel
Quoted 150 lines
--- lib/igt_core.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-)lib/igt_core.h +63
-6@@ -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 * Signature · 6 lines
2.4.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx