From patchwork Tue Jun 13 11:54:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 9783723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5B2160212 for ; Tue, 13 Jun 2017 11:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B898420243 for ; Tue, 13 Jun 2017 11:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACECB28617; Tue, 13 Jun 2017 11:55:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4727B20243 for ; Tue, 13 Jun 2017 11:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753226AbdFMLzD (ORCPT ); Tue, 13 Jun 2017 07:55:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33944 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752525AbdFMLzC (ORCPT ); Tue, 13 Jun 2017 07:55:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCB2EC0B39F8 for ; Tue, 13 Jun 2017 11:55:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DCB2EC0B39F8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=drjones@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DCB2EC0B39F8 Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C27977C0D; Tue, 13 Jun 2017 11:55:00 +0000 (UTC) From: Andrew Jones 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 Message-Id: <20170613115451.6240-5-drjones@redhat.com> In-Reply-To: <20170613115451.6240-1-drjones@redhat.com> References: <20170613115451.6240-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 13 Jun 2017 11:55:02 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Laurent Vivier --- 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/'[^']*$//")