Skip to contentSkip to conversation

drmtest: don't discard return value in do_ioctl()

PATCH In review Robert Bragg 2 participants 6 messages May 4, 2016 – May 5, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drmtest: don't discard return value in do_ioctl()

In preparation for testing DRM_IOCTL_I915_PERF_OPEN which returns a file descriptor this allows us to get the return value of ioctl called by the do_ioctl() utility.

---
 lib/drmtest.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
lib/drmtest.h +8 -3
index c391464..6aee1e8 100644
@@ -104,11 +104,16 @@ bool is_i915_device(int fd);
  *
  * This macro wraps drmIoctl() and uses igt_assert to check that it has been
  * successfully executed.
+ *
+ * It's implemented using a gcc statement expression to still be able to
+ * assign the ioctl's return value after the assertion too.
  */
-#define do_ioctl(fd, ioc, ioc_data) do { \
-	igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), 0); \
+#define do_ioctl(fd, ioc, ioc_data) ({ \
+        int _ret = drmIoctl((fd), (ioc), (ioc_data)); \
+        igt_assert(_ret >= 0); \
 	errno = 0; \
-} while (0)
+        _ret; \
+})
 
 /**
  * do_ioctl_err:
Signature · 6 lines
2.7.1

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

PATCH 2/2 igt/perf: add i915 perf stream tests

---
 tests/Makefile.sources |    1 +
 tests/perf.c           | 2053 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 2054 insertions(+)
 create mode 100644 tests/perf.c
tests/Makefile.sources +1 -0
index 9ea9b5b..5292749 100644
@@ -195,6 +195,7 @@ TESTS_progs = \
 	kms_pwrite_crc \
 	kms_sink_crc_basic \
 	prime_udl \
+	perf \
 	$(NULL)
 
 # IMPORTANT: The ZZ_ tests need to be run last!
tests/perf.c new file +2053 -0

2,053 lines not on this page · raw message

Signature · 6 lines
2.7.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
In reply to Robert Bragg
Quoted 15 lines · Robert Bragg

In preparation for testing DRM_IOCTL_I915_PERF_OPEN which returns a file descriptor this allows us to get the return value of ioctl called by the do_ioctl() utility.

---
 lib/drmtest.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
lib/drmtest.h +0 -0
index c391464..6aee1e8 100644
@@ -104,11 +104,16 @@ bool is_i915_device(int fd);
  *

lib/drmtest.h bool is_i915_device(int fd); · line 112

Quoted 10 lines
lib/drmtest.h +5 -2
  * This macro wraps drmIoctl() and uses igt_assert to check that it has been
  * successfully executed.
+ *
+ * It's implemented using a gcc statement expression to still be able to
+ * assign the ioctl's return value after the assertion too.
  */
-#define do_ioctl(fd, ioc, ioc_data) do { \
-	igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), 0); \
+#define do_ioctl(fd, ioc, ioc_data) ({ \
+        int _ret = drmIoctl((fd), (ioc), (ioc_data)); \

No. Breaking igt is not acceptable.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 1/1 drmtest: don't discard return value in do_ioctl()

Fixed a rebase mistake where I dropped the use of the igt_ioctl wrapper in do_ioctl().

I'm not entirely sure a.t.m whether the assertion change from ret == 0 to ret >= 0 will break anything, though comparing run-tests.sh -s -t basic before/after didn't seem to highlight a problem for me.

--- >8 ---

In preparation for testing DRM_IOCTL_I915_PERF_OPEN which returns a file descriptor this allows us to get the return value of ioctl called by the do_ioctl() utility.

---
 lib/drmtest.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
lib/drmtest.h +8 -3
index c391464..b917ecb 100644
@@ -104,11 +104,16 @@ bool is_i915_device(int fd);
  *
  * This macro wraps drmIoctl() and uses igt_assert to check that it has been
  * successfully executed.
+ *
+ * It's implemented using a gcc statement expression to still be able to
+ * assign the ioctl's return value after the assertion too.
  */
