[igt-dev] [PATCH i-g-t v3 8/9] tests/perf_pmu: Explicitly test for engine availability in init tests
Tvrtko Ursulin
tursulin at ursulin.net
Mon Feb 5 15:02:21 UTC 2018
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Test will succeed if present engine can be opened, or if the missing
engine reports the correct error code.
v2:
* Use the right errno.
* Close fd only on success. (Chris Wilson)
v3:
* Only sample errno on failure. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/perf_pmu.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 3d1b3a2c7c61..5b38712fe734 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -72,11 +72,21 @@ static int open_group(uint64_t config, int group)
static void
init(int gem_fd, const struct intel_execution_engine2 *e, uint8_t sample)
{
- int fd;
+ int fd, err = 0;
- fd = open_pmu(__I915_PMU_ENGINE(e->class, e->instance, sample));
+ errno = 0;
+ fd = perf_i915_open(__I915_PMU_ENGINE(e->class, e->instance, sample));
+ if (fd < 0)
+ err = errno;
- close(fd);
+ if (gem_has_engine(gem_fd, e->class, e->instance)) {
+ igt_assert_eq(err, 0);
+ igt_assert_fd(fd);
+ close(fd);
+ } else {
+ igt_assert_lt(fd, 0);
+ igt_assert_eq(err, ENODEV);
+ }
}
static uint64_t pmu_read_single(int fd)
--
2.14.1
More information about the igt-dev
mailing list