blob: 6aba555a9c95d6e5cd6afe857fa51108b432e61a [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 """
Klement Sekerab8c72a42018-11-08 11:21:39 +010017 var = "TEST_DIR"
Neale Ranns812ed392017-10-16 04:20:13 -070018 built_root = os.getenv(var, None)
19 self.assertIsNotNone(built_root,
20 "Environment variable `%s' not set" % var)
Klement Sekerab8c72a42018-11-08 11:21:39 +010021 executable = "%s/build/vom_test/vom_test" % built_root
Neale Ranns812ed392017-10-16 04:20:13 -070022 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)