summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2021-01-25 23:04:17 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2021-01-27 20:32:39 +0000
commite2a754840c4d413b7b7a642caca47f7d174d6304 (patch)
tree6cdece9a5b521cf446d2eaac2da3f8d8037a08ec /tests
parenta85398dcae50930c0e27548cf8c9575ad0bf69d1 (diff)
i915/sysfs_client: Ignore clients being closed as we read their sysfs
An earlier client from an old test may still be lingering and disappear as we scan the sysfs. Be graceful and let it go without tripping over it. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3008 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/i915/sysfs_clients.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/i915/sysfs_clients.c b/tests/i915/sysfs_clients.c
index 6be52c04..a3a1f81e 100644
--- a/tests/i915/sysfs_clients.c
+++ b/tests/i915/sysfs_clients.c
@@ -62,11 +62,13 @@
static void strterm(char *s, int len)
{
- igt_assert(len > 0);
-
- s[len] = '\0';
- if (s[len - 1] == '\n')
- s[len - 1] = '\0';
+ if (len < 0) {
+ *s = '\0';
+ } else {
+ s[len] = '\0';
+ if (s[len - 1] == '\n')
+ s[len - 1] = '\0';
+ }
}
static void pidname(int i915, int clients)
@@ -78,7 +80,6 @@ static void pidname(int i915, int clients)
long count;
pid_t pid;
DIR *dir;
- int len;
dir = fdopendir(dup(clients));
igt_assert(dir);
@@ -90,13 +91,11 @@ static void pidname(int i915, int clients)
continue;
snprintf(buf, sizeof(buf), "%s/name", de->d_name);
- len = igt_sysfs_read(clients, buf, buf, sizeof(buf) - 1);
- igt_assert_f(len > 0, "failed to open '%s/name'\n", de->d_name);
- strterm(buf, len);
+ strterm(buf, igt_sysfs_read(clients, buf, buf, sizeof(buf) - 1));
igt_debug("%s: %s\n", de->d_name, buf);
/* Ignore closed clients created by drm_driver_open() */
- if (*buf == '<')
+ if (*buf == '\0' || *buf == '<')
continue;
close(me);