Re: [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided

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

 



On 06/06/2017 20:22, Andrew Jones wrote:
> Provide a table mapping errata to minimum kernel versions and
> a function that will use the host's kernel version to determine
> the values for each errata variable. These errata variables, with
> values based on the host kernel, are now provided to all unit
> tests by default, if no environ is provided. Errata variables
> passed from the run script environment still take precedence.
> 
> Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
> ---
>  configure             | 11 +++++++++++
>  errata.txt            |  5 +++++
>  scripts/arch-run.bash | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 62 insertions(+)
>  create mode 100644 errata.txt
> 
> diff --git a/configure b/configure
> index 64722c9b263b..cde2cfe9db61 100755
> --- a/configure
> +++ b/configure
> @@ -14,6 +14,7 @@ host=$arch
>  cross_prefix=
>  endian=""
>  pretty_print_stacks=yes
> +environ_default=yes
>  u32_long=
>  
>  usage() {
> @@ -31,6 +32,9 @@ usage() {
>  	    --endian=ENDIAN        endianness to compile for (little or big, ppc64 only)
>  	    --[enable|disable]-pretty-print-stacks
>  	                           enable or disable pretty stack printing (enabled by default)
> +	    --[enable|disable]-default-environ
> +	                           enable or disable the generation of a default environ when
> +	                           no environ is provided by the user (enabled by default)
>  EOF
>      exit 1
>  }
> @@ -73,6 +77,12 @@ while [[ "$1" = -* ]]; do
>  	--disable-pretty-print-stacks)
>  	    pretty_print_stacks=no
>  	    ;;
> +	--enable-default-environ)
> +	    environ_default=yes
> +	    ;;
> +	--disable-default-environ)
> +	    environ_default=no
> +	    ;;
>  	--help)
>  	    usage
>  	    ;;
> @@ -183,5 +193,6 @@ TEST_DIR=$testdir
>  FIRMWARE=$firmware
>  ENDIAN=$endian
>  PRETTY_PRINT_STACKS=$pretty_print_stacks
> +ENVIRON_DEFAULT=$environ_default
>  U32_LONG_FMT=$u32_long
>  EOF
> diff --git a/errata.txt b/errata.txt
> new file mode 100644
> index 000000000000..95b66c837c63
> --- /dev/null
> +++ b/errata.txt
> @@ -0,0 +1,5 @@
> +#---------------:-----------------------:--------------------------------------
> +# commit	: minimum kernel	: summary
> +# 12 hex digits	: version		:
> +#---------------:-----------------------:--------------------------------------
> +#---------------:-----------------------:--------------------------------------
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 09072ee46366..b4aa67f3c94c 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -172,6 +172,8 @@ env_add_errata ()
>  			test -v $errata && continue
>  			eval export "$line"
>  		done
> +	elif [ ! -f "$ENV" ]; then
> +		env_generate_errata
>  	fi
>  
>  	if grep -q '^ERRATA_' <(env); then
> @@ -183,6 +185,50 @@ env_add_errata ()
>  	fi
>  }
>  
> +env_generate_errata ()
> +{
> +	local kernel_version_string=$(uname -r)
> +	local kernel_version kernel_patchlevel kernel_sublevel
> +	local line commit minver errata v p s have
> +
> +	IFS=. read kernel_version kernel_patchlevel kernel_sublevel <<<$kernel_version_string
> +	kernel_sublevel=${kernel_sublevel%%[!0-9]*}

I don't understand the pattern.

BASH(1)

${parameter%%word}
    The word is expanded to produce a pattern just as in pathname
    expansion

Pathname Expansion

    *      Matches any string
    [...]  Matches any one of the enclosed characters
           If  the  first character following the [ is a !  or a ^ then
           any character not enclosed is matched

So you need only "${kernel_sublevel%%-*}"

Laurent



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux