[igt-dev] [PATCH i-g-t 8/9] tests/perf_pmu: Explicitly test for engine availability in init tests
Chris Wilson
chris at chris-wilson.co.uk
Fri Feb 2 20:57:07 UTC 2018
Quoting Tvrtko Ursulin (2018-02-02 18:37:53)
> 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);
Be valgrind friendly and only close() after success.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
(Do I have to go looking for other cases where we could be checking for
missed invalid tests? I hope not!)
-Chris
More information about the igt-dev
mailing list