Re: [PATCH i-g-t 06/15] lib: s/IGT_DEBUG_INTERACTIVE/--interactive-debug=var

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 12, 2015 at 10:21:58AM -0800, Rodrigo Vivi wrote:
> Use cmdline variable for interactive debug instead of env var.
> 
> v2: Make interactive-debug domain optional and use "all" when not set.
> 
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>

I went ahead and applied this one to igt.
-Daniel

> ---
>  lib/igt_aux.c  | 20 ++++++++++----------
>  lib/igt_aux.h  |  2 +-
>  lib/igt_core.c |  9 +++++++++
>  lib/igt_core.h |  2 ++
>  4 files changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index 3bad6c0..54e5c58 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -450,32 +450,32 @@ void igt_drop_root(void)
>  
>  /**
>   * igt_debug_wait_for_keypress:
> - * @key: env var lookup to to enable this wait
> + * @var: var lookup to to enable this wait
>   *
>   * Waits for a key press when run interactively and when the corresponding debug
> - * key is set in the IGT_DEBUG_INTERACTIVE environment variable. Multiple keys
> + * var is set in the --interactive-debug=<var> variable. Multiple keys
>   * can be specified as a comma-separated list or alternatively "all" if a wait
> - * should happen for all keys.  When not connected to a terminal the environment
> - * setting is ignored and execution immediately continues.
> + * should happen for all cases.
> + *
> + * When not connected to a terminal interactive_debug is ignored
> + * and execution immediately continues.
>   *
>   * This is useful for display tests where under certain situation manual
>   * inspection of the display is useful. Or when running a testcase in the
>   * background.
>   */
> -void igt_debug_wait_for_keypress(const char *key)
> +void igt_debug_wait_for_keypress(const char *var)
>  {
>  	struct termios oldt, newt;
> -	const char *env;
>  
>  	if (!isatty(STDIN_FILENO))
>  		return;
>  
> -	env = getenv("IGT_DEBUG_INTERACTIVE");
> -
> -	if (!env)
> +	if (!igt_interactive_debug)
>  		return;
>  
> -	if (!strstr(env, key) && !strstr(env, "all"))
> +	if (!strstr(igt_interactive_debug, var) &&
> +	    !strstr(igt_interactive_debug, "all"))
>  		return;
>  
>  	igt_info("Press any key to continue ...\n");
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index e1909a9..798a5b4 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -64,7 +64,7 @@ void igt_system_suspend_autoresume(void);
>  /* dropping priviledges */
>  void igt_drop_root(void);
>  
> -void igt_debug_wait_for_keypress(const char *key);
> +void igt_debug_wait_for_keypress(const char *var);
>  
>  enum igt_runtime_pm_status {
>  	IGT_RUNTIME_PM_STATUS_ACTIVE,
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index a74fe09..bd655be 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -233,6 +233,7 @@ enum {
>   OPT_RUN_SUBTEST,
>   OPT_DESCRIPTION,
>   OPT_DEBUG,
> + OPT_INTERACTIVE_DEBUG,
>   OPT_HELP = 'h'
>  };
>  
> @@ -403,6 +404,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>  	fprintf(f, "  --list-subtests\n"
>  		   "  --run-subtest <pattern>\n"
>  		   "  --debug[=log-domain]\n"
> +		   "  --interactive-debug[=domain]\n"
>  		   "  --help-description\n"
>  		   "  --help\n");
>  	if (help_str)
> @@ -435,6 +437,7 @@ static int common_init(int argc, char **argv,
>  		{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
>  		{"help-description", 0, 0, OPT_DESCRIPTION},
>  		{"debug", optional_argument, 0, OPT_DEBUG},
> +		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
>  		{"help", 0, 0, OPT_HELP},
>  		{0, 0, 0, 0}
>  	};
> @@ -520,6 +523,12 @@ static int common_init(int argc, char **argv,
>  	while ((c = getopt_long(argc, argv, short_opts, combined_opts,
>  			       &option_index)) != -1) {
>  		switch(c) {
> +		case OPT_INTERACTIVE_DEBUG:
> +			if (optarg && strlen(optarg) > 0)
> +				igt_interactive_debug = strdup(optarg);
> +			else
> +				igt_interactive_debug = "all";
> +			break;
>  		case OPT_DEBUG:
>  			igt_log_level = IGT_LOG_DEBUG;
>  			if (optarg && strlen(optarg) > 0)
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 5c5ee25..32041f6 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -511,6 +511,8 @@ bool igt_run_in_simulation(void);
>  
>  void igt_skip_on_simulation(void);
>  
> +const char *igt_interactive_debug;
> +
>  /* structured logging */
>  #ifndef IGT_LOG_DOMAIN
>  #define IGT_LOG_DOMAIN (NULL)
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux