From: Rob Clark <robdclark@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
Petri Latvala <petri.latvala@intel.com>,
linux-arm-msm@vger.kernel.org,
Akhil P Oommen <akhilpo@codeaurora.org>,
Jordan Crouse <jordan@cosmicpenguin.net>,
freedreno@lists.freedesktop.org
Subject: [igt-dev] [PATCH igt v3 2/4] lib/igt_debugfs: Add helper for detecting debugfs files
Date: Mon, 15 Nov 2021 16:30:40 -0800 [thread overview]
Message-ID: <20211116003042.439107-3-robdclark@gmail.com> (raw)
In-Reply-To: <20211116003042.439107-1-robdclark@gmail.com>
From: Rob Clark <robdclark@chromium.org>
Add a helper that can be used with, for ex, igt_require() so that tests
can be skipped if the kernel is too old.
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
lib/igt_debugfs.c | 21 +++++++++++++++++++++
lib/igt_debugfs.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index dd6f2995..7211c410 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -307,6 +307,27 @@ int igt_debugfs_open(int device, const char *filename, int mode)
return ret;
}
+/**
+ * igt_debugfs_exists:
+ * @device: the drm device file fd
+ * @filename: file name
+ * @mode: mode bits as used by open()
+ *
+ * Test that the specified debugfs file exists and can be opened with the
+ * requested mode.
+ */
+bool igt_debugfs_exists(int device, const char *filename, int mode)
+{
+ int fd = igt_debugfs_open(device, filename, mode);
+
+ if (fd >= 0) {
+ close(fd);
+ return true;
+ }
+
+ return false;
+}
+
/**
* igt_debugfs_simple_read:
* @filename: file name
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index b4867681..37e85067 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -39,6 +39,7 @@ int igt_debugfs_connector_dir(int device, char *conn_name, int mode);
int igt_debugfs_pipe_dir(int device, int pipe, int mode);
int igt_debugfs_open(int fd, const char *filename, int mode);
+bool igt_debugfs_exists(int fd, const char *filename, int mode);
void __igt_debugfs_read(int fd, const char *filename, char *buf, int size);
void __igt_debugfs_write(int fd, const char *filename, const char *buf, int size);
int igt_debugfs_simple_read(int dir, const char *filename, char *buf, int size);
--
2.33.1
next prev parent reply other threads:[~2021-11-16 0:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-16 0:30 [igt-dev] [PATCH igt v3 0/4] msm: Add tests for gpu fault handling Rob Clark
2021-11-16 0:30 ` [igt-dev] [PATCH igt v3 1/4] lib/igt_debugfs: Add helper for writing debugfs files Rob Clark
2021-11-16 0:30 ` Rob Clark [this message]
2021-11-16 4:59 ` [igt-dev] [PATCH igt v3 2/4] lib/igt_debugfs: Add helper for detecting " Petri Latvala
2021-11-16 0:30 ` [igt-dev] [PATCH igt v3 3/4] msm: Add helper for cmdstream building and submission Rob Clark
2021-11-16 0:30 ` [igt-dev] [PATCH igt v3 4/4] msm: Add recovery tests Rob Clark
2021-11-16 1:20 ` [igt-dev] ✓ Fi.CI.BAT: success for msm: Add tests for gpu fault handling (rev3) Patchwork
2021-11-16 2:35 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2021-11-19 11:55 ` [igt-dev] [PATCH igt v3 0/4] msm: Add tests for gpu fault handling Petri Latvala
2021-11-19 16:19 ` Rob Clark
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=20211116003042.439107-3-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=akhilpo@codeaurora.org \
--cc=freedreno@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=jordan@cosmicpenguin.net \
--cc=linux-arm-msm@vger.kernel.org \
--cc=petri.latvala@intel.com \
--cc=robdclark@chromium.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