Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib/drmtest: Change do_ioctl_err() macro to function
Date: Fri, 28 Apr 2023 13:52:57 +0200	[thread overview]
Message-ID: <20230428115257.59885-1-zbigniew.kempczynski@intel.com> (raw)

Chris enlightened me after I did some review do_ioctl_err() macro
is a little bit problematic when it catches unexpected error (debug
output isn't much descriptive). As we plan to use it widely in xe
uapi verification lets make error callstack more readable.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 lib/drmtest.c | 12 ++++++++++++
 lib/drmtest.h | 10 +++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index c91a914257..759e889874 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -681,3 +681,15 @@ void igt_require_xe(int fd)
 {
 	igt_require(is_xe_device(fd));
 }
+
+void do_ioctl_err(int fd, unsigned long ioc, void *ioc_data, int err)
+{
+	int ret;
+
+	ret = igt_ioctl(fd, ioc, ioc_data);
+	igt_assert_f(ret == -1,
+		     "ioctl should fail with -1 but returned %d\n", ret);
+	igt_assert_f(errno == err,
+		     "errno fail - returned: %d, expected: %d\n", errno, err);
+	errno = 0;
+}
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 3c88b85c6f..792996dd28 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -153,13 +153,9 @@ bool is_intel_device(int fd);
  * @ioc_data: data pointer for the ioctl operation
  * @err: value to expect in errno
  *
- * This macro wraps drmIoctl() and uses igt_assert to check that it fails,
- * returning a particular value in errno.
+ * This function wraps drmIoctl() and uses igt_assert to check that it fails,
+ * verifying expected errno in @err.
  */
-#define do_ioctl_err(fd, ioc, ioc_data, err) do { \
-	igt_assert_eq(igt_ioctl((fd), (ioc), (ioc_data)), -1); \
-	igt_assert_eq(errno, err); \
-	errno = 0; \
-} while (0)
+void do_ioctl_err(int fd, unsigned long ioc, void *ioc_data, int err);
 
 #endif /* DRMTEST_H */
-- 
2.34.1

             reply	other threads:[~2023-04-28 11:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 11:52 Zbigniew Kempczyński [this message]
2023-04-28 16:24 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/drmtest: Change do_ioctl_err() macro to function Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-05-09  6:39 [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński
2023-05-09  8:01 ` Kamil Konieczny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428115257.59885-1-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox