[igt-dev] [PATCH i-g-t v2 8/9] tests/perf_pmu: Explicitly test for engine availability in init tests
Tvrtko Ursulin
tursulin at ursulin.net
Mon Feb 5 11:37:41 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)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk> # v1
---
tests/perf_pmu.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index d00838c41333..260b04b09c86 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -72,11 +72,20 @@ 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));
+ 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