From: Andrew Jones Subject: [PATCH kvm-unit-tests 15/15] Introduce lib/errata.h Date: Fri, 13 Jan 2017 19:15:33 +0100 Message-ID: <20170113181533.15145-16-drjones@redhat.com> References: <20170113181533.15145-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbdAMSQA (ORCPT ); Fri, 13 Jan 2017 13:16:00 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07DA4445D6 for ; Fri, 13 Jan 2017 18:16:01 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Now that we have environment variables we can apply them to defining errata booleans to determine behavior of report_skip or report_xfail in tests. lib/errata.h provides handy wrappers allowing one to do things like: Only running dangerous tests (host crashers) when the errata has been applied if (!ERRATA(PPC64_TM_01)) report_skip("ERRATA_PPC64_TM_01 not set 'y', skipping..."); else report(...); Trigger an XFAIL vs. a FAIL, when set to 'n' report_xfail("APIC test", !ERRATA_RELAXED(x86_APIC_01), ...); The xfail example uses ERRATA_RELAXED to ensure we have the same behavior as now (assuming the software under test should pass, i.e output FAIL if it does not), when testing without the optional environ. Signed-off-by: Andrew Jones --- lib/errata.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/errata.h diff --git a/lib/errata.h b/lib/errata.h new file mode 100644 index 000000000000..5e63f73b3727 --- /dev/null +++ b/lib/errata.h @@ -0,0 +1,24 @@ +#ifndef _ERRATA_H_ +#define _ERRATA_H_ + +#define _ERRATA(erratum) errata("ERRATA_" # erratum) +#define ERRATA(erratum) _ERRATA(erratum) + +#define _ERRATA_RELAXED(erratum) errata_relaxed("ERRATA_" # erratum) +#define ERRATA_RELAXED(erratum) _ERRATA_RELAXED(erratum) + +static inline bool errata(const char *erratum) +{ + char *s = getenv(erratum); + + return s && (*s == '1' || *s == 'y' || *s == 'Y'); +} + +static inline bool errata_relaxed(const char *erratum) +{ + char *s = getenv(erratum); + + return !(s && (*s == '0' || *s == 'n' || *s == 'N')); +} + +#endif -- 2.9.3