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

Chris Wilson chris at chris-wilson.co.uk
Mon Feb 5 14:14:42 UTC 2018


Quoting Tvrtko Ursulin (2018-02-05 11:37:41)
> 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;

To be really pedantic, errno is only valid on success.

err = 0;
if (fd < 0)
	err = errno;

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list