blob: bfd7007fbec98fd274da23331220d65c8d09fdda [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
7import subprocess
8from threading import Thread
9from log import single_line_delim
10from framework import VppTestCase, running_extended_tests, \
11 running_on_centos, VppTestRunner, Worker
12
13
14@unittest.skipUnless(running_extended_tests(), "part of extended tests")
15class 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
47if __name__ == '__main__':
48 unittest.main(testRunner=VppTestRunner)