Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Paul Vinciguerra | dd3c5d2 | 2019-01-13 16:09:10 -0800 | [diff] [blame] | 2 | """Test framework utility functions tests""" |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 3 | |
| 4 | import unittest |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 5 | from framework import VppTestRunner, CPUInterface |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 6 | from vpp_papi import mac_pton, mac_ntop |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 7 | |
| 8 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame^] | 9 | class TestUtil(CPUInterface, unittest.TestCase): |
| 10 | """Test framework utility tests""" |
Andrew Yourtchenko | a3b7c55 | 2020-08-26 14:33:54 +0000 | [diff] [blame] | 11 | |
| 12 | @classmethod |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 13 | def is_tagged_run_solo(cls): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame^] | 14 | """if the test case class is timing-sensitive - return true""" |
Andrew Yourtchenko | a3b7c55 | 2020-08-26 14:33:54 +0000 | [diff] [blame] | 15 | return False |
| 16 | |
Andrew Yourtchenko | c8eae8d | 2021-01-20 20:30:36 +0000 | [diff] [blame] | 17 | @classmethod |
| 18 | def has_tag(cls, tag): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame^] | 19 | """if the test case has a given tag - return true""" |
Andrew Yourtchenko | c8eae8d | 2021-01-20 20:30:36 +0000 | [diff] [blame] | 20 | try: |
| 21 | return tag in cls.test_tags |
| 22 | except AttributeError: |
| 23 | pass |
| 24 | return False |
| 25 | |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 26 | @classmethod |
| 27 | def get_cpus_required(cls): |
| 28 | return 0 |
| 29 | |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 30 | def test_mac_to_binary(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame^] | 31 | """MAC to binary and back""" |
| 32 | mac = "aa:bb:cc:dd:ee:ff" |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 33 | b = mac_pton(mac) |
| 34 | mac2 = mac_ntop(b) |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 35 | self.assertEqual(type(mac), type(mac2)) |
| 36 | self.assertEqual(mac2, mac) |
| 37 | |
Paul Vinciguerra | dd3c5d2 | 2019-01-13 16:09:10 -0800 | [diff] [blame] | 38 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame^] | 39 | if __name__ == "__main__": |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 40 | unittest.main(testRunner=VppTestRunner) |