public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com,
	thuth@redhat.com
Subject: [PATCH kvm-unit-tests v3 4/9] arch-run: generate errata when no environ is provided
Date: Tue, 13 Jun 2017 13:54:46 +0200	[thread overview]
Message-ID: <20170613115451.6240-5-drjones@redhat.com> (raw)
In-Reply-To: <20170613115451.6240-1-drjones@redhat.com>

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>
Reviewed-by: Laurent Vivier <lvivier@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 135342ef48f2..27b8531fcfcf 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -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/'[^']*$//")
-- 
2.9.4

  parent reply	other threads:[~2017-06-13 11:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 11:54 [PATCH kvm-unit-tests v3 0/9] Extend and apply the errata framework Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 1/9] arch-run: introduce initrd_create Andrew Jones
2017-06-13 12:09   ` Laurent Vivier
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 2/9] arch-run: provide errata from run env Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 3/9] x86/run: source config.mak Andrew Jones
2017-06-13 11:54 ` Andrew Jones [this message]
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 5/9] mkstandalone: provide errata to tests Andrew Jones
2017-06-13 12:15   ` Laurent Vivier
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 6/9] errata: add ERRATA_FORCE Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 7/9] README: add section on guarding unsafe tests Andrew Jones
2017-06-13 12:15   ` Laurent Vivier
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 8/9] AArch32: apply errata framework to unsafe pmccntr64 test Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 9/9] arm/arm64: apply errata framework to unsafe cpu-on test Andrew Jones
2017-06-14 18:58 ` [PATCH kvm-unit-tests v3 0/9] Extend and apply the errata framework Radim Krčmář

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=20170613115451.6240-5-drjones@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox