xref: /kvm-unit-tests/lib/errata.h (revision 4363f1d9a646a5c7ea673bee8fc33ca6f2cddbd8)
1 /*
2  * errata functions
3  *
4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Library General Public License version 2.
6  */
7 #ifndef _ERRATA_H_
8 #define _ERRATA_H_
9 
10 #define _ERRATA(erratum) errata("ERRATA_" # erratum)
11 #define ERRATA(erratum) _ERRATA(erratum)
12 
13 #define _ERRATA_RELAXED(erratum) errata_relaxed("ERRATA_" # erratum)
14 #define ERRATA_RELAXED(erratum) _ERRATA_RELAXED(erratum)
15 
16 static inline bool errata_force(void)
17 {
18 	char *s = getenv("ERRATA_FORCE");
19 
20 	return s && (*s == '1' || *s == 'y' || *s == 'Y');
21 }
22 
23 static inline bool errata(const char *erratum)
24 {
25 	char *s;
26 
27 	if (errata_force())
28 		return true;
29 
30 	s = getenv(erratum);
31 
32 	return s && (*s == '1' || *s == 'y' || *s == 'Y');
33 }
34 
35 static inline bool errata_relaxed(const char *erratum)
36 {
37 	char *s;
38 
39 	if (errata_force())
40 		return true;
41 
42 	s = getenv(erratum);
43 
44 	return !(s && (*s == '0' || *s == 'n' || *s == 'N'));
45 }
46 
47 #endif
48