blob: 52aeeb1691e48fd9094af42775cb7cd119a3d978 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Paul Vinciguerradd3c5d22019-01-13 16:09:10 -08002"""Test framework utility functions tests"""
Ole Troan7f991832018-12-06 17:35:12 +01003
4import unittest
Klement Sekera558ceab2021-04-08 19:37:41 +02005from framework import VppTestRunner, CPUInterface
Ole Troan8006c6a2018-12-17 12:02:26 +01006from vpp_papi import mac_pton, mac_ntop
Ole Troan7f991832018-12-06 17:35:12 +01007
8
Klement Sekerad9b0c6f2022-04-26 19:02:15 +02009class TestUtil(CPUInterface, unittest.TestCase):
10 """Test framework utility tests"""
Andrew Yourtchenkoa3b7c552020-08-26 14:33:54 +000011
12 @classmethod
Andrew Yourtchenko06f32812021-01-14 10:19:08 +000013 def is_tagged_run_solo(cls):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020014 """if the test case class is timing-sensitive - return true"""
Andrew Yourtchenkoa3b7c552020-08-26 14:33:54 +000015 return False
16
Andrew Yourtchenkoc8eae8d2021-01-20 20:30:36 +000017 @classmethod
18 def has_tag(cls, tag):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020019 """if the test case has a given tag - return true"""
Andrew Yourtchenkoc8eae8d2021-01-20 20:30:36 +000020 try:
21 return tag in cls.test_tags
22 except AttributeError:
23 pass
24 return False
25
Klement Sekera558ceab2021-04-08 19:37:41 +020026 @classmethod
27 def get_cpus_required(cls):
28 return 0
29
Ole Troan7f991832018-12-06 17:35:12 +010030 def test_mac_to_binary(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020031 """MAC to binary and back"""
32 mac = "aa:bb:cc:dd:ee:ff"
Ole Troan8006c6a2018-12-17 12:02:26 +010033 b = mac_pton(mac)
34 mac2 = mac_ntop(b)
Ole Troan7f991832018-12-06 17:35:12 +010035 self.assertEqual(type(mac), type(mac2))
36 self.assertEqual(mac2, mac)
37
Paul Vinciguerradd3c5d22019-01-13 16:09:10 -080038
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039if __name__ == "__main__":
Ole Troan7f991832018-12-06 17:35:12 +010040 unittest.main(testRunner=VppTestRunner)