-#define do_ioctl(fd, ioc, ioc_data) do { \
-	igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), 0); \
+#define do_ioctl(fd, ioc, ioc_data) ({ \
+        int _ret = igt_ioctl((fd), (ioc), (ioc_data)); \
+        igt_assert(_ret >= 0); \
 	errno = 0; \
-} while (0)
+        _ret; \
+})
 
 /**
  * do_ioctl_err:
Signature · 6 lines
2.7.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 25 lines · Robert Bragg

Fixed a rebase mistake where I dropped the use of the igt_ioctl wrapper in do_ioctl().

I'm not entirely sure a.t.m whether the assertion change from ret == 0 to ret >= 0 will break anything, though comparing run-tests.sh -s -t basic before/after didn't seem to highlight a problem for me.

--- >8 ---

In preparation for testing DRM_IOCTL_I915_PERF_OPEN which returns a file descriptor this allows us to get the return value of ioctl called by the do_ioctl() utility.

---
 lib/drmtest.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
lib/drmtest.h +0 -0
index c391464..b917ecb 100644
@@ -104,11 +104,16 @@ bool is_i915_device(int fd);
  *
  * This macro wraps drmIoctl() and uses igt_assert to check that it has been

lib/drmtest.h bool is_i915_device(int fd); · line 113

Quoted 10 lines
lib/drmtest.h +6 -2
  * successfully executed.
+ *
+ * It's implemented using a gcc statement expression to still be able to
+ * assign the ioctl's return value after the assertion too.
  */
-#define do_ioctl(fd, ioc, ioc_data) do { \
-	igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), 0); \
+#define do_ioctl(fd, ioc, ioc_data) ({ \
+        int _ret = igt_ioctl((fd), (ioc), (ioc_data)); \
+        igt_assert(_ret >= 0); \

And now we have the unhelpful error message !(_ret >= 0)

For the single user, just don't use do_ioctl.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 41 lines · Chris Wilson
Quoted 1 line · Robert Bragg

Fixed a rebase mistake where I dropped the use of the igt_ioctl wrapper

in

Quoted 22 lines

do_ioctl().

I'm not entirely sure a.t.m whether the assertion change from ret == 0 to ret >= 0 will break anything, though comparing run-tests.sh -s -t basic before/after didn't seem to highlight a problem for me.

--- >8 ---

In preparation for testing DRM_IOCTL_I915_PERF_OPEN which returns a file descriptor this allows us to get the return value of ioctl called by the do_ioctl() utility.

---
 lib/drmtest.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
lib/drmtest.h +0 -0
index c391464..b917ecb 100644

lib/drmtest.h bool is_i915_device(int fd); · line 105

Quoted 2 lines
lib/drmtest.h +0 -0
@@ -104,11 +104,16 @@ bool is_i915_device(int fd);
  *
  * This macro wraps drmIoctl() and uses igt_assert to check that it has

been

lib/drmtest.h bool is_i915_device(int fd); · line 113

Quoted 10 lines
lib/drmtest.h +6 -2
  * successfully executed.
+ *
+ * It's implemented using a gcc statement expression to still be able to
+ * assign the ioctl's return value after the assertion too.
  */
-#define do_ioctl(fd, ioc, ioc_data) do { \
-     igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), 0); \
+#define do_ioctl(fd, ioc, ioc_data) ({ \
+        int _ret = igt_ioctl((fd), (ioc), (ioc_data)); \
+        igt_assert(_ret >= 0); \

And now we have the unhelpful error message !(_ret >= 0)

Quoted 2 lines

For the single user, just don't use do_ioctl.

Ah, right, not great.

I suppose having something like igt_assert((_ret = igt_ioctl((fd), (ioc), (ioc_data))) >= 0); might be a bit better, but adds noise to the simpler cases. Sounds ok to just have a special case ioctl wrapper in tests/perf.c.

- Robert

Quoted 5 lines

-Chris

--
Chris Wilson, Intel Open Source Technology Centre

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