Skip to content

Commit 9c0780f

Browse files
committed
Add test that checks all feature flags are defined
Add test that checks that all feature flags that are defined in a feature set have an entry in the flag-name<->cpuinfo-flag-name dict.
1 parent 346fcdd commit 9c0780f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_all.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ def test_get_current_cpu_flags(self):
4646
for flag in current_flags:
4747
self.assertTrue(isinstance(flag, str))
4848

49+
class Test_FeatureFlags(unittest.TestCase):
50+
def test_feature_flags(self):
51+
REQUIRED_FEATURES = x86_feature_check.REQUIRED_FEATURES
52+
FLAG_NAMES = x86_feature_check.FLAG_NAMES
53+
54+
# Create list of all feature flags defined in any feature set
55+
all_feature_flags = []
56+
for feature_set_name in REQUIRED_FEATURES:
57+
all_feature_flags.extend(REQUIRED_FEATURES[feature_set_name])
58+
all_feature_flags = sorted(list(set(all_feature_flags)))
59+
60+
for flag_name in all_feature_flags:
61+
with self.subTest(flag_name = flag_name):
62+
self.assertTrue(
63+
flag_name in FLAG_NAMES,
64+
msg = 'Flag "{}" is not known! Cannot check for support'.format(flag_name))
65+
4966
class Test_X86Levels(unittest.TestCase):
5067
"""
5168
Map from CPU Name to expected maximum feature set

0 commit comments

Comments
 (0)