Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 5 | from asfframework import VppAsfTestCase, VppTestRunner |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 6 | |
| 7 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 8 | class TestString(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 9 | """String Test Cases""" |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 10 | |
| 11 | @classmethod |
| 12 | def setUpClass(cls): |
| 13 | super(TestString, cls).setUpClass() |
| 14 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 15 | @classmethod |
| 16 | def tearDownClass(cls): |
| 17 | super(TestString, cls).tearDownClass() |
| 18 | |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 19 | def setUp(self): |
| 20 | super(TestString, self).setUp() |
| 21 | |
| 22 | def tearDown(self): |
| 23 | super(TestString, self).tearDown() |
| 24 | |
| 25 | def test_string_unittest(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 26 | """String unit tests""" |
| 27 | names = [ |
| 28 | "memcpy_s", |
| 29 | "clib_memcmp", |
| 30 | "clib_memcpy", |
| 31 | "clib_memset", |
| 32 | "clib_strcmp", |
| 33 | "clib_strncmp", |
| 34 | "clib_strncpy", |
| 35 | "clib_strnlen", |
| 36 | "clib_strtok", |
| 37 | "memcmp_s", |
| 38 | "memcpy_s", |
| 39 | "memset_s ", |
| 40 | "strcat_s", |
| 41 | "strcmp_s", |
| 42 | "strcpy_s", |
| 43 | "strncat_s", |
| 44 | "strncmp_s", |
| 45 | "strncpy_s", |
| 46 | "strnlen_s", |
| 47 | "strstr_s", |
| 48 | "strtok_s", |
| 49 | ] |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 50 | |
| 51 | for name in names: |
| 52 | error = self.vapi.cli("test string " + name) |
| 53 | if error.find("failed") != -1: |
| 54 | self.logger.critical("FAILURE in the " + name + " test") |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 55 | self.assertNotIn("failed", error) |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 56 | |
Steven Luong | 51ddd38 | 2021-11-03 15:33:21 -0700 | [diff] [blame] | 57 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 58 | if __name__ == "__main__": |
Steven | b059849 | 2018-10-24 21:15:45 -0700 | [diff] [blame] | 59 | unittest.main(testRunner=VppTestRunner) |