summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-01-11 10:32:59 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-01-11 11:38:15 +0000
commite7fb96af70605a6a8fa4838c5ca7c132c8b5e942 (patch)
treead64c7bc1be6c80483381731cc856a4a311265a5 /tests
parent861435af62a43237203877c2f5cf9c4cb61a2a3d (diff)
i915/hangman: Read a dummy byte to check sysfs existence
sysfs doesn't give the driver an open() callback, so we can only report the unavailability of HW on the first read; so check read() after checking open(). Fixes: 93f0ad4b835e ("i915/hangman: Skip if disabled by the kernel") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/i915/hangman.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/i915/hangman.c b/tests/i915/hangman.c
index 4035f738..df1e0afe 100644
--- a/tests/i915/hangman.c
+++ b/tests/i915/hangman.c
@@ -44,14 +44,20 @@ static int sysfs = -1;
static bool has_error_state(int dir)
{
+ bool result;
int fd;
fd = openat(dir, "error", O_RDONLY);
if (fd < 0)
return false;
+ if (read(fd, &result, sizeof(result)) < 0)
+ result = false;
+ else
+ result = true;
+
close(fd);
- return true;
+ return result;
}
static void assert_entry(const char *s, bool expect)