2019-10-31 13:31:07 -05:00
|
|
|
#!/usr/bin/env python3
|
2019-01-13 16:09:10 -08:00
|
|
|
"""Test framework utility functions tests"""
|
2018-12-06 17:35:12 +01:00
|
|
|
|
|
|
|
import unittest
|
2021-04-08 19:37:41 +02:00
|
|
|
from framework import VppTestRunner, CPUInterface
|
2018-12-17 12:02:26 +01:00
|
|
|
from vpp_papi import mac_pton, mac_ntop
|
2018-12-06 17:35:12 +01:00
|
|
|
|
|
|
|
|
2021-04-08 19:37:41 +02:00
|
|
|
class TestUtil (CPUInterface, unittest.TestCase):
|
2020-08-26 14:33:54 +00:00
|
|
|
""" Test framework utility tests """
|
|
|
|
|
|
|
|
@classmethod
|
2021-01-14 10:19:08 +00:00
|
|
|
def is_tagged_run_solo(cls):
|
2020-08-26 14:33:54 +00:00
|
|
|
""" if the test case class is timing-sensitive - return true """
|
|
|
|
return False
|
|
|
|
|
2021-01-20 20:30:36 +00:00
|
|
|
@classmethod
|
|
|
|
def has_tag(cls, tag):
|
|
|
|
""" if the test case has a given tag - return true """
|
|
|
|
try:
|
|
|
|
return tag in cls.test_tags
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
return False
|
|
|
|
|
2021-04-08 19:37:41 +02:00
|
|
|
@classmethod
|
|
|
|
def get_cpus_required(cls):
|
|
|
|
return 0
|
|
|
|
|
2018-12-06 17:35:12 +01:00
|
|
|
def test_mac_to_binary(self):
|
2020-08-26 14:33:54 +00:00
|
|
|
""" MAC to binary and back """
|
2018-12-06 17:35:12 +01:00
|
|
|
mac = 'aa:bb:cc:dd:ee:ff'
|
2018-12-17 12:02:26 +01:00
|
|
|
b = mac_pton(mac)
|
|
|
|
mac2 = mac_ntop(b)
|
2018-12-06 17:35:12 +01:00
|
|
|
self.assertEqual(type(mac), type(mac2))
|
|
|
|
self.assertEqual(mac2, mac)
|
|
|
|
|
2019-01-13 16:09:10 -08:00
|
|
|
|
2018-12-06 17:35:12 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(testRunner=VppTestRunner)
|