From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jonathan.cavitt@intel.com, saurabhg.gupta@intel.com,
alex.zuo@intel.com, kamil.konieczny@linux.intel.com,
vinay.belgaumkar@intel.com
Subject: [PATCH v2 1/2] tests/intel/sysfs: Restore sysfs values on test failure
Date: Thu, 31 Oct 2024 16:31:21 +0000 [thread overview]
Message-ID: <20241031163122.37356-2-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20241031163122.37356-1-jonathan.cavitt@intel.com>
The tests xe_sysfs_preempt_timeout and xe_sysfs_timeslice_duration
modify the values of preempt_timeout_us and timeslice_duration_us,
respectively. However, on a test failure, it is possible that these
values may remain in their modified states, resulting in the values
being used in future tests and causing unexpected behavior.
Save the respective modified values before starting the test and attempt
to restore the values on test exit.
Suggested-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
---
tests/intel/xe_sysfs_preempt_timeout.c | 34 ++++++++++++++++-------
tests/intel/xe_sysfs_timeslice_duration.c | 33 ++++++++++++++++------
2 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/tests/intel/xe_sysfs_preempt_timeout.c b/tests/intel/xe_sysfs_preempt_timeout.c
index 7fa0dfcdf7..1b9c26bfdc 100644
--- a/tests/intel/xe_sysfs_preempt_timeout.c
+++ b/tests/intel/xe_sysfs_preempt_timeout.c
@@ -183,8 +183,10 @@ igt_main
"preempt_timeout_min",
"preempt_timeout_max"}, };
int count = sizeof(property) / sizeof(property[0]);
+ int gt_count = 0;
int fd = -1, sys_fd, gt;
- int engines_fd = -1, gt_fd = -1;
+ int engines_fd[8], gt_fd[8];
+ unsigned int pts[8];
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
@@ -192,26 +194,38 @@ igt_main
sys_fd = igt_sysfs_open(fd);
igt_require(sys_fd != -1);
close(sys_fd);
+
+ xe_for_each_gt(fd, gt) {
+ gt_fd[gt_count] = xe_sysfs_gt_open(fd, gt);
+ igt_require(gt_fd[gt_count] != -1);
+ engines_fd[gt_count] = openat(gt_fd[gt_count], "engines", O_RDONLY);
+ igt_require(engines_fd[gt_count] != -1);
+ igt_assert(igt_sysfs_scanf(engines_fd[gt_count],
+ "preempt_timeout_us",
+ "%u", &pts[gt_count]) == 1);
+ gt_count++;
+ }
+
}
for (int i = 0; i < count; i++) {
for (typeof(*tests) *t = tests; t->name; t++) {
igt_subtest_with_dynamic_f("%s-%s", property[i][0], t->name) {
+ int j = 0;
xe_for_each_gt(fd, gt) {
- gt_fd = xe_sysfs_gt_open(fd, gt);
- igt_require(gt_fd != -1);
- engines_fd = openat(gt_fd, "engines", O_RDONLY);
- igt_require(engines_fd != -1);
-
- igt_sysfs_engines(fd, engines_fd, gt, 1, property[i],
- t->fn);
- close(engines_fd);
- close(gt_fd);
+ igt_sysfs_engines(fd, engines_fd[j], gt, 1, property[i],
+ t->fn);
+ j++;
}
}
}
}
igt_fixture {
+ for (int i = gt_count - 1; i >= 0; i--) {
+ set_preempt_timeout(engines_fd[i], pts[i]);
+ close(engines_fd[i]);
+ close(gt_fd[i]);
+ }
drm_close_driver(fd);
}
}
diff --git a/tests/intel/xe_sysfs_timeslice_duration.c b/tests/intel/xe_sysfs_timeslice_duration.c
index cf95a3ac1c..914575a282 100644
--- a/tests/intel/xe_sysfs_timeslice_duration.c
+++ b/tests/intel/xe_sysfs_timeslice_duration.c
@@ -155,8 +155,10 @@ igt_main
"timeslice_duration_min",
"timeslice_duration_max"}, };
int count = sizeof(property) / sizeof(property[0]);
+ int gt_count = 0;
int fd = -1, sys_fd, gt;
- int engines_fd = -1, gt_fd = -1;
+ int engines_fd[8], gt_fd[8];
+ unsigned int tds[8];
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
@@ -164,25 +166,38 @@ igt_main
sys_fd = igt_sysfs_open(fd);
igt_require(sys_fd != -1);
close(sys_fd);
+
+ xe_for_each_gt(fd, gt) {
+ gt_fd[gt_count] = xe_sysfs_gt_open(fd, gt);
+ igt_require(gt_fd[gt_count] != -1);
+ engines_fd[gt_count] = openat(gt_fd[gt_count],
+ "engines", O_RDONLY);
+ igt_require(engines_fd[gt_count] != -1);
+ igt_assert(igt_sysfs_scanf(engines_fd[gt_count],
+ "timeslice_duration_us",
+ "%u", &tds[gt_count]) == 1);
+ gt_count++;
+ }
}
for (int i = 0; i < count; i++) {
for (typeof(*tests) *t = tests; t->name; t++) {
igt_subtest_with_dynamic_f("%s-%s", property[i][0], t->name) {
+ int j = 0;
xe_for_each_gt(fd, gt) {
- gt_fd = xe_sysfs_gt_open(fd, gt);
- igt_require(gt_fd != -1);
- engines_fd = openat(gt_fd, "engines", O_RDONLY);
- igt_require(engines_fd != -1);
- igt_sysfs_engines(fd, engines_fd, gt, 1, property[i],
- t->fn);
- close(engines_fd);
- close(gt_fd);
+ igt_sysfs_engines(fd, engines_fd[j], gt, 1, property[i],
+ t->fn);
+ j++;
}
}
}
}
igt_fixture {
+ for (int i = gt_count - 1; i >= 0; i--) {
+ set_timeslice_duration(engines_fd[i], tds[i]);
+ close(engines_fd[i]);
+ close(gt_fd[i]);
+ }
drm_close_driver(fd);
}
}
--
2.43.0
next prev parent reply other threads:[~2024-10-31 16:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 16:31 [PATCH v2 0/2] test/intel/xe_sysfs: Restore sysfs params correctly Jonathan Cavitt
2024-10-31 16:31 ` Jonathan Cavitt [this message]
2024-10-31 18:16 ` [PATCH v2 1/2] tests/intel/sysfs: Restore sysfs values on test failure Kamil Konieczny
2024-10-31 21:07 ` Cavitt, Jonathan
2024-10-31 16:31 ` [PATCH v2 2/2] tests/intel/xe_sysfs_timeslice_duration: Restore preempt timeout Jonathan Cavitt
2024-10-31 18:30 ` Kamil Konieczny
2024-10-31 21:08 ` Cavitt, Jonathan
2024-11-04 16:32 ` ✓ CI.xeBAT: success for test/intel/xe_sysfs: Restore sysfs params correctly Patchwork
2024-11-04 16:39 ` ✓ Fi.CI.BAT: " Patchwork
2024-11-04 23:34 ` ✗ CI.xeFULL: failure " Patchwork
2024-11-05 6:42 ` ✗ Fi.CI.IGT: " Patchwork
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=20241031163122.37356-2-jonathan.cavitt@intel.com \
--to=jonathan.cavitt@intel.com \
--cc=alex.zuo@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=saurabhg.gupta@intel.com \
--cc=vinay.belgaumkar@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