[Intel-gfx] [PATCH igt] igt/tools_test: Check the tools exist before executing

Petri Latvala petri.latvala at intel.com
Wed Dec 13 09:53:13 UTC 2017


On Tue, Dec 12, 2017 at 05:22:01PM +0000, Chris Wilson wrote:
> As a simple fail-safe against a bad installation, check the tools exist
> before testing whether they work.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102935
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  tests/tools_test.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 6aea7a8a4..a4fc68e8b 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -26,6 +26,9 @@
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <fcntl.h>
> +#include <unistd.h>
> +
> +#define TOOLS "../tools/"
>  
>  struct line_check {
>  	int found;
> @@ -112,17 +115,13 @@ igt_main
>  	}
>  
>  	igt_subtest("tools_test") {
> -		char *cmd;
> -
> -		igt_assert(asprintf(&cmd,
> -				    "../tools/intel_reg read 0x4030")
> -			   != -1);
> -		igt_assert(igt_system_quiet(cmd) == IGT_EXIT_SUCCESS);
> -		free(cmd);
> -
> -		igt_assert(asprintf(&cmd, "../tools/intel_reg dump")
> -			   != -1);
> -		igt_assert(igt_system_quiet(cmd) == IGT_EXIT_SUCCESS);
> -		free(cmd);
> +		igt_require(access(TOOLS "intel_reg_read", X_OK) == 0);
> +		igt_require(access(TOOLS "intel_reg_dump", X_OK) == 0);
> +
> +		igt_assert_eq(igt_system_quiet(TOOLS "intel_reg read 0x4030"),
> +			      IGT_EXIT_SUCCESS);
> +
> +		igt_assert_eq(igt_system_quiet(TOOLS "intel_reg dump"),
> +			      IGT_EXIT_SUCCESS);
>  	}
>  }


This whole test needs some loving in the form of a helper to find an
executable in $srcdir/tools or $bindir, like igt_fopen_data(), but
that can be left for later.

Can you also add the same check in the l3 parity subtest?


Reviewed-by: Petri Latvala <petri.latvala at intel.com>


More information about the Intel-gfx mailing list