Skip to contentSkip to conversation

tests/gem_create: Explicitly check for -EINVAL on create-invalid-size

PATCH In review Joonas Lahtinen 3 participants 6 messages Oct 3, 2017 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tests/gem_create: Explicitly check for -EINVAL on create-invalid-size

Merge the remaining testing coverage delta from gem_bad_length and check that creating an object of zero size fails with -EINVAL.

---
 tests/gem_create.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tests/gem_create.c +9 -5
index de7b8209..655f7a4e 100644
@@ -70,17 +70,18 @@ struct local_i915_gem_create_v2 {
 	uint32_t pad;
 #define I915_CREATE_PLACEMENT_STOLEN (1<<0)
 	uint32_t flags;
-} create;
+};
 
 #define LOCAL_IOCTL_I915_GEM_CREATE       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct local_i915_gem_create_v2)
 
 static void invalid_flag_test(int fd)
 {
+	struct local_i915_gem_create_v2 create;
 	int ret;
 
 	gem_require_stolen_support(fd);
 
-	create.handle = 0;
+	CLEAR(create);
 	create.size = PAGE_SIZE;
 	create.flags = ~I915_CREATE_PLACEMENT_STOLEN;
 	ret = drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CREATE, &create);
@@ -95,10 +96,13 @@ static void invalid_flag_test(int fd)
 
 static void invalid_size_test(int fd)
 {
-	int handle;
+	struct i915_gem_create create;
+
+	CLEAR(create);
+	create.size = 0;
+	igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1);
 
