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

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

 



On Mon, May 29, 2017 at 05:00:14PM +0200, Laurent Vivier wrote:
> On 24/05/2017 18:08, 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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 61 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 3ba6354608da..d35a176ef210 100644
> > --- a/scripts/arch-run.bash
> > +++ b/scripts/arch-run.bash
> > @@ -172,6 +172,8 @@ env_add_errata ()
> >  			grep -q $errata <(env) && continue
> >  			eval export "$line"
> >  		done
> > +	elif [ ! -f "$ENV" ]; then
> > +		env_generate_errata
> >  	fi
> >  
> >  	if grep -q '^ERRATA_' <(env); then
> > @@ -183,6 +185,49 @@ env_add_errata ()
> >  	fi
> >  }
> >  
> > +env_generate_errata ()
> > +{
> > +	local kernel_version_string=$(uname -r)
> > +	local kernel_version=$(echo "$kernel_version_string" | cut -d. -f1)
> > +	local kernel_patchlevel=$(echo "$kernel_version_string" | cut -d. -f2 | sed 's/[^0-9].*//')
> > +	local kernel_sublevel=$(echo "$kernel_version_string" | cut -d. -f3- | sed 's/[^0-9].*//')
> > +	local line commit minver errata v p s have
> > +
> > +	[ "$ENVIRON_DEFAULT" != "yes" ] && return
> > +	[ ! -f errata.txt ] && return
> > +
> > +	for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do
> > +		commit=$(echo $line | cut -d: -f1)
> > +		minver=$(echo $line | cut -d: -f2)
> > +
> > +		errata="ERRATA_$commit"
> > +		grep -q $errata <(env) && continue
> 
> you can use:
> 
>     test -v $errata && continue
> 
> > +
> > +		v=$(echo "$minver" | cut -d. -f1)
> > +		p=$(echo "$minver" | cut -d. -f2)
> > +		s=$(echo "$minver" | cut -d. -f3)
> 
> you can use:
> 
>     IFS=. read v p s <<<$minver

Nice suggestions. Will do.

Thanks,
drew



[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