blob: 7dea7697f8cd9ed40aa8d9da892d459f6bc2eaf1 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Neale Ranns812ed392017-10-16 04:20:13 -07002""" 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 """
Dave Wallacef0797d12019-11-15 17:29:15 -050025 var = "TEST_BR"
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)
Dave Wallacef0797d12019-11-15 17:29:15 -050029 executable = "%s/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)