[PATCH 35/66] tests/xe_eudebug: Exercise lseek

Christoph Manszewski christoph.manszewski at intel.com
Mon Jul 29 16:01:28 UTC 2024


From: Jonathan Cavitt <jonathan.cavitt at intel.com>

Add an additional check in debugger_test_vma that simultaneously
exercises lseek support and also that pwrite successfully wrote the
new buffer contents to the vma via pwrite.

Suggested-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
Cc: Christoph Manszewski <christoph.manszewski at intel.com>
---
 tests/intel/xe_eudebug.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c
index edb76685e..928dcdce4 100644
--- a/tests/intel/xe_eudebug.c
+++ b/tests/intel/xe_eudebug.c
@@ -1414,13 +1414,15 @@ static void debugger_test_vma(struct xe_eudebug_debugger *d,
 			      uint64_t va_length)
 {
 	struct drm_xe_eudebug_vm_open vo = { 0, };
-	uint64_t *v;
+	uint64_t *v1, *v2;
 	uint64_t items = va_length / sizeof(uint64_t);
 	int fd;
 	int r, i;
 
-	v = malloc(va_length);
-	igt_assert(v);
+	v1 = malloc(va_length);
+	igt_assert(v1);
+	v2 = malloc(va_length);
+	igt_assert(v2);
 
 	vo.client_handle = client_handle;
 	vo.vm_handle = vm_handle;
@@ -1428,22 +1430,30 @@ static void debugger_test_vma(struct xe_eudebug_debugger *d,
 	fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
 	igt_assert_lte(0, fd);
 
-	r = pread(fd, v, va_length, va_start);
+	r = pread(fd, v1, va_length, va_start);
 	igt_assert_eq(r, va_length);
 
 	for (i = 0; i < items; i++)
-		igt_assert_eq(v[i], va_start + i);
+		igt_assert_eq(v1[i], va_start + i);
 
 	for (i = 0; i < items; i++)
-		v[i] = va_start + i + 1;
+		v1[i] = va_start + i + 1;
 
-	r = pwrite(fd, v, va_length, va_start);
+	r = pwrite(fd, v1, va_length, va_start);
+	igt_assert_eq(r, va_length);
+
+	lseek(fd, va_start, SEEK_SET);
+	r = read(fd, v2, va_length);
 	igt_assert_eq(r, va_length);
 
+	for (i = 0; i < items; i++)
+		igt_assert_eq(v1[i], v2[i]);
+
 	fsync(fd);
 
 	close(fd);
-	free(v);
+	free(v1);
+	free(v2);
 }
 
 static void vm_trigger(struct xe_eudebug_debugger *d,
-- 
2.34.1



More information about the igt-dev mailing list