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