tests: improve lcov stats for memory_api.c 68/27568/2
authorDave Barach <dave@barachs.net>
Mon, 15 Jun 2020 21:38:12 +0000 (17:38 -0400)
committerDave Wallace <dwallacelf@gmail.com>
Sat, 20 Jun 2020 01:58:34 +0000 (01:58 +0000)
Cover vl_mem_api_dead_client_scan(...), which is not so simple.  Spin
up vpp_api_test using pexpect.spawn, make it bootstrap a private
memory segment, kill vpp_api_test, and wait for the dead client
scanner to run a few times so that it declares the client dead.

The test only runs if GCOV_TESTS=yes is set in the environment.

Type: test

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I3c712fa011df2e23761a2e73c1aba0c7e50123a6

test/test_vlib.py

index 3c6288c..8bc5f57 100644 (file)
@@ -1,7 +1,9 @@
 #!/usr/bin/env python3
 
 import unittest
-
+import pexpect
+import time
+import signal
 from framework import VppTestCase, VppTestRunner, running_extended_tests
 from framework import running_gcov_tests
 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
@@ -186,5 +188,21 @@ class TestVlib(VppTestCase):
                 else:
                     self.logger.info(cmd + " FAIL retval " + str(r.retval))
 
+    @unittest.skipUnless(running_gcov_tests, "part of code coverage tests")
+    def test_vlib_main_unittest(self):
+        """ Private Binary API Segment Test (takes 70 seconds) """
+
+        vat_path = self.vpp_bin + '_api_test'
+        vat = pexpect.spawn(vat_path, ['socket-name', self.api_sock])
+        vat.expect("vat# ", timeout=10)
+        vat.sendline('sock_init_shm')
+        vat.expect("vat# ", timeout=10)
+        vat.sendline('sh api cli')
+        vat.kill(signal.SIGKILL)
+        vat.wait()
+        self.logger.info("vat terminated, 70 second wait for the Reaper")
+        time.sleep(70)
+        self.logger.info("Reaper should be complete...")
+
 if __name__ == '__main__':
     unittest.main(testRunner=VppTestRunner)