Re: [PATCH kvm-unit-tests 15/15] Introduce lib/errata.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <drjones@xxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux