blob: 3df8fe8dae291b8eba4f7df0af76de17f6046c35 [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001#!/usr/bin/env python
2""" VAPI test """
3
4import unittest
5import os
6import signal
Neale Ranns812ed392017-10-16 04:20:13 -07007from framework import VppTestCase, running_extended_tests, \
Klement Sekeracae71342018-02-22 14:47:00 +01008 VppTestRunner, Worker
Neale Ranns812ed392017-10-16 04:20:13 -07009
10
11@unittest.skipUnless(running_extended_tests(), "part of extended tests")
12class VOMTestCase(VppTestCase):
13 """ VPP Object Model Test """
14
15 def test_vom_cpp(self):
16 """ run C++ VOM tests """
17 var = "BR"
18 built_root = os.getenv(var, None)
19 self.assertIsNotNone(built_root,
20 "Environment variable `%s' not set" % var)
21 executable = "%s/vom_test/vom_test" % built_root
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
44if __name__ == '__main__':
45 unittest.main(testRunner=VppTestRunner)