[PATCH] tests/intel/xe_vm_create: Check negative cases for vm_create ioctl
Gurram, Pravalika
pravalika.gurram at intel.com
Fri Dec 13 10:15:57 UTC 2024
> -----Original Message-----
> From: Piecielska, Katarzyna <katarzyna.piecielska at intel.com>
> Sent: Friday, December 13, 2024 2:40 PM
> To: Gurram, Pravalika <pravalika.gurram at intel.com>; igt-
> dev at lists.freedesktop.org
> Cc: Gurram, Pravalika <pravalika.gurram at intel.com>
> Subject: RE: [PATCH] tests/intel/xe_vm_create: Check negative cases for
> vm_create ioctl
>
> Negative test to check vm_create ioctl returns expected error when invalid
> flags, extensions, reserved param is used.
>
> Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> ---
> tests/intel/xe_vm_create.c | 104 +++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 2 files changed, 105 insertions(+)
> create mode 100644 tests/intel/xe_vm_create.c
>
> (Kasia) We have binary tests/intel/xe_vm.c - in my opinion this new test should
> go there instead of creating new binary.
>
xe_vm.c is using to validate the "DRM_IOCTL_XE_VM_BIND" ioctl
below subtest which doing negative test is using VM_BIND
hence I have created new file bind_flag_invalid(fd);
> diff --git a/tests/intel/xe_vm_create.c b/tests/intel/xe_vm_create.c new file
> mode 100644 index 000000000..2430e6739
> --- /dev/null
> +++ b/tests/intel/xe_vm_create.c
> @@ -0,0 +1,104 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2024 Intel Corporation
> + */
> +
> +#include "igt.h"
> +#include "xe_drm.h"
> +
> +/**
> + * TEST: Negative test for vm create 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_scrach_fault: xe_vm_create_scrach_fault
> + * @xe_vm_create_scrach_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: invalid-reserved
> + * Description: Check query with invalid reserved value returns
> +expected error code */
> +
> +static void inavlid_extensions(int fd)
> I believe we have typo here ^ s/inavlid/invalid/
> +{
> + struct drm_xe_vm_create create = {
> + .extensions = -1,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
> +
> +}
> +
> +static void inavlid_reserved(int fd)
> I believe we have typo here ^ s/inavlid/invalid/
> +{
> + struct drm_xe_vm_create create = {
> + .reserved[0] = 0xffff,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
> +
> +}
> +
> +igt_main
> +{
> + int fd;
> +
> + const struct section {
> + const char *name;
> + __u32 flags;
> + } vm_create_flags_fail_functions[] = {
> + { "xe_vm_create_fault",
> DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
> + { "xe_vm_create_scrach_fault",
> + DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
> + DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
> + { "xe_vm_create_scrach_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);
> +
> + for (const struct section *s = vm_create_flags_fail_functions; s->name;
> s++) {
> + igt_subtest_f("invalid-flag-%s", s->name)
> + invalid_flag(fd, s->flags);
> + }
> +
> + igt_subtest("invalid-extensions")
> + inavlid_extensions(fd);
> I believe we have typo here ^ s/inavlid/invalid/
> +
> + igt_subtest("invalid-reserved")
> + inavlid_reserved(fd);
> I believe we have typo here ^ s/inavlid/invalid/
> +
> + igt_fixture {
> + drm_close_driver(fd);
> + }
> +
> +}
> diff --git a/tests/meson.build b/tests/meson.build index 2724c7a9a..fb9fc75d8
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -321,6 +321,7 @@ intel_xe_progs = [
> 'xe_sysfs_scheduler',
> 'xe_sysfs_timeslice_duration',
> 'xe_tlb',
> + 'xe_vm_create',
> ]
>
> intel_xe_eudebug_progs = [
> --
> 2.34.1
More information about the igt-dev
mailing list