[igt-dev] [PATCH i-g-t 8/9] tests/perf_pmu: Explicitly test for engine availability in init tests

Tvrtko Ursulin tursulin at ursulin.net
Fri Feb 2 18:37:53 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.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 tests/perf_pmu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index d654ece63bb7..201aa0b40068 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -74,7 +74,12 @@ init(int gem_fd, const struct intel_execution_engine2 *e, uint8_t sample)
 {
 	int fd;
 
-	fd = open_pmu(__I915_PMU_ENGINE(e->class, e->instance, sample));
+	fd = perf_i915_open(__I915_PMU_ENGINE(e->class, e->instance, sample));
+
+	if (gem_has_engine(gem_fd, e->class, e->instance))
+		igt_assert(fd >= 0);
+	else
+		igt_assert(fd < 0 && errno == ENODEV);
 
 	close(fd);
 }
-- 
2.14.1



More information about the igt-dev mailing list