All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com,
	thuth@redhat.com
Subject: Re: [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided
Date: Tue, 13 Jun 2017 10:12:48 +0200	[thread overview]
Message-ID: <20170613081248.6hmjkd6rlyi5hhp5@kamzik.brq.redhat.com> (raw)
In-Reply-To: <01074441-0ed2-6ab1-6962-82f045c379b6@redhat.com>

On Thu, Jun 08, 2017 at 12:43:20PM +0200, Laurent Vivier wrote:
> 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@redhat.com>
> > ---
> >  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%%-*}"

This assumes the kernel's EXTRAVERSION starts with a '-', which is likely
a safe assumption, but the pattern I used ensures any non-digit will be
dropped, which is safer, because kernel_sublevel gets used in arithmetic
expressions.

Thanks,
drew

  reply	other threads:[~2017-06-13  8:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 18:22 [PATCH kvm-unit-tests v2 0/9] Extend and apply the errata framework Andrew Jones
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 1/9] arch-run: introduce initrd_create Andrew Jones
2017-06-08 10:04   ` Laurent Vivier
2017-06-13  8:04     ` Andrew Jones
2017-06-13  9:50       ` Laurent Vivier
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 2/9] arch-run: provide errata from run env Andrew Jones
2017-06-08 10:25   ` Laurent Vivier
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 3/9] x86/run: source config.mak Andrew Jones
2017-06-08 10:25   ` Laurent Vivier
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided Andrew Jones
2017-06-08 10:43   ` Laurent Vivier
2017-06-13  8:12     ` Andrew Jones [this message]
2017-06-13 10:01       ` Laurent Vivier
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 5/9] mkstandalone: provide errata to tests Andrew Jones
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 6/9] errata: add ERRATA_FORCE Andrew Jones
2017-06-08 10:56   ` Laurent Vivier
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 7/9] README: add section on guarding unsafe tests Andrew Jones
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 8/9] AArch32: apply errata framework to unsafe pmccntr64 test Andrew Jones
2017-06-06 18:22 ` [PATCH kvm-unit-tests v2 9/9] arm/arm64: apply errata framework to unsafe cpu-on test Andrew Jones

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=20170613081248.6hmjkd6rlyi5hhp5@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.