-	handle = __gem_create(fd, 0);
-	igt_assert(!handle);
+	igt_assert_eq(errno, EINVAL);
 }
 
 /*
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 tests: Drop gem_bad_length as redundant

From: Daniele Ceraolo Spurio <[email protected]>

Most of the gem_bad_length code is compiled out because creating a zero-length object is not allowed anymore by i915 and thus it is not possible to execute it. The remaining part checks that creation of a zero-length object does indeed fail, which is also checked by gem_create/create-invalid-size.
The only difference between the 2 tests is that gem_bad_length checks specifically for EINVAL while create-invalid-size only looks for failure, so after adding the EINVAL check to create-invalid-size it is safe to drop gem_bad_length.

v2 (Joonas):
- Clarify header line, split the patch, fix Meson build and add Cc:

---
 tests/Makefile.sources |   1 -
 tests/gem_bad_length.c | 133 -------------------------------------------------
 tests/meson.build      |   1 -
 3 files changed, 135 deletions(-)
 delete mode 100644 tests/gem_bad_length.c
tests/Makefile.sources +0 -1
index c4d320eb..142ff2bb 100644
@@ -40,7 +40,6 @@ TESTS_progs = \
 	drv_module_reload \
 	drv_selftest \
 	drv_suspend \
-	gem_bad_length \
 	gem_bad_reloc \
 	gem_basic \
 	gem_busy \
tests/gem_bad_length.c deleted +0 -133

133 lines not on this page · raw message

tests/meson.build +0 -1
index 6cb3584a..85666f6d 100644
@@ -20,7 +20,6 @@ test_progs = [
 	'drv_module_reload',
 	'drv_selftest',
 	'drv_suspend',
-	'gem_bad_length',
 	'gem_bad_reloc',
 	'gem_basic',
 	'gem_busy',
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH i-g-t 2/2] tests: Drop gem_bad_length as redundant

Quoting Joonas Lahtinen (2017-10-03 12:47:34)

Quoted 12 lines

From: Daniele Ceraolo Spurio <[email protected]>

Most of the gem_bad_length code is compiled out because creating a zero-length object is not allowed anymore by i915 and thus it is not possible to execute it. The remaining part checks that creation of a zero-length object does indeed fail, which is also checked by gem_create/create-invalid-size.
The only difference between the 2 tests is that gem_bad_length checks specifically for EINVAL while create-invalid-size only looks for failure, so after adding the EINVAL check to create-invalid-size it is safe to drop gem_bad_length.

Quoted 6 lines

v2 (Joonas):
- Clarify header line, split the patch, fix Meson build and add Cc:

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/2
#3 lore raw
In reply to Joonas Lahtinen

Quoting Joonas Lahtinen (2017-10-03 12:47:33)

tests/gem_create.c static void invalid_flag_test(int fd)

Quoted 37 lines

Merge the remaining testing coverage delta from gem_bad_length and check that creating an object of zero size fails with -EINVAL.

---
 tests/gem_create.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tests/gem_create.c +3 -2
index de7b8209..655f7a4e 100644
@@ -70,17 +70,18 @@ struct local_i915_gem_create_v2 {
        uint32_t pad;
 #define I915_CREATE_PLACEMENT_STOLEN (1<<0)
        uint32_t flags;
-} create;
+};
 
 #define LOCAL_IOCTL_I915_GEM_CREATE       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct local_i915_gem_create_v2)
 
 static void invalid_flag_test(int fd)
 {
+       struct local_i915_gem_create_v2 create;
        int ret;
 
        gem_require_stolen_support(fd);
 
-       create.handle = 0;
+       CLEAR(create);
        create.size = PAGE_SIZE;
        create.flags = ~I915_CREATE_PLACEMENT_STOLEN;
        ret = drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CREATE, &create);
@@ -95,10 +96,13 @@ static void invalid_flag_test(int fd)

First chunk,

Second chunk, I think we should fix __gem_create() to follow the convention of returning the error code.
-Chris

Quoted 18 lines
tests/gem_create.c +6 -3
 static void invalid_size_test(int fd)
 {
-       int handle;
+       struct i915_gem_create create;
+
+       CLEAR(create);
+       create.size = 0;
+       igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1);
 
-       handle = __gem_create(fd, 0);
-       igt_assert(!handle);
+       igt_assert_eq(errno, EINVAL);
 }
 
 /*
Signature · 1 line
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 40 lines · Chris Wilson

Quoting Joonas Lahtinen (2017-10-03 12:47:33)

tests/gem_create.c static void invalid_flag_test(int fd)

Quoted 37 lines

Merge the remaining testing coverage delta from gem_bad_length and check that creating an object of zero size fails with -EINVAL.

---
 tests/gem_create.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tests/gem_create.c +3 -2
index de7b8209..655f7a4e 100644
@@ -70,17 +70,18 @@ struct local_i915_gem_create_v2 {
        uint32_t pad;
 #define I915_CREATE_PLACEMENT_STOLEN (1<<0)
        uint32_t flags;
-} create;
+};
 
 #define LOCAL_IOCTL_I915_GEM_CREATE       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct local_i915_gem_create_v2)
 
 static void invalid_flag_test(int fd)
 {
+       struct local_i915_gem_create_v2 create;
        int ret;
 
        gem_require_stolen_support(fd);
 
-       create.handle = 0;
+       CLEAR(create);
        create.size = PAGE_SIZE;
        create.flags = ~I915_CREATE_PLACEMENT_STOLEN;
        ret = drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CREATE, &create);
@@ -95,10 +96,13 @@ static void invalid_flag_test(int fd)

First chunk,

Quoted 4 lines

Second chunk, I think we should fix __gem_create() to follow the convention of returning the error code.

That's indeed better, I reviewed it. Please merge it first, I'll rebase these two patches.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/2] tests/gem_create: Explicitly check for -EINVAL on create-invalid-size

In reply to Joonas Lahtinen
== Series Details ==

== Series Details ==

Series: series starting with [1/2] tests/gem_create: Explicitly check for -EINVAL on create-invalid-size
URL : https://patchwork.freedesktop.org/series/31316/
State : failure

== Summary ==

IGT patchset build failed on latest successful build 08a2f887b26c89cfb1e1b5715a23d561b75e0dab lib: Reduce dependency on glib

make all-recursive
Making all in lib
make all-recursive
Making all in .
Making all in tests
make[4]: Nothing to be done for 'all'.
Making all in man
make[2]: Nothing to be done for 'all'.
Making all in tools
Making all in null_state_gen
make[3]: Nothing to be done for 'all'.
Making all in registers
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in scripts
make[2]: Nothing to be done for 'all'.
Making all in benchmarks
Making all in wsim
make[3]: Nothing to be done for 'all'.
Making all in ezbench.d
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in tests
Making all in intel-ci
make[3]: Nothing to be done for 'all'.

  CCLD     gem_bad_batch
  CCLD     gem_hang
  CCLD     gem_bad_blit
  CCLD     gem_bad_address
  CCLD     gem_non_secure_batch
  CCLD     gem_stress
  CCLD     core_auth
  CCLD     core_get_client_auth
  CCLD     core_getclient
  CCLD     core_getstats
  CCLD     core_getversion
  CCLD     core_prop_blob
  CCLD     core_setmaster_vs_auth
  CCLD     debugfs_test
  CCLD     drm_import_export
  CCLD     drm_mm
  CCLD     drm_read
  CCLD     drm_vma_limiter
  CCLD     drm_vma_limiter_cached
  CCLD     drm_vma_limiter_cpu
  CCLD     drm_vma_limiter_gtt
  CCLD     drv_getparams_basic
  CCLD     drv_hangman
  CCLD     drv_missed_irq
  CCLD     drv_module_reload
  CCLD     drv_selftest
  CCLD     drv_suspend
  CCLD     gem_bad_reloc
  CCLD     gem_basic
  CCLD     gem_busy
  CCLD     gem_caching
  CCLD     gem_close
  CCLD     gem_close_race
  CCLD     gem_concurrent_blit
  CCLD     gem_cpu_reloc
  CC       gem_create.o
gem_create.c: In function ‘invalid_size_test’:
gem_create.c:99:25: error: storage size of ‘create’ isn’t known
  struct i915_gem_create create;
                         ^~~~~~
In file included from ./../lib/intel_batchbuffer.h:8:0,
                 from gem_create.c:52:
gem_create.c:103:30: error: ‘IOCTL_I915_GEM_CREATE’ undeclared (first use in this function)
  igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1);
                              ^
./../lib/igt_core.h:396:15: note: in definition of macro ‘igt_assert_cmpint’
   int __n1 = (n1), __n2 = (n2); \
               ^~

gem_create.c:103:2: note: in expansion of macro ‘igt_assert_eq’
igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1);
^~~~~~~~~~~~~
gem_create.c:103:30: note: each undeclared identifier is reported only once for each function it appears in

  igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1);
                              ^
./../lib/igt_core.h:396:15: note: in definition of macro ‘igt_assert_cmpint’
   int __n1 = (n1), __n2 = (n2); \
               ^~

gem_create.c:103:2: note: in expansion of macro ‘igt_assert_eq’
igt_assert_eq(igt_ioctl(fd, IOCTL_I915_GEM_CREATE, &create), -1); ^~~~~~~~~~~~~
gem_create.c:99:25: warning: unused variable ‘create’ [-Wunused-variable]

  struct i915_gem_create create;
                         ^~~~~~

Makefile:3947: recipe for target 'gem_create.o' failed make[3]: *** [gem_create.o] Error 1 Makefile:4432: recipe for target 'all-recursive' failed make[2]: *** [all-recursive] Error 1 Makefile:533: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 Makefile:465: recipe for target 'all' failed
make: *** [all] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx