blob: 5194429623329150e915b9d47533e779a4132703 [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
Klement Sekerad9b0c6f2022-04-26 19:02:15 +02007from framework import VppTestCase, running_extended_tests, VppTestRunner, Worker
Neale Ranns812ed392017-10-16 04:20:13 -07008
9
Paul Vinciguerradefde0f2018-12-06 07:46:13 -080010@unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Ranns812ed392017-10-16 04:20:13 -070011class VOMTestCase(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020012 """VPP Object Model Test"""
Neale Ranns812ed392017-10-16 04:20:13 -070013
Paul Vinciguerra8d991d92019-01-25 14:05:48 -080014 @classmethod
15 def setUpClass(cls):
16 super(VOMTestCase, cls).setUpClass()
17
18 @classmethod
19 def tearDownClass(cls):
20 super(VOMTestCase, cls).tearDownClass()
21
Neale Ranns812ed392017-10-16 04:20:13 -070022 def test_vom_cpp(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020023 """run C++ VOM tests"""
Dave Wallacef0797d12019-11-15 17:29:15 -050024 var = "TEST_BR"
Neale Ranns812ed392017-10-16 04:20:13 -070025 built_root = os.getenv(var, None)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020026 self.assertIsNotNone(built_root, "Environment variable `%s' not set" % var)
Dave Wallacef0797d12019-11-15 17:29:15 -050027 executable = "%s/vom_test/vom_test" % built_root
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020028 worker = Worker(
29 [executable, "vpp object model", self.get_api_segment_prefix()], self.logger
30 )
Neale Ranns812ed392017-10-16 04:20:13 -070031 worker.start()
32 timeout = 120
33 worker.join(timeout)
34 self.logger.info("Worker result is `%s'" % worker.result)
35 error = False
36 if worker.result is None:
37 try:
38 error = True
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 self.logger.error("Timeout! Worker did not finish in %ss" % timeout)
Neale Ranns812ed392017-10-16 04:20:13 -070040 os.killpg(os.getpgid(worker.process.pid), signal.SIGTERM)
41 worker.join()
42 except:
43 raise Exception("Couldn't kill worker-spawned process")
44 if error:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020045 raise Exception("Timeout! Worker did not finish in %ss" % timeout)
Neale Ranns812ed392017-10-16 04:20:13 -070046 self.assert_equal(worker.result, 0, "Binary test return code")
47
48
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020049if __name__ == "__main__":
Neale Ranns812ed392017-10-16 04:20:13 -070050 unittest.main(testRunner=VppTestRunner)