From patchwork Wed May 24 16:08:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 9746343 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 AB08D6032B for ; Wed, 24 May 2017 16:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AFDE28973 for ; Wed, 24 May 2017 16:08:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ED7228991; Wed, 24 May 2017 16:08:37 +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 3738128973 for ; Wed, 24 May 2017 16:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030528AbdEXQIf (ORCPT ); Wed, 24 May 2017 12:08:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030500AbdEXQIb (ORCPT ); Wed, 24 May 2017 12:08:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 604AB19D241 for ; Wed, 24 May 2017 16:08:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 604AB19D241 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=drjones@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 604AB19D241 Received: from kamzik.brq.redhat.com (kamzik.brq.redhat.com [10.34.1.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF87291721; Wed, 24 May 2017 16:08:23 +0000 (UTC) From: Andrew Jones To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, lvivier@redhat.com, thuth@redhat.com Subject: [PATCH kvm-unit-tests 2/8] arch-run: provide errata from run env Date: Wed, 24 May 2017 18:08:12 +0200 Message-Id: <20170524160818.4326-3-drjones@redhat.com> In-Reply-To: <20170524160818.4326-1-drjones@redhat.com> References: <20170524160818.4326-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 24 May 2017 16:08:25 +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 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. 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 --- scripts/arch-run.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 581552a21f2e..3ba6354608da 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -158,5 +158,33 @@ search_qemu_binary () initrd_create () { + env_add_errata [ -f "$ENV" ] && export 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=$(echo "$line" | cut -d= -f1) + grep -q $errata <(env) && 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 +}