Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 2 | """ VAPI test """ |
| 3 | |
| 4 | import unittest |
| 5 | import os |
| 6 | import signal |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 7 | from framework import VppTestCase, running_extended_tests, VppTestRunner, Worker |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 8 | |
| 9 | |
Paul Vinciguerra | defde0f | 2018-12-06 07:46:13 -0800 | [diff] [blame] | 10 | @unittest.skipUnless(running_extended_tests, "part of extended tests") |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 11 | class VOMTestCase(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 12 | """VPP Object Model Test""" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 13 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 14 | @classmethod |
| 15 | def setUpClass(cls): |
| 16 | super(VOMTestCase, cls).setUpClass() |
| 17 | |
| 18 | @classmethod |
| 19 | def tearDownClass(cls): |
| 20 | super(VOMTestCase, cls).tearDownClass() |
| 21 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 22 | def test_vom_cpp(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 23 | """run C++ VOM tests""" |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 24 | var = "TEST_BR" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 25 | built_root = os.getenv(var, None) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 26 | self.assertIsNotNone(built_root, "Environment variable `%s' not set" % var) |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 27 | executable = "%s/vom_test/vom_test" % built_root |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 28 | worker = Worker( |
| 29 | [executable, "vpp object model", self.get_api_segment_prefix()], self.logger |
| 30 | ) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 31 | worker.start() |
| 32 | timeout = 120 |
| 33 | worker.join(timeout) |
| 34 | self.logger.info("Worker result is `%s'" % worker.result) |
| 35 | error = False |
| 36 | if worker.result is None: |
| 37 | try: |
| 38 | error = True |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 39 | self.logger.error("Timeout! Worker did not finish in %ss" % timeout) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 40 | os.killpg(os.getpgid(worker.process.pid), signal.SIGTERM) |
| 41 | worker.join() |
| 42 | except: |
| 43 | raise Exception("Couldn't kill worker-spawned process") |
| 44 | if error: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 45 | raise Exception("Timeout! Worker did not finish in %ss" % timeout) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 46 | self.assert_equal(worker.result, 0, "Binary test return code") |
| 47 | |
| 48 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 49 | if __name__ == "__main__": |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 50 | unittest.main(testRunner=VppTestRunner) |