[PATCH v2] tests/intel/xe_vm: Check negative cases for vm_create/destroy ioctl
Pravalika Gurram
pravalika.gurram at intel.com
Tue Dec 17 13:04:29 UTC 2024
Negative test to check vm_create/destroy ioctl returns expected error when
invalid flags, extensions, reserved, pad, vm_id param is used.
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
---
tests/intel/xe_vm.c | 136 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index d51a75aec..b10269191 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -2247,6 +2247,107 @@ static void bind_flag_invalid(int fd)
xe_vm_destroy(fd, vm);
}
+/**
+ * TEST: Negative test for vm create/destroy ioctl
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: Synchronization
+ * Functionality: vm create
+ * Test category: negative test
+ */
+
+/**
+ * SUBTEST: invalid-flag-%s
+ * Description: function %arg[1] used in vm create IOCTL to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_vm_create_fault: xe_vm_create_fault
+ * @xe_vm_create_scratch_fault: xe_vm_create_scrach_fault
+ * @xe_vm_create_scratch_fault_lr: xe_vm_create_scrach_fault_lr
+ */
+
+static void invalid_flag(int fd, __u32 flags)
+{
+ struct drm_xe_vm_create create = {
+ .flags = flags,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
+}
+
+/**
+ * SUBTEST: invalid-extensions
+ * Description: Check query with invalid extensions returns expected error code
+ *
+ * SUBTEST: vm-create-invalid-reserved
+ * Description: Send query with invalid reserved value for vm_create ioctl
+ */
+
+static void invalid_extensions(int fd)
+{
+ struct drm_xe_vm_create create = {
+ .extensions = -1,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
+}
+
+static void vm_create_invalid_reserved(int fd)
+{
+ struct drm_xe_vm_create create = {
+ .reserved[0] = 0xffff,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
+
+ create.reserved[0] = 0;
+ create.reserved[1] = 0xffff;
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
+}
+
+/**
+ * SUBTEST: vm-destroy-invalid-reserved
+ * Description: Send query with invalid reserved value for vm_destroy ioctl
+ *
+ * SUBTEST: invalid-pad
+ * Description: Check query with invalid pad returns expected error code
+ *
+ * SUBTEST: invalid-vm-id
+ * Description: Check query with invalid vm_id returns expected error code
+ */
+
+static void vm_destroy_invalid_reserved(int fd)
+{
+ struct drm_xe_vm_destroy destroy = {
+ .reserved[0] = 0xffff,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_DESTROY, &destroy, EINVAL);
+
+ destroy.reserved[0] = 0;
+ destroy.reserved[1] = 0xffff;
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_DESTROY, &destroy, EINVAL);
+}
+
+static void invalid_pad(int fd)
+{
+ struct drm_xe_vm_destroy destroy = {
+ .pad = 1,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_DESTROY, &destroy, EINVAL);
+}
+
+static void invalid_vm_id(int fd)
+{
+ struct drm_xe_vm_destroy destroy = {
+ .vm_id = 0xdeadbeef,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_DESTROY, &destroy, ENOENT);
+}
+
igt_main
{
struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL;
@@ -2344,6 +2445,21 @@ igt_main
{ NULL },
};
+ const struct vm_create_section {
+ const char *name;
+ __u32 flags;
+ } xe_vm_create_invalid_flags[] = {
+ { "xe_vm_create_fault", DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
+ { "xe_vm_create_scratch_fault",
+ DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
+ DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
+ { "xe_vm_create_scratch_fault_lr",
+ ~(DRM_XE_VM_CREATE_FLAG_LR_MODE |
+ DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
+ DRM_XE_VM_CREATE_FLAG_FAULT_MODE) },
+ { }
+ };
+
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
@@ -2603,6 +2719,26 @@ igt_main
}
}
+ for (const struct vm_create_section *s = xe_vm_create_invalid_flags; s->name; s++) {
+ igt_subtest_f("invalid-flag-%s", s->name)
+ invalid_flag(fd, s->flags);
+ }
+
+ igt_subtest("invalid-extensions")
+ invalid_extensions(fd);
+
+ igt_subtest("vm-create-invalid-reserved")
+ vm_create_invalid_reserved(fd);
+
+ igt_subtest("vm-destroy-invalid-reserved")
+ vm_destroy_invalid_reserved(fd);
+
+ igt_subtest("invalid-pad")
+ invalid_pad(fd);
+
+ igt_subtest("invalid-vm-id")
+ invalid_vm_id(fd);
+
igt_fixture
drm_close_driver(fd);
}
--
2.34.1
More information about the igt-dev
mailing list