Using $(CURDIR) to fix the absolute path issue
[vpp.git] / test / test_vom.py
1 #!/usr/bin/env python
2 """ VAPI test """
3
4 import unittest
5 import os
6 import signal
7 import subprocess
8 from threading import Thread
9 from log import single_line_delim
10 from framework import VppTestCase, running_extended_tests, \
11     running_on_centos, VppTestRunner, Worker
12
13
14 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
15 class VOMTestCase(VppTestCase):
16     """ VPP Object Model Test """
17
18     def test_vom_cpp(self):
19         """ run C++ VOM tests """
20         var = "BR"
21         built_root = os.getenv(var, None)
22         self.assertIsNotNone(built_root,
23                              "Environment variable `%s' not set" % var)
24         executable = "%s/vom_test/vom_test" % built_root
25         worker = Worker(
26             [executable, "vpp object model", self.shm_prefix], self.logger)
27         worker.start()
28         timeout = 120
29         worker.join(timeout)
30         self.logger.info("Worker result is `%s'" % worker.result)
31         error = False
32         if worker.result is None:
33             try:
34                 error = True
35                 self.logger.error(
36                     "Timeout! Worker did not finish in %ss" % timeout)
37                 os.killpg(os.getpgid(worker.process.pid), signal.SIGTERM)
38                 worker.join()
39             except:
40                 raise Exception("Couldn't kill worker-spawned process")
41         if error:
42             raise Exception(
43                 "Timeout! Worker did not finish in %ss" % timeout)
44         self.assert_equal(worker.result, 0, "Binary test return code")
45
46
47 if __name__ == '__main__':
48     unittest.main(testRunner=VppTestRunner)