[Intel-gfx] [PATCH i-g-t 8/9] lib/igt_aux: Extend igt_debug_wait_for_keypres.

Daniel Vetter daniel at ffwll.ch
Wed Dec 10 02:20:20 PST 2014


On Tue, Dec 09, 2014 at 09:01:56PM -0500, Rodrigo Vivi wrote:
> Return key pressed and allow different messages.
> 
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

Hm, not sure how useful this really is - when the test fails I just hit ^C
and scream ;-)

What kind of use-case do you have in mind which requires such a structured
approach? In case of doubt I prefer my igt helpers to be really simple, so
if you think we really needs this we should add a new fancy version of
wait_for_keypress with the added msg and return code.
-Daniel

> ---
>  lib/igt_aux.c            | 9 ++++++---
>  lib/igt_aux.h            | 2 +-
>  lib/igt_kms.c            | 3 ++-
>  tests/kms_psr_sink_crc.c | 5 +++--
>  4 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index ff668d4..a6c5ba6 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -386,9 +386,10 @@ void igt_drop_root(void)
>   * inspection of the display is useful. Or when running a testcase in the
>   * background.
>   */
> -void igt_debug_wait_for_keypress(const char *var)
> +char igt_debug_wait_for_keypress(const char *var, const char *msg)
>  {
>  	struct termios oldt, newt;
> +	char key;
>  
>  	if (!isatty(STDIN_FILENO))
>  		return;
> @@ -400,14 +401,16 @@ void igt_debug_wait_for_keypress(const char *var)
>  	    !strstr(igt_interactive_debug, "all"))
>  		return;
>  
> -	igt_info("Press any key to continue ...\n");
> +	igt_info(msg);
>  
>  	tcgetattr ( STDIN_FILENO, &oldt );
>  	newt = oldt;
>  	newt.c_lflag &= ~ICANON;
>  	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
> -	getchar();
> +	key = getchar();
>  	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
> +
> +	return key;
>  }
>  
>  #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power"
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index 59022cd..158e4c5 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -60,7 +60,7 @@ void igt_system_suspend_autoresume(void);
>  /* dropping priviledges */
>  void igt_drop_root(void);
>  
> -void igt_debug_wait_for_keypress(const char *var);
> +char igt_debug_wait_for_keypress(const char *var, const char *msg);
>  
>  enum igt_runtime_pm_status {
>  	IGT_RUNTIME_PM_STATUS_ACTIVE,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 1387d01..5c7b2c7 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1561,7 +1561,8 @@ static int do_display_commit(igt_display_t *display,
>  
>  	LOG_UNINDENT(display);
>  
> -	igt_debug_wait_for_keypress("modeset");
> +	igt_debug_wait_for_keypress("modeset",
> +				    "Press any key to continue ...\n");
>  
>  	return 0;
>  }
> diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
> index e7a2ef4..8103ebb 100644
> --- a/tests/kms_psr_sink_crc.c
> +++ b/tests/kms_psr_sink_crc.c
> @@ -256,7 +256,7 @@ static void get_sink_crc(data_t *data, char *crc) {
>  	fclose(file);
>  
>  	igt_debug("%s\n", crc);
> -	igt_debug_wait_for_keypress("crc");
> +	igt_debug_wait_for_keypress("crc", "Press any key to continue ...\n");
>  
>  	/* The important value was already taken.
>  	 * Now give a time for human eyes
> @@ -305,7 +305,8 @@ static void assert_or_manual(bool condition, const char *expected)
>  		igt_info("Is %s?\n", expected);
>  	else
>  		igt_debug("%s\n", expected);
> -	igt_debug_wait_for_keypress("manual");
> +	igt_debug_wait_for_keypress("manual",
> +				    "Press any key to continue ...\n");
>  	igt_assert(igt_interactive_debug || condition);
>  }
>  
> -- 
> 1.9.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the Intel-gfx mailing list