From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH kvm-unit-tests 15/15] Introduce lib/errata.h Date: Fri, 3 Mar 2017 15:40:07 +0100 Message-ID: <20170303144006.GC23831@potion> References: <20170113181533.15145-1-drjones@redhat.com> <20170113181533.15145-16-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52290 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751691AbdCCOrM (ORCPT ); Fri, 3 Mar 2017 09:47:12 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D6DEC04D2E2 for ; Fri, 3 Mar 2017 14:40:11 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170113181533.15145-16-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-01-13 19:15+0100, Andrew Jones: > 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), ...); I changed the examples to use commit hashes as errata IDs (as we agreed) and applied, thanks. > 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 >