linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: "André Almeida" <andrealmeid@collabora.com>
Cc: linux-block@vger.kernel.org, osandov@fb.com,
	kernel@collabora.com, krisman@collabora.com
Subject: Re: [PATCH blktests 1/3] check: Add configuration file option
Date: Wed, 30 Oct 2019 14:16:52 -0700	[thread overview]
Message-ID: <20191030211652.GB326591@vader> (raw)
In-Reply-To: <20191029200942.83044-2-andrealmeid@collabora.com>

On Tue, Oct 29, 2019 at 05:09:40PM -0300, André Almeida wrote:
> Add an option to be possible to use a different configuration file
> rather than the default "config" file.
> 
> Signed-off-by: André Almeida <andrealmeid@collabora.com>
> ---
>  check | 29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/check b/check
> index 981058c..936b0c3 100755
> --- a/check
> +++ b/check
> @@ -635,6 +635,9 @@ Test runs:
>    -x, --exclude=TEST	 exclude a test (or test group) from the list of
>  			 tests to run
>  
> +  -c, --config=FILE	 use FILE for loading configuration instead of
> +			 default 'config' filename.
> +
>  Miscellaneous:
>    -h, --help             display this help message and exit"
>  
> @@ -650,7 +653,7 @@ Miscellaneous:
>  	esac
>  }
>  
> -if ! TEMP=$(getopt -o 'do:q::x:h' --long 'quick::,exclude:,output:,help' -n "$0" -- "$@"); then
> +if ! TEMP=$(getopt -o 'do:q::x:c:h' --long 'quick::,exclude:,output:,config:,help' -n "$0" -- "$@"); then
>  	exit 1
>  fi
>  
> @@ -659,10 +662,8 @@ unset TEMP
>  
>  LOGGER_PROG="$(type -P logger)" || LOGGER_PROG=true
>  
> -if [[ -r config ]]; then
> -	# shellcheck disable=SC1091
> -	. config
> -fi
> +# true if the default configuration file "config" should be used
> +DEFAULT_CONFIG=true
>  
>  # Default configuration.
>  : "${DEVICE_ONLY:=0}"
> @@ -706,6 +707,17 @@ while true; do
>  			EXCLUDE+=("$2")
>  			shift 2
>  			;;
> +		'-c'|'--config')
> +			if [[ -r "$2" ]]; then
> +				# shellcheck source=/dev/null
> +				. "$2"
> +				DEFAULT_CONFIG=false
> +			else
> +				echo "Configuration file $2 not found!"
> +				usage err
> +			fi
> +			shift 2
> +			;;

If the user specifies -c multiple times, it will source each one, not
just the last one. Is that intentional? That might actually be a useful
feature, but we'd want to document it.

>  		'-h'|'--help')
>  			usage out
>  			;;
> @@ -719,6 +731,13 @@ while true; do
>  	esac
>  done
>  
> +# if '-c' was not used, try to use the default config file
> +if [[ -r config ]] && $DEFAULT_CONFIG; then
> +	# shellcheck source=/dev/null
> +	. config
> +fi
> +
> +
>  if [[ $QUICK_RUN -ne 0 && ! "${TIMEOUT:-}" ]]; then
>  	_error "QUICK_RUN specified without TIMEOUT"
>  fi
> -- 
> 2.23.0
> 

  reply	other threads:[~2019-10-30 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 20:09 [PATCH blktests 0/3] Add --config argument for custom config filenames André Almeida
2019-10-29 20:09 ` [PATCH blktests 1/3] check: Add configuration file option André Almeida
2019-10-30 21:16   ` Omar Sandoval [this message]
2019-10-30 22:05     ` André Almeida
2019-10-29 20:09 ` [PATCH blktests 2/3] Documentation: Add information about `--config` argument André Almeida
2019-10-29 20:09 ` [PATCH blktests 3/3] check: Make "device-only" option a valid option André Almeida
2019-10-30 21:18 ` [PATCH blktests 0/3] Add --config argument for custom config filenames Omar Sandoval
2019-10-30 22:14   ` André Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191030211652.GB326591@vader \
    --to=osandov@osandov.com \
    --cc=andrealmeid@collabora.com \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).