blob: 3a61d64b28f62a514098b2be20cd62be7137d506 [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 Sekera558ceab2021-04-08 19:37:41 +02009class TestUtil (CPUInterface, unittest.TestCase):
Andrew Yourtchenkoa3b7c552020-08-26 14:33:54 +000010 """ Test framework utility tests """
11
12 @classmethod
Andrew Yourtchenko06f32812021-01-14 10:19:08 +000013 def is_tagged_run_solo(cls):
Andrew Yourtchenkoa3b7c552020-08-26 14:33:54 +000014 """ if the test case class is timing-sensitive - return true """
15 return False
16
Andrew Yourtchenkoc8eae8d2021-01-20 20:30:36 +000017 @classmethod
18 def has_tag(cls, tag):
19 """ if the test case has a given tag - return true """
20 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):
Andrew Yourtchenkoa3b7c552020-08-26 14:33:54 +000031 """ MAC to binary and back """
Ole Troan7f991832018-12-06 17:35:12 +010032 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
Ole Troan7f991832018-12-06 17:35:12 +010039if __name__ == '__main__':
40 unittest.main(testRunner=VppTestRunner)