public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 0/2] Add assert for pointers compare and fix armhf compilation
@ 2026-04-17 18:11 Kamil Konieczny
  2026-04-17 18:11 ` [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision Kamil Konieczny
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kamil Konieczny @ 2026-04-17 18:11 UTC (permalink / raw)
  To: igt-dev
  Cc: Kamil Konieczny, Nishit Sharma, Arvind Yadav,
	Zbigniew Kempczyński

Recent commits break amrhf compilation as could be seen on GitLab:

https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/jobs/97703144

with errors:
../tests/intel/xe_madvise.c:201:35: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  201 |  igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
      |                                   ^
../lib/igt_core.h:796:33: note: in definition of macro ‘igt_assert_cmpu64’
  796 |   uint64_t __n1 = (n1), __n2 = (n2); \
      |                                 ^~
../tests/intel/xe_madvise.c:201:2: note: in expansion of macro ‘igt_assert_eq_u64’
  201 |  igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
      |  ^~~~~~~~~~~~~~~~~

This series introduces new macro for pointer comparision
and uses it for fixing compilation for armhf platform.

v2: add cast to 'void *' in macro (Zbigniew)

Cc: Nishit Sharma <nishit.sharma@intel.com>
Cc: Arvind Yadav <arvind.yadav@intel.com>
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>

Kamil Konieczny (2):
  lib/igt_core: Create asserts for pointer comparision
  tests/intel/xe_madvise: Fix armhf compilation

 lib/igt_core.h           | 42 ++++++++++++++++++++++++++++++++++++++++
 tests/intel/xe_madvise.c |  4 ++--
 2 files changed, 44 insertions(+), 2 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision
  2026-04-17 18:11 [PATCH i-g-t v2 0/2] Add assert for pointers compare and fix armhf compilation Kamil Konieczny
@ 2026-04-17 18:11 ` Kamil Konieczny
  2026-04-20 10:26   ` Karthik B S
  2026-04-17 18:11 ` [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation Kamil Konieczny
  2026-04-21 11:51 ` ✗ Fi.CI.BAT: failure for Add assert for pointers compare and fix armhf compilation (rev2) Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Kamil Konieczny @ 2026-04-17 18:11 UTC (permalink / raw)
  To: igt-dev; +Cc: Kamil Konieczny, Zbigniew Kempczyński

Create two macros for pointer comparisions, igt_assert_eq_ptr
and igt_assert_neq_ptr. They will print corresponding pointers
on fail. This will allow us to remove ugly casts, for example

igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);

could be rewritten into

igt_assert_eq_ptr(ptr, MAP_FAILED);

v2: add cast to 'void *' in macro (Zbigniew)

Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/igt_core.h | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/lib/igt_core.h b/lib/igt_core.h
index 6845f853c..9fe3997e7 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -723,6 +723,48 @@ void igt_describe_f(const char *fmt, ...);
  */
 #define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f)
 
+/**
+ * igt_assert_cmpptr:
+ * @n1: first value
+ * @cmp: compare operator
+ * @ncmp: negated version of @cmp
+ * @n2: second value
+ *
+ * Fails (sub-)test if the condition is not met
+ *
+ * Should be used everywhere where a test compares two pointers.
+ *
+ * Like igt_assert(), but displays the pointers being compared on failure instead
+ * of simply printing the stringified expression.
+ */
+#define igt_assert_cmpptr(n1, cmp, ncmp, n2) \
+	do { \
+		void *__n1 = (void *)(n1); \
+		void *__n2 = (void *)(n2); \
+		if (__n1 cmp __n2) ; else \
+		__igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
+				  #n1 " " #cmp " " #n2, \
+				  "error: %p " #ncmp " %p\n", __n1, __n2); \
+	} while (0)
+
+/**
+ * igt_assert_eq_ptr:
+ * @n1: first pointer
+ * @n2: second pointer
+ *
+ * Like igt_assert_eq(), but for pointers.
+ */
+#define igt_assert_eq_ptr(n1, n2) igt_assert_cmpptr(n1, ==, !=, n2)
+
+/**
+ * igt_assert_neq_ptr:
+ * @n1: first pointer
+ * @n2: second pointer
+ *
+ * Like igt_assert_neq(), but for pointers.
+ */
+#define igt_assert_neq_ptr(n1, n2) igt_assert_cmpptr(n1, !=, ==, n2)
+
 /**
  * igt_assert_cmpint:
  * @n1: first value
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation
  2026-04-17 18:11 [PATCH i-g-t v2 0/2] Add assert for pointers compare and fix armhf compilation Kamil Konieczny
  2026-04-17 18:11 ` [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision Kamil Konieczny
@ 2026-04-17 18:11 ` Kamil Konieczny
  2026-04-20 10:27   ` Karthik B S
  2026-04-21 11:51 ` ✗ Fi.CI.BAT: failure for Add assert for pointers compare and fix armhf compilation (rev2) Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Kamil Konieczny @ 2026-04-17 18:11 UTC (permalink / raw)
  To: igt-dev
  Cc: Kamil Konieczny, Arvind Yadav, Nishit Sharma,
	Zbigniew Kempczyński

There are a compiler errors on armhf, related to a cast from pointer
to uint64_t:

../tests/intel/xe_madvise.c:201:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  201 |  igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
      |                    ^

Fix it by using igt_assert_eq_ptr() macro.

Cc: Arvind Yadav <arvind.yadav@intel.com>
Cc: Nishit Sharma <nishit.sharma@intel.com>
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Fixes: 42d669fde782 ("tests/intel/xe_madvise: Add purged-mmap-blocked subtest")
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 tests/intel/xe_madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_madvise.c b/tests/intel/xe_madvise.c
index 805de793a..e9bf55ff5 100644
--- a/tests/intel/xe_madvise.c
+++ b/tests/intel/xe_madvise.c
@@ -198,7 +198,7 @@ static void test_purged_mmap_blocked(int fd)
 	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);
 
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert_eq_ptr(ptr, MAP_FAILED);
 	igt_assert_eq(errno, EINVAL);
 
 	gem_close(fd, bo);
@@ -340,7 +340,7 @@ static void test_dontneed_before_mmap(int fd)
 
 	/* mmap() on a DONTNEED BO must fail with EBUSY. */
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert_eq_ptr(ptr, MAP_FAILED);
 	igt_assert_eq(errno, EBUSY);
 
 	/* Restore to WILLNEED before cleanup */
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision
  2026-04-17 18:11 ` [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision Kamil Konieczny
@ 2026-04-20 10:26   ` Karthik B S
  0 siblings, 0 replies; 6+ messages in thread
From: Karthik B S @ 2026-04-20 10:26 UTC (permalink / raw)
  To: Kamil Konieczny, igt-dev; +Cc: Zbigniew Kempczyński


On 4/17/2026 11:41 PM, Kamil Konieczny wrote:
> Create two macros for pointer comparisions, igt_assert_eq_ptr
> and igt_assert_neq_ptr. They will print corresponding pointers
> on fail. This will allow us to remove ugly casts, for example
>
> igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
>
> could be rewritten into
>
> igt_assert_eq_ptr(ptr, MAP_FAILED);
>
> v2: add cast to 'void *' in macro (Zbigniew)
>
> Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Karthik B S <karthik.b.s@intel.com>
> ---
>   lib/igt_core.h | 42 ++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 42 insertions(+)
>
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 6845f853c..9fe3997e7 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -723,6 +723,48 @@ void igt_describe_f(const char *fmt, ...);
>    */
>   #define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f)
>   
> +/**
> + * igt_assert_cmpptr:
> + * @n1: first value
> + * @cmp: compare operator
> + * @ncmp: negated version of @cmp
> + * @n2: second value
> + *
> + * Fails (sub-)test if the condition is not met
> + *
> + * Should be used everywhere where a test compares two pointers.
> + *
> + * Like igt_assert(), but displays the pointers being compared on failure instead
> + * of simply printing the stringified expression.
> + */
> +#define igt_assert_cmpptr(n1, cmp, ncmp, n2) \
> +	do { \
> +		void *__n1 = (void *)(n1); \
> +		void *__n2 = (void *)(n2); \
> +		if (__n1 cmp __n2) ; else \
> +		__igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
> +				  #n1 " " #cmp " " #n2, \
> +				  "error: %p " #ncmp " %p\n", __n1, __n2); \
> +	} while (0)
> +
> +/**
> + * igt_assert_eq_ptr:
> + * @n1: first pointer
> + * @n2: second pointer
> + *
> + * Like igt_assert_eq(), but for pointers.
> + */
> +#define igt_assert_eq_ptr(n1, n2) igt_assert_cmpptr(n1, ==, !=, n2)
> +
> +/**
> + * igt_assert_neq_ptr:
> + * @n1: first pointer
> + * @n2: second pointer
> + *
> + * Like igt_assert_neq(), but for pointers.
> + */
> +#define igt_assert_neq_ptr(n1, n2) igt_assert_cmpptr(n1, !=, ==, n2)
> +
>   /**
>    * igt_assert_cmpint:
>    * @n1: first value

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation
  2026-04-17 18:11 ` [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation Kamil Konieczny
@ 2026-04-20 10:27   ` Karthik B S
  0 siblings, 0 replies; 6+ messages in thread
From: Karthik B S @ 2026-04-20 10:27 UTC (permalink / raw)
  To: Kamil Konieczny, igt-dev
  Cc: Arvind Yadav, Nishit Sharma, Zbigniew Kempczyński


On 4/17/2026 11:41 PM, Kamil Konieczny wrote:
> There are a compiler errors on armhf, related to a cast from pointer
> to uint64_t:
>
> ../tests/intel/xe_madvise.c:201:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>    201 |  igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
>        |                    ^
>
> Fix it by using igt_assert_eq_ptr() macro.
>
> Cc: Arvind Yadav <arvind.yadav@intel.com>
> Cc: Nishit Sharma <nishit.sharma@intel.com>
> Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
> Fixes: 42d669fde782 ("tests/intel/xe_madvise: Add purged-mmap-blocked subtest")
> Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Karthik B S <karthik.b.s@intel.com>
> ---
>   tests/intel/xe_madvise.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/intel/xe_madvise.c b/tests/intel/xe_madvise.c
> index 805de793a..e9bf55ff5 100644
> --- a/tests/intel/xe_madvise.c
> +++ b/tests/intel/xe_madvise.c
> @@ -198,7 +198,7 @@ static void test_purged_mmap_blocked(int fd)
>   	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);
>   
>   	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
> -	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
> +	igt_assert_eq_ptr(ptr, MAP_FAILED);
>   	igt_assert_eq(errno, EINVAL);
>   
>   	gem_close(fd, bo);
> @@ -340,7 +340,7 @@ static void test_dontneed_before_mmap(int fd)
>   
>   	/* mmap() on a DONTNEED BO must fail with EBUSY. */
>   	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
> -	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
> +	igt_assert_eq_ptr(ptr, MAP_FAILED);
>   	igt_assert_eq(errno, EBUSY);
>   
>   	/* Restore to WILLNEED before cleanup */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ✗ Fi.CI.BAT: failure for Add assert for pointers compare and fix armhf compilation (rev2)
  2026-04-17 18:11 [PATCH i-g-t v2 0/2] Add assert for pointers compare and fix armhf compilation Kamil Konieczny
  2026-04-17 18:11 ` [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision Kamil Konieczny
  2026-04-17 18:11 ` [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation Kamil Konieczny
@ 2026-04-21 11:51 ` Patchwork
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2026-04-21 11:51 UTC (permalink / raw)
  To: Kamil Konieczny; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

== Series Details ==

Series: Add assert for pointers compare and fix armhf compilation (rev2)
URL   : https://patchwork.freedesktop.org/series/165068/
State : failure

== Summary ==

Series 165068 revision 2 was fully merged or fully failed: no git log



[-- Attachment #2: Type: text/html, Size: 725 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-21 11:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 18:11 [PATCH i-g-t v2 0/2] Add assert for pointers compare and fix armhf compilation Kamil Konieczny
2026-04-17 18:11 ` [PATCH i-g-t v2 1/2] lib/igt_core: Create asserts for pointer comparision Kamil Konieczny
2026-04-20 10:26   ` Karthik B S
2026-04-17 18:11 ` [PATCH i-g-t v2 2/2] tests/intel/xe_madvise: Fix armhf compilation Kamil Konieczny
2026-04-20 10:27   ` Karthik B S
2026-04-21 11:51 ` ✗ Fi.CI.BAT: failure for Add assert for pointers compare and fix armhf compilation (rev2) Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox