From: priyanka.dandamudi@intel.com
To: janga.rahul.kumar@intel.com, tejas.upadhyay@intel.com,
igt-dev@lists.freedesktop.org, ramadevi.gandi@intel.com,
priyanka.dandamudi@intel.com
Subject: [igt-dev] [PATCH i-g-t 1/3] lib/igt_sysfs: Add support to iterate over engines
Date: Wed, 28 Jun 2023 15:22:37 +0530 [thread overview]
Message-ID: <20230628095239.615655-2-priyanka.dandamudi@intel.com> (raw)
In-Reply-To: <20230628095239.615655-1-priyanka.dandamudi@intel.com>
From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
It helps to test engines by iterating over sysfs/engines.
v2: Updated a parameter to accept array of strings to make dynamic for all schedulers.
Updated engine to engine_fd for better readability.(rahul)
Added description for lib function.(Kamil)
Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
lib/igt_sysfs.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_sysfs.h | 3 +++
2 files changed, 50 insertions(+)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 35a4faa9a..3a4bf6f97 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -856,3 +856,50 @@ void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw)
igt_assert_eq(get, prev);
igt_assert(!ret);
}
+
+/**
+ * igt_sysfs_engines:
+ * @xe: fd of the device
+ * @engines: fd of the directory engine
+ * @property: property array
+ * @test: Dynamic engine test
+ *
+ * It iterates over sysfs/engines and runs a dynamic engine test.
+ *
+ */
+void igt_sysfs_engines(int xe, int engines, const char **property,
+ void (*test)(int, int, const char **))
+{
+ struct dirent *de;
+ DIR *dir;
+
+ lseek(engines, 0, SEEK_SET);
+
+ dir = fdopendir(engines);
+ if (!dir)
+ close(engines);
+
+ while ((de = readdir(dir))) {
+ int engine_fd;
+
+ if (*de->d_name == '.')
+ continue;
+
+ engine_fd = openat(engines, de->d_name, O_RDONLY);
+ if (engine < 0)
+ continue;
+
+ igt_dynamic(de->d_name) {
+ if (property) {
+ struct stat st;
+
+ igt_require(fstatat(engine_fd, property[0], &st, 0) == 0);
+ igt_require(fstatat(engine_fd, property[1], &st, 0) == 0);
+ igt_require(fstatat(engine_fd, property[2], &st, 0) == 0);
+ }
+ errno = 0;
+ test(xe, engine_fd, property);
+ }
+ close(engine_fd);
+ }
+}
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 978b6906e..5635fc690 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -147,4 +147,7 @@ typedef struct igt_sysfs_rw_attr {
void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw);
+void igt_sysfs_engines(int xe, int engines, const char **property,
+ void (*test)(int, int, const char **));
+
#endif /* __IGT_SYSFS_H__ */
--
2.25.1
next prev parent reply other threads:[~2023-06-28 9:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 9:52 [igt-dev] [PATCH i-g-t 0/3] Add tests for scheduler control interface priyanka.dandamudi
2023-06-28 9:52 ` priyanka.dandamudi [this message]
2023-06-28 12:42 ` [igt-dev] [PATCH i-g-t 1/3] lib/igt_sysfs: Add support to iterate over engines Kumar, Janga Rahul
2023-06-28 9:52 ` [igt-dev] [PATCH i-g-t 2/3] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
2023-06-28 12:41 ` Kumar, Janga Rahul
2023-06-28 9:52 ` [igt-dev] [PATCH i-g-t 3/3] xe/xe_sysfs_scheduler: Verify scheduler control interface priyanka.dandamudi
2023-06-28 12:38 ` Kumar, Janga Rahul
2023-06-28 13:57 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Add tests for scheduler control interface (rev3) Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-06-29 5:43 [igt-dev] [PATCH i-g-t 0/3] Add tests for scheduler control interface priyanka.dandamudi
2023-06-29 5:43 ` [igt-dev] [PATCH i-g-t 1/3] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
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=20230628095239.615655-2-priyanka.dandamudi@intel.com \
--to=priyanka.dandamudi@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=janga.rahul.kumar@intel.com \
--cc=ramadevi.gandi@intel.com \
--cc=tejas.upadhyay@intel.com \
/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