blob: a27d5310f521048fa05b8514c0479b9460f6cbbf [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
Paul Vinciguerradefde0f2018-12-06 07:46:13 -080011@unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Ranns812ed392017-10-16 04:20:13 -070012class VOMTestCase(VppTestCase):
13 """ VPP Object Model Test """
14
Paul Vinciguerra8d991d92019-01-25 14:05:48 -080015 @classmethod
16 def setUpClass(cls):
17 super(VOMTestCase, cls).setUpClass()
18
19 @classmethod
20 def tearDownClass(cls):
21 super(VOMTestCase, cls).tearDownClass()
22
Neale Ranns812ed392017-10-16 04:20:13 -070023 def test_vom_cpp(self):
24 """ run C++ VOM tests """
Klement Sekerab8c72a42018-11-08 11:21:39 +010025 var = "TEST_DIR"
Neale Ranns812ed392017-10-16 04:20:13 -070026 built_root = os.getenv(var, None)
27 self.assertIsNotNone(built_root,
28 "Environment variable `%s' not set" % var)
Klement Sekerab8c72a42018-11-08 11:21:39 +010029 executable = "%s/build/vom_test/vom_test" % built_root
Neale Ranns812ed392017-10-16 04:20:13 -070030 worker = Worker(
31 [executable, "vpp object model", self.shm_prefix], self.logger)
32 worker.start()
33 timeout = 120
34 worker.join(timeout)
35 self.logger.info("Worker result is `%s'" % worker.result)
36 error = False
37 if worker.result is None:
38 try:
39 error = True
40 self.logger.error(
41 "Timeout! Worker did not finish in %ss" % timeout)
42 os.killpg(os.getpgid(worker.process.pid), signal.SIGTERM)
43 worker.join()
44 except:
45 raise Exception("Couldn't kill worker-spawned process")
46 if error:
47 raise Exception(
48 "Timeout! Worker did not finish in %ss" % timeout)
49 self.assert_equal(worker.result, 0, "Binary test return code")
50
51
52if __name__ == '__main__':
53 unittest.main(testRunner=VppTestRunner)