Adds a validation test for trait names
Standard trait names should follow the regex "^[A-Z][A-Z0-9]*$". One of the traits (HW_CPU_X86_AES-NI) erroneously contained a hyphen, so we correct that and add a test to ensure no future traits wander from the standard trait name regex. Luckily, nothing yet is consuming os-traits and so the AES-NI slipup is yet to have any impact. Change-Id: I0603bcb4a1038289d2a3b6ce18aa823c7fac0829
This commit is contained in:
parent
8503afd938
commit
b169eb4a8e
|
@ -46,7 +46,7 @@ TRAITS = [
|
|||
'BMI2',
|
||||
'TBM',
|
||||
# ref: https://en.wikipedia.org/wiki/AES_instruction_set
|
||||
'AES-NI',
|
||||
'AESNI',
|
||||
# ref: https://en.wikipedia.org/wiki/Intel_SHA_extensions
|
||||
'SHA',
|
||||
# ref: https://en.wikipedia.org/wiki/Intel_MPX
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
import os_traits as ot
|
||||
from os_traits.hw.cpu import x86
|
||||
from os_traits.hw.nic import offload
|
||||
|
@ -53,3 +55,11 @@ class TestSymbols(base.TestCase):
|
|||
def test_is_custom(self):
|
||||
self.assertTrue(ot.is_custom('CUSTOM_FOO'))
|
||||
self.assertFalse(ot.is_custom('HW_CPU_X86_SSE42'))
|
||||
|
||||
def test_trait_names_match_regex(self):
|
||||
traits = ot.get_traits()
|
||||
valid_name = re.compile("^[A-Z][A-Z0-9_]*$")
|
||||
for t in traits:
|
||||
match = valid_name.match(t)
|
||||
if not match:
|
||||
self.fail("Trait %s does not validate name regex." % t)
|
||||
|
|
Loading…
Reference in New Issue