summaryrefslogtreecommitdiff
path: root/tests/perf_pmu.c
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-05 15:02:21 +0000
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-05 18:02:36 +0000
commitf5166e367265ea164d4c459dfe3ea7c08f01764e (patch)
treeea07d484db03f5b9e3393dda3835ac3f6cb79e48 /tests/perf_pmu.c
parent5eb6a554dec274618ae351c7aa3c1b6bc2295160 (diff)
tests/perf_pmu: Explicitly test for engine availability in init tests
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@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/perf_pmu.c')
-rw-r--r--tests/perf_pmu.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 3d1b3a2c..5b38712f 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)