Extend and apply the errata framework
Subsystems (3)
v2 cover Extend and apply the errata framework
We've had an errata framework merged in for a while, but it hasn't been getting used (at least not upstream). This series extends it to allow run script environment provided and host kernel version based generated errata variables to be automatically provided to unit tests. It then changes a couple arm unit tests to use the errata framework, now that it's more useful.
The benefit of this over always using the 'nodefault' group is that once a host has been patched the unit test will automatically start running as a regression test - no need to manually run it, meaning no concern that it will likely never actually be run...
v2:
- apply a couple good bash suggestions from Laurent
- apply some debatable bashisms for string manipulation, which swaps readability for reduced pipes... [me]
Andrew Jones (9):
arch-run: introduce initrd_create
arch-run: provide errata from run env
x86/run: source config.mak
arch-run: generate errata when no environ is provided
mkstandalone: provide errata to tests
errata: add ERRATA_FORCE
README: add section on guarding unsafe tests
AArch32: apply errata framework to unsafe pmccntr64 test arm/arm64: apply errata framework to unsafe cpu-on test
README.md | 34 +++++++++++++++++++++ arm/pmu.c | 26 +++++++++++----- arm/psci.c | 7 ++++- arm/run | 5 ++-- arm/unittests.cfg | 2 +- configure | 12 ++++++++ errata.txt | 7 +++++ lib/errata.h | 21 +++++++++++-- powerpc/run | 5 ++-- run_tests.sh | 2 ++ scripts/arch-run.bash | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/mkstandalone.sh | 6 ++++ x86/run | 14 +++++++-- 13 files changed, 201 insertions(+), 19 deletions(-) create mode 100644 errata.txt
Signature · 1 line
2.9.4
PATCH v2 1/9 arch-run: introduce initrd_create
Encapsulate the preparation of the optional initrd command line option.
--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)
arm/run +3 -2
@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"
powerpc/run +3 -2
@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"
scripts/arch-run.bash +5 -0
@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && INITRD="-initrd $ENV" +}
x86/run +3 -2
@@ -26,9 +26,10 @@ else pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" fi +initrd_create + command="${qemu} -nodefaults -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -kernel" +command+=" $INITRD -kernel" command="$(timeout_cmd) $command" echo ${command} "$@"
Signature · 1 line
2.9.4
PATCH v2 3/9 x86/run: source config.mak
In reply to Andrew Jonesx86/run will need to start looking at config vars with the next patch.
--- x86/run | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
x86/run +8 -1
@@ -1,6 +1,13 @@ #!/usr/bin/env bash -[ -z "$STANDALONE" ] && source scripts/arch-run.bash +if [ -z "$STANDALONE" ]; then + if [ ! -f config.mak ]; then + echo "run ./configure && make first. See ./configure -h" + exit 2 + fi + source config.mak + source scripts/arch-run.bash +fi qemu=$(search_qemu_binary)
Signature · 1 line
2.9.4
PATCH v2 5/9 mkstandalone: provide errata to tests
In reply to Andrew Jones--- configure | 1 + scripts/arch-run.bash | 4 ++-- scripts/mkstandalone.sh | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
configure +1 -0
@@ -194,5 +194,6 @@ FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks ENVIRON_DEFAULT=$environ_default +ERRATATXT=errata.txt U32_LONG_FMT=$u32_long EOF
scripts/arch-run.bash +2 -2
@@ -195,9 +195,9 @@ env_generate_errata () kernel_sublevel=${kernel_sublevel%%[!0-9]*} [ "$ENVIRON_DEFAULT" != "yes" ] && return - [ ! -f errata.txt ] && return + [ ! -f "$ERRATATXT" ] && return - for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do + for line in $(grep -v '^#' "$ERRATATXT" | tr -d '[:blank:]' | cut -d: -f1,2); do commit=${line%:*} minver=${line#*:}
scripts/mkstandalone.sh +6 -0
@@ -40,6 +40,7 @@ generate_test () echo "#!/usr/bin/env bash" echo "export STANDALONE=yes" + echo "export ENVIRON_DEFAULT=yes" echo "export HOST=\$(uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/')" echo "export PRETTY_PRINT_STACKS=no"
@@ -62,6 +63,11 @@ generate_test () echo 'export FIRMWARE' fi + if [ "$ERRATATXT" ]; then + temp_file ERRATATXT "$ERRATATXT" + echo 'export ERRATATXT' + fi + temp_file bin "$kernel" args[3]='$bin'
Signature · 1 line
2.9.4
PATCH v2 2/9 arch-run: provide errata from run env
In reply to Andrew JonesAllow the run script environment to provide ERRATA_* variables to the unit tests. These variables will augment/override variables in any provided unit test environ (the file specified with $ENV) or trigger the creation of a temporary environ file, which contains them.
Now something like
ERRATA_abcd01234567=y ./run_tests.sh
may be run in order to inform all unit tests that they may execute all subtests guarded by ERRATA_abcd01234567.
--- scripts/arch-run.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
scripts/arch-run.bash +28 -0
@@ -158,5 +158,33 @@ search_qemu_binary () initrd_create () { + env_add_errata [ -f "$ENV" ] && INITRD="-initrd $ENV" } + +env_add_errata () +{ + local line errata + + if [ -f "$ENV" ] && grep -q '^ERRATA_' <(env); then + for line in $(grep '^ERRATA_' "$ENV"); do + errata=${line%%=*} + test -v $errata && continue + eval export "$line" + done + fi + + if grep -q '^ERRATA_' <(env); then + export ENV_OLD="$ENV" + export ENV=$(mktemp) + trap_exit_push 'rm -f $ENV; [ "$ENV_OLD" ] && export ENV="$ENV_OLD" || unset ENV; unset ENV_OLD' + [ -f "$ENV_OLD" ] && grep -v '^ERRATA_' "$ENV_OLD" > $ENV + grep '^ERRATA_' <(env) >> $ENV + fi +} + +trap_exit_push () +{ + local old_exit=$(trap -p EXIT | sed "s/^[^']*'//;s/'[^']*$//") + trap -- "$1; $old_exit" EXIT +}
Signature · 1 line
2.9.4
PATCH v2 4/9 arch-run: generate errata when no environ is provided
In reply to Andrew JonesProvide 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.
--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 errata.txt
configure +11 -0
@@ -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
errata.txt new file +5 -0
@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------
scripts/arch-run.bash +46 -0
58 lines not on this page · raw message
Signature · 1 line
2.9.4
PATCH v2 8/9 AArch32: apply errata framework to unsafe pmccntr64 test
In reply to Andrew Jones--- arm/pmu.c | 26 ++++++++++++++++++-------- errata.txt | 1 + 2 files changed, 19 insertions(+), 8 deletions(-)
arm/pmu.c +18 -8
@@ -14,6 +14,7 @@* for more details. */ #include "libcflat.h" +#include "errata.h" #include "asm/barrier.h" #include "asm/sysreg.h" #include "asm/processor.h"
@@ -57,18 +58,12 @@ static inline uint8_t get_pmu_version(void)static inline uint64_t get_pmccntr (void ) { -if (pmu_version ==0x3 ) -return read_sysreg (PMCCNTR64 ); -else -return read_sysreg (PMCCNTR32 ); +return read_sysreg (PMCCNTR32 ); }static inline void set_pmccntr (uint64_t value) { -if (pmu_version ==0x3 ) -write_sysreg (value,PMCCNTR64 ); -else -write_sysreg (value &0xffffffff ,PMCCNTR32 ); +write_sysreg (value &0xffffffff ,PMCCNTR32 ); }/* PMCCFILTR is an obsolete name for PMXEVTYPER31 in ARMv7 */
@@ -267,6 +262,19 @@ static bool check_cpi(int cpi)return true; } +static void pmccntr64_test (void ) +{ +#ifdef __arm__ +if (pmu_version ==0x3 ) { +if (ERRATA (9e3f7a296940 )) { +write_sysreg (0xdead ,PMCCNTR64 ); +report ("pmccntr64" ,read_sysreg (PMCCNTR64 ) ==0xdead ); + }else +report_skip ("Skipping unsafe pmccntr64 test. Set ERRATA_9e3f7a296940=y to enable." ); + } +#endif +} +/* Return FALSE if no PMU found, otherwise return TRUE */ bool pmu_probe (void ) {
@@ -293,5 +301,7 @@ int main(int argc, char *argv[])report ("Monotonically increasing cycle count" ,check_cycles_increase ());report ("Cycle/instruction ratio" ,check_cpi (cpi)); +pmccntr64_test (); +return report_summary (); }
errata.txt +1 -0
@@ -2,4 +2,5 @@ # commit : minimum kernel : summary # 12 hex digits : version : #---------------:-----------------------:-------------------------------------- +9e3f7a296940 : 4.9 : arm64: KVM: pmu: Fix AArch32 cycle counter access #---------------:-----------------------:--------------------------------------
Signature · 1 line
2.9.4
PATCH v2 6/9 errata: add ERRATA_FORCE
In reply to Andrew JonesProvide an easy way for test runners to run all tests, even those guarded by an erratum. Setting ERRATA_FORCE forces errata() and errata_relaxed() to always return true. ./run_tests.sh -a is also updated to set it.
--- lib/errata.h | 21 +++++++++++++++++++-- run_tests.sh | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-)
lib/errata.h +19 -2
@@ -13,16 +13,33 @@#define _ERRATA_RELAXED (erratum) errata_relaxed("ERRATA_" # erratum)#define ERRATA_RELAXED (erratum) _ERRATA_RELAXED(erratum) +static inline bool errata_force (void ) +{ +char *s =getenv ("ERRATA_FORCE" ); + +return s && (*s =='1' || *s =='y' || *s =='Y' ); +} +static inline bool errata (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return s && (*s =='1' || *s =='y' || *s =='Y' ); }static inline bool errata_relaxed (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return !(s && (*s =='0' || *s =='n' || *s =='N' )); }
run_tests.sh +2 -0
@@ -19,6 +19,7 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] -h: Output this help text -v: Enables verbose mode -a: Run all tests, including those flagged as 'nodefault' + and those guarded by errata. -g: Only execute tests in the given group -j: Execute tests in parallel
@@ -35,6 +36,7 @@ while getopts "ag:hj:v" opt; do case $opt in a) run_all_tests="yes" + export ERRATA_FORCE=y ;; g) only_group=$OPTARG
Signature · 1 line
2.9.4
PATCH v2 9/9 arm/arm64: apply errata framework to unsafe cpu-on test
In reply to Andrew JonesWith the unsafe subtest guarded by an erratum we no longer need nodefault.
--- arm/psci.c | 7 ++++++- arm/unittests.cfg | 2 +- errata.txt | 1 + 3 files changed, 8 insertions(+), 2 deletions(-)
arm/psci.c +6 -1
@@ -8,6 +8,7 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> +#include <errata.h> #include <asm/processor.h> #include <asm/smp.h> #include <asm/psci.h>
@@ -135,7 +136,11 @@ int main(void)report ("invalid-function" ,psci_invalid_function ());report ("affinity-info-on" ,psci_affinity_info_on ());report ("affinity-info-off" ,psci_affinity_info_off ()); -report ("cpu-on" ,psci_cpu_on_test ()); + + if (ERRATA(6c7a5dce22b3)) +report ("cpu-on" ,psci_cpu_on_test ()); +else +report_skip ("Skipping unsafe cpu-on test. Set ERRATA_6c7a5dce22b3=y to enable." ); done: #if 0
arm/unittests.cfg +1 -1
@@ -108,4 +108,4 @@ groups = gic [psci] file = psci.flat smp = $MAX_SMP -groups = nodefault,psci +groups = psci
errata.txt +1 -0
@@ -3,4 +3,5 @@ # 12 hex digits : version : #---------------:-----------------------:-------------------------------------- 9e3f7a296940 : 4.9 : arm64: KVM: pmu: Fix AArch32 cycle counter access +6c7a5dce22b3 : 4.12 : KVM: arm/arm64: fix races in kvm_psci_vcpu_on #---------------:-----------------------:--------------------------------------
Signature · 1 line
2.9.4
PATCH v2 7/9 README: add section on guarding unsafe tests
In reply to Andrew Jones--- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
README.md +34 -0
@@ -71,6 +71,40 @@ Additionally these self-explanatory variables are reserved QEMU_MAJOR, QEMU_MINOR, QEMU_MICRO, KERNEL_VERSION, KERNEL_PATCHLEVEL, KERNEL_SUBLEVEL, KERNEL_EXTRAVERSION +# Guarding unsafe tests + +Some tests are not safe to run by default, as they may crash the +host. kvm-unit-tests provides two ways to handle tests like those. + + 1) Adding 'nodefault' to the groups field for the unit test in the + unittests.cfg file. When a unit test is in the nodefault group + it is only run when invoked + + a) independently, arch-run arch/test + b) by specifying any other non-nodefault group it is in, + groups = nodefault,mygroup : ./run_tests.sh -g mygroup + c) by specifying all tests should be run, ./run_tests.sh -a + + 2) Making the test conditional on errata in the code, + if (ERRATA(abcdef012345)) { + do_unsafe_test(); + } + + With the errata condition the unsafe unit test is only run + when + + a) the ERRATA_abcdef012345 environ variable is provided and 'y' + b) the ERRATA_FORCE environ variable is provided and 'y' + c) by specifying all tests should be run, ./run_tests.sh -a + (The -a switch ensures the ERRATA_FORCE is provided and set + to 'y'.) + +The errata.txt file provides a mapping of the commits needed by errata +conditionals to their respective minimum kernel versions. By default, +when the user does not provide an environ, then an environ generated +from the errata.txt file and the host's kernel version is provided to +all unit tests. + # Contributing ## Directory structure
Signature · 1 line
2.9.4
Re: [PATCH kvm-unit-tests v2 1/9] arch-run: introduce initrd_create
In reply to Andrew JonesQuoted 53 lines · Andrew Jones
Encapsulate the preparation of the optional initrd command line option.
Signed-off-by Andrew Jones <[email protected]>--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)arm/run +3
-2@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"powerpc/run +3
-2@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"scripts/arch-run.bash +0
-0
scripts/arch-run.bash search_qemu_binary () · line 162
Quoted 8 lines
scripts/arch-run.bash +5
-0@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && INITRD="-initrd $ENV" +}
Is this intentional to not clear INITRD and thus to allow it to be imported from the environment?
Laurent
Re: [PATCH kvm-unit-tests v2 2/9] arch-run: provide errata from run env
In reply to Andrew JonesQuoted 6 lines · Andrew Jones
Allow the run script environment to provide ERRATA_* variables to the unit tests. These variables will augment/override variables in any provided unit test environ (the file specified with $ENV) or trigger the creation of a temporary environ file, which contains them.
Quoted 8 lines
Now something like
ERRATA_abcd01234567=y ./run_tests.sh
may be run in order to inform all unit tests that they may execute all subtests guarded by
ERRATA_abcd01234567.Signed-off-by Andrew Jones <[email protected]>
Quoted 43 lines
--- scripts/arch-run.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)scripts/arch-run.bash +28
-0@@ -158,5 +158,33 @@ search_qemu_binary () initrd_create () { + env_add_errata [ -f "$ENV" ] && INITRD="-initrd $ENV" } + +env_add_errata () +{ + local line errata + + if [ -f "$ENV" ] && grep -q '^ERRATA_' <(env); then + for line in $(grep '^ERRATA_' "$ENV"); do + errata=${line%%=*} + test -v $errata && continue + eval export "$line" + done + fi + + if grep -q '^ERRATA_' <(env); then + export ENV_OLD="$ENV" + export ENV=$(mktemp) + trap_exit_push 'rm -f $ENV; [ "$ENV_OLD" ] && export ENV="$ENV_OLD" || unset ENV; unset ENV_OLD' + [ -f "$ENV_OLD" ] && grep -v '^ERRATA_' "$ENV_OLD" > $ENV + grep '^ERRATA_' <(env) >> $ENV + fi +} + +trap_exit_push () +{ + local old_exit=$(trap -p EXIT | sed "s/^[^']*'//;s/'[^']*$//") + trap -- "$1; $old_exit" EXIT +}
Re: [PATCH kvm-unit-tests v2 3/9] x86/run: source config.mak
In reply to Andrew JonesQuoted 4 lines · Andrew Jones
x86/run will need to start looking at config vars with the next patch.
Signed-off-by Andrew Jones <[email protected]>
Quoted 24 lines
--- x86/run | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)x86/run +8
-1@@ -1,6 +1,13 @@ #!/usr/bin/env bash -[ -z "$STANDALONE" ] && source scripts/arch-run.bash +if [ -z "$STANDALONE" ]; then + if [ ! -f config.mak ]; then + echo "run ./configure && make first. See ./configure -h" + exit 2 + fi + source config.mak + source scripts/arch-run.bash +fi qemu=$(search_qemu_binary)
Re: [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided
In reply to Andrew JonesQuoted 83 lines · Andrew Jones
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 <[email protected]>--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 errata.txtconfigure +11
-0@@ -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 EOFerrata.txt new file +5
-0@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------scripts/arch-run.bash +2
-0@@ -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
scripts/arch-run.bash env_add_errata () · line 195
Quoted 10 lines
scripts/arch-run.bash +8
-0} +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
Re: [PATCH kvm-unit-tests v2 6/9] errata: add ERRATA_FORCE
In reply to Andrew JonesQuoted 6 lines · Andrew Jones
Provide an easy way for test runners to run all tests, even those guarded by an erratum. Setting
ERRATA_FORCEforceserrata()anderrata_relaxed()to always return true. ./run_tests.sh -a is also updated to set it.Signed-off-by Andrew Jones <[email protected]>
Quoted 66 lines
--- lib/errata.h | 21 +++++++++++++++++++-- run_tests.sh | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-)lib/errata.h +19
-2@@ -13,16 +13,33 @@#define _ERRATA_RELAXED (erratum) errata_relaxed("ERRATA_" # erratum)#define ERRATA_RELAXED (erratum) _ERRATA_RELAXED(erratum) +static inline bool errata_force (void ) +{ +char *s =getenv ("ERRATA_FORCE" ); + +return s && (*s =='1' || *s =='y' || *s =='Y' ); +} +static inline bool errata (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return s && (*s =='1' || *s =='y' || *s =='Y' ); }static inline bool errata_relaxed (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return !(s && (*s =='0' || *s =='n' || *s =='N' )); }run_tests.sh +2
-0@@ -19,6 +19,7 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] -h: Output this help text -v: Enables verbose mode -a: Run all tests, including those flagged as 'nodefault' + and those guarded by errata. -g: Only execute tests in the given group -j: Execute tests in parallel@@ -35,6 +36,7 @@ while getopts "ag:hj:v" opt; do case $opt in a) run_all_tests="yes" + export ERRATA_FORCE=y ;; g) only_group=$OPTARG
Re: [PATCH kvm-unit-tests v2 1/9] arch-run: introduce initrd_create
In reply to Laurent VivierQuoted 49 lines · Laurent Vivier
Quoted 48 lines · Andrew Jones
Encapsulate the preparation of the optional initrd command line option.
Signed-off-by Andrew Jones <[email protected]>--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)arm/run +3
-2@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"powerpc/run +3
-2@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"
Quoted 16 lines
scripts/arch-run.bash search_qemu_binary () · line 162
Quoted 13 lines
scripts/arch-run.bash +5
-0@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && INITRD="-initrd $ENV" +}Is this intentional to not clear INITRD and thus to allow it to be imported from the environment?
Actually no, that wasn't intentional. I'm not sure I have much of a preference, but I'm leaning towards wanting to clear it. What do you think?
Thanks,
drew
Re: [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided
In reply to Laurent VivierQuoted 103 lines · Laurent Vivier
Quoted 83 lines · Andrew Jones
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 <[email protected]>--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 errata.txtconfigure +11
-0@@ -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 EOFerrata.txt new file +5
-0@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------scripts/arch-run.bash +2
-0@@ -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 () fiscripts/arch-run.bash env_add_errata () · line 195
Quoted 10 lines
scripts/arch-run.bash +8
-0} +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
Quoted 8 lines
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 matchedSo 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
Re: [PATCH kvm-unit-tests v2 1/9] arch-run: introduce initrd_create
In reply to Andrew JonesQuoted 67 lines · Andrew Jones
Quoted 49 lines · Laurent Vivier
Quoted 48 lines · Andrew Jones
Encapsulate the preparation of the optional initrd command line option.
Signed-off-by Andrew Jones <[email protected]>--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)arm/run +3
-2@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"powerpc/run +3
-2@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"Quoted 16 lines
scripts/arch-run.bash search_qemu_binary () · line 162
Quoted 13 lines
scripts/arch-run.bash +5
-0@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && INITRD="-initrd $ENV" +}Is this intentional to not clear INITRD and thus to allow it to be imported from the environment?
Quoted 3 lines
Actually no, that wasn't intentional. I'm not sure I have much of a preference, but I'm leaning towards wanting to clear it. What do you think?
I think it's better to clear it to have a deterministic behavior of the test (only influenced by ENV).
Laurent
Laurent Vivier
Reviewed-byRe: [PATCH kvm-unit-tests v2 4/9] arch-run: generate errata when no environ is provided
In reply to Andrew JonesQuoted 111 lines · Andrew Jones
Quoted 110 lines · Laurent Vivier
Quoted 83 lines · Andrew Jones
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 <[email protected]>--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 errata.txtconfigure +11
-0@@ -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 EOFerrata.txt new file +5
-0@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------scripts/arch-run.bash +2
-0@@ -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 () fiscripts/arch-run.bash env_add_errata () · line 195
Quoted 10 lines
scripts/arch-run.bash +8
-0} +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 expansionPathname 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
Quoted 6 lines
Quoted 1 line
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_sublevelgets used in arithmetic expressions.
ok, thanks.
Laurent