Commit 70fcb64b authored by Andrew Jones's avatar Andrew Jones Committed by Radim Krčmář
Browse files

arch-run: generate errata when no environ is provided



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's avatarAndrew Jones <drjones@redhat.com>
Reviewed-by: default avatarLaurent Vivier <lvivier@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 786bfc8d
......@@ -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
#---------------:-----------------------:--------------------------------------
# commit : minimum kernel : summary
# 12 hex digits : version :
#---------------:-----------------------:--------------------------------------
#---------------:-----------------------:--------------------------------------
......@@ -173,6 +173,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
......@@ -184,6 +186,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]*}
[ "$ENVIRON_DEFAULT" != "yes" ] && return
[ ! -f errata.txt ] && return
for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do
commit=${line%:*}
minver=${line#*:}
errata="ERRATA_$commit"
test -v $errata && continue
IFS=. read v p s <<<$minver
s=${s%%[!0-9]*}
if (( $kernel_version > $v ||
($kernel_version == $v && $kernel_patchlevel > $p) )); then
have=y
elif (( $kernel_version == $v && $kernel_patchlevel == $p )); then
if [ "$kernel_sublevel" ] && [ "$s" ]; then
if (( $kernel_sublevel >= $s )); then
have=y
else
have=n
fi
elif [ "$s" ] && (( $s != 0 )); then
have=n
else
have=y
fi
else
have=n
fi
eval export "$errata=$have"
done
}
trap_exit_push ()
{
local old_exit=$(trap -p EXIT | sed "s/^[^']*'//;s/'[^']*$//")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment